Skip to content

Commit

Permalink
revert clonable change
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed Feb 13, 2024
1 parent 47c752d commit 16fe055
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/java/dev/openfeature/sdk/ImmutableStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ImmutableStructure(Map<String, Value> attributes) {
.collect(HashMap::new,
(accumulated, entry) -> accumulated.put(entry.getKey(),
Optional.ofNullable(entry.getValue())
.map(Value::copy)
.map(Value::clone)
.orElse(null)),
HashMap::putAll)));
}
Expand All @@ -54,7 +54,7 @@ public Set<String> keySet() {
@Override
public Value getValue(String key) {
Value value = this.attributes.get(key);
return value != null ? value.copy() : null;
return value != null ? value.clone() : null;
}

/**
Expand All @@ -70,7 +70,7 @@ public Map<String, Value> asMap() {
.collect(HashMap::new,
(accumulated, entry) -> accumulated.put(entry.getKey(),
Optional.ofNullable(entry.getValue())
.map(Value::copy)
.map(Value::clone)
.orElse(null)),
HashMap::putAll);
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/dev/openfeature/sdk/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@ToString
@EqualsAndHashCode
@SuppressWarnings({"PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType", "checkstyle:NoFinalizer"})
public class Value {
public class Value implements Cloneable {

private final Object innerObject;

Expand Down Expand Up @@ -262,12 +262,13 @@ public Instant asInstant() {
}

/**
* Perform a deep copy of this value.
* Perform deep clone of value object.
*
* @return Value
*/
@SneakyThrows
protected Value copy() {
@Override
protected Value clone() {
if (this.isList()) {
List<Value> copy = this.asList().stream().map(Value::new).collect(Collectors.toList());
return new Value(copy);
Expand Down

0 comments on commit 16fe055

Please sign in to comment.