Skip to content

Commit 2f0189e

Browse files
Copilotedburns
andauthored
fix: update Javadoc for Optional-based API and fix test assertions
- Update @return tags to describe Optional.empty()/OptionalInt.empty() instead of null - Update @param tags to remove null references on primitive setters - Fix exception message in CopilotSession to use valid Java syntax - Fix ElicitationTest to use assertEquals(Boolean.TRUE, ...) to avoid NPE Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
1 parent 6196b8f commit 2f0189e

11 files changed

Lines changed: 55 additions & 34 deletions

src/main/java/com/github/copilot/sdk/CopilotSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ private void assertElicitation() {
11201120
SessionCapabilities caps = capabilities;
11211121
if (caps == null || caps.getUi() == null || !caps.getUi().getElicitation().orElse(false)) {
11221122
throw new IllegalStateException("Elicitation is not supported by the host. "
1123-
+ "Check session.getCapabilities().getUi()?.getElicitation() before calling UI methods.");
1123+
+ "Check session.getCapabilities().getUi().getElicitation().orElse(false) before calling UI methods.");
11241124
}
11251125
}
11261126

src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ public CopilotClientOptions setTelemetry(TelemetryConfig telemetry) {
503503
* Gets the server-wide idle timeout for sessions in seconds.
504504
*
505505
* @return an {@link OptionalInt} containing the session idle timeout in
506-
* seconds, or empty to disable (sessions live indefinitely)
506+
* seconds, or {@link java.util.OptionalInt#empty()} if not set. Use
507+
* {@link #clearSessionIdleTimeoutSeconds()} to revert to the default.
507508
* @since 1.3.0
508509
*/
509510
@JsonIgnore

src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ public CustomAgentConfig setMcpServers(Map<String, McpServerConfig> mcpServers)
199199
/**
200200
* Gets whether inference mode is enabled.
201201
*
202-
* @return the infer flag, or {@code null} if not set
202+
* @return an {@link java.util.Optional} containing the infer flag, or
203+
* {@link java.util.Optional#empty()} if not set
203204
*/
204205
@JsonIgnore
205206
public Optional<Boolean> getInfer() {

src/main/java/com/github/copilot/sdk/json/InputOptions.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ public InputOptions setDescription(String description) {
4949
return this;
5050
}
5151

52-
/** Gets the minimum character length. @return the min length */
52+
/**
53+
* Gets the minimum character length.
54+
*
55+
* @return an {@link java.util.OptionalInt} containing the min length, or
56+
* {@link java.util.OptionalInt#empty()} if not set
57+
*/
5358
@JsonIgnore
5459
public OptionalInt getMinLength() {
5560
return minLength == null ? OptionalInt.empty() : OptionalInt.of(minLength);
@@ -74,7 +79,12 @@ public InputOptions clearMinLength() {
7479
return this;
7580
}
7681

77-
/** Gets the maximum character length. @return the max length */
82+
/**
83+
* Gets the maximum character length.
84+
*
85+
* @return an {@link java.util.OptionalInt} containing the max length, or
86+
* {@link java.util.OptionalInt#empty()} if not set
87+
*/
7888
@JsonIgnore
7989
public OptionalInt getMaxLength() {
8090
return maxLength == null ? OptionalInt.empty() : OptionalInt.of(maxLength);

src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,21 @@ public static class Supports {
109109
/**
110110
* Gets the vision override.
111111
*
112-
* @return {@code true} to enable vision, {@code false} to disable, or
113-
* {@code null} to use the runtime default
112+
* @return an {@link java.util.Optional} containing {@code true} to enable
113+
* vision or {@code false} to disable, or
114+
* {@link java.util.Optional#empty()} to use the runtime default
114115
*/
115116
@JsonIgnore
116117
public Optional<Boolean> getVision() {
117118
return Optional.ofNullable(vision);
118119
}
119120

120121
/**
121-
* Sets whether vision (image input) is enabled.
122+
* Sets whether vision (image input) is enabled. Use {@link #clearVision()} to
123+
* revert to the runtime default.
122124
*
123125
* @param vision
124-
* {@code true} to enable, {@code false} to disable, or {@code null}
125-
* to use the runtime default
126+
* {@code true} to enable, {@code false} to disable
126127
* @return this instance for method chaining
127128
*/
128129
public Supports setVision(boolean vision) {
@@ -143,20 +144,21 @@ public Supports clearVision() {
143144
/**
144145
* Gets the reasoning effort override.
145146
*
146-
* @return {@code true} to enable reasoning effort, {@code false} to disable, or
147-
* {@code null} to use the runtime default
147+
* @return an {@link java.util.Optional} containing {@code true} to enable
148+
* reasoning effort or {@code false} to disable, or
149+
* {@link java.util.Optional#empty()} to use the runtime default
148150
*/
149151
@JsonIgnore
150152
public Optional<Boolean> getReasoningEffort() {
151153
return Optional.ofNullable(reasoningEffort);
152154
}
153155

154156
/**
155-
* Sets whether reasoning effort configuration is enabled.
157+
* Sets whether reasoning effort configuration is enabled. Use
158+
* {@link #clearReasoningEffort()} to revert to the runtime default.
156159
*
157160
* @param reasoningEffort
158-
* {@code true} to enable, {@code false} to disable, or {@code null}
159-
* to use the runtime default
161+
* {@code true} to enable, {@code false} to disable
160162
* @return this instance for method chaining
161163
*/
162164
public Supports setReasoningEffort(boolean reasoningEffort) {

src/main/java/com/github/copilot/sdk/json/ProviderConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ public ProviderConfig setWireModel(String wireModel) {
298298
/**
299299
* Gets the maximum prompt token override.
300300
*
301-
* @return the max prompt tokens, or {@code null} if not set
301+
* @return an {@link java.util.OptionalInt} containing the max prompt tokens, or
302+
* {@link java.util.OptionalInt#empty()} if not set
302303
*/
303304
@JsonIgnore
304305
public OptionalInt getMaxPromptTokens() {
@@ -335,7 +336,8 @@ public ProviderConfig clearMaxPromptTokens() {
335336
/**
336337
* Gets the maximum output token override.
337338
*
338-
* @return the max output tokens, or {@code null} if not set
339+
* @return an {@link java.util.OptionalInt} containing the max output tokens, or
340+
* {@link java.util.OptionalInt#empty()} if not set
339341
*/
340342
@JsonIgnore
341343
public OptionalInt getMaxOutputTokens() {

src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,16 @@ public ResumeSessionConfig setProvider(ProviderConfig provider) {
236236

237237
/**
238238
* Enables or disables internal session telemetry for this session. When
239-
* {@code false}, disables session telemetry. When {@code null} (the default) or
239+
* {@code false}, disables session telemetry. When unset (the default) or
240240
* {@code true}, telemetry is enabled for GitHub-authenticated sessions. When a
241241
* custom {@link ProviderConfig} (BYOK) is configured, session telemetry is
242242
* always disabled regardless of this setting. This is independent of
243243
* {@link com.github.copilot.sdk.json.CopilotClientOptions#getTelemetry()
244244
* CopilotClientOptions.TelemetryConfig}, which configures OpenTelemetry export
245245
* for observability.
246246
*
247-
* @return whether session telemetry is enabled
247+
* @return an {@link java.util.Optional} containing whether session telemetry is
248+
* enabled, or {@link java.util.Optional#empty()} for the default
248249
*/
249250
@JsonIgnore
250251
public Optional<Boolean> getEnableSessionTelemetry() {
@@ -253,7 +254,7 @@ public Optional<Boolean> getEnableSessionTelemetry() {
253254

254255
/**
255256
* Enables or disables internal session telemetry for this session. When
256-
* {@code false}, disables session telemetry. When {@code null} (the default) or
257+
* {@code false}, disables session telemetry. When unset (the default) or
257258
* {@code true}, telemetry is enabled for GitHub-authenticated sessions. When a
258259
* custom {@link ProviderConfig} (BYOK) is configured, session telemetry is
259260
* always disabled regardless of this setting.

src/main/java/com/github/copilot/sdk/json/SessionConfig.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,16 @@ public SessionConfig setProvider(ProviderConfig provider) {
290290

291291
/**
292292
* Enables or disables internal session telemetry for this session. When
293-
* {@code false}, disables session telemetry. When {@code null} (the default) or
293+
* {@code false}, disables session telemetry. When unset (the default) or
294294
* {@code true}, telemetry is enabled for GitHub-authenticated sessions. When a
295295
* custom {@link ProviderConfig} (BYOK) is configured, session telemetry is
296296
* always disabled regardless of this setting. This is independent of
297297
* {@link com.github.copilot.sdk.json.CopilotClientOptions#getTelemetry()
298298
* CopilotClientOptions.TelemetryConfig}, which configures OpenTelemetry export
299299
* for observability.
300300
*
301-
* @return whether session telemetry is enabled
301+
* @return an {@link java.util.Optional} containing whether session telemetry is
302+
* enabled, or {@link java.util.Optional#empty()} for the default
302303
*/
303304
@JsonIgnore
304305
public Optional<Boolean> getEnableSessionTelemetry() {
@@ -307,7 +308,7 @@ public Optional<Boolean> getEnableSessionTelemetry() {
307308

308309
/**
309310
* Enables or disables internal session telemetry for this session. When
310-
* {@code false}, disables session telemetry. When {@code null} (the default) or
311+
* {@code false}, disables session telemetry. When unset (the default) or
311312
* {@code true}, telemetry is enabled for GitHub-authenticated sessions. When a
312313
* custom {@link ProviderConfig} (BYOK) is configured, session telemetry is
313314
* always disabled regardless of this setting.
@@ -671,8 +672,9 @@ public SessionConfig setConfigDir(String configDir) {
671672
/**
672673
* Gets whether automatic configuration discovery is enabled.
673674
*
674-
* @return {@code true} to enable discovery, {@code false} to disable, or
675-
* {@code null} to use the runtime default
675+
* @return an {@link java.util.Optional} containing {@code true} to enable
676+
* discovery or {@code false} to disable, or
677+
* {@link java.util.Optional#empty()} to use the runtime default
676678
*/
677679
@JsonIgnore
678680
public Optional<Boolean> getEnableConfigDiscovery() {
@@ -690,8 +692,7 @@ public Optional<Boolean> getEnableConfigDiscovery() {
690692
* name collision.
691693
*
692694
* @param enableConfigDiscovery
693-
* {@code true} to enable discovery, {@code false} to disable, or
694-
* {@code null} to use the runtime default
695+
* {@code true} to enable discovery, {@code false} to disable
695696
* @return this config instance for method chaining
696697
*/
697698
public SessionConfig setEnableConfigDiscovery(boolean enableConfigDiscovery) {
@@ -712,8 +713,9 @@ public SessionConfig clearEnableConfigDiscovery() {
712713
/**
713714
* Gets whether sub-agent streaming events are included.
714715
*
715-
* @return {@code true} to include sub-agent streaming events, {@code false} to
716-
* suppress them, or {@code null} to use the runtime default
716+
* @return an {@link java.util.Optional} containing {@code true} to include
717+
* sub-agent streaming events or {@code false} to suppress them, or
718+
* {@link java.util.Optional#empty()} to use the runtime default
717719
*/
718720
@JsonIgnore
719721
public Optional<Boolean> getIncludeSubAgentStreamingEvents() {

src/main/java/com/github/copilot/sdk/json/TelemetryConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ public TelemetryConfig setSourceName(String sourceName) {
132132
* Maps to the {@code OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT}
133133
* environment variable.
134134
*
135-
* @return {@code true} to capture content, {@code false} to suppress it, or
136-
* {@code null} to use the default
135+
* @return an {@link java.util.Optional} containing {@code true} to capture
136+
* content or {@code false} to suppress it, or
137+
* {@link java.util.Optional#empty()} to use the default
137138
*/
138139
@JsonIgnore
139140
public Optional<Boolean> getCaptureContent() {

src/main/java/com/github/copilot/sdk/json/UserInputRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public UserInputRequest setChoices(List<String> choices) {
7777
/**
7878
* Returns whether freeform text input is allowed.
7979
*
80-
* @return {@code true} if freeform input is allowed, {@code null} if not
80+
* @return an {@link java.util.Optional} containing {@code true} if freeform
81+
* input is allowed, or {@link java.util.Optional#empty()} if not
8182
* specified
8283
*/
8384
@JsonIgnore

0 commit comments

Comments
 (0)