Hook context is immutable and some properties can't be null.
This commit is contained in:
parent
3da9a635ef
commit
7dfe0a3b99
|
|
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue