1616
1717package com .optimizely .ab .notification ;
1818
19-
2019import com .optimizely .ab .bucketing .FeatureDecision ;
21- import com .optimizely .ab .config .FeatureVariable ;
2220import com .optimizely .ab .config .Variation ;
2321
2422import javax .annotation .Nonnull ;
@@ -69,8 +67,8 @@ public static ExperimentDecisionNotificationBuilder newExperimentDecisionNotific
6967 }
7068
7169 public static class ExperimentDecisionNotificationBuilder {
72- public final static String EXPERIMENT_KEY = "experiment_key " ;
73- public final static String VARIATION_KEY = "variation_key " ;
70+ public final static String EXPERIMENT_KEY = "experimentKey " ;
71+ public final static String VARIATION_KEY = "variationKey " ;
7472
7573 private String type ;
7674 private String experimentKey ;
@@ -116,4 +114,81 @@ public DecisionNotification build() {
116114 decisionInfo );
117115 }
118116 }
117+
118+ public static FeatureDecisionNotificationBuilder newFeatureDecisionNotificationBuilder () {
119+ return new FeatureDecisionNotificationBuilder ();
120+ }
121+
122+ public static class FeatureDecisionNotificationBuilder {
123+ public final static String FEATURE_KEY = "featureKey" ;
124+ public final static String FEATURE_ENABLED = "featureEnabled" ;
125+ public final static String SOURCE = "source" ;
126+ public final static String SOURCE_INFO = "sourceInfo" ;
127+ public final static String EXPERIMENT_KEY = "experimentKey" ;
128+ public final static String VARIATION_KEY = "variationKey" ;
129+
130+ private String featureKey ;
131+ private Boolean featureEnabled ;
132+ private String experimentKey ;
133+ private String variationKey ;
134+ private FeatureDecision .DecisionSource source ;
135+ private String userId ;
136+ private Map <String , ?> attributes ;
137+ private Map <String , Object > decisionInfo ;
138+
139+ public FeatureDecisionNotificationBuilder withUserId (String userId ) {
140+ this .userId = userId ;
141+ return this ;
142+ }
143+
144+ public FeatureDecisionNotificationBuilder withAttributes (Map <String , ?> attributes ) {
145+ this .attributes = attributes ;
146+ return this ;
147+ }
148+
149+ public FeatureDecisionNotificationBuilder withExperimentKey (String experimentKey ) {
150+ this .experimentKey = experimentKey ;
151+ return this ;
152+ }
153+
154+ public FeatureDecisionNotificationBuilder withVariationKey (String variationKey ) {
155+ this .variationKey = variationKey ;
156+ return this ;
157+ }
158+
159+ public FeatureDecisionNotificationBuilder withSource (FeatureDecision .DecisionSource source ) {
160+ this .source = source ;
161+ return this ;
162+ }
163+
164+ public FeatureDecisionNotificationBuilder withFeatureKey (String featureKey ) {
165+ this .featureKey = featureKey ;
166+ return this ;
167+ }
168+
169+ public FeatureDecisionNotificationBuilder withFeatureEnabled (Boolean featureEnabled ) {
170+ this .featureEnabled = featureEnabled ;
171+ return this ;
172+ }
173+
174+ public DecisionNotification build () {
175+ decisionInfo = new HashMap <>();
176+ decisionInfo .put (FEATURE_KEY , featureKey );
177+ decisionInfo .put (FEATURE_ENABLED , featureEnabled );
178+ decisionInfo .put (SOURCE , source );
179+
180+ Map <String , String > sourceInfo = new HashMap <>();
181+ if (source .equals (FeatureDecision .DecisionSource .FEATURE_TEST )) {
182+ sourceInfo .put (EXPERIMENT_KEY , experimentKey );
183+ sourceInfo .put (VARIATION_KEY , variationKey );
184+ }
185+ decisionInfo .put (SOURCE_INFO , sourceInfo );
186+
187+ return new DecisionNotification (
188+ NotificationCenter .DecisionNotificationType .FEATURE .toString (),
189+ userId ,
190+ attributes ,
191+ decisionInfo );
192+ }
193+ }
119194}
0 commit comments