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