public FromClassGenericMetadataSupport(Class<?> clazz) { this.clazz = clazz; registerTypeParametersOn(clazz.getTypeParameters()); registerAllTypeVariables(clazz); }
/** * Create an new instance of {@link GenericMetadataSupport} inferred from a {@link Type}. * * <p> * At the moment <code>type</code> can only be a {@link Class} or a {@link ParameterizedType}, otherwise * it'll throw a {@link MockitoException}. * </p> * * @param type The class from which the {@link GenericMetadataSupport} should be built. * @return The new {@link GenericMetadataSupport}. * @throws MockitoException Raised if type is not a {@link Class} or a {@link ParameterizedType}. */ public static GenericMetadataSupport inferFrom(Type type) { Checks.checkNotNull(type, "type"); if (type instanceof Class) { return new FromClassGenericMetadataSupport((Class<?>) type); } if (type instanceof ParameterizedType) { return new FromParameterizedTypeGenericMetadataSupport((ParameterizedType) type); } throw new MockitoException("Type meta-data for this Type (" + type.getClass().getCanonicalName() + ") is not supported : " + type); }