diff --git a/lib/src/main/java/dev/openfeature/javasdk/BaseEvaluation.java b/lib/src/main/java/dev/openfeature/javasdk/BaseEvaluation.java index bccdfe5d..c6ab9a3e 100644 --- a/lib/src/main/java/dev/openfeature/javasdk/BaseEvaluation.java +++ b/lib/src/main/java/dev/openfeature/javasdk/BaseEvaluation.java @@ -1,7 +1,7 @@ package dev.openfeature.javasdk; /** - * We differ between the evaluation results that providers return and what is given to the end users. This is a common interface between them. + * This is the common interface between the evaluation results that providers return and what is given to the end users. * @param The type of flag being evaluated. */ public interface BaseEvaluation { diff --git a/lib/src/main/java/dev/openfeature/javasdk/EvaluationContext.java b/lib/src/main/java/dev/openfeature/javasdk/EvaluationContext.java index 7eb3b16d..407fc842 100644 --- a/lib/src/main/java/dev/openfeature/javasdk/EvaluationContext.java +++ b/lib/src/main/java/dev/openfeature/javasdk/EvaluationContext.java @@ -1,6 +1,6 @@ package dev.openfeature.javasdk; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; // jackson is pretty standard, I'm glad you decided on this for object support import lombok.*; import java.time.ZonedDateTime; @@ -28,6 +28,8 @@ public class EvaluationContext { } // TODO Not sure if I should have sneakythrows or checked exceptions here.. + // do you mean un-checked exceptions? + // I had no idea about SneakyThrows, but it seems like a nicer solution than swallowing in an unchecked exception. @SneakyThrows public void addStructureAttribute(String key, T value) { jsonAttributes.put(key, objMapper.writeValueAsString(value)); diff --git a/lib/src/main/java/dev/openfeature/javasdk/FeatureProvider.java b/lib/src/main/java/dev/openfeature/javasdk/FeatureProvider.java index c1310831..308e188b 100644 --- a/lib/src/main/java/dev/openfeature/javasdk/FeatureProvider.java +++ b/lib/src/main/java/dev/openfeature/javasdk/FeatureProvider.java @@ -5,6 +5,7 @@ */ public interface FeatureProvider { Metadata getMetadata(); + // I think default methods are nicer than an abstract class, +1 to this. ProviderEvaluation getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx, FlagEvaluationOptions options); ProviderEvaluation getStringEvaluation(String key, String defaultValue, EvaluationContext ctx, FlagEvaluationOptions options); ProviderEvaluation getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx, FlagEvaluationOptions options); diff --git a/lib/src/main/java/dev/openfeature/javasdk/Features.java b/lib/src/main/java/dev/openfeature/javasdk/Features.java index d831b3a6..c837ce4c 100644 --- a/lib/src/main/java/dev/openfeature/javasdk/Features.java +++ b/lib/src/main/java/dev/openfeature/javasdk/Features.java @@ -1,7 +1,7 @@ package dev.openfeature.javasdk; /** - * An API for the type-specific fetch methods we offer end users. + * An API for the type-specific fetch methods offered to users. */ public interface Features { diff --git a/lib/src/main/java/dev/openfeature/javasdk/FlagEvaluationOptions.java b/lib/src/main/java/dev/openfeature/javasdk/FlagEvaluationOptions.java index 37dd4bfc..83f2ee13 100644 --- a/lib/src/main/java/dev/openfeature/javasdk/FlagEvaluationOptions.java +++ b/lib/src/main/java/dev/openfeature/javasdk/FlagEvaluationOptions.java @@ -9,7 +9,9 @@ @Data @Builder public class FlagEvaluationOptions { - @Singular private List hooks; + // I guess because we are using boxed types, we can pass "Object" as T everywhere to avoid the + // "raw types" warning, but I'm not sure if that's really too helpful beyond removing some warnings + @Singular private List> hooks; @Builder.Default private ImmutableMap hookHints = ImmutableMap.of(); } diff --git a/lib/src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java b/lib/src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java index d7b6313c..5dcc141a 100644 --- a/lib/src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java +++ b/lib/src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java @@ -93,6 +93,7 @@ FlagEvaluationDetails evaluateFlag(FlagValueType type, String key, T defa return details; } + // errorHooks and afterAllHooks error handling seems consistent with spec, and what I implemented. I'm glad we landed here. private void errorHooks(HookContext hookCtx, Exception e, List hooks, ImmutableMap hints) { for (Hook hook : hooks) { try { @@ -122,6 +123,7 @@ private void afterHooks(HookContext hookContext, FlagEvaluationDetails de private EvaluationContext beforeHooks(HookContext hookCtx, List hooks, ImmutableMap hints) { // These traverse backwards from normal. EvaluationContext ctx = hookCtx.getCtx(); + // This is a bit counter-intuitive to me, just want to make sure... this is the stage that gets reversed because ArrayList.addAll() does a prepend, right? for (Hook hook : Lists.reverse(hooks)) { Optional newCtx = hook.before(hookCtx, hints); if (newCtx != null && newCtx.isPresent()) {