Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,51 +77,30 @@ public int getValue() {

}

private HarmCategory category;
private final HarmCategory category;

private HarmBlockThreshold threshold;
private final HarmBlockThreshold threshold;

private HarmBlockMethod method;
private final HarmBlockMethod method;

// Default constructor
public VertexAiGeminiSafetySetting() {
this.category = HarmCategory.HARM_CATEGORY_UNSPECIFIED;
this.threshold = HarmBlockThreshold.HARM_BLOCK_THRESHOLD_UNSPECIFIED;
this.method = HarmBlockMethod.HARM_BLOCK_METHOD_UNSPECIFIED;
private VertexAiGeminiSafetySetting(Builder builder) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are changing the public accessor of this constructor to private, we need to deprecate this constructor by keeping this change. The deprecated method can further be removed right after 1.1.0 release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ctor should not accept a builder, the builder should be calling the private ctor that contains the full argument list

Copy link
Contributor Author

@mjkhub mjkhub May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code to use the full-argument constructor as you mentioned 🫡

As for deprecating the public constructor, I tried to add the annotation, but since the new one has the exact same parameters, it's not actually possible to keep both.

this.category = builder.category;
this.threshold = builder.threshold;
this.method = builder.method;
}

// Constructor with all fields
public VertexAiGeminiSafetySetting(HarmCategory category, HarmBlockThreshold threshold, HarmBlockMethod method) {
this.category = category;
this.threshold = threshold;
this.method = method;
}

// Getters and setters
public HarmCategory getCategory() {
return this.category;
}

public void setCategory(HarmCategory category) {
this.category = category;
}

public HarmBlockThreshold getThreshold() {
return this.threshold;
}

public void setThreshold(HarmBlockThreshold threshold) {
this.threshold = threshold;
}

public HarmBlockMethod getMethod() {
return this.method;
}

public void setMethod(HarmBlockMethod method) {
this.method = method;
}

@Override
public String toString() {
return "SafetySetting{" + "category=" + this.category + ", threshold=" + this.threshold + ", method="
Expand Down Expand Up @@ -180,7 +159,7 @@ public Builder withMethod(HarmBlockMethod method) {
}

public VertexAiGeminiSafetySetting build() {
return new VertexAiGeminiSafetySetting(this.category, this.threshold, this.method);
return new VertexAiGeminiSafetySetting(this);
}

}
Expand Down