-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ForcedDecisions): add forced-decisions APIs to OptimizelyUserCon…
…text (#451) ## Summary Add a set of new APIs for forced-decisions to OptimizelyUserContext: - setForcedDecision - getForcedDecision - removeForcedDecision - removeAllForcedDecisions ## Test plan - unit tests for the new APIs - FSC tests with new test cases
- Loading branch information
1 parent
e25985f
commit 04d379a
Showing
14 changed files
with
1,287 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
core-api/src/main/java/com/optimizely/ab/OptimizelyDecisionContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* | ||
* Copyright 2021, Optimizely and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.optimizely.ab; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class OptimizelyDecisionContext { | ||
public static final String OPTI_NULL_RULE_KEY = "$opt-null-rule-key"; | ||
public static final String OPTI_KEY_DIVIDER = "-$opt$-"; | ||
|
||
private String flagKey; | ||
private String ruleKey; | ||
|
||
public OptimizelyDecisionContext(@Nonnull String flagKey, @Nullable String ruleKey) { | ||
this.flagKey = flagKey; | ||
this.ruleKey = ruleKey; | ||
} | ||
|
||
public String getFlagKey() { | ||
return flagKey; | ||
} | ||
|
||
public String getRuleKey() { | ||
return ruleKey != null ? ruleKey : OPTI_NULL_RULE_KEY; | ||
} | ||
|
||
public String getKey() { | ||
StringBuilder keyBuilder = new StringBuilder(); | ||
keyBuilder.append(flagKey); | ||
keyBuilder.append(OPTI_KEY_DIVIDER); | ||
keyBuilder.append(getRuleKey()); | ||
return keyBuilder.toString(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core-api/src/main/java/com/optimizely/ab/OptimizelyForcedDecision.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* | ||
* Copyright 2021, Optimizely and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.optimizely.ab; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class OptimizelyForcedDecision { | ||
private String variationKey; | ||
|
||
public OptimizelyForcedDecision(@Nonnull String variationKey) { | ||
this.variationKey = variationKey; | ||
} | ||
|
||
public String getVariationKey() { | ||
return variationKey; | ||
} | ||
} |
Oops, something went wrong.