Skip to content

Commit cd32276

Browse files
authored
docs: Add comprehensive Javadoc to spec module classes (#527)
Added Javadoc documentation for: - Public constants (error codes, method names, type identifiers) - Generic type parameters in base request/response classes - Record compact constructors (12 record classes) - Exception constructors (5 exception classes) - APIKeySecurityScheme (enum, methods, constructors, Builder) - Builder classes and methods (CancelTaskRequest, DeleteTaskPushNotificationConfig*) - Request/response constructors This resolves all Javadoc warnings and errors in the spec module, enabling clean builds with the -Prelease profile. Signed-off-by: Emmanuel Hugonnet <[email protected]>
1 parent 7465213 commit cd32276

28 files changed

+438
-3
lines changed

spec/src/main/java/io/a2a/json/JsonUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static GsonBuilder createBaseGsonBuilder() {
7979
* <p>
8080
* Used throughout the SDK for consistent JSON serialization and deserialization.
8181
*
82-
* @see GsonBuilder
82+
* @see JsonUtil#createBaseGsonBuilder()
8383
*/
8484
public static final Gson OBJECT_MAPPER = createBaseGsonBuilder()
8585
.registerTypeHierarchyAdapter(Part.class, new PartTypeAdapter())

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public class A2AClientHTTPError extends A2AClientError {
3333
private final int code;
3434
private final String message;
3535

36+
/**
37+
* Creates a new HTTP client error with the specified status code and message.
38+
*
39+
* @param code the HTTP status code
40+
* @param message the error message
41+
* @param data additional error data (may be the response body)
42+
* @throws IllegalArgumentException if code or message is null
43+
*/
3644
public A2AClientHTTPError(int code, String message, Object data) {
3745
Assert.checkNotNullParam("code", code);
3846
Assert.checkNotNullParam("message", message);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,27 @@
2727
*/
2828
public class A2AClientInvalidArgsError extends A2AClientError {
2929

30+
/**
31+
* Creates a new invalid arguments error with no message.
32+
*/
3033
public A2AClientInvalidArgsError() {
3134
}
3235

36+
/**
37+
* Creates a new invalid arguments error with the specified message.
38+
*
39+
* @param message the error message
40+
*/
3341
public A2AClientInvalidArgsError(String message) {
3442
super("Invalid arguments error: " + message);
3543
}
3644

45+
/**
46+
* Creates a new invalid arguments error with the specified message and cause.
47+
*
48+
* @param message the error message
49+
* @param cause the underlying cause
50+
*/
3751
public A2AClientInvalidArgsError(String message, Throwable cause) {
3852
super("Invalid arguments error: " + message, cause);
3953
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,27 @@
2626
*/
2727
public class A2AClientInvalidStateError extends A2AClientError {
2828

29+
/**
30+
* Creates a new invalid state error with no message.
31+
*/
2932
public A2AClientInvalidStateError() {
3033
}
3134

35+
/**
36+
* Creates a new invalid state error with the specified message.
37+
*
38+
* @param message the error message
39+
*/
3240
public A2AClientInvalidStateError(String message) {
3341
super("Invalid state error: " + message);
3442
}
3543

44+
/**
45+
* Creates a new invalid state error with the specified message and cause.
46+
*
47+
* @param message the error message
48+
* @param cause the underlying cause
49+
*/
3650
public A2AClientInvalidStateError(String message, Throwable cause) {
3751
super("Invalid state error: " + message, cause);
3852
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,27 @@
2727
*/
2828
public class A2AClientJSONError extends A2AClientError {
2929

30+
/**
31+
* Creates a new JSON error with no message.
32+
*/
3033
public A2AClientJSONError() {
3134
}
3235

36+
/**
37+
* Creates a new JSON error with the specified message.
38+
*
39+
* @param message the error message
40+
*/
3341
public A2AClientJSONError(String message) {
3442
super(message);
3543
}
3644

45+
/**
46+
* Creates a new JSON error with the specified message and cause.
47+
*
48+
* @param message the error message
49+
* @param cause the underlying cause
50+
*/
3751
public A2AClientJSONError(String message, Throwable cause) {
3852
super(message, cause);
3953
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,39 @@
55
*/
66
public interface A2AErrorCodes {
77

8+
/** Error code indicating the requested task was not found (-32001). */
89
int TASK_NOT_FOUND_ERROR_CODE = -32001;
10+
11+
/** Error code indicating the task cannot be canceled in its current state (-32002). */
912
int TASK_NOT_CANCELABLE_ERROR_CODE = -32002;
13+
14+
/** Error code indicating push notifications are not supported by this agent (-32003). */
1015
int PUSH_NOTIFICATION_NOT_SUPPORTED_ERROR_CODE = -32003;
16+
17+
/** Error code indicating the requested operation is not supported (-32004). */
1118
int UNSUPPORTED_OPERATION_ERROR_CODE = -32004;
19+
20+
/** Error code indicating the content type is not supported (-32005). */
1221
int CONTENT_TYPE_NOT_SUPPORTED_ERROR_CODE = -32005;
22+
23+
/** Error code indicating the agent returned an invalid response (-32006). */
1324
int INVALID_AGENT_RESPONSE_ERROR_CODE = -32006;
25+
26+
/** Error code indicating authenticated extended card is not configured (-32007). */
1427
int AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED_ERROR_CODE = -32007;
1528

29+
/** JSON-RPC error code for invalid request structure (-32600). */
1630
int INVALID_REQUEST_ERROR_CODE = -32600;
31+
32+
/** JSON-RPC error code for method not found (-32601). */
1733
int METHOD_NOT_FOUND_ERROR_CODE = -32601;
34+
35+
/** JSON-RPC error code for invalid method parameters (-32602). */
1836
int INVALID_PARAMS_ERROR_CODE = -32602;
37+
38+
/** JSON-RPC error code for internal server errors (-32603). */
1939
int INTERNAL_ERROR_CODE = -32603;
2040

41+
/** JSON-RPC error code for JSON parsing errors (-32700). */
2142
int JSON_PARSE_ERROR_CODE = -32700;
2243
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,37 @@
1919
*/
2020
public class A2AServerException extends A2AException {
2121

22+
/**
23+
* Creates a new A2AServerException with no message.
24+
*/
2225
public A2AServerException() {
2326
super();
2427
}
2528

29+
/**
30+
* Creates a new A2AServerException with the specified message.
31+
*
32+
* @param msg the exception message
33+
*/
2634
public A2AServerException(final String msg) {
2735
super(msg);
2836
}
2937

38+
/**
39+
* Creates a new A2AServerException with the specified cause.
40+
*
41+
* @param cause the underlying cause
42+
*/
3043
public A2AServerException(final Throwable cause) {
3144
super(cause);
3245
}
3346

47+
/**
48+
* Creates a new A2AServerException with the specified message and cause.
49+
*
50+
* @param msg the exception message
51+
* @param cause the underlying cause
52+
*/
3453
public A2AServerException(final String msg, final Throwable cause) {
3554
super(msg, cause);
3655
}

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

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
public final class APIKeySecurityScheme implements SecurityScheme {
2020

21+
/** The security scheme type identifier for API key authentication. */
2122
public static final String API_KEY = "apiKey";
2223
private final Location location;
2324
private final String name;
@@ -28,8 +29,13 @@ public final class APIKeySecurityScheme implements SecurityScheme {
2829
* Represents the location of the API key.
2930
*/
3031
public enum Location {
32+
/** API key sent in a cookie. */
3133
COOKIE("cookie"),
34+
35+
/** API key sent in an HTTP header. */
3236
HEADER("header"),
37+
38+
/** API key sent as a query parameter. */
3339
QUERY("query");
3440

3541
private final String location;
@@ -38,10 +44,22 @@ public enum Location {
3844
this.location = location;
3945
}
4046

47+
/**
48+
* Converts this location to its string representation.
49+
*
50+
* @return the string representation of this location
51+
*/
4152
public String asString() {
4253
return location;
4354
}
4455

56+
/**
57+
* Converts a string to a Location enum value.
58+
*
59+
* @param location the string location ("cookie", "header", or "query")
60+
* @return the corresponding Location enum value
61+
* @throws IllegalArgumentException if the location string is invalid
62+
*/
4563
public static Location fromString(String location) {
4664
switch (location) {
4765
case "cookie" -> {
@@ -58,10 +76,27 @@ public static Location fromString(String location) {
5876
}
5977
}
6078

79+
/**
80+
* Creates a new APIKeySecurityScheme with the specified location, name, and description.
81+
*
82+
* @param location the location where the API key is sent (required)
83+
* @param name the name of the API key parameter (required)
84+
* @param description a human-readable description (optional)
85+
* @throws IllegalArgumentException if location or name is null
86+
*/
6187
public APIKeySecurityScheme(Location location, String name, String description) {
6288
this(location, name, description, API_KEY);
6389
}
6490

91+
/**
92+
* Creates a new APIKeySecurityScheme with explicit type specification.
93+
*
94+
* @param location the location where the API key is sent (required)
95+
* @param name the name of the API key parameter (required)
96+
* @param description a human-readable description (optional)
97+
* @param type the security scheme type (must be "apiKey")
98+
* @throws IllegalArgumentException if location, name, or type is null, or if type is not "apiKey"
99+
*/
65100
public APIKeySecurityScheme(Location location, String name,
66101
String description, String type) {
67102
Assert.checkNotNullParam("location", location);
@@ -76,43 +111,99 @@ public APIKeySecurityScheme(Location location, String name,
76111
this.type = type;
77112
}
78113

114+
/**
115+
* Gets the human-readable description of this security scheme.
116+
*
117+
* @return the description, or null if not provided
118+
*/
79119
@Override
80120
public String getDescription() {
81121
return description;
82122
}
83123

124+
/**
125+
* Gets the location where the API key is sent.
126+
*
127+
* @return the API key location
128+
*/
84129
public Location getLocation() {
85130
return location;
86131
}
87132

133+
/**
134+
* Gets the name of the API key parameter.
135+
*
136+
* @return the parameter name
137+
*/
88138
public String getName() {
89139
return name;
90140
}
91141

142+
/**
143+
* Gets the security scheme type.
144+
*
145+
* @return always returns "apiKey"
146+
*/
92147
public String getType() {
93148
return type;
94149
}
95150

151+
/**
152+
* Builder for constructing immutable {@link APIKeySecurityScheme} instances.
153+
* <p>
154+
* Example usage:
155+
* <pre>{@code
156+
* APIKeySecurityScheme scheme = new APIKeySecurityScheme.Builder()
157+
* .location(Location.HEADER)
158+
* .name("X-API-Key")
159+
* .description("API key authentication")
160+
* .build();
161+
* }</pre>
162+
*/
96163
public static class Builder {
97164
private Location location;
98165
private String name;
99166
private String description;
100167

168+
/**
169+
* Sets the location where the API key should be sent.
170+
*
171+
* @param location the API key location (header, query, or cookie) (required)
172+
* @return this builder for method chaining
173+
*/
101174
public Builder location(Location location) {
102175
this.location = location;
103176
return this;
104177
}
105178

179+
/**
180+
* Sets the name of the API key parameter.
181+
*
182+
* @param name the parameter name (required)
183+
* @return this builder for method chaining
184+
*/
106185
public Builder name(String name) {
107186
this.name = name;
108187
return this;
109188
}
110189

190+
/**
191+
* Sets the human-readable description of the security scheme.
192+
*
193+
* @param description the description (optional)
194+
* @return this builder for method chaining
195+
*/
111196
public Builder description(String description) {
112197
this.description = description;
113198
return this;
114199
}
115200

201+
/**
202+
* Builds a new immutable {@link APIKeySecurityScheme} from the current builder state.
203+
*
204+
* @return a new APIKeySecurityScheme instance
205+
* @throws IllegalArgumentException if location or name is null
206+
*/
116207
public APIKeySecurityScheme build() {
117208
return new APIKeySecurityScheme(location, name, description);
118209
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public static class Builder {
5656
private boolean stateTransitionHistory;
5757
private List<AgentExtension> extensions;
5858

59+
/**
60+
* Creates a new Builder with all capabilities set to false by default.
61+
*/
62+
public Builder() {
63+
}
64+
5965
/**
6066
* Sets whether the agent supports streaming responses.
6167
* <p>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
public record AgentCardSignature(Map<String, Object> header, @SerializedName("protected")String protectedHeader,
3535
String signature) {
3636

37+
/**
38+
* Compact constructor that validates required fields.
39+
*
40+
* @throws IllegalArgumentException if protectedHeader or signature is null
41+
*/
3742
public AgentCardSignature {
3843
Assert.checkNotNullParam("protectedHeader", protectedHeader);
3944
Assert.checkNotNullParam("signature", signature);
@@ -56,6 +61,12 @@ public static class Builder {
5661
String protectedHeader;
5762
String signature;
5863

64+
/**
65+
* Creates a new Builder with all fields unset.
66+
*/
67+
public Builder() {
68+
}
69+
5970
/**
6071
* Sets the optional unprotected header with additional metadata.
6172
*

0 commit comments

Comments
 (0)