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

.withoutCustomer() #101

Open
nbudzyn opened this issue Jul 14, 2015 · 4 comments
Open

.withoutCustomer() #101

nbudzyn opened this issue Jul 14, 2015 · 4 comments

Comments

@nbudzyn
Copy link

nbudzyn commented Jul 14, 2015

I'm using PojoBuilder withBuilderProperties, which is great to stick stuff together.

However, I'm experiencing some pain when setting properties to null. As .withCustomer(null) would be ambiguous, I have to write something like .withCustomer((Customer) null).

Wouldn't it be nice if we had no-args methods like .withoutCustomer(), setting the customer property to null?

@mkarneim
Copy link
Owner

Err, I see what you mean...

I have to think about how this could be realized.
For example, I guess we have to provide not only a flag which defines if these 'without' methods should be generated, but also the concrete name of these methods (since you also can define the name of the 'with' methods...)

@nbudzyn
Copy link
Author

nbudzyn commented Apr 8, 2016

I have to think about how this could be realized.

Great!

withUnsetterProperties = true, withUnsetterNamePattern = "without*"?

Which would yield .withoutCustomer().

@pleibfried
Copy link

I'd just like to say that I would very much welcome this feature, too :-)

@Adrodoc
Copy link
Contributor

Adrodoc commented Mar 4, 2019

There is a really nice workaround for this if you are using @GeneratePojoBuilder(withBuilderProperties=Builder.class). Add a method called $null():

public static <T> Builder<T> $null() {
  return () -> null;
}

And use that method instead of a null value:

.withCustomer($null())

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

No branches or pull requests

4 participants