I am unable to understand what the generics code below does. I am new to generics so would appreciate all the help i can get!
Public abstract class AMetadata< C extends CMetadata, P extends PMetadata, R extends RMetadata> extends GEntityMetada<C>
{
// class does stuff here
}
Could anyone explain how the classes are related ?
This specifies that the
AMetadataclass will deal with three generically-defined types, each of which are guaranteed to extend a different type (CMetadata,PMetadata, andRMetadata, respectively).Furthermore, the
AMetadataclass itself extends theGEntityMetadageneric class, with its generic argument being the first generic argument type (C, which extendsCMetadata) passed toAMetadata.To say how the classes are related would require more knowledge of the code base than this snippet provides. For example, it is possible (though unlikely) that a single type could actually extend CMetadata, PMetadata, and RMetadata, and that type could therefore be used as an argument to all three classes. But there is nothing in this generic definition to indicate that there has to be any relationship between these three classes.
The only other information you can really get from this is that a type that extends
CMetadatais a valid generic parameter for theGEntityMetadaclass. WhetherGEntityMetadarequires its argument to extendCMetadatais unclear.