So I have this problem that I want to have a factory / manager class UserManager that manages Users. And Users have both UserType1 and UserType2 extending to it.
currently I have this for UserManager.
public abstract class UserManager<T extends User> {
// T is either UserType1 or UserType2
public ArrayList<T> users;
}
Now I want to create UserType1 or UserType2 depending on conditions, e.g.
public T create(boolean isType1) {
if(isType1) // create UserType1
else // create UserType2
}
And I can't just do
T newUser = new T();
I'm stuck, any help is appreciated!!