diff --git a/core/src/main/java/com/google/adk/events/EventActions.java b/core/src/main/java/com/google/adk/events/EventActions.java index 4873a5f49..0b167de93 100644 --- a/core/src/main/java/com/google/adk/events/EventActions.java +++ b/core/src/main/java/com/google/adk/events/EventActions.java @@ -28,36 +28,32 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Represents the actions attached to an event. */ // TODO - b/414081262 make json wire camelCase @JsonDeserialize(builder = EventActions.Builder.class) public class EventActions extends JsonBaseModel { - private Optional skipSummarization; + private @Nullable Boolean skipSummarization; private ConcurrentMap stateDelta; private ConcurrentMap artifactDelta; private Set deletedArtifactIds; - private Optional transferToAgent; - private Optional escalate; + private @Nullable String transferToAgent; + private @Nullable Boolean escalate; private ConcurrentMap> requestedAuthConfigs; private ConcurrentMap requestedToolConfirmations; private boolean endOfAgent; - private Optional compaction; + private @Nullable EventCompaction compaction; /** Default constructor for Jackson. */ public EventActions() { - this.skipSummarization = Optional.empty(); this.stateDelta = new ConcurrentHashMap<>(); this.artifactDelta = new ConcurrentHashMap<>(); this.deletedArtifactIds = new HashSet<>(); - this.transferToAgent = Optional.empty(); - this.escalate = Optional.empty(); this.requestedAuthConfigs = new ConcurrentHashMap<>(); this.requestedToolConfirmations = new ConcurrentHashMap<>(); this.endOfAgent = false; - this.compaction = Optional.empty(); } private EventActions(Builder builder) { @@ -75,19 +71,15 @@ private EventActions(Builder builder) { @JsonProperty("skipSummarization") public Optional skipSummarization() { - return skipSummarization; + return Optional.ofNullable(skipSummarization); } public void setSkipSummarization(@Nullable Boolean skipSummarization) { - this.skipSummarization = Optional.ofNullable(skipSummarization); - } - - public void setSkipSummarization(Optional skipSummarization) { this.skipSummarization = skipSummarization; } public void setSkipSummarization(boolean skipSummarization) { - this.skipSummarization = Optional.of(skipSummarization); + this.skipSummarization = skipSummarization; } @JsonProperty("stateDelta") @@ -130,30 +122,22 @@ public void setDeletedArtifactIds(Set deletedArtifactIds) { @JsonProperty("transferToAgent") public Optional transferToAgent() { - return transferToAgent; + return Optional.ofNullable(transferToAgent); } - public void setTransferToAgent(Optional transferToAgent) { + public void setTransferToAgent(@Nullable String transferToAgent) { this.transferToAgent = transferToAgent; } - public void setTransferToAgent(String transferToAgent) { - this.transferToAgent = Optional.ofNullable(transferToAgent); - } - @JsonProperty("escalate") public Optional escalate() { - return escalate; + return Optional.ofNullable(escalate); } - public void setEscalate(Optional escalate) { + public void setEscalate(@Nullable Boolean escalate) { this.escalate = escalate; } - public void setEscalate(boolean escalate) { - this.escalate = Optional.of(escalate); - } - @JsonProperty("requestedAuthConfigs") public ConcurrentMap> requestedAuthConfigs() { return requestedAuthConfigs; @@ -199,14 +183,6 @@ public Optional endInvocation() { return endOfAgent ? Optional.of(true) : Optional.empty(); } - /** - * @deprecated Use {@link #setEndOfAgent(boolean)} instead. - */ - @Deprecated - public void setEndInvocation(Optional endInvocation) { - this.endOfAgent = endInvocation.orElse(false); - } - /** * @deprecated Use {@link #setEndOfAgent(boolean)} instead. */ @@ -217,10 +193,10 @@ public void setEndInvocation(boolean endInvocation) { @JsonProperty("compaction") public Optional compaction() { - return compaction; + return Optional.ofNullable(compaction); } - public void setCompaction(Optional compaction) { + public void setCompaction(@Nullable EventCompaction compaction) { this.compaction = compaction; } @@ -269,47 +245,43 @@ public int hashCode() { /** Builder for {@link EventActions}. */ public static class Builder { - private Optional skipSummarization; + private @Nullable Boolean skipSummarization; private ConcurrentMap stateDelta; private ConcurrentMap artifactDelta; private Set deletedArtifactIds; - private Optional transferToAgent; - private Optional escalate; + private @Nullable String transferToAgent; + private @Nullable Boolean escalate; private ConcurrentMap> requestedAuthConfigs; private ConcurrentMap requestedToolConfirmations; private boolean endOfAgent = false; - private Optional compaction; + private @Nullable EventCompaction compaction; public Builder() { - this.skipSummarization = Optional.empty(); this.stateDelta = new ConcurrentHashMap<>(); this.artifactDelta = new ConcurrentHashMap<>(); this.deletedArtifactIds = new HashSet<>(); - this.transferToAgent = Optional.empty(); - this.escalate = Optional.empty(); this.requestedAuthConfigs = new ConcurrentHashMap<>(); this.requestedToolConfirmations = new ConcurrentHashMap<>(); - this.compaction = Optional.empty(); } private Builder(EventActions eventActions) { - this.skipSummarization = eventActions.skipSummarization(); + this.skipSummarization = eventActions.skipSummarization; this.stateDelta = new ConcurrentHashMap<>(eventActions.stateDelta()); this.artifactDelta = new ConcurrentHashMap<>(eventActions.artifactDelta()); this.deletedArtifactIds = new HashSet<>(eventActions.deletedArtifactIds()); - this.transferToAgent = eventActions.transferToAgent(); - this.escalate = eventActions.escalate(); + this.transferToAgent = eventActions.transferToAgent; + this.escalate = eventActions.escalate; this.requestedAuthConfigs = new ConcurrentHashMap<>(eventActions.requestedAuthConfigs()); this.requestedToolConfirmations = new ConcurrentHashMap<>(eventActions.requestedToolConfirmations()); - this.endOfAgent = eventActions.endOfAgent(); - this.compaction = eventActions.compaction(); + this.endOfAgent = eventActions.endOfAgent; + this.compaction = eventActions.compaction; } @CanIgnoreReturnValue @JsonProperty("skipSummarization") public Builder skipSummarization(boolean skipSummarization) { - this.skipSummarization = Optional.of(skipSummarization); + this.skipSummarization = skipSummarization; return this; } @@ -336,15 +308,15 @@ public Builder deletedArtifactIds(Set value) { @CanIgnoreReturnValue @JsonProperty("transferToAgent") - public Builder transferToAgent(String agentId) { - this.transferToAgent = Optional.ofNullable(agentId); + public Builder transferToAgent(@Nullable String agentId) { + this.transferToAgent = agentId; return this; } @CanIgnoreReturnValue @JsonProperty("escalate") public Builder escalate(boolean escalate) { - this.escalate = Optional.of(escalate); + this.escalate = escalate; return this; } @@ -391,8 +363,8 @@ public Builder endInvocation(boolean endInvocation) { @CanIgnoreReturnValue @JsonProperty("compaction") - public Builder compaction(EventCompaction value) { - this.compaction = Optional.ofNullable(value); + public Builder compaction(@Nullable EventCompaction value) { + this.compaction = value; return this; }