Skip to content

Commit 5d4a1cc

Browse files
authored
Revert removed builders for Resource and ResourceTemplate (#947)
Instead of fully breaking the API, this is a step which depreactes the existing non-argument builder. It allows the users to gradually migrate while preserving the necessary checks. Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com> Co-authored-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com>
1 parent 22a0efa commit 5d4a1cc

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,16 @@ public static Builder builder(String uri, String name) {
12121212
return new Builder(uri, name);
12131213
}
12141214

1215+
@Deprecated
1216+
public static Builder builder() {
1217+
return new Builder();
1218+
}
1219+
12151220
public static class Builder {
12161221

1217-
private final String uri;
1222+
private /* final */ String uri;
12181223

1219-
private final String name;
1224+
private /* final */ String name;
12201225

12211226
private String title;
12221227

@@ -1230,6 +1235,24 @@ public static class Builder {
12301235

12311236
private Map<String, Object> meta;
12321237

1238+
@Deprecated
1239+
public Builder() {
1240+
}
1241+
1242+
@Deprecated
1243+
public Builder uri(String uri) {
1244+
Assert.hasText(uri, "uri must not be empty");
1245+
this.uri = uri;
1246+
return this;
1247+
}
1248+
1249+
@Deprecated
1250+
public Builder name(String name) {
1251+
this.name = name;
1252+
Assert.hasText(name, "name must not be empty");
1253+
return this;
1254+
}
1255+
12331256
private Builder(String uri, String name) {
12341257
Assert.hasText(uri, "uri must not be empty");
12351258
Assert.hasText(name, "name must not be empty");
@@ -1330,11 +1353,16 @@ public static Builder builder(String uriTemplate, String name) {
13301353
return new Builder(uriTemplate, name);
13311354
}
13321355

1356+
@Deprecated
1357+
public static Builder builder() {
1358+
return new Builder();
1359+
}
1360+
13331361
public static class Builder {
13341362

1335-
private final String uriTemplate;
1363+
private /* final */ String uriTemplate;
13361364

1337-
private final String name;
1365+
private /* final */ String name;
13381366

13391367
private String title;
13401368

@@ -1346,13 +1374,32 @@ public static class Builder {
13461374

13471375
private Map<String, Object> meta;
13481376

1377+
@Deprecated
1378+
private Builder() {
1379+
1380+
}
1381+
13491382
private Builder(String uriTemplate, String name) {
13501383
Assert.hasText(uriTemplate, "uriTemplate must not be empty");
13511384
Assert.hasText(name, "name must not be empty");
13521385
this.uriTemplate = uriTemplate;
13531386
this.name = name;
13541387
}
13551388

1389+
@Deprecated
1390+
public Builder uriTemplate(String uriTemplate) {
1391+
Assert.hasText(uriTemplate, "uriTemplate must not be empty");
1392+
this.uriTemplate = uriTemplate;
1393+
return this;
1394+
}
1395+
1396+
@Deprecated
1397+
public Builder name(String name) {
1398+
Assert.hasText(name, "name must not be empty");
1399+
this.name = name;
1400+
return this;
1401+
}
1402+
13561403
public Builder title(String title) {
13571404
this.title = title;
13581405
return this;

0 commit comments

Comments
 (0)