Hook context is immutable and some properties can't be null.

This commit is contained in:
Justin Abrahms 2022-05-08 15:38:53 -07:00
parent 3da9a635ef
commit 7dfe0a3b99
No known key found for this signature in database
GPG Key ID: 599E2E12011DC474
1 changed files with 15 additions and 15 deletions

View File

@ -1,25 +1,25 @@
package javasdk; package javasdk;
import lombok.Data; import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@Data @Value @Builder
public class HookContext<T> { public class HookContext<T> {
String flagKey; @NonNull String flagKey;
FlagValueType type; @NonNull FlagValueType type;
@NonNull T defaultValue;
@NonNull EvaluationContext ctx;
Client client; Client client;
EvaluationContext ctx;
FeatureProvider provider; FeatureProvider provider;
T defaultValue;
HookEvaluation<T> executedHooks;
public static <T> HookContext<T> from(String key, FlagValueType type, Client client, EvaluationContext ctx, T defaultValue) { public static <T> HookContext<T> from(String key, FlagValueType type, Client client, EvaluationContext ctx, T defaultValue) {
HookContext<T> hc = new HookContext<>(); return HookContext.<T>builder()
hc.flagKey = key; .flagKey(key)
hc.type = type; .type(type)
hc.client = client; .client(client)
hc.ctx = ctx; .ctx(ctx)
hc.executedHooks = new HookEvaluation<T>(); .defaultValue(defaultValue)
hc.defaultValue = defaultValue; .build();
return hc;
} }
} }