Skip to content

Refactor builder pattern in VertexAiGeminiSafetySetting #3326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mjkhub
Copy link

@mjkhub mjkhub commented May 26, 2025

Hey boss, I noticed a small part that could be cleaned up to better align with the builder pattern.

It’s not a big change, but I thought it might be helpful—please take a look when you have a chance.

Thanks 👍

@mjkhub mjkhub force-pushed the refactor-builder-pattern-VertexAiGeminiSafetySetting branch from 4533c0c to 0e1a536 Compare May 26, 2025 08:17
@mjkhub
Copy link
Author

mjkhub commented May 26, 2025

@ilayaperumalg

Boss, would really appreciate it if you could take a quick look at this PR 🫡

@mjkhub mjkhub force-pushed the refactor-builder-pattern-VertexAiGeminiSafetySetting branch from 84e6164 to 3f96019 Compare May 27, 2025 06:30
@mjkhub
Copy link
Author

mjkhub commented May 27, 2025

@ilayaperumalg

Boss, I’ve fixed the formatting issues using spring-javaformat:apply.

@ilayaperumalg ilayaperumalg self-assigned this May 27, 2025
@ilayaperumalg
Copy link
Member

@mjkhub Thanks for the PR using the builder!

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
Author

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.

Since this class is currently only used in test code, I believe it’s safe to make this change without introducing any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants