Skip to content

Commit 4aa7107

Browse files
authored
fix: Why not set tenant to "" in ListTasksParams$Builder? (#657)
ListTasksParams.Builder should set the tenant to "" when it is not defined. Fixes #653 🦕 Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
1 parent 760b6a8 commit 4aa7107

File tree

6 files changed

+223
-3
lines changed

6 files changed

+223
-3
lines changed

spec/src/main/java/io/a2a/spec/DeleteTaskPushNotificationConfigParams.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44

55
import io.a2a.util.Assert;
6+
import io.a2a.util.Utils;
67
import org.jspecify.annotations.Nullable;
78

89
/**
@@ -111,7 +112,7 @@ public DeleteTaskPushNotificationConfigParams build() {
111112
return new DeleteTaskPushNotificationConfigParams(
112113
Assert.checkNotNullParam("id", id),
113114
Assert.checkNotNullParam("pushNotificationConfigId", pushNotificationConfigId),
114-
Assert.checkNotNullParam("tenant", tenant));
115+
Utils.defaultIfNull(tenant,""));
115116
}
116117
}
117118
}

spec/src/main/java/io/a2a/spec/GetTaskPushNotificationConfigParams.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44

55
import io.a2a.util.Assert;
6+
import io.a2a.util.Utils;
67
import org.jspecify.annotations.Nullable;
78

89
/**
@@ -108,7 +109,7 @@ public GetTaskPushNotificationConfigParams build() {
108109
return new GetTaskPushNotificationConfigParams(
109110
Assert.checkNotNullParam("id", id),
110111
Assert.checkNotNullParam("pushNotificationConfigId", pushNotificationConfigId),
111-
Assert.checkNotNullParam("tenant", tenant));
112+
Utils.defaultIfNull(tenant,""));
112113
}
113114
}
114115
}

spec/src/main/java/io/a2a/spec/ListTaskPushNotificationConfigParams.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.a2a.spec;
22

33
import io.a2a.util.Assert;
4+
import io.a2a.util.Utils;
5+
import org.jspecify.annotations.Nullable;
46

57
/**
68
* Parameters for listing all push notification configurations for a task.
@@ -51,4 +53,88 @@ public int getEffectivePageSize() {
5153
}
5254
return pageSize;
5355
}
56+
57+
/**
58+
* Create a new Builder
59+
*
60+
* @return the builder
61+
*/
62+
public static Builder builder() {
63+
return new Builder();
64+
}
65+
66+
/**
67+
* Builder for constructing instances.
68+
*/
69+
public static class Builder {
70+
private @Nullable String id;
71+
private @Nullable Integer pageSize;
72+
private @Nullable String pageToken;
73+
private @Nullable String tenant;
74+
75+
/**
76+
* Creates a new Builder with all fields unset.
77+
*/
78+
private Builder() {
79+
}
80+
81+
/**
82+
* Sets the id.
83+
*
84+
* @param id the task identifier (required)
85+
* @return this builder for method chaining
86+
*/
87+
public Builder id(String id) {
88+
this.id = id;
89+
return this;
90+
}
91+
92+
/**
93+
* Sets the pageSize.
94+
*
95+
* @param pageSize the maximum number of items to return per page
96+
* @return this builder for method chaining
97+
*/
98+
public Builder pageSize(Integer pageSize) {
99+
this.pageSize = pageSize;
100+
return this;
101+
}
102+
103+
/**
104+
* Sets the pageToken.
105+
*
106+
* @param pageToken the pagination token for the next page
107+
* @return this builder for method chaining
108+
*/
109+
public Builder pageToken(String pageToken) {
110+
this.pageToken = pageToken;
111+
return this;
112+
}
113+
114+
/**
115+
* Sets the tenant.
116+
*
117+
* @param tenant the tenant identifier
118+
* @return this builder for method chaining
119+
*/
120+
public Builder tenant(String tenant) {
121+
this.tenant = tenant;
122+
return this;
123+
}
124+
125+
/**
126+
* Builds the ListTaskPushNotificationConfigParams.
127+
*
128+
* @return a new ListTaskPushNotificationConfigParams instance
129+
* @throws IllegalArgumentException if id is null
130+
*/
131+
public ListTaskPushNotificationConfigParams build() {
132+
return new ListTaskPushNotificationConfigParams(
133+
Assert.checkNotNullParam("id", id),
134+
pageSize != null ? pageSize : 0,
135+
pageToken != null ? pageToken : "",
136+
Utils.defaultIfNull(tenant,"")
137+
);
138+
}
139+
}
54140
}

spec/src/main/java/io/a2a/spec/ListTasksParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public Builder tenant(String tenant) {
227227
*/
228228
public ListTasksParams build() {
229229
return new ListTasksParams(contextId, status, pageSize, pageToken, historyLength,
230-
statusTimestampAfter, includeArtifacts, Assert.checkNotNullParam("tenant", tenant));
230+
statusTimestampAfter, includeArtifacts, tenant == null ? "" : tenant);
231231
}
232232
}
233233
}

spec/src/main/java/io/a2a/spec/TaskIdParams.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.a2a.spec;
22

33
import io.a2a.util.Assert;
4+
import io.a2a.util.Utils;
5+
import org.jspecify.annotations.Nullable;
46

57
/**
68
* Parameters containing a task identifier for task-related operations.
@@ -34,4 +36,62 @@ public record TaskIdParams(String id, String tenant) {
3436
public TaskIdParams(String id) {
3537
this(id, "");
3638
}
39+
40+
/**
41+
* Create a new Builder
42+
*
43+
* @return the builder
44+
*/
45+
public static Builder builder() {
46+
return new Builder();
47+
}
48+
49+
/**
50+
* Builder for constructing instances.
51+
*/
52+
public static class Builder {
53+
private @Nullable String id;
54+
private @Nullable String tenant;
55+
56+
/**
57+
* Creates a new Builder with all fields unset.
58+
*/
59+
private Builder() {
60+
}
61+
62+
/**
63+
* Sets the id.
64+
*
65+
* @param id the task identifier (required)
66+
* @return this builder for method chaining
67+
*/
68+
public Builder id(String id) {
69+
this.id = id;
70+
return this;
71+
}
72+
73+
/**
74+
* Sets the tenant.
75+
*
76+
* @param tenant the tenant identifier
77+
* @return this builder for method chaining
78+
*/
79+
public Builder tenant(String tenant) {
80+
this.tenant = tenant;
81+
return this;
82+
}
83+
84+
/**
85+
* Builds the TaskIdParams.
86+
*
87+
* @return a new TaskIdParams instance
88+
* @throws IllegalArgumentException if id is null
89+
*/
90+
public TaskIdParams build() {
91+
return new TaskIdParams(
92+
Assert.checkNotNullParam("id", id),
93+
Utils.defaultIfNull(tenant,"")
94+
);
95+
}
96+
}
3797
}

spec/src/main/java/io/a2a/spec/TaskQueryParams.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.a2a.spec;
22

33
import io.a2a.util.Assert;
4+
import io.a2a.util.Utils;
45
import org.jspecify.annotations.Nullable;
56

67
/**
@@ -47,4 +48,75 @@ public TaskQueryParams(String id, @Nullable Integer historyLength) {
4748
public TaskQueryParams(String id) {
4849
this(id, null, "");
4950
}
51+
52+
/**
53+
* Create a new Builder
54+
*
55+
* @return the builder
56+
*/
57+
public static Builder builder() {
58+
return new Builder();
59+
}
60+
61+
/**
62+
* Builder for constructing instances.
63+
*/
64+
public static class Builder {
65+
private @Nullable String id;
66+
private @Nullable Integer historyLength;
67+
private @Nullable String tenant;
68+
69+
/**
70+
* Creates a new Builder with all fields unset.
71+
*/
72+
private Builder() {
73+
}
74+
75+
/**
76+
* Sets the id.
77+
*
78+
* @param id the task identifier (required)
79+
* @return this builder for method chaining
80+
*/
81+
public Builder id(String id) {
82+
this.id = id;
83+
return this;
84+
}
85+
86+
/**
87+
* Sets the historyLength.
88+
*
89+
* @param historyLength the maximum number of history items to include
90+
* @return this builder for method chaining
91+
*/
92+
public Builder historyLength(Integer historyLength) {
93+
this.historyLength = historyLength;
94+
return this;
95+
}
96+
97+
/**
98+
* Sets the tenant.
99+
*
100+
* @param tenant the tenant identifier
101+
* @return this builder for method chaining
102+
*/
103+
public Builder tenant(String tenant) {
104+
this.tenant = tenant;
105+
return this;
106+
}
107+
108+
/**
109+
* Builds the TaskQueryParams.
110+
*
111+
* @return a new TaskQueryParams instance
112+
* @throws IllegalArgumentException if id is null or historyLength is negative
113+
*/
114+
public TaskQueryParams build() {
115+
return new TaskQueryParams(
116+
Assert.checkNotNullParam("id", id),
117+
historyLength,
118+
Utils.defaultIfNull(tenant,"")
119+
);
120+
}
121+
}
50122
}

0 commit comments

Comments
 (0)