Skip to content

Commit befd206

Browse files
Copilotedburns
andauthored
Add @JsonCreator to AgentMode for JSON round-trip and update @SInCE to 1.1.0
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
1 parent 5305220 commit befd206

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/main/java/com/github/copilot/rpc/AgentMode.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package com.github.copilot.rpc;
66

7+
import com.fasterxml.jackson.annotation.JsonCreator;
78
import com.fasterxml.jackson.annotation.JsonValue;
89

910
/**
@@ -13,7 +14,7 @@
1314
* specific mode; defaults to the session's current mode when unset.
1415
*
1516
* @see MessageOptions
16-
* @since 1.0.0
17+
* @since 1.1.0
1718
*/
1819
public enum AgentMode {
1920

@@ -44,4 +45,28 @@ public enum AgentMode {
4445
public String getValue() {
4546
return value;
4647
}
48+
49+
/**
50+
* Deserializes a JSON string value into the corresponding {@code AgentMode}
51+
* enum constant.
52+
*
53+
* @param value
54+
* the JSON string value
55+
* @return the matching {@code AgentMode}, or {@code null} if value is
56+
* {@code null}
57+
* @throws IllegalArgumentException
58+
* if the value does not match any known agent mode
59+
*/
60+
@JsonCreator
61+
public static AgentMode fromValue(String value) {
62+
if (value == null) {
63+
return null;
64+
}
65+
for (AgentMode mode : values()) {
66+
if (mode.value.equals(value)) {
67+
return mode;
68+
}
69+
}
70+
throw new IllegalArgumentException("Unknown AgentMode: " + value);
71+
}
4772
}

0 commit comments

Comments
 (0)