/** Forked from {@code org.apache.commons.lang3.Validate#noNullElements}. */ private static <T> T[] validateNoNullElements(final T[] array, final String message, final Object... values) { validateNotNull(array); for (int i = 0; i < array.length; i++) { if (array[i] == null) { final Object[] values2 = new Object[values.length + 1]; System.arraycopy(values, 0, values2, 0, values.length); values2[values.length] = Integer.valueOf(i); throw new IllegalArgumentException(String.format(message, values2)); } } return array; }
/** Forked from {@code org.apache.commons.lang3.Validate#noNullElements}. */ private static <T> T[] validateNoNullElements(final T[] array, final String message, final Object... values) { validateNotNull(array); for (int i = 0; i < array.length; i++) { if (array[i] == null) { final Object[] values2 = new Object[values.length + 1]; System.arraycopy(values, 0, values2, 0, values.length); values2[values.length] = Integer.valueOf(i); throw new IllegalArgumentException(String.format(message, values2)); } } return array; }
validateNotNull(var, "var is null"); final StringBuilder buf = new StringBuilder(); final GenericDeclaration d = ((TypeVariable<?>) var)
final Type owner, final Class<?> raw, final Type... typeArguments) validateNotNull(raw, "raw class is null"); final Type useOwner; if (raw.getEnclosingClass() == null) {
private static String toString(final Type type, final Set<Type> done) { validateNotNull(type); if (type instanceof Class) { return classToString((Class<?>) type, done); } if (type instanceof ParameterizedType) { return parameterizedTypeToString((ParameterizedType) type, done); } if (type instanceof WildcardType) { return wildcardTypeToString((WildcardType) type, done); } if (type instanceof CaptureType) { return captureTypeToString((CaptureType) type, done); } if (type instanceof TypeVariable) { return typeVariableToString((TypeVariable<?>) type, done); } if (type instanceof GenericArrayType) { return genericArrayTypeToString((GenericArrayType) type); } throw new IllegalArgumentException("Unknown generic type: " + // type.getClass().getName()); }
private static String toString(final Type type, final Set<Type> done) { validateNotNull(type); if (type instanceof Class) { return classToString((Class<?>) type, done); } if (type instanceof ParameterizedType) { return parameterizedTypeToString((ParameterizedType) type, done); } if (type instanceof WildcardType) { return wildcardTypeToString((WildcardType) type, done); } if (type instanceof CaptureType) { return captureTypeToString((CaptureType) type, done); } if (type instanceof TypeVariable) { return typeVariableToString((TypeVariable<?>) type, done); } if (type instanceof GenericArrayType) { return genericArrayTypeToString((GenericArrayType) type); } throw new IllegalArgumentException("Unknown generic type: " + // type.getClass().getName()); }
/** * <p> * Returns an array containing the sole value of {@link Object} if * {@link WildcardType#getUpperBounds()} returns an empty array. Otherwise, * it returns the result of {@link WildcardType#getUpperBounds()} passed * into {@link #normalizeUpperBounds}. * </p> * * @param wildcardType the subject wildcard type, not {@code null} * @return a non-empty array containing the upper bounds of the wildcard * type. */ public static Type[] getImplicitUpperBounds( final WildcardType wildcardType) { validateNotNull(wildcardType, "wildcardType is null"); final Type[] bounds = wildcardType.getUpperBounds(); return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds); }
/** * <p> * Returns an array containing the sole value of {@link Object} if * {@link WildcardType#getUpperBounds()} returns an empty array. Otherwise, * it returns the result of {@link WildcardType#getUpperBounds()} passed * into {@link #normalizeUpperBounds}. * </p> * * @param wildcardType the subject wildcard type, not {@code null} * @return a non-empty array containing the upper bounds of the wildcard * type. */ public static Type[] getImplicitUpperBounds( final WildcardType wildcardType) { validateNotNull(wildcardType, "wildcardType is null"); final Type[] bounds = wildcardType.getUpperBounds(); return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds); }
/** * <p> * Returns an array containing a single value of {@code null} if * {@link WildcardType#getLowerBounds()} returns an empty array. Otherwise, * it returns the result of {@link WildcardType#getLowerBounds()}. * </p> * * @param wildcardType the subject wildcard type, not {@code null} * @return a non-empty array containing the lower bounds of the wildcard * type. */ public static Type[] getImplicitLowerBounds( final WildcardType wildcardType) { validateNotNull(wildcardType, "wildcardType is null"); final Type[] bounds = wildcardType.getLowerBounds(); return bounds.length == 0 ? new Type[] { null } : bounds; }
/** * Create a parameterized type instance. * * @param owner the owning type * @param raw the raw class to create a parameterized type instance for * @param typeArgMappings the mapping used for parameterization * @return {@link ParameterizedType} * @since 3.2 */ public static final ParameterizedType parameterizeWithOwner( final Type owner, final Class<?> raw, final Map<TypeVariable<?>, Type> typeArgMappings) { validateNotNull(raw, "raw class is null"); validateNotNull(typeArgMappings, "typeArgMappings is null"); return parameterizeWithOwner(owner, raw, extractTypeArgumentsFrom( typeArgMappings, raw.getTypeParameters())); }
/** * Create a parameterized type instance. * * @param owner the owning type * @param raw the raw class to create a parameterized type instance for * @param typeArgMappings the mapping used for parameterization * @return {@link ParameterizedType} * @since 3.2 */ public static final ParameterizedType parameterizeWithOwner( final Type owner, final Class<?> raw, final Map<TypeVariable<?>, Type> typeArgMappings) { validateNotNull(raw, "raw class is null"); validateNotNull(typeArgMappings, "typeArgMappings is null"); return parameterizeWithOwner(owner, raw, extractTypeArgumentsFrom( typeArgMappings, raw.getTypeParameters())); }
/** * <p> * Returns an array containing the sole type of {@link Object} if * {@link TypeVariable#getBounds()} returns an empty array. Otherwise, it * returns the result of {@link TypeVariable#getBounds()} passed into * {@link #normalizeUpperBounds}. * </p> * * @param typeVariable the subject type variable, not {@code null} * @return a non-empty array containing the bounds of the type variable. */ public static Type[] getImplicitBounds(final TypeVariable<?> typeVariable) { validateNotNull(typeVariable, "typeVariable is null"); final Type[] bounds = typeVariable.getBounds(); return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds); }
/** * <p> * Returns an array containing the sole type of {@link Object} if * {@link TypeVariable#getBounds()} returns an empty array. Otherwise, it * returns the result of {@link TypeVariable#getBounds()} passed into * {@link #normalizeUpperBounds}. * </p> * * @param typeVariable the subject type variable, not {@code null} * @return a non-empty array containing the bounds of the type variable. */ public static Type[] getImplicitBounds(final TypeVariable<?> typeVariable) { validateNotNull(typeVariable, "typeVariable is null"); final Type[] bounds = typeVariable.getBounds(); return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds); }
/** * <p> * Returns an array containing a single value of {@code null} if * {@link WildcardType#getLowerBounds()} returns an empty array. Otherwise, * it returns the result of {@link WildcardType#getLowerBounds()}. * </p> * * @param wildcardType the subject wildcard type, not {@code null} * @return a non-empty array containing the lower bounds of the wildcard * type. */ public static Type[] getImplicitLowerBounds( final WildcardType wildcardType) { validateNotNull(wildcardType, "wildcardType is null"); final Type[] bounds = wildcardType.getLowerBounds(); return bounds.length == 0 ? new Type[] { null } : bounds; }
/** * Create a parameterized type instance. * * @param raw the raw class to create a parameterized type instance for * @param typeArgMappings the mapping used for parameterization * @return {@link ParameterizedType} * @since 3.2 */ public static final ParameterizedType parameterize(final Class<?> raw, final Map<TypeVariable<?>, Type> typeArgMappings) { validateNotNull(raw, "raw class is null"); validateNotNull(typeArgMappings, "typeArgMappings is null"); return parameterizeWithOwner(null, raw, extractTypeArgumentsFrom( typeArgMappings, raw.getTypeParameters())); }
/** * Create a parameterized type instance. * * @param raw the raw class to create a parameterized type instance for * @param typeArgMappings the mapping used for parameterization * @return {@link ParameterizedType} * @since 3.2 */ public static final ParameterizedType parameterize(final Class<?> raw, final Map<TypeVariable<?>, Type> typeArgMappings) { validateNotNull(raw, "raw class is null"); validateNotNull(typeArgMappings, "typeArgMappings is null"); return parameterizeWithOwner(null, raw, extractTypeArgumentsFrom( typeArgMappings, raw.getTypeParameters())); }
/** Forked from {@code org.apache.commons.lang3.Validate#notNull}. */ private static <T> T validateNotNull(final T object) { return validateNotNull(object, DEFAULT_IS_NULL_EX_MESSAGE); }
/** * Create a generic array type instance. * * @param componentType the type of the elements of the array. For example * the component type of {@code boolean[]} is {@code boolean} * @return {@link GenericArrayType} * @since 3.2 */ public static GenericArrayType genericArrayType(final Type componentType) { return new GenericArrayTypeImpl(validateNotNull(componentType, "componentType is null")); }
/** * Create a generic array type instance. * * @param componentType the type of the elements of the array. For example * the component type of {@code boolean[]} is {@code boolean} * @return {@link GenericArrayType} * @since 3.2 */ public static GenericArrayType genericArrayType(final Type componentType) { return new GenericArrayTypeImpl(validateNotNull(componentType, "componentType is null")); }
/** Forked from {@code org.apache.commons.lang3.Validate#notNull}. */ private static <T> T validateNotNull(final T object) { return validateNotNull(object, DEFAULT_IS_NULL_EX_MESSAGE); }