blob: 72eb59ea1bbe9ce0ffc644b32957b80740adf632 (
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
|
//
// SDLPermissionFilter.m
// SmartDeviceLink-iOS
//
// Created by Joel Fischer on 11/18/15.
// Copyright © 2015 smartdevicelink. All rights reserved.
//
#import "SDLPermissionFilter.h"
NS_ASSUME_NONNULL_BEGIN
@implementation SDLPermissionFilter
#pragma mark - Lifecycle
- (instancetype)init {
return [self initWithRPCNames:@[] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionRPCName *,NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) {}];
}
- (instancetype)initWithRPCNames:(NSArray<SDLPermissionRPCName *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionObserver)observer {
self = [super init];
if (!self) {
return nil;
}
_identifier = [NSUUID UUID];
_rpcNames = rpcNames;
_groupType = groupType;
_observer = observer;
return self;
}
+ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionRPCName *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionObserver)observer {
return [[self alloc] initWithRPCNames:rpcNames groupType:groupType observer:observer];
}
#pragma mark - NSCopying
- (id)copyWithZone:(nullable NSZone *)zone {
SDLPermissionFilter *newFilter = [[self.class allocWithZone:zone] initWithRPCNames:[_rpcNames copyWithZone:zone] groupType:_groupType observer:[_observer copyWithZone:zone]];
newFilter->_identifier = _identifier;
return newFilter;
}
#pragma mark - Equality
- (BOOL)isEqual:(id)object {
if (object == self) {
return YES;
}
if (![object isMemberOfClass:[self class]]) {
return NO;
}
return [self isEqualToFilter:object];
}
- (BOOL)isEqualToFilter:(SDLPermissionFilter *)otherFilter {
return [self.identifier isEqual:otherFilter.identifier];
}
#pragma mark - Description
- (NSString *)description {
return [NSString stringWithFormat:@"identifier: %@, group type: %@, rpcs: %@", self.identifier, @(self.groupType), self.rpcNames];
}
@end
NS_ASSUME_NONNULL_END
|