@Test void typeVariableLocallyDefined_isClassDefinition() throws Exception { Method method = LocalGenericTypes.class.getMethod("localStuff"); TypeDefinition typeDefinition = this.typeDefinitionFactory.create( method.getGenericReturnType(), ExplicitTypes.class); assertThat(typeDefinition).isInstanceOf(ClassTypeDefinition.class); }
public TypeDefinition create(Type type, Class<?> context) { if (type instanceof Class<?>) { return new ClassTypeDefinition((Class<?>) type); } else if (type instanceof ParameterizedType) { return this.define((ParameterizedType) type, context); } else if (type instanceof GenericArrayType) { return this.define((GenericArrayType) type, context); } else if (type instanceof WildcardType) { return this.define((WildcardType) type, context); } else if (type instanceof TypeVariable) { return this.define((TypeVariable) type, context); } throw new IllegalArgumentException("Type " + type.getTypeName() + " is not supported."); }
TypeDefinitionFactory { public TypeDefinition create(Type type, Class<?> context) { if (type instanceof Class<?>) { return new ClassTypeDefinition((Class<?>) type); } else if (type instanceof ParameterizedType) { return this.define((ParameterizedType) type, context); } else if (type instanceof GenericArrayType) { return this.define((GenericArrayType) type, context); } else if (type instanceof WildcardType) { return this.define((WildcardType) type, context); } else if (type instanceof TypeVariable) { return this.define((TypeVariable) type, context); } throw new IllegalArgumentException("Type " + type.getTypeName() + " is not supported."); } }
TypeDefinitionFactory { public TypeDefinition create(Type type, Class<?> context) { if (type instanceof Class<?>) { return new ClassTypeDefinition((Class<?>) type); } else if (type instanceof ParameterizedType) { return this.define((ParameterizedType) type, context); } else if (type instanceof GenericArrayType) { return this.define((GenericArrayType) type, context); } else if (type instanceof WildcardType) { return this.define((WildcardType) type, context); } else if (type instanceof TypeVariable) { return this.define((TypeVariable) type, context); } throw new IllegalArgumentException("Type " + type.getTypeName() + " is not supported."); }  }
TypeDefinitionFactory { public TypeDefinition create(Type type, Class<?> context) { if (type instanceof Class<?>) { return new ClassTypeDefinition((Class<?>) type); } else if (type instanceof ParameterizedType) { return this.define((ParameterizedType) type, context); } else if (type instanceof GenericArrayType) { return this.define((GenericArrayType) type, context); } else if (type instanceof WildcardType) { return this.define((WildcardType) type, context); } else if (type instanceof TypeVariable) { return this.define((TypeVariable) type, context); } throw new IllegalArgumentException("Type " + type.getTypeName() + " is not supported."); }  static TypeDefinitionFactory getInstance(); TypeDefinition create(Type type, Class<?> context); }
TypeDefinitionFactory { public TypeDefinition create(Type type, Class<?> context) { if (type instanceof Class<?>) { return new ClassTypeDefinition((Class<?>) type); } else if (type instanceof ParameterizedType) { return this.define((ParameterizedType) type, context); } else if (type instanceof GenericArrayType) { return this.define((GenericArrayType) type, context); } else if (type instanceof WildcardType) { return this.define((WildcardType) type, context); } else if (type instanceof TypeVariable) { return this.define((TypeVariable) type, context); } throw new IllegalArgumentException("Type " + type.getTypeName() + " is not supported."); }  static TypeDefinitionFactory getInstance(); TypeDefinition create(Type type, Class<?> context);  }