Closed uvula closed 7 years ago
Yes, that's right.
Since an interface has no constructor implementation, you have to provide a factory method to create instances of it. Just annotate that factory method, and PB knows how to build instances.
Here is an example:
public class IPersonFactory {
@GeneratePojoBuilder
public static IPerson create(String name) {
Person result = new Person(name);
return result;
}
}
I just starting to examine your pojobuilder. A question: if the pojo implements an interfaces. How can the builder return the Interface? class Person implemnts IPerson ... IPerson p = new PersonBuilder()....build();
Must I use the Factory approach? I tried this, it works.