-
Notifications
You must be signed in to change notification settings - Fork 32
feat(api): Accepting all types for attributes values #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c401466
d73f4eb
6173eee
be4de1c
0b23827
cc9a5a6
20f83bf
881774f
6274260
a47f8af
e49c473
20974f4
6ef444d
7c868cb
9f0593f
b484960
4aa66fe
7e1dd58
a17bdbd
f90b466
d9d23e2
0b6aad9
182c4fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* | ||
* Copyright 2016-2017, Optimizely and contributors | ||
* Copyright 2016-2018, 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. | ||
|
@@ -37,7 +37,7 @@ public Condition getCondition() { | |
return condition; | ||
} | ||
|
||
public boolean evaluate(Map<String, String> attributes) { | ||
public boolean evaluate(Map<String, ?> attributes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to update the |
||
return !condition.evaluate(attributes); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* | ||
* Copyright 2016-2017, Optimizely and contributors | ||
* Copyright 2016-2018, 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. | ||
|
@@ -36,7 +36,7 @@ public List<Condition> getConditions() { | |
return conditions; | ||
} | ||
|
||
public boolean evaluate(Map<String, String> attributes) { | ||
public boolean evaluate(Map<String, ?> attributes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above re: the toString method |
||
for (Condition condition : conditions) { | ||
if (condition.evaluate(attributes)) | ||
return true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* | ||
* Copyright 2016-2017, Optimizely and contributors | ||
* Copyright 2016-2018, 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. | ||
|
@@ -29,9 +29,9 @@ public class UserAttribute implements Condition { | |
|
||
private final String name; | ||
private final String type; | ||
private final String value; | ||
private final Object value; | ||
|
||
public UserAttribute(@Nonnull String name, @Nonnull String type, @Nullable String value) { | ||
public UserAttribute(@Nonnull String name, @Nonnull String type, @Nullable Object value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thomaszurkan-optimizely do we need to overload this constructor to allow you to pass in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind, I think this will be fine as is. Can ignore my previous comment. |
||
this.name = name; | ||
this.type = type; | ||
this.value = value; | ||
|
@@ -45,12 +45,13 @@ public String getType() { | |
return type; | ||
} | ||
|
||
public String getValue() { | ||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
public boolean evaluate(Map<String, String> attributes) { | ||
String userAttributeValue = attributes.get(name); | ||
public boolean evaluate(Map<String, ?> attributes) { | ||
// Valid for primative types, but needs to change when a value is an object or an array | ||
Object userAttributeValue = attributes.get(name); | ||
|
||
if (value != null) { // if there is a value in the condition | ||
// check user attribute value is equal | ||
|
@@ -69,7 +70,7 @@ else if (userAttributeValue != null) { // if the datafile value is null but user | |
public String toString() { | ||
return "{name='" + name + "\'" + | ||
", type='" + type + "\'" + | ||
", value='" + value + "\'" + | ||
", value='" + value.toString() + "\'" + | ||
"}"; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the header on this file to be
2016-2018
. Please also do it for other files you've touched in this commit.