@@ -37,7 +37,8 @@ public class ProjectConfig {
37
37
38
38
public enum Version {
39
39
V2 ("2" ),
40
- V3 ("3" );
40
+ V3 ("3" ),
41
+ V4 ("4" );
41
42
42
43
private final String version ;
43
44
@@ -56,54 +57,100 @@ public String toString() {
56
57
private final String revision ;
57
58
private final String version ;
58
59
private final boolean anonymizeIP ;
59
- private final List <Group > groups ;
60
- private final List <Experiment > experiments ;
61
60
private final List <Attribute > attributes ;
62
- private final List <EventType > events ;
63
61
private final List <Audience > audiences ;
62
+ private final List <EventType > events ;
63
+ private final List <Experiment > experiments ;
64
+ private final List <FeatureFlag > featureFlags ;
65
+ private final List <Group > groups ;
64
66
private final List <LiveVariable > liveVariables ;
65
67
66
- // convenience mappings for efficient lookup
67
- private final Map <String , Experiment > experimentKeyMapping ;
68
+ // key to entity mappings
68
69
private final Map <String , Attribute > attributeKeyMapping ;
69
- private final Map <String , LiveVariable > liveVariableKeyMapping ;
70
70
private final Map <String , EventType > eventNameMapping ;
71
+ private final Map <String , Experiment > experimentKeyMapping ;
72
+ private final Map <String , FeatureFlag > featureKeyMapping ;
73
+ private final Map <String , LiveVariable > liveVariableKeyMapping ;
74
+
75
+ // id to entity mappings
71
76
private final Map <String , Audience > audienceIdMapping ;
72
77
private final Map <String , Experiment > experimentIdMapping ;
73
78
private final Map <String , Group > groupIdMapping ;
79
+
80
+ // other mappings
74
81
private final Map <String , List <Experiment >> liveVariableIdToExperimentsMapping ;
75
82
private final Map <String , Map <String , LiveVariableUsageInstance >> variationToLiveVariableUsageInstanceMapping ;
76
83
84
+ // v2 constructor
77
85
public ProjectConfig (String accountId , String projectId , String version , String revision , List <Group > groups ,
78
86
List <Experiment > experiments , List <Attribute > attributes , List <EventType > eventType ,
79
87
List <Audience > audiences ) {
80
88
this (accountId , projectId , version , revision , groups , experiments , attributes , eventType , audiences , false ,
81
89
null );
82
90
}
83
91
92
+ // v3 constructor
84
93
public ProjectConfig (String accountId , String projectId , String version , String revision , List <Group > groups ,
85
94
List <Experiment > experiments , List <Attribute > attributes , List <EventType > eventType ,
86
95
List <Audience > audiences , boolean anonymizeIP , List <LiveVariable > liveVariables ) {
96
+ this (
97
+ accountId ,
98
+ anonymizeIP ,
99
+ projectId ,
100
+ revision ,
101
+ version ,
102
+ attributes ,
103
+ audiences ,
104
+ eventType ,
105
+ experiments ,
106
+ null ,
107
+ groups ,
108
+ liveVariables
109
+ );
110
+ }
111
+
112
+ // v4 constructor
113
+ public ProjectConfig (String accountId ,
114
+ boolean anonymizeIP ,
115
+ String projectId ,
116
+ String revision ,
117
+ String version ,
118
+ List <Attribute > attributes ,
119
+ List <Audience > audiences ,
120
+ List <EventType > events ,
121
+ List <Experiment > experiments ,
122
+ List <FeatureFlag > featureFlags ,
123
+ List <Group > groups ,
124
+ List <LiveVariable > liveVariables ) {
87
125
88
126
this .accountId = accountId ;
89
127
this .projectId = projectId ;
90
128
this .version = version ;
91
129
this .revision = revision ;
92
130
this .anonymizeIP = anonymizeIP ;
93
131
132
+ this .attributes = Collections .unmodifiableList (attributes );
133
+ this .audiences = Collections .unmodifiableList (audiences );
134
+ this .events = Collections .unmodifiableList (events );
135
+ if (featureFlags == null ) {
136
+ this .featureFlags = Collections .emptyList ();
137
+ }
138
+ else {
139
+ this .featureFlags = Collections .unmodifiableList (featureFlags );
140
+ }
141
+
94
142
this .groups = Collections .unmodifiableList (groups );
143
+
95
144
List <Experiment > allExperiments = new ArrayList <Experiment >();
96
145
allExperiments .addAll (experiments );
97
146
allExperiments .addAll (aggregateGroupExperiments (groups ));
98
147
this .experiments = Collections .unmodifiableList (allExperiments );
99
- this .attributes = Collections .unmodifiableList (attributes );
100
- this .events = Collections .unmodifiableList (eventType );
101
- this .audiences = Collections .unmodifiableList (audiences );
102
148
103
149
// generate the name mappers
104
- this .experimentKeyMapping = ProjectConfigUtils .generateNameMapping (this .experiments );
105
150
this .attributeKeyMapping = ProjectConfigUtils .generateNameMapping (attributes );
106
- this .eventNameMapping = ProjectConfigUtils .generateNameMapping (events );
151
+ this .eventNameMapping = ProjectConfigUtils .generateNameMapping (this .events );
152
+ this .experimentKeyMapping = ProjectConfigUtils .generateNameMapping (this .experiments );
153
+ this .featureKeyMapping = ProjectConfigUtils .generateNameMapping (this .featureFlags );
107
154
108
155
// generate audience id to audience mapping
109
156
this .audienceIdMapping = ProjectConfigUtils .generateIdMapping (audiences );
0 commit comments