dimanche 25 juin 2017

How to implement constraint that a type parameter is a parameterized type

I'd like to make a program that from a FileDialog takes a .class (or maybe a .java file) file on the condition that the class is a generic type, such as LinkedList<T>, ArrayList<T>, or whatever data structure the user selects. I would like to throw an exception if the class is not a generic type. For further explanation, I would like to test if

inputClassX instanceof ParameterizedType

but because I would like to test any arbitrary class that may not implement ParameterizedType, I cannot do that test.

How would I test if an object, or a Class, is a generic type?





Aucun commentaire:

Enregistrer un commentaire