mercredi 13 février 2019

Get generics how many generics a class receives java

Quickly:

aPossibleClassOrInstanceOverWhichToInvoke.theMethodThatINeed(java.util.List.class);

returns 1

aPossibleClassOrInstanceOverWhichToInvoke.theMethodThatINeed(java.util.Map.class);

returns 2;

aPossibleClassOrInstanceOverWhichToInvoke.theMethodThatINeed(java.util.function.BiFunction.class);

returns 3;

No, this is not about the type, I know thats removed by erasure; I basically need how many generic a class receives, List<1>, Map<1,2>, BiFunction<1,2,3>





Aucun commentaire:

Enregistrer un commentaire