Skip to content

Commit

Permalink
feat: add object to value wrapper
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <toddbaert@gmail.com>
  • Loading branch information
toddbaert committed Sep 9, 2022
1 parent 35c9c7e commit 0152a1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/dev/openfeature/javasdk/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public Value() {
this.innerObject = null;
}

public Value(Object value) {
this.innerObject = value;
}

public Value(Value value) {
this.innerObject = value.innerObject;
}
Expand Down Expand Up @@ -131,6 +135,15 @@ public Boolean asBoolean() {
return null;
}

/**
* Retrieve the underlying object.
*
* @return Object
*/
public Object asObject() {
return this.innerObject;
}

/**
* Retrieve the underlying String value, or null.
*
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/dev/openfeature/javasdk/ValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class ValueTest {
assertTrue(value.isNull());
}

@Test public void objectArgShouldContainObject() {
Object innerValue = new Object();
Value value = new Value(innerValue);
assertEquals(innerValue, value.asObject());
}

@Test public void boolArgShouldContainBool() {
boolean innerValue = true;
Value value = new Value(innerValue);
Expand Down

0 comments on commit 0152a1e

Please sign in to comment.