Thursday, 29 August 2013

Getter and setter for bounded wild card type property

Getter and setter for bounded wild card type property

I have a class that contains a List<? extends BaseType>. Now BaseType can
have two subtypes: SubTypeA and SubTypeB. At runtime the list may be
either a List<SubTypeA> or List<SubTypeB>. How should the signature of
getter and setter look for this property?
class ListHolder{
private List<? extends BaseType> listOfBaseType;
//getter and setter for listOfBaseType
}

No comments:

Post a Comment