Closed atomgomba closed 7 years ago
PB already supports inner classes. Just make it static.
Yes, it's strange. The builder class gets created for the inner class at the right place, like I can open and examine the generated .java file in my IDE. However I keep getting a gradle error upon build using a configuration like this:
@Parcel
public class ContactListModel {
@Parcel
@GeneratePojoBuilder
public static class ContactItem {
protected String name;
protected String email;
}
protected List<ContactItem> mItems = new ArrayList<>();
public ContactListModel(List<Response> items) {
for (Response response : items) {
ContactItem newItem = new ContactItemBuilder()
.withName(response.getFullName())
.withEmail(response.getCredentials().getEmail())
.build();
mItems.add(newItem);
}
}
}
Compiling this results in a
Error:(x, y) error: cannot find symbol class ContactItemBuilder
It seems odd, since the generated file is there and the error doesn't occur when I put the inner class into it's own file. Seemingly this must be related to my environment, not PojoBuilder.
Is there a plan to add support for nested classes? Sometimes a POJO is used to inject arguments into an object instead of having a constructor/factory method with a long list of arguments. So for example being able to organize code like this could be handy:
At the moment I have to keep the settings POJO in a separate file with a name like
ItemSelectDialogOptions
because I cannot use the external class as namespace.