My problem is that I'm trying to instantiate a list with a parameter that have the same class as my function's argument :
public <A extends CommunicationObject> List<A> Myfunction(A myObject){
List<A> firstList;
//do something
}
When I call the function :
List<person> persons = Myfunction(person myObject);
The first list take A as CommunicationObject and this is not what I want.
I also tried to do this :
public <A extends CommunicationObject> List<A> Myfunction(A myObject){
List<myObject.getClass()> firstList;
//do something
}
but it is not allowed. Is there any chance that I can fix this ?
Update :
"person" is a subClass of "CumminicationObject". There is some attributes that exists in person and not in CommunicationObject. Actually this is just an example. What I'm trying to do is to convert a JSON to List"<"A">", and A can be "person" or other class that extends CommunicationObject.
The JSON contain the same attributes as the "A" class in List"<"A">".
In order to do the convertion, the parameter "A" in List"<"A">" have to be the same as my object Class in myfunction(A myObject).
persona subtype ofCommunicationObject? If no: why are you passing it toMyFunction? If yes: isn't the actual behavior identical to what you want?