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

[Task] Add fluent api to create jackson classes #534

Open
MelleD opened this issue Feb 28, 2024 · 2 comments
Open

[Task] Add fluent api to create jackson classes #534

MelleD opened this issue Feb 28, 2024 · 2 comments
Labels
acknowledged Has been viewed by one of the maintainers and is ready for further work, discussion or other steps. task

Comments

@MelleD
Copy link
Contributor

MelleD commented Feb 28, 2024

Is your task related to a problem? Please describe.
As a developer I would like to have a fluent API to create the jackson classes to have some advantages in the code.
The advantages lie in the easier development of useful programs and the better readability of the program code written for them. Fluent interfaces can come very close to a natural language sentence. This means you only need to add a little additional comment.

Example:

public class Person {

	@NotNull
	@Pattern(regexp = "[0-9A-Z]{4}")
	private String name;
	private Optional<String> lastname;
        private int age;

Currently

Person person = new Person();
person.setName("Dennis");
person.setLastname(Optional.of("Melle"));
person.setAge(21); // :-)

Describe the solution you'd like
I would like to have fluent api directly in the classes

Person person = new Person();

person.name("Dennis")
.lastname("Melle");
.age(21); 

or

Person person = new Person()
                            .name("Dennis")
                            .lastname("Melle");
                            .age(21); 

Describe alternatives you've considered
Maybe a builder api could also make sense

Person.Builder builder = Person.Builder();
Person person = builder.name("Dennis")
                            .lastname("Melle");
                            .age(21).build();
@MelleD MelleD added the task label Feb 28, 2024
@chris-volk chris-volk added the acknowledged Has been viewed by one of the maintainers and is ready for further work, discussion or other steps. label Mar 19, 2024
@chris-volk
Copy link
Contributor

@MelleD , Would it solve your issue to include lombok to add builder or fluent with the according annotations?

@MelleD
Copy link
Contributor Author

MelleD commented Apr 9, 2024

Would it solve your issue to include lombok to add builder or fluent with the according annotations?

I don't know if it's a good idea to have a hard dependency on Lombok. We are currently not using Lombok and there are currently no needs for Lombok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged Has been viewed by one of the maintainers and is ready for further work, discussion or other steps. task
Projects
None yet
Development

No branches or pull requests

2 participants