/** * <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) { Validate.notNull(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 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) { Validate.notNull(wildcardType, "wildcardType is null"); final Type[] bounds = wildcardType.getUpperBounds(); return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds); }
@Test public void testLang820() throws Exception { final Type[] typeArray = {String.class, String.class}; final Type[] expectedArray = {String.class}; assertArrayEquals(expectedArray, TypeUtils.normalizeUpperBounds(typeArray)); }
/** * <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) { Validate.notNull(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 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) { Validate.notNull(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 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) { Validate.notNull(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) { Validate.notNull(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 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) { Validate.notNull(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) { Validate.notNull(wildcardType, "wildcardType is null"); final Type[] bounds = wildcardType.getUpperBounds(); return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds); }