Skip to content

Commit 8e1ebe6

Browse files
committed
chore: replace JDK 9+ API (List.of, Map.of) with JDK 8 equivalents, update java.version to 1.8, version to 2.3.x
1 parent 870659c commit 8e1ebe6

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>io.github.hiwepy</groupId>
77
<artifactId>opencode-java-sdk</artifactId>
88
<description>OpenCode Java SDK (HTTP Server + local CLI)</description>
9-
<version>2.7.x.20260605-SNAPSHOT</version>
9+
<version>2.3.x.20260605-SNAPSHOT</version>
1010
<name>${project.groupId}:${project.artifactId}</name>
1111
<url>https://github.com/hiwepy/${project.artifactId}</url>
1212
<packaging>jar</packaging>
@@ -370,7 +370,7 @@
370370

371371
<properties>
372372
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
373-
<java.version>17</java.version>
373+
<java.version>1.8</java.version>
374374
<maven.version>3.0</maven.version>
375375
<okhttp3.version>4.12.0</okhttp3.version>
376376
<jackson.version>2.21.2</jackson.version>

src/main/java/io/github/hiwepy/opencode/api/OpenCodeHttpClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.slf4j.LoggerFactory;
1313

1414
import java.io.IOException;
15+
import java.util.Collections;
16+
import java.util.HashMap;
1517
import java.util.List;
1618
import java.util.Map;
1719
import java.util.Objects;
@@ -64,7 +66,7 @@ public HealthStatus health() {
6466
// ============================================================
6567

6668
public Session createSession(String title) {
67-
Map<String, Object> body = title != null ? Map.of("title", title) : Map.of();
69+
Map<String, Object> body = title != null ? Collections.singletonMap("title", title) : Collections.emptyMap();
6870
return post("/session", body, Session.class);
6971
}
7072

src/main/java/io/github/hiwepy/opencode/api/model/ChatRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.NoArgsConstructor;
66
import lombok.Setter;
77

8+
import java.util.Collections;
89
import java.util.List;
910
import java.util.Map;
1011

@@ -58,7 +59,7 @@ public class ChatRequest {
5859
/** 快捷构造:单条 user 消息。 */
5960
public static ChatRequest ofUser(String content) {
6061
ChatRequest req = new ChatRequest();
61-
req.setMessages(List.of(ChatMessage.user(content)));
62+
req.setMessages(Collections.singletonList(ChatMessage.user(content)));
6263
return req;
6364
}
6465

src/main/java/io/github/hiwepy/opencode/api/model/PromptRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.Data;
66
import lombok.NoArgsConstructor;
77

8+
import java.util.Collections;
89
import java.util.List;
910

1011
/**
@@ -58,7 +59,7 @@ public static PromptRequest ofText(String text) {
5859
p.setType("text");
5960
p.setText(text);
6061
PromptRequest req = new PromptRequest();
61-
req.setParts(List.of(p));
62+
req.setParts(Collections.singletonList(p));
6263
return req;
6364
}
6465

0 commit comments

Comments
 (0)