Skip to content
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

Builder pattern on static functions #9

Open
github2023spring opened this issue Sep 8, 2024 · 2 comments
Open

Builder pattern on static functions #9

github2023spring opened this issue Sep 8, 2024 · 2 comments

Comments

@github2023spring
Copy link

Java Lombok Builder is able to convert a static method into a BuilderClass.

May I know if it is possible to do the same for Rust lombok?

@sokomishalov
Copy link
Owner

I haven't heard of it before 🙃
Can you please refer to this functionality in the doc or provide the exact way how it looks and what is solves?
Thanks!

@github2023spring
Copy link
Author

github2023spring commented Sep 16, 2024

Yes, it looks like something below.

library developer

@Builder(builderMethodName = "builder", builderClassName = "HttpsImmutableClientBuilder")
public static ImmutableClient newHttpsClient(String name) {
     return new ImmutableClient("Https", name);
}

library consumer

HttpsImmutableClientBuilder.builder().name("name").build().

It allows you to write common builder logics into the static method, while the consumer can continue to use builder pattern to generate the object..

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

No branches or pull requests

2 participants