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

Allow non-static factory methods #46

Open
drekbour opened this issue May 18, 2013 · 1 comment
Open

Allow non-static factory methods #46

drekbour opened this issue May 18, 2013 · 1 comment

Comments

@drekbour
Copy link
Contributor

When annotating a method for building it is currently the case that it must be a proper static Factory Method. If the method is written solely for the builder to use, it would be nice to place it in a scope where only the builder can access it. The best way to do this is with package access. This can be improved upon further though by making an instance method on a baseclass to improve encapsulation.

So long as the method is accessible then it should be legal to annotate it:

public AbstractFruitBuilder {
  @GeneratePojoBuilder(withBaseclass=AbstractFruitBuilder.class)
  Fruit createFruit( String type, Color color ) {
   return new Fruit( type, color );
  }
}

In theory this should hold even if there are other classes in a hierarchy between AbstractFruitBuilder and the baseclass.

@mkarneim mkarneim modified the milestones: 3.1.0, 3.0.0, 3.2.0 Aug 31, 2014
@mkarneim mkarneim modified the milestones: 3.2.0, 3.3.0 Oct 5, 2014
@mkarneim mkarneim modified the milestones: 3.4.0, 3.3.0 Nov 29, 2014
@mkarneim mkarneim modified the milestones: 3.5.0, 3.4.0 Mar 11, 2015
@drekbour
Copy link
Contributor Author

drekbour commented Jan 7, 2020

Per #166, this would also allow a simple implementation of an "updater" to be written.

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

2 participants