@@ -37,7 +37,8 @@ public class ProjectConfig {
3737
3838 public enum Version {
3939 V2 ("2" ),
40- V3 ("3" );
40+ V3 ("3" ),
41+ V4 ("4" );
4142
4243 private final String version ;
4344
@@ -56,54 +57,100 @@ public String toString() {
5657 private final String revision ;
5758 private final String version ;
5859 private final boolean anonymizeIP ;
59- private final List <Group > groups ;
60- private final List <Experiment > experiments ;
6160 private final List <Attribute > attributes ;
62- private final List <EventType > events ;
6361 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 ;
6466 private final List <LiveVariable > liveVariables ;
6567
66- // convenience mappings for efficient lookup
67- private final Map <String , Experiment > experimentKeyMapping ;
68+ // key to entity mappings
6869 private final Map <String , Attribute > attributeKeyMapping ;
69- private final Map <String , LiveVariable > liveVariableKeyMapping ;
7070 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
7176 private final Map <String , Audience > audienceIdMapping ;
7277 private final Map <String , Experiment > experimentIdMapping ;
7378 private final Map <String , Group > groupIdMapping ;
79+
80+ // other mappings
7481 private final Map <String , List <Experiment >> liveVariableIdToExperimentsMapping ;
7582 private final Map <String , Map <String , LiveVariableUsageInstance >> variationToLiveVariableUsageInstanceMapping ;
7683
84+ // v2 constructor
7785 public ProjectConfig (String accountId , String projectId , String version , String revision , List <Group > groups ,
7886 List <Experiment > experiments , List <Attribute > attributes , List <EventType > eventType ,
7987 List <Audience > audiences ) {
8088 this (accountId , projectId , version , revision , groups , experiments , attributes , eventType , audiences , false ,
8189 null );
8290 }
8391
92+ // v3 constructor
8493 public ProjectConfig (String accountId , String projectId , String version , String revision , List <Group > groups ,
8594 List <Experiment > experiments , List <Attribute > attributes , List <EventType > eventType ,
8695 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 ) {
87125
88126 this .accountId = accountId ;
89127 this .projectId = projectId ;
90128 this .version = version ;
91129 this .revision = revision ;
92130 this .anonymizeIP = anonymizeIP ;
93131
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+
94142 this .groups = Collections .unmodifiableList (groups );
143+
95144 List <Experiment > allExperiments = new ArrayList <Experiment >();
96145 allExperiments .addAll (experiments );
97146 allExperiments .addAll (aggregateGroupExperiments (groups ));
98147 this .experiments = Collections .unmodifiableList (allExperiments );
99- this .attributes = Collections .unmodifiableList (attributes );
100- this .events = Collections .unmodifiableList (eventType );
101- this .audiences = Collections .unmodifiableList (audiences );
102148
103149 // generate the name mappers
104- this .experimentKeyMapping = ProjectConfigUtils .generateNameMapping (this .experiments );
105150 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 );
107154
108155 // generate audience id to audience mapping
109156 this .audienceIdMapping = ProjectConfigUtils .generateIdMapping (audiences );
0 commit comments