Repository: open-feature/java-sdk
Pull request #478 (2023-06-15 15:15:19)

chore: rename flag metadata
Renames the `FlagMetadata` class (it can be used for event metadata as well). Talked with @Kavindu-Dodan (the implementer) about this. This is not yet released, so there's no breaking change to worry about.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/open-feature/java-sdk/pull/478?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature) Report
> Merging [#478](https://app.codecov.io/gh/open-feature/java-sdk/pull/478?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature) (97f120c) into [main](https://app.codecov.io/gh/open-feature/java-sdk/commit/d309d1633018217e1c2fad8bff8f3b55706aa016?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature) (d309d16) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff            @@
##               main     #478   +/-   ##
=========================================
  Coverage     94.44%   94.44%           
  Complexity      268      268           
=========================================
  Files            25       25           
  Lines           612      612           
  Branches         36       36           
=========================================
  Hits            578      578           
  Misses           17       17           
  Partials         17       17           
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `94.44% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://app.codecov.io/gh/open-feature/java-sdk/pull/478?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature) | Coverage Δ | |
|---|---|---|
| [...ava/dev/openfeature/sdk/FlagEvaluationDetails.java](https://app.codecov.io/gh/open-feature/java-sdk/pull/478?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature#diff-c3JjL21haW4vamF2YS9kZXYvb3BlbmZlYXR1cmUvc2RrL0ZsYWdFdmFsdWF0aW9uRGV0YWlscy5qYXZh) | `100.00% <ø> (ø)` | |
| [...in/java/dev/openfeature/sdk/ImmutableMetadata.java](https://app.codecov.io/gh/open-feature/java-sdk/pull/478?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature#diff-c3JjL21haW4vamF2YS9kZXYvb3BlbmZlYXR1cmUvc2RrL0ltbXV0YWJsZU1ldGFkYXRhLmphdmE=) | `100.00% <100.00%> (ø)` | |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-feature)

sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=open-feature_java-sdk&pullRequest=478)

[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=BUG)  
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=VULNERABILITY)  
[![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=SECURITY_HOTSPOT)  
[![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=CODE_SMELL)

[![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=open-feature_java-sdk&pullRequest=478) No Coverage information  
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=open-feature_java-sdk&pullRequest=478&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=open-feature_java-sdk&pullRequest=478&metric=new_duplicated_lines_density&view=list)


sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=open-feature_java-sdk&pullRequest=478)

[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=BUG)  
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=VULNERABILITY)  
[![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=SECURITY_HOTSPOT)  
[![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=open-feature_java-sdk&pullRequest=478&resolved=false&types=CODE_SMELL)

[![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=open-feature_java-sdk&pullRequest=478) No Coverage information  
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=open-feature_java-sdk&pullRequest=478&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=open-feature_java-sdk&pullRequest=478&metric=new_duplicated_lines_density&view=list)



Patch:
diff --git a/src/main/java/dev/openfeature/sdk/FlagEvaluationDetails.java b/src/main/java/dev/openfeature/sdk/FlagEvaluationDetails.java
index 24e6a39..0a60565 100644
--- a/src/main/java/dev/openfeature/sdk/FlagEvaluationDetails.java
+++ b/src/main/java/dev/openfeature/sdk/FlagEvaluationDetails.java
@@ -20,7 +20,7 @@ public class FlagEvaluationDetails<T> implements BaseEvaluation<T> {
     @Nullable private String reason;
     private ErrorCode errorCode;
     @Nullable private String errorMessage;
-    @Builder.Default private FlagMetadata flagMetadata = FlagMetadata.builder().build();
+    @Builder.Default private ImmutableMetadata flagMetadata = ImmutableMetadata.builder().build();
 
     /**
      * Generate detail payload from the provider response.
diff --git a/src/main/java/dev/openfeature/sdk/FlagMetadata.java b/src/main/java/dev/openfeature/sdk/ImmutableMetadata.java
similarity index 80%
rename from src/main/java/dev/openfeature/sdk/FlagMetadata.java
rename to src/main/java/dev/openfeature/sdk/ImmutableMetadata.java
index 7cd91f8..1bc130b 100644
--- a/src/main/java/dev/openfeature/sdk/FlagMetadata.java
+++ b/src/main/java/dev/openfeature/sdk/ImmutableMetadata.java
@@ -10,10 +10,10 @@ import java.util.Map;
  * through builder and accessors.
  */
 @Slf4j
-public class FlagMetadata {
+public class ImmutableMetadata {
     private final Map<String, Object> metadata;
 
-    private FlagMetadata(Map<String, Object> metadata) {
+    private ImmutableMetadata(Map<String, Object> metadata) {
         this.metadata = metadata;
     }
 
@@ -98,19 +98,19 @@ public class FlagMetadata {
 
 
     /**
-     * Obtain a builder for {@link FlagMetadata}.
+     * Obtain a builder for {@link ImmutableMetadata}.
      */
-    public static FlagMetadataBuilder builder() {
-        return new FlagMetadataBuilder();
+    public static ImmutableMetadataBuilder builder() {
+        return new ImmutableMetadataBuilder();
     }
 
     /**
-     * Immutable builder for {@link FlagMetadata}.
+     * Immutable builder for {@link ImmutableMetadata}.
      */
-    public static class FlagMetadataBuilder {
+    public static class ImmutableMetadataBuilder {
         private final Map<String, Object> metadata;
 
-        private FlagMetadataBuilder() {
+        private ImmutableMetadataBuilder() {
             metadata = new HashMap<>();
         }
 
@@ -120,7 +120,7 @@ public class FlagMetadata {
          * @param key   flag metadata key to add
          * @param value flag metadata value to add
          */
-        public FlagMetadataBuilder addString(final String key, final String value) {
+        public ImmutableMetadataBuilder addString(final String key, final String value) {
             metadata.put(key, value);
             return this;
         }
@@ -131,7 +131,7 @@ public class FlagMetadata {
          * @param key   flag metadata key to add
          * @param value flag metadata value to add
          */
-        public FlagMetadataBuilder addInteger(final String key, final Integer value) {
+        public ImmutableMetadataBuilder addInteger(final String key, final Integer value) {
             metadata.put(key, value);
             return this;
         }
@@ -142,7 +142,7 @@ public class FlagMetadata {
          * @param key   flag metadata key to add
          * @param value flag metadata value to add
          */
-        public FlagMetadataBuilder addLong(final String key, final Long value) {
+        public ImmutableMetadataBuilder addLong(final String key, final Long value) {
             metadata.put(key, value);
             return this;
         }
@@ -153,7 +153,7 @@ public class FlagMetadata {
          * @param key   flag metadata key to add
          * @param value flag metadata value to add
          */
-        public FlagMetadataBuilder addFloat(final String key, final Float value) {
+        public ImmutableMetadataBuilder addFloat(final String key, final Float value) {
             metadata.put(key, value);
             return this;
         }
@@ -164,7 +164,7 @@ public class FlagMetadata {
          * @param key   flag metadata key to add
          * @param value flag metadata value to add
          */
-        public FlagMetadataBuilder addDouble(final String key, final Double value) {
+        public ImmutableMetadataBuilder addDouble(final String key, final Double value) {
             metadata.put(key, value);
             return this;
         }
@@ -175,16 +175,16 @@ public class FlagMetadata {
          * @param key   flag metadata key to add
          * @param value flag metadata value to add
          */
-        public FlagMetadataBuilder addBoolean(final String key, final Boolean value) {
+        public ImmutableMetadataBuilder addBoolean(final String key, final Boolean value) {
             metadata.put(key, value);
             return this;
         }
 
         /**
-         * Retrieve {@link FlagMetadata} with provided key,value pairs.
+         * Retrieve {@link ImmutableMetadata} with provided key,value pairs.
          */
-        public FlagMetadata build() {
-            return new FlagMetadata(this.metadata);
+        public ImmutableMetadata build() {
+            return new ImmutableMetadata(this.metadata);
         }
 
     }
diff --git a/src/main/java/dev/openfeature/sdk/ProviderEvaluation.java b/src/main/java/dev/openfeature/sdk/ProviderEvaluation.java
index ffa5c3c..42441a8 100644
--- a/src/main/java/dev/openfeature/sdk/ProviderEvaluation.java
+++ b/src/main/java/dev/openfeature/sdk/ProviderEvaluation.java
@@ -14,5 +14,5 @@ public class ProviderEvaluation<T> implements BaseEvaluation<T> {
     ErrorCode errorCode;
     @Nullable private String errorMessage;
     @Builder.Default
-    private FlagMetadata flagMetadata = FlagMetadata.builder().build();
+    private ImmutableMetadata flagMetadata = ImmutableMetadata.builder().build();
 }


Test patch:
diff --git a/src/test/java/dev/openfeature/sdk/DoSomethingProvider.java b/src/test/java/dev/openfeature/sdk/DoSomethingProvider.java
index 26e6737..8d1c451 100644
--- a/src/test/java/dev/openfeature/sdk/DoSomethingProvider.java
+++ b/src/test/java/dev/openfeature/sdk/DoSomethingProvider.java
@@ -4,7 +4,7 @@ class DoSomethingProvider implements FeatureProvider {
 
     static final String name = "Something";
     // Flag evaluation metadata
-    static final FlagMetadata flagMetadata = FlagMetadata.builder().build();
+    static final ImmutableMetadata flagMetadata = ImmutableMetadata.builder().build();
 
     private EvaluationContext savedContext;
 
diff --git a/src/test/java/dev/openfeature/sdk/FlagMetadataTest.java b/src/test/java/dev/openfeature/sdk/FlagMetadataTest.java
index 8f96e61..c300daa 100644
--- a/src/test/java/dev/openfeature/sdk/FlagMetadataTest.java
+++ b/src/test/java/dev/openfeature/sdk/FlagMetadataTest.java
@@ -11,7 +11,7 @@ class FlagMetadataTest {
     @DisplayName("Test metadata payload construction and retrieval")
     public void builder_validation() {
         // given
-        FlagMetadata flagMetadata = FlagMetadata.builder()
+        ImmutableMetadata flagMetadata = ImmutableMetadata.builder()
                 .addString("string", "string")
                 .addInteger("integer", 1)
                 .addLong("long", 1L)
@@ -44,7 +44,7 @@ class FlagMetadataTest {
     @DisplayName("Value type mismatch returns a null")
     public void value_type_validation() {
         // given
-        FlagMetadata flagMetadata = FlagMetadata.builder()
+        ImmutableMetadata flagMetadata = ImmutableMetadata.builder()
                 .addString("string", "string")
                 .build();
 
@@ -56,7 +56,7 @@ class FlagMetadataTest {
     @DisplayName("A null is returned if key does not exist")
     public void notfound_error_validation() {
         // given
-        FlagMetadata flagMetadata = FlagMetadata.builder().build();
+        ImmutableMetadata flagMetadata = ImmutableMetadata.builder().build();
 
         // then
         assertThat(flagMetadata.getBoolean("string")).isNull();