|
30 | 30 | @JsonDeserialize(builder = EventActions.Builder.class) |
31 | 31 | public class EventActions { |
32 | 32 |
|
33 | | - private Optional<Boolean> skipSummarization = Optional.empty(); |
34 | | - private ConcurrentMap<String, Object> stateDelta = new ConcurrentHashMap<>(); |
35 | | - private ConcurrentMap<String, Part> artifactDelta = new ConcurrentHashMap<>(); |
36 | | - private Optional<String> transferToAgent = Optional.empty(); |
37 | | - private Optional<Boolean> escalate = Optional.empty(); |
38 | | - private ConcurrentMap<String, ConcurrentMap<String, Object>> requestedAuthConfigs = |
39 | | - new ConcurrentHashMap<>(); |
40 | | - private ConcurrentMap<String, ToolConfirmation> requestedToolConfirmations = |
41 | | - new ConcurrentHashMap<>(); |
42 | | - private Optional<Boolean> endInvocation = Optional.empty(); |
43 | | - private Optional<EventCompaction> compaction = Optional.empty(); |
| 33 | + private Optional<Boolean> skipSummarization; |
| 34 | + private ConcurrentMap<String, Object> stateDelta; |
| 35 | + private ConcurrentMap<String, Part> artifactDelta; |
| 36 | + private Optional<String> transferToAgent; |
| 37 | + private Optional<Boolean> escalate; |
| 38 | + private ConcurrentMap<String, ConcurrentMap<String, Object>> requestedAuthConfigs; |
| 39 | + private ConcurrentMap<String, ToolConfirmation> requestedToolConfirmations; |
| 40 | + private Optional<Boolean> endInvocation; |
| 41 | + private Optional<EventCompaction> compaction; |
44 | 42 |
|
45 | 43 | /** Default constructor for Jackson. */ |
46 | | - public EventActions() {} |
| 44 | + public EventActions() { |
| 45 | + this.skipSummarization = Optional.empty(); |
| 46 | + this.stateDelta = new ConcurrentHashMap<>(); |
| 47 | + this.artifactDelta = new ConcurrentHashMap<>(); |
| 48 | + this.transferToAgent = Optional.empty(); |
| 49 | + this.escalate = Optional.empty(); |
| 50 | + this.requestedAuthConfigs = new ConcurrentHashMap<>(); |
| 51 | + this.requestedToolConfirmations = new ConcurrentHashMap<>(); |
| 52 | + this.endInvocation = Optional.empty(); |
| 53 | + this.compaction = Optional.empty(); |
| 54 | + } |
| 55 | + |
| 56 | + private EventActions(Builder builder) { |
| 57 | + this.skipSummarization = builder.skipSummarization; |
| 58 | + this.stateDelta = builder.stateDelta; |
| 59 | + this.artifactDelta = builder.artifactDelta; |
| 60 | + this.transferToAgent = builder.transferToAgent; |
| 61 | + this.escalate = builder.escalate; |
| 62 | + this.requestedAuthConfigs = builder.requestedAuthConfigs; |
| 63 | + this.requestedToolConfirmations = builder.requestedToolConfirmations; |
| 64 | + this.endInvocation = builder.endInvocation; |
| 65 | + this.compaction = builder.compaction; |
| 66 | + } |
47 | 67 |
|
48 | 68 | @JsonProperty("skipSummarization") |
49 | 69 | public Optional<Boolean> skipSummarization() { |
@@ -191,19 +211,27 @@ public int hashCode() { |
191 | 211 |
|
192 | 212 | /** Builder for {@link EventActions}. */ |
193 | 213 | public static class Builder { |
194 | | - private Optional<Boolean> skipSummarization = Optional.empty(); |
195 | | - private ConcurrentMap<String, Object> stateDelta = new ConcurrentHashMap<>(); |
196 | | - private ConcurrentMap<String, Part> artifactDelta = new ConcurrentHashMap<>(); |
197 | | - private Optional<String> transferToAgent = Optional.empty(); |
198 | | - private Optional<Boolean> escalate = Optional.empty(); |
199 | | - private ConcurrentMap<String, ConcurrentMap<String, Object>> requestedAuthConfigs = |
200 | | - new ConcurrentHashMap<>(); |
201 | | - private ConcurrentMap<String, ToolConfirmation> requestedToolConfirmations = |
202 | | - new ConcurrentHashMap<>(); |
203 | | - private Optional<Boolean> endInvocation = Optional.empty(); |
204 | | - private Optional<EventCompaction> compaction = Optional.empty(); |
205 | | - |
206 | | - public Builder() {} |
| 214 | + private Optional<Boolean> skipSummarization; |
| 215 | + private ConcurrentMap<String, Object> stateDelta; |
| 216 | + private ConcurrentMap<String, Part> artifactDelta; |
| 217 | + private Optional<String> transferToAgent; |
| 218 | + private Optional<Boolean> escalate; |
| 219 | + private ConcurrentMap<String, ConcurrentMap<String, Object>> requestedAuthConfigs; |
| 220 | + private ConcurrentMap<String, ToolConfirmation> requestedToolConfirmations; |
| 221 | + private Optional<Boolean> endInvocation; |
| 222 | + private Optional<EventCompaction> compaction; |
| 223 | + |
| 224 | + public Builder() { |
| 225 | + this.skipSummarization = Optional.empty(); |
| 226 | + this.stateDelta = new ConcurrentHashMap<>(); |
| 227 | + this.artifactDelta = new ConcurrentHashMap<>(); |
| 228 | + this.transferToAgent = Optional.empty(); |
| 229 | + this.escalate = Optional.empty(); |
| 230 | + this.requestedAuthConfigs = new ConcurrentHashMap<>(); |
| 231 | + this.requestedToolConfirmations = new ConcurrentHashMap<>(); |
| 232 | + this.endInvocation = Optional.empty(); |
| 233 | + this.compaction = Optional.empty(); |
| 234 | + } |
207 | 235 |
|
208 | 236 | private Builder(EventActions eventActions) { |
209 | 237 | this.skipSummarization = eventActions.skipSummarization(); |
@@ -284,48 +312,20 @@ public Builder compaction(EventCompaction value) { |
284 | 312 |
|
285 | 313 | @CanIgnoreReturnValue |
286 | 314 | public Builder merge(EventActions other) { |
287 | | - if (other.skipSummarization().isPresent()) { |
288 | | - this.skipSummarization = other.skipSummarization(); |
289 | | - } |
290 | | - if (other.stateDelta() != null) { |
291 | | - this.stateDelta.putAll(other.stateDelta()); |
292 | | - } |
293 | | - if (other.artifactDelta() != null) { |
294 | | - this.artifactDelta.putAll(other.artifactDelta()); |
295 | | - } |
296 | | - if (other.transferToAgent().isPresent()) { |
297 | | - this.transferToAgent = other.transferToAgent(); |
298 | | - } |
299 | | - if (other.escalate().isPresent()) { |
300 | | - this.escalate = other.escalate(); |
301 | | - } |
302 | | - if (other.requestedAuthConfigs() != null) { |
303 | | - this.requestedAuthConfigs.putAll(other.requestedAuthConfigs()); |
304 | | - } |
305 | | - if (other.requestedToolConfirmations() != null) { |
306 | | - this.requestedToolConfirmations.putAll(other.requestedToolConfirmations()); |
307 | | - } |
308 | | - if (other.endInvocation().isPresent()) { |
309 | | - this.endInvocation = other.endInvocation(); |
310 | | - } |
311 | | - if (other.compaction().isPresent()) { |
312 | | - this.compaction = other.compaction(); |
313 | | - } |
| 315 | + other.skipSummarization().ifPresent(this::skipSummarization); |
| 316 | + this.stateDelta.putAll(other.stateDelta()); |
| 317 | + this.artifactDelta.putAll(other.artifactDelta()); |
| 318 | + other.transferToAgent().ifPresent(this::transferToAgent); |
| 319 | + other.escalate().ifPresent(this::escalate); |
| 320 | + this.requestedAuthConfigs.putAll(other.requestedAuthConfigs()); |
| 321 | + this.requestedToolConfirmations.putAll(other.requestedToolConfirmations()); |
| 322 | + other.endInvocation().ifPresent(this::endInvocation); |
| 323 | + other.compaction().ifPresent(this::compaction); |
314 | 324 | return this; |
315 | 325 | } |
316 | 326 |
|
317 | 327 | public EventActions build() { |
318 | | - EventActions eventActions = new EventActions(); |
319 | | - eventActions.setSkipSummarization(this.skipSummarization); |
320 | | - eventActions.setStateDelta(this.stateDelta); |
321 | | - eventActions.setArtifactDelta(this.artifactDelta); |
322 | | - eventActions.setTransferToAgent(this.transferToAgent); |
323 | | - eventActions.setEscalate(this.escalate); |
324 | | - eventActions.setRequestedAuthConfigs(this.requestedAuthConfigs); |
325 | | - eventActions.setRequestedToolConfirmations(this.requestedToolConfirmations); |
326 | | - eventActions.setEndInvocation(this.endInvocation); |
327 | | - eventActions.setCompaction(this.compaction); |
328 | | - return eventActions; |
| 328 | + return new EventActions(this); |
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
0 commit comments