Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Optionals #10

Open
adnang opened this issue Mar 21, 2015 · 1 comment
Open

Support for Optionals #10

adnang opened this issue Mar 21, 2015 · 1 comment

Comments

@adnang
Copy link

adnang commented Mar 21, 2015

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.

@douglarek
Copy link

@adnang Optional type for a field is not recommended;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants