-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: null handling with Structure, Value (#663)
Signed-off-by: Todd Baert <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Giovanni Liva <[email protected]>
- Loading branch information
1 parent
75ff31e
commit 3ab330a
Showing
10 changed files
with
140 additions
and
81 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
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
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,35 @@ | ||
package dev.openfeature.sdk; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@SuppressWarnings({ "PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType" }) | ||
abstract class AbstractStructure implements Structure { | ||
|
||
protected final Map<String, Value> attributes; | ||
|
||
AbstractStructure() { | ||
this.attributes = new HashMap<>(); | ||
} | ||
|
||
AbstractStructure(Map<String, Value> attributes) { | ||
this.attributes = attributes; | ||
} | ||
|
||
/** | ||
* Get all values as their underlying primitives types. | ||
* | ||
* @return all attributes on the structure into a Map | ||
*/ | ||
@Override | ||
public Map<String, Object> asObjectMap() { | ||
return attributes | ||
.entrySet() | ||
.stream() | ||
// custom collector, workaround for Collectors.toMap in JDK8 | ||
// https://bugs.openjdk.org/browse/JDK-8148463 | ||
.collect(HashMap::new, | ||
(accumulated, entry) -> accumulated.put(entry.getKey(), convertValue(entry.getValue())), | ||
HashMap::putAll); | ||
} | ||
} |
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
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
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
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
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
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
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