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

Using the getterPrefix and/or booleanPrefix settings with the addFunctionalMethodsToWith setting generates a broken nested "With" interface. #200

Open
matt-isaman opened this issue Feb 10, 2025 · 0 comments

Comments

@matt-isaman
Copy link

matt-isaman commented Feb 10, 2025

Using the following versions:

  • RecordBuilder: 44
  • Java: 17/21

Minimal example to reproduce the issue:

@RecordBuilder
@RecordBuilder.Options(getterPrefix = "get",
                       booleanPrefix = "is",
                       addFunctionalMethodsToWith = true)
public record Minimal(int value, boolean flag) implements MinimalBuilder.With {}

The above code produces the following functional interfaces:

/**
 * Map record components into a new object
 */
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
default <R> R map(Function<R> proc) {
    return proc.apply(getValue(), isFlag());
}

/**
 * Perform an operation on record components
 */
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
default void accept(Consumer proc) {
    proc.apply(getValue(), isFlag());
}

Edit: I wasn't clear enough about why the generated code above is a bad thing. The With interface that these methods are created in does not have either of the getValue() or isFlag() methods. Which causes the build to break for the generated class.

Found this at random while poking around in the code experimenting with things. I also have a potential fix for this that I will create a PR for shortly.

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

1 participant