Class Types

java.lang.Object
org.apache.maven.di.impl.Types

public class Types extends Object
Various helper methods for type processing
  • Field Details

    • NO_TYPES

      public static final Type[] NO_TYPES
    • WILDCARD_TYPE_ANY

      public static final WildcardType WILDCARD_TYPE_ANY
  • Constructor Details

    • Types

      public Types()
  • Method Details

    • getRawType

      public static Class<?> getRawType(Type type)
      Returns a raw Class for a given Type.

      A type can be any of Class, ParameterizedType, WildcardType, GenericArrayType or TypeVariable

    • getUppermostType

      public static Type getUppermostType(Type[] types)
      Returns the most common type among given types
    • getActualTypeArguments

      public static Type[] getActualTypeArguments(Type type)
      Returns an array of actual type arguments for a given Type
      Parameters:
      type - type whose actual type arguments should be retrieved
      Returns:
      an array of actual type arguments for a given Type
    • getTypeBindings

      public static Map<TypeVariable<?>,Type> getTypeBindings(Type type)
      Returns a map of type bindings for a given Type
    • getAllTypeBindings

      public static Map<TypeVariable<?>,Type> getAllTypeBindings(Type type)
      Returns a map of all type bindings for a given Type. Includes type bindings from a whole class hierarchy
    • bind

      public static Type bind(Type type, Map<TypeVariable<?>,Type> bindings)
      Binds a given type with actual type arguments
      Parameters:
      type - a type to be bound
      bindings - a map of actual types
    • bind

      public static Type bind(Type type, Function<TypeVariable<?>,Type> bindings)
      Binds a given type with actual type arguments
      Parameters:
      type - a type to be bound
      bindings - a lookup function for actual types
    • parameterizedType

      public static ParameterizedType parameterizedType(@Nullable Type ownerType, Type rawType, Type[] parameters)
      Creates an instance of ParameterizedType
      Parameters:
      ownerType - an owner type
      rawType - a type to be parameterized
      parameters - parameter types
      Returns:
      an instance of ParameterizedType
    • parameterizedType

      public static ParameterizedType parameterizedType(Class<?> rawType, Type... parameters)
      Creates an instance of ParameterizedType
      See Also:
    • getAllSuperTypes

      public static Set<Type> getAllSuperTypes(Type original)
      Get all super classes and interface implemented by the given type.
    • simplifyType

      public static Type simplifyType(Type original)
    • isAssignable

      public static boolean isAssignable(Type to, Type from)
      Tests whether a from type is assignable to to type
      Parameters:
      to - a 'to' type that should be checked for possible assignment
      from - a 'from' type that should be checked for possible assignment
      Returns:
      whether an object of type from is assignable to an object of type to
    • wildcardType

      public static WildcardType wildcardType(Type[] upperBounds, Type[] lowerBounds)
      Creates an instance of WildcardType bound by upper and lower bounds
      Parameters:
      upperBounds - a wildcard upper bound types
      lowerBounds - a wildcard lower bound types
      Returns:
      an instance of WildcardType
    • wildcardTypeAny

      public static WildcardType wildcardTypeAny()
      Returns an instance of WildcardType that matches any type

      E.g. <?>

      See Also:
    • wildcardTypeExtends

      public static WildcardType wildcardTypeExtends(Type upperBound)
      Creates an instance of WildcardType bound by a single upper bound

      E.g. <? extends UpperBound>

      Parameters:
      upperBound - a wildcard upper bound type
      Returns:
      an instance of WildcardType
      See Also:
    • wildcardTypeSuper

      public static WildcardType wildcardTypeSuper(Type lowerBound)
      Creates an instance of WildcardType bound by a single lower bound

      E.g. <? super LowerBound>

      Parameters:
      lowerBound - a wildcard lower bound type
      Returns:
      an instance of WildcardType
      See Also:
    • genericArrayType

      public static GenericArrayType genericArrayType(Type componentType)
      Creates an instance of GenericArrayType with a given component type

      Same as T[]

      Parameters:
      componentType - a component type of generic array
      Returns:
      an instance of GenericArrayType
      See Also:
    • getSimpleName

      public static String getSimpleName(Type type)
      Returns a simple name for a given Type
      See Also: