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>
This commit is contained in:
Dariusz Jędrzejczyk 2026-05-05 11:22:48 +02:00 • committed by GitHub
commit 5d4a1cce42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1212,11 +1212,16 @@ public final class McpSchema {
return new Builder(uri, name);
}
@Deprecated
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final String uri;
private /* final */ String uri;
private final String name;
private /* final */ String name;
private String title;
@ -1230,6 +1235,24 @@ public final class McpSchema {
private Map<String, Object> meta;
@Deprecated
public Builder() {
}
@Deprecated
public Builder uri(String uri) {
Assert.hasText(uri, "uri must not be empty");
this.uri = uri;
return this;
}
@Deprecated
public Builder name(String name) {
this.name = name;
Assert.hasText(name, "name must not be empty");
return this;
}
private Builder(String uri, String name) {
Assert.hasText(uri, "uri must not be empty");
Assert.hasText(name, "name must not be empty");
@ -1330,11 +1353,16 @@ public final class McpSchema {
return new Builder(uriTemplate, name);
}
@Deprecated
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final String uriTemplate;
private /* final */ String uriTemplate;
private final String name;
private /* final */ String name;
private String title;
@ -1346,6 +1374,11 @@ public final class McpSchema {
private Map<String, Object> meta;
@Deprecated
private Builder() {
}
private Builder(String uriTemplate, String name) {
Assert.hasText(uriTemplate, "uriTemplate must not be empty");
Assert.hasText(name, "name must not be empty");
@ -1353,6 +1386,20 @@ public final class McpSchema {
this.name = name;
}
@Deprecated
public Builder uriTemplate(String uriTemplate) {
Assert.hasText(uriTemplate, "uriTemplate must not be empty");
this.uriTemplate = uriTemplate;
return this;
}
@Deprecated
public Builder name(String name) {
Assert.hasText(name, "name must not be empty");
this.name = name;
return this;
}
public Builder title(String title) {
this.title = title;
return this;