/** * @param type the type to check. * * @return Returns {@code true} if {@code type} is implementing {@code List}, {@code false} otherwise. */ public static boolean isList(Type type) { if ( type instanceof Class && List.class.isAssignableFrom( (Class<?>) type ) ) { return true; } if ( type instanceof ParameterizedType ) { return isList( ( (ParameterizedType) type ).getRawType() ); } if ( type instanceof WildcardType ) { Type[] upperBounds = ( (WildcardType) type ).getUpperBounds(); return upperBounds.length != 0 && isList( upperBounds[0] ); } return false; }
/** * @param type the type to check. * * @return Returns <code>true</code> if <code>type</code> is implementing <code>List</code>, <code>false</code> otherwise. */ public static boolean isList(Type type) { if ( type instanceof Class && List.class.isAssignableFrom( (Class<?>) type ) ) { return true; } if ( type instanceof ParameterizedType ) { return isList( ( (ParameterizedType) type ).getRawType() ); } if ( type instanceof WildcardType ) { Type[] upperBounds = ( (WildcardType) type ).getUpperBounds(); return upperBounds.length != 0 && isList( upperBounds[0] ); } return false; }
/** * Indicates if the type is considered indexable (ie is a {@code List}, an array or a {@code Map}). * <p> * Note that it does not include {@code Set}s as they are not indexable. * * @param type the type to inspect. * * @return Returns true if the type is indexable. */ public static boolean isIndexable(Type type) { return isList( type ) || isMap( type ) || TypeHelper.isArray( type ); }
/** * Indicates if the type is considered indexable (ie is a {@code List}, an array or a {@code Map}). * <p> * Note that it does not include {@code Set}s as they are not indexable. * * @param type the type to inspect. * * @return Returns true if the type is indexable. */ public static boolean isIndexable(Type type) { return isList( type ) || isMap( type ) || TypeHelper.isArray( type ); }