You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This boxes on every call, can throw a NullPointerException when the supplier returns null for a primitive field, and is flagged by Sonar rule java:S4276 in every generated builder. It came up in #429, where the hand-maintained DTO builders were switched to BooleanSupplier manually.
Proposal
For fields with a primitive type, generate the matching specialised interface:
Field type
Generated parameter
Call
boolean
BooleanSupplier
getAsBoolean()
int
IntSupplier
getAsInt()
long
LongSupplier
getAsLong()
double
DoubleSupplier
getAsDouble()
byte, short, char, float
Supplier<Byte> etc. (no JDK interface)
unchanged
wrapper types (Boolean, Integer, …)
Supplier<Boolean> etc. (null is a valid value)
unchanged
Also check the other generators that wrap the field type in a functional interface (e.g. update helpers, conditional methods) for the same pattern, so that the matching primitive specialisation is chosen everywhere it exists.
Things to consider
Compatibility: lambdas and method references keep compiling, but callers passing an existing Supplier<Boolean> variable break. This needs a release note or a configuration option (default on/off to decide).
Javadoc examples generated with addExampleChainFragmentWithSupplier must use the new type.
Regenerate the committed examples and extend the processor tests for every row of the table.
Activity