Skip to content

Commit b238292

Browse files
oakbanithomaszurkan-optimizely
authored andcommitted
fix: JSONModel definitions for all data models in the objective c sdk (#334)
* Fix JSONModel definitions for all data models in the objective c sdk. * Updates license
1 parent 5750115 commit b238292

File tree

21 files changed

+75
-66
lines changed

21 files changed

+75
-66
lines changed

OptimizelySDKCore/OPTLYJSONModelTests/Models/Headers/ConcurrentReposModel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
/****************************************************************************
99
* Modifications to JSONModel by Optimizely, Inc. *
10-
* Copyright 2017, Optimizely, Inc. and contributors *
10+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
1111
* *
1212
* Licensed under the Apache License, Version 2.0 (the "License"); *
1313
* you may not use this file except in compliance with the License. *
@@ -45,9 +45,10 @@
4545
@end
4646

4747
@protocol ConcurrentModel;
48+
@class ConcurrentModel;
4849

4950
@interface ConcurrentReposModel : OPTLYJSONModel
5051

51-
@property (strong, nonatomic) NSMutableArray<ConcurrentModel>* repositories;
52+
@property (strong, nonatomic) NSMutableArray<ConcurrentModel *><ConcurrentModel>* repositories;
5253

5354
@end

OptimizelySDKCore/OPTLYJSONModelTests/Models/Headers/DrugModel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
/****************************************************************************
66
* Modifications to JSONModel by Optimizely, Inc. *
7-
* Copyright 2017, Optimizely, Inc. and contributors *
7+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
88
* *
99
* Licensed under the Apache License, Version 2.0 (the "License"); *
1010
* you may not use this file except in compliance with the License. *
@@ -23,10 +23,11 @@
2323
@import OptimizelySDKCore;
2424

2525
@protocol InteractionModel;
26+
@class InteractionModel;
2627

2728
@interface DrugModel : OPTLYJSONModel
2829

2930
@property NSString *brand_name;
30-
@property NSArray<InteractionModel> *interaction_list;
31+
@property NSArray<InteractionModel *><InteractionModel> *interaction_list;
3132

3233
@end

OptimizelySDKCore/OPTLYJSONModelTests/Models/Headers/ExtremeNestingModel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
/****************************************************************************
66
* Modifications to JSONModel by Optimizely, Inc. *
7-
* Copyright 2017, Optimizely, Inc. and contributors *
7+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
88
* *
99
* Licensed under the Apache License, Version 2.0 (the "License"); *
1010
* you may not use this file except in compliance with the License. *
@@ -23,9 +23,10 @@
2323
@import OptimizelySDKCore;
2424

2525
@protocol DrugModel;
26+
@class DrugModel;
2627

2728
@interface ExtremeNestingModel : OPTLYJSONModel
2829

29-
@property NSArray<DrugModel> *drugs;
30+
@property NSArray<DrugModel *><DrugModel> *drugs;
3031

3132
@end

OptimizelySDKCore/OPTLYJSONModelTests/Models/Headers/NestedModel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
/****************************************************************************
99
* Modifications to JSONModel by Optimizely, Inc. *
10-
* Copyright 2017, Optimizely, Inc. and contributors *
10+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
1111
* *
1212
* Licensed under the Apache License, Version 2.0 (the "License"); *
1313
* you may not use this file except in compliance with the License. *
@@ -30,7 +30,7 @@
3030
@interface NestedModel : OPTLYJSONModel
3131

3232
@property (strong, nonatomic) ImageModel* singleImage;
33-
@property (strong, nonatomic) NSArray<ImageModel>* images;
33+
@property (strong, nonatomic) NSArray<ImageModel *><ImageModel>* images;
3434
@property (strong, nonatomic) NSDictionary<ImageModel>* imagesObject;
3535

3636
@end

OptimizelySDKCore/OPTLYJSONModelTests/Models/Headers/PostsModel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
/****************************************************************************
99
* Modifications to JSONModel by Optimizely, Inc. *
10-
* Copyright 2017, Optimizely, Inc. and contributors *
10+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
1111
* *
1212
* Licensed under the Apache License, Version 2.0 (the "License"); *
1313
* you may not use this file except in compliance with the License. *
@@ -25,9 +25,10 @@
2525
@import OptimizelySDKCore;
2626

2727
@protocol PostModel;
28+
@class PostModel;
2829

2930
@interface PostsModel : OPTLYJSONModel
3031

31-
@property (strong, nonatomic) NSArray<PostModel>* posts;
32+
@property (strong, nonatomic) NSArray<PostModel *><PostModel>* posts;
3233

3334
@end

OptimizelySDKCore/OPTLYJSONModelTests/Models/Headers/ReposModel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
/****************************************************************************
99
* Modifications to JSONModel by Optimizely, Inc. *
10-
* Copyright 2017, Optimizely, Inc. and contributors *
10+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
1111
* *
1212
* Licensed under the Apache License, Version 2.0 (the "License"); *
1313
* you may not use this file except in compliance with the License. *
@@ -25,10 +25,11 @@
2525
@import OptimizelySDKCore;
2626

2727
@protocol GitHubRepoModel;
28+
@class GitHubRepoModel;
2829

2930
@interface ReposModel : OPTLYJSONModel
3031

31-
@property (strong, nonatomic) NSMutableArray<GitHubRepoModel>* repositories;
32+
@property (strong, nonatomic) NSMutableArray<GitHubRepoModel *><GitHubRepoModel>* repositories;
3233

3334
@end
3435

OptimizelySDKCore/OptimizelySDKCore/OPTLYAudience.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -32,7 +32,7 @@
3232
/// The audience name
3333
@property (nonatomic, strong) NSString *audienceName;
3434
/// Audience evaluator conditionals
35-
@property (nonatomic, strong) NSArray<OPTLYCondition> *conditions;
35+
@property (nonatomic, strong) NSArray<OPTLYCondition *><OPTLYCondition> *conditions;
3636

3737
/// Override OPTLYJSONModel set conditions
3838
- (void)setConditionsWithNSString:(NSString *)string;

OptimizelySDKCore/OptimizelySDKCore/OPTLYCondition.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -27,21 +27,21 @@
2727

2828
@interface OPTLYCondition : NSObject
2929

30-
+ (NSArray<OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray
30+
+ (NSArray<OPTLYCondition *><OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray
3131
error:(NSError * __autoreleasing *)error;
32-
+ (NSArray<OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray;
32+
+ (NSArray<OPTLYCondition *><OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray;
3333

3434
@end
3535

3636
@interface OPTLYAndCondition : NSObject <OPTLYCondition>
3737

38-
@property (nonatomic, strong) NSArray<OPTLYCondition> *subConditions;
38+
@property (nonatomic, strong) NSArray<OPTLYCondition *><OPTLYCondition> *subConditions;
3939

4040
@end
4141

4242
@interface OPTLYOrCondition : NSObject <OPTLYCondition>
4343

44-
@property (nonatomic, strong) NSArray<OPTLYCondition> *subConditions;
44+
@property (nonatomic, strong) NSArray<OPTLYCondition *><OPTLYCondition> *subConditions;
4545

4646
@end
4747

OptimizelySDKCore/OptimizelySDKCore/OPTLYCondition.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -21,13 +21,13 @@
2121

2222
@implementation OPTLYCondition
2323

24-
+ (NSArray<OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray {
24+
+ (NSArray<OPTLYCondition *><OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray {
2525
return [OPTLYCondition deserializeJSONArray:jsonArray error:nil];
2626
}
2727

2828
// example jsonArray:
2929
// [“and", [“or", [“or", {"name": "sample_attribute_key", "type": "custom_attribute", "value": “a”}], [“or", {"name": "sample_attribute_key", "type": "custom_attribute", "value": "b"}], [“or", {"name": "sample_attribute_key", "type": "custom_attribute", "value": "c"}]
30-
+ (NSArray<OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray
30+
+ (NSArray<OPTLYCondition *><OPTLYCondition> *)deserializeJSONArray:(NSArray *)jsonArray
3131
error:(NSError * __autoreleasing *)error {
3232

3333
// need to check if the jsonArray is actually an array, otherwise, something is wrong with the audience condition
@@ -44,7 +44,7 @@ @implementation OPTLYCondition
4444
if (jsonArray.count > 1 && [OPTLYBaseCondition isBaseConditionJSON:jsonArray[1]]) { //base case condition
4545

4646
// generate all base conditions
47-
NSMutableArray<OPTLYCondition> *conditions = (NSMutableArray<OPTLYCondition> *)[[NSMutableArray alloc] initWithCapacity:(jsonArray.count - 1)];
47+
NSMutableArray<OPTLYCondition *><OPTLYCondition> *conditions = (NSMutableArray<OPTLYCondition *><OPTLYCondition> *)[[NSMutableArray alloc] initWithCapacity:(jsonArray.count - 1)];
4848
for (int i = 1; i < jsonArray.count; i++) {
4949
NSDictionary *info = jsonArray[i];
5050
NSError *err = nil;
@@ -62,10 +62,10 @@ @implementation OPTLYCondition
6262
// return an (And/Or/Not) Condition handling the base conditions
6363
NSObject<OPTLYCondition> *condition = [OPTLYCondition createConditionInstanceOfClass:jsonArray[0]
6464
withConditions:conditions];
65-
return (NSArray<OPTLYCondition> *)@[condition];
65+
return (NSArray<OPTLYCondition *><OPTLYCondition> *)@[condition];
6666
}
6767
else { // further condition arrays to deserialize
68-
NSMutableArray<OPTLYCondition> *subConditions = (NSMutableArray<OPTLYCondition> *)[[NSMutableArray alloc] initWithCapacity:(jsonArray.count - 1)];
68+
NSMutableArray<OPTLYCondition *><OPTLYCondition> *subConditions = (NSMutableArray<OPTLYCondition *><OPTLYCondition> *)[[NSMutableArray alloc] initWithCapacity:(jsonArray.count - 1)];
6969
for (int i = 1; i < jsonArray.count; i++) {
7070
NSError *err = nil;
7171
NSArray *deserializedJsonObject = [OPTLYCondition deserializeJSONArray:jsonArray[i] error:&err];
@@ -81,11 +81,11 @@ @implementation OPTLYCondition
8181
}
8282
NSObject<OPTLYCondition> *condition = [OPTLYCondition createConditionInstanceOfClass:jsonArray[0]
8383
withConditions:subConditions];
84-
return (NSArray<OPTLYCondition> *)@[condition];
84+
return (NSArray<OPTLYCondition *><OPTLYCondition> *)@[condition];
8585
}
8686
}
8787

88-
+ (NSObject<OPTLYCondition> *)createConditionInstanceOfClass:(NSString *)conditionClass withConditions:(NSArray<OPTLYCondition> *)conditions {
88+
+ (NSObject<OPTLYCondition> *)createConditionInstanceOfClass:(NSString *)conditionClass withConditions:(NSArray<OPTLYCondition *><OPTLYCondition> *)conditions {
8989
if ([conditionClass isEqualToString:OPTLYDatafileKeysAndCondition]) {
9090
OPTLYAndCondition *andCondition = [[OPTLYAndCondition alloc] init];
9191
andCondition.subConditions = conditions;

OptimizelySDKCore/OptimizelySDKCore/OPTLYDecisionEventTicket.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -22,7 +22,7 @@
2222

2323
// Model object representing a Decision Ticket sent when layer decision is made.
2424

25-
@class OPTLYEventHeader, OPTLYEventDecision;
25+
@class OPTLYEventHeader, OPTLYEventDecision, OPTLYEventDecisionTicket, OPTLYEventFeature;
2626
@protocol OPTLYEventDecisionTicket, OPTLYEventFeature;
2727

2828
@interface OPTLYDecisionEventTicket : OPTLYJSONModel
@@ -50,15 +50,15 @@
5050
// The layer affected by this decision
5151
@property (nonatomic, strong, nonnull) NSString *layerId;
5252
// Visitor-specific input to Client Decision Engine
53-
@property (nonatomic, strong, nullable) NSArray<OPTLYEventDecisionTicket, OPTLYOptional> *decisionTicket;
53+
@property (nonatomic, strong, nullable) NSArray<OPTLYEventDecisionTicket *><OPTLYEventDecisionTicket, OPTLYOptional> *decisionTicket;
5454
// Output of the Client Decision Engine
5555
@property (nonatomic, strong, nonnull) OPTLYEventDecision *decision;
5656
// The ID of the user
5757
@property (nonatomic, strong, nonnull) NSString *visitorId;
5858
// The unique user ID of the user (if available)
5959
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *visitorUUID;
6060
// Features attached to the user
61-
@property (nonatomic, strong, nonnull) NSArray<OPTLYEventFeature> *userFeatures;
61+
@property (nonatomic, strong, nonnull) NSArray<OPTLYEventFeature *><OPTLYEventFeature> *userFeatures;
6262
// If true, then the experience in this decision was held back at the global level
6363
@property (nonatomic, assign) BOOL isGlobalHoldback;
6464
// If true, then anonymize IP.

OptimizelySDKCore/OptimizelySDKCore/OPTLYEventDecisionTicket.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -24,14 +24,15 @@
2424
#endif
2525

2626
@protocol OPTLYEventAudience;
27+
@class OPTLYEventAudience;
2728

2829
@protocol OPTLYEventDecisionTicket
2930
@end
3031

3132
@interface OPTLYEventDecisionTicket : OPTLYJSONModel
3233

3334
// The audiences bucketed at decision time
34-
@property (nonatomic, strong, nullable) NSArray<OPTLYEventAudience, OPTLYOptional> *audiences;
35+
@property (nonatomic, strong, nullable) NSArray<OPTLYEventAudience *><OPTLYEventAudience, OPTLYOptional> *audiences;
3536
// Id (UUID or visitorId) used for bucketing
3637
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *bucketingId;
3738

OptimizelySDKCore/OptimizelySDKCore/OPTLYEventView.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -24,6 +24,7 @@
2424
// Model object for a view.
2525

2626
@protocol OPTLYEventFeature;
27+
@class OPTLYEventFeature;
2728

2829
@protocol OPTLYEventView
2930
@end
@@ -35,6 +36,6 @@
3536
// The timestamp when the containing view was activated.
3637
@property (nonatomic, strong, nullable) NSNumber<OPTLYOptional> *activatedTimestamp;
3738
// Features attached to the view.
38-
@property (nonatomic, strong, nullable) NSArray<OPTLYEventFeature, OPTLYOptional> *viewFeatures;
39+
@property (nonatomic, strong, nullable) NSArray<OPTLYEventFeature *><OPTLYEventFeature, OPTLYOptional> *viewFeatures;
3940

4041
@end

OptimizelySDKCore/OptimizelySDKCore/OPTLYExperiment.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -21,7 +21,7 @@
2121
#import <OptimizelySDKCore/OPTLYJSONModelLib.h>
2222
#endif
2323

24-
@class OPTLYVariation;
24+
@class OPTLYVariation, OPTLYTrafficAllocation, OPTLYVariation;
2525
@protocol OPTLYTrafficAllocation, OPTLYVariation;
2626

2727
/**
@@ -46,11 +46,11 @@ NS_ASSUME_NONNULL_END
4646
/// The group ID the experiment belongs to.
4747
@property (nonatomic, strong, nullable) NSString<Ignore> *groupId;
4848
/// The experiment's traffic allocations.
49-
@property (nonatomic, strong, nonnull) NSArray<OPTLYTrafficAllocation> *trafficAllocations;
49+
@property (nonatomic, strong, nonnull) NSArray<OPTLYTrafficAllocation *><OPTLYTrafficAllocation> *trafficAllocations;
5050
/// An array of audience Ids for the experiment
5151
@property (nonatomic, strong, nonnull) NSArray<NSString *> *audienceIds;
5252
/// An array of variation Ids for the experiment
53-
@property (nonatomic, strong, nonnull) NSArray<OPTLYVariation> *variations;
53+
@property (nonatomic, strong, nonnull) NSArray<OPTLYVariation *><OPTLYVariation> *variations;
5454
/// A dictionary indicating the forced and control variation
5555
@property (nonatomic, strong, nonnull) NSDictionary<NSString *, NSString *> *forcedVariations;
5656
/// Personalization layer id

OptimizelySDKCore/OptimizelySDKCore/OPTLYFeatureFlag.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2017, Optimizely, Inc. and contributors *
2+
* Copyright 2017-2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -37,7 +37,7 @@
3737
/// an NSArray of the IDs of the experiments the feature flag is attached to.
3838
@property (nonatomic, strong, nonnull) NSArray<NSString *> *experimentIds;
3939
/// an NSArray of the feature variables that are part of this feature
40-
@property (nonatomic, strong, nonnull) NSArray<OPTLYFeatureVariable> *variables;
40+
@property (nonatomic, strong, nonnull) NSArray<OPTLYFeatureVariable *><OPTLYFeatureVariable> *variables;
4141
/// an NSString to hold the group Id the feature belongs to.
4242
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *groupId;
4343

OptimizelySDKCore/OptimizelySDKCore/OPTLYGroup.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -22,6 +22,7 @@
2222
#endif
2323

2424
@protocol OPTLYExperiment, OPTLYTrafficAllocation;
25+
@class OPTLYTrafficAllocation, OPTLYExperiment;
2526
/**
2627
* This class is a representation of an Optimizely Group.
2728
*/
@@ -36,8 +37,8 @@
3637
/// The Group's policy.
3738
@property (nonatomic, strong) NSString *policy;
3839
/// The Group's traffic allocations.
39-
@property (nonatomic, strong) NSArray<OPTLYTrafficAllocation> *trafficAllocations;
40+
@property (nonatomic, strong) NSArray<OPTLYTrafficAllocation *><OPTLYTrafficAllocation> *trafficAllocations;
4041
/// The Group's experiments.
41-
@property (nonatomic, strong) NSArray<OPTLYExperiment> *experiments;
42+
@property (nonatomic, strong) NSArray<OPTLYExperiment *><OPTLYExperiment> *experiments;
4243

4344
@end

0 commit comments

Comments
 (0)