Closed koppor closed 2 months ago
You can get that behavior by using addConcreteSettersForOptional = true
. E.g.,
@RecordBuilder
@RecordBuilder.Options(builderMode = RecordBuilder.BuilderMode.STAGED_REQUIRED_ONLY, interpretNotNulls = true, useImmutableCollections = true, addConcreteSettersForOptional = true)
public record OptionalListStaged(int a, Optional<String> b, double c, List<Instant> d, @Null String e, String f) {
}
Thank you for the quick reply! 🤩 (I was about to comment after reading through https://github.com/Randgalt/record-builder/blob/master/options.md)
At https://github.com/Randgalt/record-builder/commit/62011fe2b395fef52421b7d9793cce7612fdc3b9#diff-9894c8ca988dd9ba18c16d1cc0176ca25e915f1b212f12e9c5f285d44fa10e72R81, the value of the example optional Property "b" was made using
.b(Optional.of("bbbb")
. I wonder, why one could not simply write.b("bbbb")
? The methodb
can create theOptional
by itself. - IMHO the code would be more readable.