@@ -95,30 +95,6 @@ public Variation getVariation(@Nonnull Experiment experiment,
9595 @ Nonnull ProjectConfig projectConfig ,
9696 @ Nonnull List <OptimizelyDecideOption > options ,
9797 @ Nonnull DecisionReasons reasons ) {
98-
99- // support existing custom DecisionServices
100- if (isMethodOverriden ("getVariation" , Experiment .class , String .class , Map .class , ProjectConfig .class )) {
101- return getVariation (experiment , userId , filteredAttributes , projectConfig );
102- }
103-
104- return getVariationCore (experiment , userId , filteredAttributes , projectConfig , options , reasons );
105- }
106-
107- @ Nullable
108- public Variation getVariation (@ Nonnull Experiment experiment ,
109- @ Nonnull String userId ,
110- @ Nonnull Map <String , ?> filteredAttributes ,
111- @ Nonnull ProjectConfig projectConfig ) {
112- return getVariationCore (experiment , userId , filteredAttributes , projectConfig , Collections .emptyList (), new DecisionReasons ());
113- }
114-
115- @ Nullable
116- public Variation getVariationCore (@ Nonnull Experiment experiment ,
117- @ Nonnull String userId ,
118- @ Nonnull Map <String , ?> filteredAttributes ,
119- @ Nonnull ProjectConfig projectConfig ,
120- @ Nonnull List <OptimizelyDecideOption > options ,
121- @ Nonnull DecisionReasons reasons ) {
12298 if (!ExperimentUtils .isExperimentActive (experiment , options , reasons )) {
12399 return null ;
124100 }
@@ -188,6 +164,14 @@ public Variation getVariationCore(@Nonnull Experiment experiment,
188164 return null ;
189165 }
190166
167+ @ Nullable
168+ public Variation getVariation (@ Nonnull Experiment experiment ,
169+ @ Nonnull String userId ,
170+ @ Nonnull Map <String , ?> filteredAttributes ,
171+ @ Nonnull ProjectConfig projectConfig ) {
172+ return getVariation (experiment , userId , filteredAttributes , projectConfig , Collections .emptyList (), new DecisionReasons ());
173+ }
174+
191175 /**
192176 * Get the variation the user is bucketed into for the FeatureFlag
193177 *
@@ -206,30 +190,6 @@ public FeatureDecision getVariationForFeature(@Nonnull FeatureFlag featureFlag,
206190 @ Nonnull ProjectConfig projectConfig ,
207191 @ Nonnull List <OptimizelyDecideOption > options ,
208192 @ Nonnull DecisionReasons reasons ) {
209- // support existing custom DecisionServices
210- if (isMethodOverriden ("getVariationForFeature" , FeatureFlag .class , String .class , Map .class , ProjectConfig .class )) {
211- return getVariationForFeature (featureFlag , userId , filteredAttributes , projectConfig );
212- }
213-
214- return getVariationForFeatureCore (featureFlag , userId , filteredAttributes , projectConfig , options , reasons );
215- }
216-
217- @ Nonnull
218- public FeatureDecision getVariationForFeature (@ Nonnull FeatureFlag featureFlag ,
219- @ Nonnull String userId ,
220- @ Nonnull Map <String , ?> filteredAttributes ,
221- @ Nonnull ProjectConfig projectConfig ) {
222-
223- return getVariationForFeatureCore (featureFlag , userId , filteredAttributes , projectConfig ,Collections .emptyList (), new DecisionReasons ());
224- }
225-
226- @ Nonnull
227- public FeatureDecision getVariationForFeatureCore (@ Nonnull FeatureFlag featureFlag ,
228- @ Nonnull String userId ,
229- @ Nonnull Map <String , ?> filteredAttributes ,
230- @ Nonnull ProjectConfig projectConfig ,
231- @ Nonnull List <OptimizelyDecideOption > options ,
232- @ Nonnull DecisionReasons reasons ) {
233193 if (!featureFlag .getExperimentIds ().isEmpty ()) {
234194 for (String experimentId : featureFlag .getExperimentIds ()) {
235195 Experiment experiment = projectConfig .getExperimentIdMapping ().get (experimentId );
@@ -256,6 +216,15 @@ public FeatureDecision getVariationForFeatureCore(@Nonnull FeatureFlag featureFl
256216 return featureDecision ;
257217 }
258218
219+ @ Nonnull
220+ public FeatureDecision getVariationForFeature (@ Nonnull FeatureFlag featureFlag ,
221+ @ Nonnull String userId ,
222+ @ Nonnull Map <String , ?> filteredAttributes ,
223+ @ Nonnull ProjectConfig projectConfig ) {
224+
225+ return getVariationForFeature (featureFlag , userId , filteredAttributes , projectConfig ,Collections .emptyList (), new DecisionReasons ());
226+ }
227+
259228 /**
260229 * Try to bucket the user into a rollout rule.
261230 * Evaluate the user for rules in priority order by seeing if the user satisfies the audience.
@@ -598,27 +567,6 @@ public Variation getForcedVariation(@Nonnull Experiment experiment,
598567 @ Nonnull String userId ,
599568 @ Nonnull List <OptimizelyDecideOption > options ,
600569 @ Nonnull DecisionReasons reasons ) {
601-
602- // support existing custom DecisionServices
603- if (isMethodOverriden ("getForcedVariation" , Experiment .class , String .class )) {
604- return getForcedVariation (experiment , userId );
605- }
606-
607- return getForcedVariationCore (experiment , userId , options , reasons );
608- }
609-
610- @ Nullable
611- public Variation getForcedVariation (@ Nonnull Experiment experiment ,
612- @ Nonnull String userId ) {
613- return getForcedVariationCore (experiment , userId , Collections .emptyList (), new DecisionReasons ());
614- }
615-
616- @ Nullable
617- public Variation getForcedVariationCore (@ Nonnull Experiment experiment ,
618- @ Nonnull String userId ,
619- @ Nonnull List <OptimizelyDecideOption > options ,
620- @ Nonnull DecisionReasons reasons ) {
621-
622570 // if the user id is invalid, return false.
623571 if (!validateUserId (userId )) {
624572 return null ;
@@ -642,6 +590,12 @@ public Variation getForcedVariationCore(@Nonnull Experiment experiment,
642590 return null ;
643591 }
644592
593+ @ Nullable
594+ public Variation getForcedVariation (@ Nonnull Experiment experiment ,
595+ @ Nonnull String userId ) {
596+ return getForcedVariation (experiment , userId , Collections .emptyList (), new DecisionReasons ());
597+ }
598+
645599 /**
646600 * Helper function to check that the provided userId is valid
647601 *
@@ -657,12 +611,4 @@ private boolean validateUserId(String userId) {
657611 return true ;
658612 }
659613
660- Boolean isMethodOverriden (String methodName , Class <?>... params ) {
661- try {
662- return getClass () != DecisionService .class && getClass ().getDeclaredMethod (methodName , params ) != null ;
663- } catch (NoSuchMethodException e ) {
664- return false ;
665- }
666- }
667-
668614}
0 commit comments