Dear Sir,
Firstly I would like to thank for providing the great and brilliant tools. I'm very appreciated.
In my environment, my bean is not a stand alone and it is derived from another super class. In fact it is a JPA data bean. Here is some example.
public class MySuperBean() {
private String id;
private String description;
private Calendar createdDate();
private String createdBy();
//...Other sharing common attributes.
//Getters/Setters
}
public class MyPerson extends MySuperBean {
private String firstName;
private String lastName;
//...Other specific attributes for Person
//Getters/Setters
}
public class MyCompany extends MySuperBean {
private String name;
private String type;
//...Other specific attributes for Company
//Getters/Setters
}
Regarding to the current implementation, I need to create 2 Builder Interface
which contains some redundant methods
from the super class
as the following example
public interface MyPersonBuilder extends Builder<MyPerson> {
MyPersonBuilder withId(final String id);
MyPersonBuilder withDescription(final String description);
// other withXXX from the MySuperBean
// other withYYY from the specific MyPerson
}
public interface MyCompanyBuilder extends Builder<MyCompany> {
MyPersonBuilder withId(final String id);
MyPersonBuilder withDescription(final String description);
// other withXXX from the MySuperBean
// other withYYY from the specific MyCompany
}
It would be nice if you may consider to provide the support for the Super Interface Builder
as the following example
public inferface MySuperBeanBuilder<T extends MySuperBeanBuilder<T>> {
T withId(final String id);
T withDescription(final String description);
// other withXXX from the MySuperBean
}
public interface MyPersonBuilder extends MySuperBeanBuilder<MyPersonBuilder>,
Builder<MyPerson> {
MyPersonBuilder withFirstName(final String firstName);
MyPersonBuilder withLastName(final String lastName);
// other withYYY from the specific MyPerson
}
public interface MyCompanyBuilder extends MySuperBeanBuilder<MyCompanyBuilder>,
Builder<MyCompany> {
MyCompanyBuilder withName(final String name);
MyCompanyBuilder withType(final String type);
// other withYYY from the specific MyCompany
}
The the actual using may look like the following
MyPerson person = ReflectionBuilder.implementationFor(MyPersonBuilder.class).
withId("some-id").
withDescription("some-description").
withCreatedBy("my-admin").
...
withFirstName("Charlee").
withLastName("Ch.").
....
build();
By overview I also have a chance to dig in your code and found some rough tweak as the following: -
public class BuilderProxy implements InvocationHandler {
...
private boolean isFluentSetter(final Method method) {
return method.getParameterTypes().length == 1
&& method.getReturnType().isAssignableFrom(this.proxied)
&& !this.isBuildMethod(method);
}
}
I'm also not sure if it is an acceptable or if it may be any effects to the module or not. Could you please help to consider? Thank you very much for your help in advance. I'm looking forward to hearing from you soon.
Regards,
Charlee Ch.