Skip to content
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

chore: rename flag metadata #478

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* 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;
}

Expand Down Expand Up @@ -98,19 +98,19 @@ public <T> T getValue(final String key, final Class<T> type) {


/**
* 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<>();
}

Expand All @@ -120,7 +120,7 @@ private FlagMetadataBuilder() {
* @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;
}
Expand All @@ -131,7 +131,7 @@ public FlagMetadataBuilder addString(final String key, final String value) {
* @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;
}
Expand All @@ -142,7 +142,7 @@ public FlagMetadataBuilder addInteger(final String key, final Integer value) {
* @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;
}
Expand All @@ -153,7 +153,7 @@ public FlagMetadataBuilder addLong(final String key, final Long value) {
* @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;
}
Expand All @@ -164,7 +164,7 @@ public FlagMetadataBuilder addFloat(final String key, final Float value) {
* @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;
}
Expand All @@ -175,16 +175,16 @@ public FlagMetadataBuilder addDouble(final String key, final Double value) {
* @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);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/dev/openfeature/sdk/FlagMetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -44,7 +44,7 @@ public void builder_validation() {
@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();

Expand All @@ -56,7 +56,7 @@ public void value_type_validation() {
@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();
Expand Down