Skip to content

Commit 590cb79

Browse files
author
Bernd Warmuth
committed
fixup! feat: implemented support for tracking
Signed-off-by: Bernd Warmuth <[email protected]>
1 parent 1131417 commit 590cb79

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/main/java/dev/openfeature/sdk/MutableTrackingEventDetails.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import lombok.ToString;
77
import lombok.experimental.Delegate;
88

9+
import java.time.Instant;
10+
import java.util.List;
911
import java.util.Map;
1012
import java.util.function.Function;
1113

@@ -31,6 +33,48 @@ public MutableTrackingEventDetails(final Number value) {
3133
this.structure = new MutableStructure();
3234
}
3335

36+
// override @Delegate methods so that we can use "add" methods and still return MutableTrackingEventDetails,
37+
// not Structure
38+
public MutableTrackingEventDetails add(String key, Boolean value) {
39+
this.structure.add(key, value);
40+
return this;
41+
}
42+
43+
public MutableTrackingEventDetails add(String key, String value) {
44+
this.structure.add(key, value);
45+
return this;
46+
}
47+
48+
public MutableTrackingEventDetails add(String key, Integer value) {
49+
this.structure.add(key, value);
50+
return this;
51+
}
52+
53+
public MutableTrackingEventDetails add(String key, Double value) {
54+
this.structure.add(key, value);
55+
return this;
56+
}
57+
58+
public MutableTrackingEventDetails add(String key, Instant value) {
59+
this.structure.add(key, value);
60+
return this;
61+
}
62+
63+
public MutableTrackingEventDetails add(String key, Structure value) {
64+
this.structure.add(key, value);
65+
return this;
66+
}
67+
68+
public MutableTrackingEventDetails add(String key, List<Value> value) {
69+
this.structure.add(key, value);
70+
return this;
71+
}
72+
73+
public MutableTrackingEventDetails add(String key, Value value) {
74+
this.structure.add(key,value);
75+
return this;
76+
}
77+
3478

3579
@SuppressWarnings("all")
3680
private static class DelegateExclusions {

src/test/java/dev/openfeature/sdk/TrackingSpecTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void eventDetails() {
150150
expectedMap.put("my-bool", new Value(true));
151151
expectedMap.put("my-struct", new Value(new MutableTrackingEventDetails()));
152152

153-
MutableStructure details = new MutableTrackingEventDetails()
153+
MutableTrackingEventDetails details = new MutableTrackingEventDetails()
154154
.add("my-str", new Value("str"))
155155
.add("my-num", new Value(1))
156156
.add("my-bool", new Value(true))

0 commit comments

Comments
 (0)