/** * Returns the element type of the given metaclass under the following conditions: * <ul> * <li>toType has a single type parameter * <li>toType's type parameter is not a wildcard * <li>toType's type parameter is a non-abstract (concrete) type * <li>toType's type parameter is not java.lang.Object * </ul> * * @param toType * The type to check for a known concrete collection element type. * @return The concrete element type meeting all above-mentioned criteria, or null if one or more * of the criteria fails. */ public static MetaClass getConcreteElementType(final MetaClass toType) { return getConcreteTypeParameter(toType, 0, 1); }
/** * Returns the element type of the given metaclass under the following conditions: * <ul> * <li>toType has a single type parameter * <li>toType's type parameter is not a wildcard * <li>toType's type parameter is a non-abstract (concrete) type * <li>toType's type parameter is not java.lang.Object * </ul> * * @param toType * The type to check for a known concrete collection element type. * @return The concrete element type meeting all above-mentioned criteria, or null if one or more * of the criteria fails. */ public static MetaClass getConcreteElementType(final MetaClass toType) { return getConcreteTypeParameter(toType, 0, 1); }
/** * Returns the map key type of the given metaclass under the following conditions: * <ul> * <li>toType is a {@link Map} * <li>toType's key type is not a wildcard * <li>toType's key type is a non-abstract (concrete) type * </ul> * * @param toType * The type to check for a known concrete map key type. * @return The concrete map key type meeting all above-mentioned criteria, or null if one or more * of the criteria fails. */ public static MetaClass getConcreteMapKeyType(final MetaClass toType) { if (toType.isAssignableTo(Map.class)) { return getConcreteTypeParameter(toType, 0, 2); } return null; }
/** * Returns the map key type of the given metaclass under the following conditions: * <ul> * <li>toType is a {@link Map} * <li>toType's key type is not a wildcard * <li>toType's key type is a non-abstract (concrete) type * </ul> * * @param toType * The type to check for a known concrete map key type. * @return The concrete map key type meeting all above-mentioned criteria, or null if one or more * of the criteria fails. */ public static MetaClass getConcreteMapKeyType(final MetaClass toType) { if (toType.isAssignableTo(Map.class)) { return getConcreteTypeParameter(toType, 0, 2); } return null; }
/** * Returns the map value type of the given metaclass under the following conditions: * <ul> * <li>toType is a {@link Map} * <li>toType's value type is not a wildcard * <li>toType's value type is a non-abstract (concrete) type * </ul> * * @param toType * The type to check for a known concrete map key type. * @return The concrete map value type meeting all above-mentioned criteria, or null if one or * more of the criteria fails. */ public static MetaClass getConcreteMapValueType(final MetaClass toType) { if (toType.isAssignableTo(Map.class)) { return getConcreteTypeParameter(toType, 1, 2); } return null; }
/** * Returns the map value type of the given metaclass under the following conditions: * <ul> * <li>toType is a {@link Map} * <li>toType's value type is not a wildcard * <li>toType's value type is a non-abstract (concrete) type * </ul> * * @param toType * The type to check for a known concrete map key type. * @return The concrete map value type meeting all above-mentioned criteria, or null if one or * more of the criteria fails. */ public static MetaClass getConcreteMapValueType(final MetaClass toType) { if (toType.isAssignableTo(Map.class)) { return getConcreteTypeParameter(toType, 1, 2); } return null; }