For example, I have a class with a builder with 5 params, instead of me manually selecting the params and populating them, is there a way to tell Intellij to do this:
MyClass myClass = MyClass.builder()
.param1()
.param2()
.param3()
.param4()
.param5()
.build();
Then I can just fill in the parameters myself. It'd be handy to make sure I haven't missed any.
Alternatively, can I set the autocomplete options to sort in the order they appear in the class?
Even if there is such a plugin I believe it would not help you really (because you still need to manually click on every method call and provide parameter) and you should definitely not use IDE to protect you from not setting all mandatory parameters.
In this case you this either put all mandatory params to the constructor or provide a validation inside build
method. Something like
public MyClass build() {
if(param1 == null) {
// handle param1 null value
}
if(param2 == null) {
// etc
}
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With