innerbuilder
innerbuilder copied to clipboard
Support for Optionals
If I have some class with final optional variables, e.g
public final class ProductData {
private final String code;
private final String category;
private final Optional<PriceData> price;
//... getters ...
}
I want a option to create builder method that takes a PriceData instance and sets price to:
public ProductDataBuilder withPrice(PriceData price){
this.price = Optional.ofNullable(price);
return this;
}
This will make building classes with optional variables much smoother as we do not need to pre-wrap the arguments.
@adnang Optional type for a field is not recommended;