analytically / innerbuilder

IntelliJ IDEA plugin which generates an inner builder class

Home Page:https://plugins.jetbrains.com/plugin/7354-innerbuilder/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Optionals

adnang opened this issue · comments

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;