I have a class A -> class B (child of A) -> class C (child of B) and class A -> class D. How can I write a function that return objects from class B and class D, example below. How to implement the calling part?
The problem is If I do A a = getFunction() I cannot access the B's functions.
public <T> T getFunction(IntegrationType integrationType) {
return (T) integrationFactory.createIntegration(integrationType);
}
Collections.<String>emptyList()- gives you a list where the return type is List<String>..public <T extends A> getFunction...- so then the return type is exactly what you want ...