private GenericMetadataSupport resolveGenericType(Type type, Method method) { if (type instanceof Class) { return new NotGenericReturnTypeSupport(this, type); } if (type instanceof ParameterizedType) { return new ParameterizedReturnType(this, method.getTypeParameters(), (ParameterizedType) type); } if (type instanceof TypeVariable) { return new TypeVariableReturnType(this, method.getTypeParameters(), (TypeVariable<?>) type); } throw new MockitoException("Ouch, it shouldn't happen, type '" + type.getClass().getCanonicalName() + "' on method : '" + method.toGenericString() + "' is not supported : " + type); }
public NotGenericReturnTypeSupport(GenericMetadataSupport source, Type genericReturnType) { returnType = (Class<?>) genericReturnType; this.contextualActualTypeParameters = source.contextualActualTypeParameters; registerAllTypeVariables(returnType); }