Class<T> also represents some instance - it is an instance of type Class , parameterized by type T
I think the best you can do is add a check if the provided type is an instance of Class , and if so, throw an IllegalArgumentException :
public <T> List<Map<String,Object>> getUIElementsList(T value) { if (value instanceof Class) { throw new IllegalArgumentException("Class instances are not supported"); } .. }
When defining type parameters, you are allowed to associate them only with intersections of existing (families) of types, but do not apply negation to given types, for example, to the goal you are aiming for, something like "all types" but one. "
source share