Skip to content

Commit 33a8edf

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: update return type for artifactDelta getter and setter to Map from ConcurrentMap
PiperOrigin-RevId: 880807999
1 parent b71900f commit 33a8edf

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

core/src/main/java/com/google/adk/events/EventActions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public void removeStateByKey(String key) {
110110
}
111111

112112
@JsonProperty("artifactDelta")
113-
public ConcurrentMap<String, Integer> artifactDelta() {
113+
public Map<String, Integer> artifactDelta() {
114114
return artifactDelta;
115115
}
116116

117-
public void setArtifactDelta(ConcurrentMap<String, Integer> artifactDelta) {
118-
this.artifactDelta = artifactDelta;
117+
public void setArtifactDelta(Map<String, Integer> artifactDelta) {
118+
this.artifactDelta = new ConcurrentHashMap<>(artifactDelta);
119119
}
120120

121121
@JsonProperty("deletedArtifactIds")
@@ -322,8 +322,8 @@ public Builder stateDelta(ConcurrentMap<String, Object> value) {
322322

323323
@CanIgnoreReturnValue
324324
@JsonProperty("artifactDelta")
325-
public Builder artifactDelta(ConcurrentMap<String, Integer> value) {
326-
this.artifactDelta = value;
325+
public Builder artifactDelta(Map<String, Integer> value) {
326+
this.artifactDelta = new ConcurrentHashMap<>(value);
327327
return this;
328328
}
329329

core/src/test/java/com/google/adk/events/EventActionsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ public void merge_mergesAllFields() {
110110
assertThat(merged.compaction()).hasValue(COMPACTION);
111111
}
112112

113+
@Test
114+
public void setArtifactDelta_copiesRegularMap() {
115+
EventActions eventActions = new EventActions();
116+
ImmutableMap<String, Integer> artifactDelta = ImmutableMap.of("artifact1", 1);
117+
118+
eventActions.setArtifactDelta(artifactDelta);
119+
120+
assertThat(eventActions.artifactDelta()).containsExactly("artifact1", 1);
121+
}
122+
113123
@Test
114124
public void removeStateByKey_marksKeyAsRemoved() {
115125
EventActions eventActions = new EventActions();

0 commit comments

Comments
 (0)