I have multiple child objects that extend the PERSON type. Then, for every type of person I have different methods that are similar to each other, and the only difference is the class subtype
-For example:
public void handlePerson1(final String request) {
PersonExample<Person1> personExample= new PersonExample<>(Person1.class);
OtherPersonExample<Person1> otherPersonExample = new OtherPersonExample<>(Person1.class);
public void handlePerson2(final String request) {
PersonExample<Person2> personExample= new PersonExample<>(Person2.class);
OtherPersonExample<Person2> otherPersonExample = new OtherPersonExample<>(Person2.class);
I tried to make the main class extend a generic type so that I could initiate the remaining classes using the type I needed, because with other functions, I have something very similar that worked out. For example, in the code above, the personExample:
public class PersonExample<T extends Person> {
private final Class<T> classType;
//Get Class Type
public PersonExample(final Class<T> classType) {
this.classType = classType;
}
public void handleFunction(Something<T> something) {
//SOMETHING CAN HAVE A PERSON1, OR PERSON2, etc...
}
Can someone help me transform handlePerson1, 2 etc.. in one singular function?