/** @deprecated Use {@link Types#raws} instead. */ @Deprecated public static List<Class<?>> getClasses(final Type type) { return Types.raws(type); }
/** @deprecated Use {@link Types#raws} instead. */ @Deprecated public static List<Class<?>> getClasses(final Type type) { return Types.raws(type); }
/** @deprecated Use {@link Types#raw} instead. */ @Deprecated public static Class<?> getClass(final Type type) { final List<Class<?>> bounds = Types.raws(type); return bounds != null && bounds.size() == 1 ? bounds.get(0) : null; }
/** @deprecated Use {@link Types#raw} instead. */ @Deprecated public static Class<?> getClass(final Type type) { final List<Class<?>> bounds = Types.raws(type); return bounds != null && bounds.size() == 1 ? bounds.get(0) : null; }
/** * @deprecated Use {@link Types#fieldType(Field, Class)} and {@link Types#raws} * instead. */ @Deprecated public static List<Class<?>> getTypes(final Field field, final Class<?> type) { return Types.raws(Types.fieldType(field, type)); }
/** * @deprecated Use {@link Types#methodReturnType} and {@link Types#raws} instead. */ @Deprecated public static List<Class<?>> getMethodReturnClasses(final Method method, final Class<?> type) { return Types.raws(Types.methodReturnType(method, type)); }
/** * @deprecated Use {@link Types#methodReturnType} and {@link Types#raws} instead. */ @Deprecated public static List<Class<?>> getMethodReturnClasses(final Method method, final Class<?> type) { return Types.raws(Types.methodReturnType(method, type)); }
/** * @deprecated Use {@link Types#fieldType(Field, Class)} and {@link Types#raws} * instead. */ @Deprecated public static List<Class<?>> getFieldClasses(final Field field, final Class<?> type) { return Types.raws(Types.fieldType(field, type)); }
/** * @deprecated Use {@link Types#fieldType(Field, Class)} and {@link Types#raws} * instead. */ @Deprecated public static List<Class<?>> getTypes(final Field field, final Class<?> type) { return Types.raws(Types.fieldType(field, type)); }
/** * @deprecated Use {@link Types#fieldType(Field, Class)} and {@link Types#raws} * instead. */ @Deprecated public static List<Class<?>> getFieldClasses(final Field field, final Class<?> type) { return Types.raws(Types.fieldType(field, type)); }
/** * Gets the (first) raw class of the given type. * <ul> * <li>If the type is a {@code Class} itself, the type itself is returned. * </li> * <li>If the type is a {@link ParameterizedType}, the raw type of the * parameterized type is returned.</li> * <li>If the type is a {@link GenericArrayType}, the returned type is the * corresponding array class. For example: {@code List<Integer>[] => List[]}. * </li> * <li>If the type is a type variable or wildcard type, the raw type of the * first upper bound is returned. For example: * {@code <X extends Foo & Bar> => Foo}.</li> * </ul> * <p> * If you want <em>all</em> raw classes of the given type, use {@link #raws}. * </p> * * @param type The type from which to discern the (first) raw class. * @return The type's first raw class. */ public static Class<?> raw(final Type type) { if (type == null) return null; if (type instanceof Class) return (Class<?>) type; final List<Class<?>> c = raws(type); if (c == null || c.size() == 0) return null; return c.get(0); }
/** * Gets the (first) raw class of the given type. * <ul> * <li>If the type is a {@code Class} itself, the type itself is returned. * </li> * <li>If the type is a {@link ParameterizedType}, the raw type of the * parameterized type is returned.</li> * <li>If the type is a {@link GenericArrayType}, the returned type is the * corresponding array class. For example: {@code List<Integer>[] => List[]}. * </li> * <li>If the type is a type variable or wildcard type, the raw type of the * first upper bound is returned. For example: * {@code <X extends Foo & Bar> => Foo}.</li> * </ul> * <p> * If you want <em>all</em> raw classes of the given type, use {@link #raws}. * </p> * * @param type The type from which to discern the (first) raw class. * @return The type's first raw class. */ public static Class<?> raw(final Type type) { if (type == null) return null; if (type instanceof Class) return (Class<?>) type; final List<Class<?>> c = raws(type); if (c == null || c.size() == 0) return null; return c.get(0); }
/** Tests {@link Types#raws}. */ @Test public void testRaws() { final Field field = Types.field(Thing.class, "thing"); // Object assertAllTheSame(Types.raws(Types.fieldType(field, Thing.class)), Object.class); // N extends Number assertAllTheSame(Types.raws(Types.fieldType(field, NumberThing.class)), Number.class); // Integer assertAllTheSame(Types.raws(Types.fieldType(field, IntegerThing.class)), Integer.class); // Serializable & Cloneable assertAllTheSame(Types.raws(Types.fieldType(field, ComplexThing.class)), Serializable.class, Cloneable.class); }