Skip to content

Commit 7dfe0a3

Browse files
committed
Hook context is immutable and some properties can't be null.
1 parent 3da9a63 commit 7dfe0a3

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
package javasdk;
22

3-
import lombok.Data;
3+
import lombok.Builder;
4+
import lombok.NonNull;
5+
import lombok.Value;
46

5-
@Data
7+
@Value @Builder
68
public class HookContext<T> {
7-
String flagKey;
8-
FlagValueType type;
9+
@NonNull String flagKey;
10+
@NonNull FlagValueType type;
11+
@NonNull T defaultValue;
12+
@NonNull EvaluationContext ctx;
913
Client client;
10-
EvaluationContext ctx;
1114
FeatureProvider provider;
12-
T defaultValue;
13-
HookEvaluation<T> executedHooks;
1415

1516
public static <T> HookContext<T> from(String key, FlagValueType type, Client client, EvaluationContext ctx, T defaultValue) {
16-
HookContext<T> hc = new HookContext<>();
17-
hc.flagKey = key;
18-
hc.type = type;
19-
hc.client = client;
20-
hc.ctx = ctx;
21-
hc.executedHooks = new HookEvaluation<T>();
22-
hc.defaultValue = defaultValue;
23-
return hc;
17+
return HookContext.<T>builder()
18+
.flagKey(key)
19+
.type(type)
20+
.client(client)
21+
.ctx(ctx)
22+
.defaultValue(defaultValue)
23+
.build();
2424
}
2525
}

0 commit comments

Comments
 (0)