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
Staged builders are useful to force compile time safety that all required attributes are set. The autocomplete they give is lovely too.
If any components are marked as nullable then they are optional.
The same isn't true for components marked with a default value. You're forced to specify a value. This is wrong I feel.
Sample code to see:
@MyStagedRecordBuilder
public record Person(
@Initializer("DEFAULT_NAME") String name,
@Nullable int age,
String somethingElse
) {
public static final String DEFAULT_NAME = "John Doe";
void test() {
var x = PersonBuilder.staged()
.name("ds")
.somethingElse("aada")
.age(21);
}
}
In this instance as name has a default value the only component I should be forced to specify is somethingElse, but i'm forced to specify name.
I'm conscious at this point this is trying to turn the library into a replacement for named and default arguments found in other languages. But seeing as both of these pieces of functionality are available I thought it worth raising :)
The text was updated successfully, but these errors were encountered:
Staged builders are useful to force compile time safety that all required attributes are set. The autocomplete they give is lovely too.
If any components are marked as nullable then they are optional.
The same isn't true for components marked with a default value. You're forced to specify a value. This is wrong I feel.
Sample code to see:
In this instance as name has a default value the only component I should be forced to specify is
somethingElse
, but i'm forced to specifyname
.I'm conscious at this point this is trying to turn the library into a replacement for named and default arguments found in other languages. But seeing as both of these pieces of functionality are available I thought it worth raising :)
The text was updated successfully, but these errors were encountered: