@@ -120,7 +120,7 @@ Variation activate(@Nonnull String experimentKey,
120
120
public @ Nullable
121
121
Variation activate (@ Nonnull String experimentKey ,
122
122
@ Nonnull String userId ,
123
- @ Nonnull Map <String , String > attributes ) throws UnknownExperimentException {
123
+ @ Nonnull Map <String , ? > attributes ) throws UnknownExperimentException {
124
124
125
125
if (experimentKey == null ) {
126
126
logger .error ("The experimentKey parameter must be nonnull." );
@@ -153,7 +153,7 @@ Variation activate(@Nonnull Experiment experiment,
153
153
public @ Nullable
154
154
Variation activate (@ Nonnull Experiment experiment ,
155
155
@ Nonnull String userId ,
156
- @ Nonnull Map <String , String > attributes ) {
156
+ @ Nonnull Map <String , ? > attributes ) {
157
157
158
158
ProjectConfig currentConfig = getProjectConfig ();
159
159
@@ -164,15 +164,15 @@ Variation activate(@Nonnull Experiment experiment,
164
164
Variation activate (@ Nonnull ProjectConfig projectConfig ,
165
165
@ Nonnull Experiment experiment ,
166
166
@ Nonnull String userId ,
167
- @ Nonnull Map <String , String > attributes ) {
167
+ @ Nonnull Map <String , ? > attributes ) {
168
168
169
169
if (!validateUserId (userId )){
170
170
logger .info ("Not activating user \" {}\" for experiment \" {}\" ." , userId , experiment .getKey ());
171
171
return null ;
172
172
}
173
173
// determine whether all the given attributes are present in the project config. If not, filter out the unknown
174
174
// attributes.
175
- Map <String , String > filteredAttributes = filterAttributes (projectConfig , attributes );
175
+ Map <String , ? > filteredAttributes = filterAttributes (projectConfig , attributes );
176
176
177
177
// bucket the user to the given experiment and dispatch an impression event
178
178
Variation variation = decisionService .getVariation (experiment , userId , filteredAttributes );
@@ -189,7 +189,7 @@ Variation activate(@Nonnull ProjectConfig projectConfig,
189
189
private void sendImpression (@ Nonnull ProjectConfig projectConfig ,
190
190
@ Nonnull Experiment experiment ,
191
191
@ Nonnull String userId ,
192
- @ Nonnull Map <String , String > filteredAttributes ,
192
+ @ Nonnull Map <String , ? > filteredAttributes ,
193
193
@ Nonnull Variation variation ) {
194
194
if (experiment .isRunning ()) {
195
195
LogEvent impressionEvent = eventFactory .createImpressionEvent (
@@ -228,13 +228,13 @@ public void track(@Nonnull String eventName,
228
228
229
229
public void track (@ Nonnull String eventName ,
230
230
@ Nonnull String userId ,
231
- @ Nonnull Map <String , String > attributes ) throws UnknownEventTypeException {
231
+ @ Nonnull Map <String , ? > attributes ) throws UnknownEventTypeException {
232
232
track (eventName , userId , attributes , Collections .<String , String >emptyMap ());
233
233
}
234
234
235
235
public void track (@ Nonnull String eventName ,
236
236
@ Nonnull String userId ,
237
- @ Nonnull Map <String , String > attributes ,
237
+ @ Nonnull Map <String , ? > attributes ,
238
238
@ Nonnull Map <String , ?> eventTags ) throws UnknownEventTypeException {
239
239
240
240
if (!validateUserId (userId )) {
@@ -259,7 +259,7 @@ public void track(@Nonnull String eventName,
259
259
260
260
// determine whether all the given attributes are present in the project config. If not, filter out the unknown
261
261
// attributes.
262
- Map <String , String > filteredAttributes = filterAttributes (currentConfig , attributes );
262
+ Map <String , ? > filteredAttributes = filterAttributes (currentConfig , attributes );
263
263
264
264
if (eventTags == null ) {
265
265
logger .warn ("Event tags is null when non-null was expected. Defaulting to an empty event tags map." );
@@ -344,7 +344,7 @@ public void track(@Nonnull String eventName,
344
344
*/
345
345
public @ Nonnull Boolean isFeatureEnabled (@ Nonnull String featureKey ,
346
346
@ Nonnull String userId ,
347
- @ Nonnull Map <String , String > attributes ) {
347
+ @ Nonnull Map <String , ? > attributes ) {
348
348
if (featureKey == null ) {
349
349
logger .warn ("The featureKey parameter must be nonnull." );
350
350
return false ;
@@ -359,7 +359,7 @@ else if (userId == null) {
359
359
return false ;
360
360
}
361
361
362
- Map <String , String > filteredAttributes = filterAttributes (projectConfig , attributes );
362
+ Map <String , ? > filteredAttributes = filterAttributes (projectConfig , attributes );
363
363
364
364
FeatureDecision featureDecision = decisionService .getVariationForFeature (featureFlag , userId , filteredAttributes );
365
365
if (featureDecision .variation != null ) {
@@ -410,7 +410,7 @@ else if (userId == null) {
410
410
public @ Nullable Boolean getFeatureVariableBoolean (@ Nonnull String featureKey ,
411
411
@ Nonnull String variableKey ,
412
412
@ Nonnull String userId ,
413
- @ Nonnull Map <String , String > attributes ) {
413
+ @ Nonnull Map <String , ? > attributes ) {
414
414
String variableValue = getFeatureVariableValueForType (
415
415
featureKey ,
416
416
variableKey ,
@@ -450,7 +450,7 @@ else if (userId == null) {
450
450
public @ Nullable Double getFeatureVariableDouble (@ Nonnull String featureKey ,
451
451
@ Nonnull String variableKey ,
452
452
@ Nonnull String userId ,
453
- @ Nonnull Map <String , String > attributes ) {
453
+ @ Nonnull Map <String , ? > attributes ) {
454
454
String variableValue = getFeatureVariableValueForType (
455
455
featureKey ,
456
456
variableKey ,
@@ -495,7 +495,7 @@ else if (userId == null) {
495
495
public @ Nullable Integer getFeatureVariableInteger (@ Nonnull String featureKey ,
496
496
@ Nonnull String variableKey ,
497
497
@ Nonnull String userId ,
498
- @ Nonnull Map <String , String > attributes ) {
498
+ @ Nonnull Map <String , ? > attributes ) {
499
499
String variableValue = getFeatureVariableValueForType (
500
500
featureKey ,
501
501
variableKey ,
@@ -540,7 +540,7 @@ else if (userId == null) {
540
540
public @ Nullable String getFeatureVariableString (@ Nonnull String featureKey ,
541
541
@ Nonnull String variableKey ,
542
542
@ Nonnull String userId ,
543
- @ Nonnull Map <String , String > attributes ) {
543
+ @ Nonnull Map <String , ? > attributes ) {
544
544
return getFeatureVariableValueForType (
545
545
featureKey ,
546
546
variableKey ,
@@ -553,7 +553,7 @@ else if (userId == null) {
553
553
String getFeatureVariableValueForType (@ Nonnull String featureKey ,
554
554
@ Nonnull String variableKey ,
555
555
@ Nonnull String userId ,
556
- @ Nonnull Map <String , String > attributes ,
556
+ @ Nonnull Map <String , ? > attributes ,
557
557
@ Nonnull LiveVariable .VariableType variableType ) {
558
558
if (featureKey == null ) {
559
559
logger .warn ("The featureKey parameter must be nonnull." );
@@ -614,7 +614,7 @@ else if (userId == null) {
614
614
* @return List of the feature keys that are enabled for the user if the userId is empty it will
615
615
* return Empty List.
616
616
*/
617
- public List <String > getEnabledFeatures (@ Nonnull String userId , @ Nonnull Map <String , String > attributes ) {
617
+ public List <String > getEnabledFeatures (@ Nonnull String userId , @ Nonnull Map <String , ? > attributes ) {
618
618
List <String > enabledFeaturesList = new ArrayList <String >();
619
619
620
620
if (!validateUserId (userId )){
@@ -642,9 +642,9 @@ Variation getVariation(@Nonnull Experiment experiment,
642
642
public @ Nullable
643
643
Variation getVariation (@ Nonnull Experiment experiment ,
644
644
@ Nonnull String userId ,
645
- @ Nonnull Map <String , String > attributes ) throws UnknownExperimentException {
645
+ @ Nonnull Map <String , ? > attributes ) throws UnknownExperimentException {
646
646
647
- Map <String , String > filteredAttributes = filterAttributes (projectConfig , attributes );
647
+ Map <String , ? > filteredAttributes = filterAttributes (projectConfig , attributes );
648
648
649
649
return decisionService .getVariation (experiment , userId , filteredAttributes );
650
650
}
@@ -659,7 +659,7 @@ Variation getVariation(@Nonnull String experimentKey,
659
659
public @ Nullable
660
660
Variation getVariation (@ Nonnull String experimentKey ,
661
661
@ Nonnull String userId ,
662
- @ Nonnull Map <String , String > attributes ) {
662
+ @ Nonnull Map <String , ? > attributes ) {
663
663
if (!validateUserId (userId )) {
664
664
return null ;
665
665
}
@@ -677,7 +677,7 @@ Variation getVariation(@Nonnull String experimentKey,
677
677
return null ;
678
678
}
679
679
680
- Map <String , String > filteredAttributes = filterAttributes (projectConfig , attributes );
680
+ Map <String , ? > filteredAttributes = filterAttributes (projectConfig , attributes );
681
681
682
682
return decisionService .getVariation (experiment ,userId ,filteredAttributes );
683
683
}
@@ -742,17 +742,18 @@ public UserProfileService getUserProfileService() {
742
742
* @return the filtered attributes map (containing only attributes that are present in the project config) or an
743
743
* empty map if a null attributes object is passed in
744
744
*/
745
- private Map <String , String > filterAttributes (@ Nonnull ProjectConfig projectConfig ,
746
- @ Nonnull Map <String , String > attributes ) {
745
+ private Map <String , ? > filterAttributes (@ Nonnull ProjectConfig projectConfig ,
746
+ @ Nonnull Map <String , ? > attributes ) {
747
747
if (attributes == null ) {
748
748
logger .warn ("Attributes is null when non-null was expected. Defaulting to an empty attributes map." );
749
749
return Collections .<String , String >emptyMap ();
750
750
}
751
751
752
+ // List of attribute keys
752
753
List <String > unknownAttributes = null ;
753
754
754
755
Map <String , Attribute > attributeKeyMapping = projectConfig .getAttributeKeyMapping ();
755
- for (Map .Entry <String , String > attribute : attributes .entrySet ()) {
756
+ for (Map .Entry <String , ? > attribute : attributes .entrySet ()) {
756
757
if (!attributeKeyMapping .containsKey (attribute .getKey ()) &&
757
758
!attribute .getKey ().startsWith (ProjectConfig .RESERVED_ATTRIBUTE_PREFIX )) {
758
759
if (unknownAttributes == null ) {
@@ -765,7 +766,7 @@ private Map<String, String> filterAttributes(@Nonnull ProjectConfig projectConfi
765
766
if (unknownAttributes != null ) {
766
767
logger .warn ("Attribute(s) {} not in the datafile." , unknownAttributes );
767
768
// make a copy of the passed through attributes, then remove the unknown list
768
- attributes = new HashMap <String , String >(attributes );
769
+ attributes = new HashMap <>(attributes );
769
770
for (String unknownAttribute : unknownAttributes ) {
770
771
attributes .remove (unknownAttribute );
771
772
}
0 commit comments