summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLLocationDetails.m
blob: e10f97ff8055c747f8e3d44c755855166071290b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//  SDLLocationDetails.m
//

#import "SDLLocationDetails.h"

#import "SDLImage.h"
#import "SDLLocationCoordinate.h"
#import "SDLNames.h"
#import "SDLOasisAddress.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLLocationDetails

- (void)setCoordinate:(nullable SDLLocationCoordinate *)coordinate {
    if (coordinate != nil) {
        store[SDLNameLocationCoordinate] = coordinate;
    } else {
        [store removeObjectForKey:SDLNameLocationCoordinate];
    }
}

- (nullable SDLLocationCoordinate *)coordinate {
    NSObject *obj = [store objectForKey: SDLNameLocationCoordinate];
    if (obj == nil || [obj isKindOfClass:SDLLocationCoordinate.class]) {
        return (SDLLocationCoordinate *)obj;
    } else {
        return [[SDLLocationCoordinate alloc] initWithDictionary:(NSMutableDictionary *)obj];
    }
}

- (void)setLocationName:(nullable NSString *)locationName {
    if (locationName != nil) {
        store[SDLNameLocationName] = locationName;
    } else {
        [store removeObjectForKey:SDLNameLocationName];
    }
}

- (nullable NSString *)locationName {
    return store[SDLNameLocationName];
}

- (void)setAddressLines:(nullable NSArray<NSString *> *)addressLines {
    if (addressLines != nil) {
        store[SDLNameAddressLines] = addressLines;
    } else {
        [store removeObjectForKey:SDLNameAddressLines];
    }
}

- (nullable NSArray<NSString *> *)addressLines {
    return store[SDLNameAddressLines];
}

- (void)setLocationDescription:(nullable NSString *)locationDescription {
    if (locationDescription != nil) {
        store[SDLNameLocationDescription] = locationDescription;
    } else {
        [store removeObjectForKey:SDLNameLocationDescription];
    }
}

- (nullable NSString *)locationDescription {
    return store[SDLNameLocationDescription];
}

- (void)setPhoneNumber:(nullable NSString *)phoneNumber {
    if (phoneNumber != nil) {
        store[SDLNamePhoneNumber] = phoneNumber;
    } else {
        [store removeObjectForKey:SDLNamePhoneNumber];
    }
}

- (nullable NSString *)phoneNumber {
    return store[SDLNamePhoneNumber];
}

- (void)setLocationImage:(nullable SDLImage *)locationImage {
    if (locationImage != nil) {
        store[SDLNameLocationImage] = locationImage;
    } else {
        [store removeObjectForKey:SDLNameLocationImage];
    }
}

- (nullable SDLImage *)locationImage {
    NSObject *obj = [store objectForKey: SDLNameLocationImage];
    if (obj == nil || [obj isKindOfClass:SDLImage.class]) {
        return (SDLImage *)obj;
    } else {
        return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj];
    }
}

- (void)setSearchAddress:(nullable SDLOasisAddress *)searchAddress {
    if (searchAddress != nil) {
        store[SDLNameSearchAddress] = searchAddress;
    } else {
        [store removeObjectForKey:SDLNameSearchAddress];
    }
}

- (nullable SDLOasisAddress *)searchAddress {
    NSObject *obj = [store objectForKey:SDLNameSearchAddress];
    if (obj == nil || [obj isKindOfClass:SDLOasisAddress.class]) {
        return (SDLOasisAddress *)obj;
    } else {
        return [[SDLOasisAddress alloc] initWithDictionary:(NSMutableDictionary *)obj];
    }
}

@end

NS_ASSUME_NONNULL_END