@Test public void invokeDeepClass() { List<Type> invoked = TypeUtil.invoke(AbstractCollection.class, StringList.class); assertThat(invoked.size(), is(1)); assertThat(invoked.get(0), is((Type) String.class)); }
public static List<Type> invoke(Class<?> target, Type context) { if (target == null) { throw new IllegalArgumentException("target must not be null"); } if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (target.isPrimitive() || target.isArray()) { throw new IllegalArgumentException("target must be a class or interface type"); } if (target == Object.class) { return Collections.emptyList(); } GenericContext generic = toGenericContext(context); if (generic == null) { throw new IllegalArgumentException("context must be a class or interface type"); } if (target.isAssignableFrom(generic.raw) == false) { return null; } if (target.getTypeParameters().length == 0) { return Collections.emptyList(); } if (target.isInterface()) { return invokeInterface(target, generic); } if (generic.raw.isInterface()) { return null; } return invokeClass(target, generic); }
TypeUtil { public static List<Type> invoke(Class<?> target, Type context) { if (target == null) { throw new IllegalArgumentException("target must not be null"); } if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (target.isPrimitive() || target.isArray()) { throw new IllegalArgumentException("target must be a class or interface type"); } if (target == Object.class) { return Collections.emptyList(); } GenericContext generic = toGenericContext(context); if (generic == null) { throw new IllegalArgumentException("context must be a class or interface type"); } if (target.isAssignableFrom(generic.raw) == false) { return null; } if (target.getTypeParameters().length == 0) { return Collections.emptyList(); } if (target.isInterface()) { return invokeInterface(target, generic); } if (generic.raw.isInterface()) { return null; } return invokeClass(target, generic); } }
TypeUtil { public static List<Type> invoke(Class<?> target, Type context) { if (target == null) { throw new IllegalArgumentException("target must not be null"); } if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (target.isPrimitive() || target.isArray()) { throw new IllegalArgumentException("target must be a class or interface type"); } if (target == Object.class) { return Collections.emptyList(); } GenericContext generic = toGenericContext(context); if (generic == null) { throw new IllegalArgumentException("context must be a class or interface type"); } if (target.isAssignableFrom(generic.raw) == false) { return null; } if (target.getTypeParameters().length == 0) { return Collections.emptyList(); } if (target.isInterface()) { return invokeInterface(target, generic); } if (generic.raw.isInterface()) { return null; } return invokeClass(target, generic); } private  TypeUtil(); }
TypeUtil { public static List<Type> invoke(Class<?> target, Type context) { if (target == null) { throw new IllegalArgumentException("target must not be null"); } if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (target.isPrimitive() || target.isArray()) { throw new IllegalArgumentException("target must be a class or interface type"); } if (target == Object.class) { return Collections.emptyList(); } GenericContext generic = toGenericContext(context); if (generic == null) { throw new IllegalArgumentException("context must be a class or interface type"); } if (target.isAssignableFrom(generic.raw) == false) { return null; } if (target.getTypeParameters().length == 0) { return Collections.emptyList(); } if (target.isInterface()) { return invokeInterface(target, generic); } if (generic.raw.isInterface()) { return null; } return invokeClass(target, generic); } private  TypeUtil(); static Class<?> erase(Type type); static List<Type> invoke(Class<?> target, Type context); }
TypeUtil { public static List<Type> invoke(Class<?> target, Type context) { if (target == null) { throw new IllegalArgumentException("target must not be null"); } if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (target.isPrimitive() || target.isArray()) { throw new IllegalArgumentException("target must be a class or interface type"); } if (target == Object.class) { return Collections.emptyList(); } GenericContext generic = toGenericContext(context); if (generic == null) { throw new IllegalArgumentException("context must be a class or interface type"); } if (target.isAssignableFrom(generic.raw) == false) { return null; } if (target.getTypeParameters().length == 0) { return Collections.emptyList(); } if (target.isInterface()) { return invokeInterface(target, generic); } if (generic.raw.isInterface()) { return null; } return invokeClass(target, generic); } private  TypeUtil(); static Class<?> erase(Type type); static List<Type> invoke(Class<?> target, Type context);  }