Class Types

java.lang.Object
com.google.common.reflect.Types

final class Types extends Object
Utilities for working with Type.
  • Field Details

    • COMMA_JOINER

      private static final Joiner COMMA_JOINER
      Class#toString without the "class " and "interface " prefixes
  • Constructor Details

    • Types

      private Types()
  • Method Details

    • newArrayType

      static Type newArrayType(Type componentType)
      Returns the array type of componentType.
    • newParameterizedTypeWithOwner

      static ParameterizedType newParameterizedTypeWithOwner(@CheckForNull Type ownerType, Class<?> rawType, Type... arguments)
      Returns a type where rawType is parameterized by arguments and is owned by ownerType.
    • newParameterizedType

      static ParameterizedType newParameterizedType(Class<?> rawType, Type... arguments)
      Returns a type where rawType is parameterized by arguments.
    • newArtificialTypeVariable

      static <D extends GenericDeclaration> TypeVariable<D> newArtificialTypeVariable(D declaration, String name, Type... bounds)
      Returns a new TypeVariable that belongs to declaration with name and bounds.
    • subtypeOf

      static WildcardType subtypeOf(Type upperBound)
      Returns a new WildcardType with upperBound.
    • supertypeOf

      static WildcardType supertypeOf(Type lowerBound)
      Returns a new WildcardType with lowerBound.
    • toString

      static String toString(Type type)
      Returns a human-readable string representation of type.

      The format is subject to change.

    • getComponentType

      @CheckForNull static Type getComponentType(Type type)
    • subtypeOfComponentType

      @CheckForNull private static Type subtypeOfComponentType(Type[] bounds)
      Returns ? extends X if any of bounds is a subtype of X[]; or null otherwise.
    • newTypeVariableImpl

      private static <D extends GenericDeclaration> TypeVariable<D> newTypeVariableImpl(D genericDeclaration, String name, Type[] bounds)
    • toArray

      private static Type[] toArray(Collection<Type> types)
    • filterUpperBounds

      private static Iterable<Type> filterUpperBounds(Iterable<Type> bounds)
    • disallowPrimitiveType

      private static void disallowPrimitiveType(Type[] types, String usedAs)
    • getArrayClass

      static Class<?> getArrayClass(Class<?> componentType)
      Returns the Class object of arrays with componentType.