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

Support for adders instead of setters for Collections record components #5

Open
sashirestela opened this issue Dec 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@sashirestela
Copy link
Owner

sashirestela commented Dec 11, 2024

This functionality is about to include "adders" methods (instead of setters) to builders for record components of Collection type. For better usability, it would be necessary to create a new annotation such as @Builder.Singular(value=optionalSingularName) to indicate what record components will be singularize and optionally to indicate what singular name to use in case it cannot be deducted from the plural name.

For example:

public record Project(Integer id, String name, @Build.Singular List<String> members) {}

Project project1 = ProjectBuilder.builder()
    .id(101)
    .name("Special Project")
    .member("Rose")
    .member("Jack")
    .build();

Take as a reference: https://projectlombok.org/features/Builder#Singular

The rules to deriving singular forms from plural words in English are:

  • Words ending in "ves", replace "ves" with "fe". Ex: lives → life
  • Words ending in "ies", replace "ies" with "y". Ex: cities → city
  • Words ending in "es", remove "es". Ex: boxes → box
  • Words ending in "s", remove "s". Ex: names → name
  • Any other case should require to indicate an explicit singular name.
@sashirestela sashirestela changed the title Support for adders instead of setters for Collections record components Support for adders instead of setters for Collections record components Dec 11, 2024
@sashirestela sashirestela added the enhancement New feature or request label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant