Class TypeUtils


  • public final class TypeUtils
    extends java.lang.Object
    Utilities for handling types in the JSON parser / serializer.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.reflect.Type[] getElementTypes​(com.google.gson.reflect.TypeToken<?> typeToken, java.lang.Class<?> targetType)
      Determine the actual type arguments of the given type token with regard to the given target type.
      static java.util.Collection<java.lang.reflect.Type> getExpectedTypes​(java.lang.reflect.Type type)
      Return all possible types that can be expected when an element of the given type is parsed.
      static boolean isEither​(java.lang.reflect.Type type)
      Test whether the given type is Either.
      static boolean isTwoTuple​(java.lang.reflect.Type type)
      Test whether the given type is a two-tuple (pair).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getElementTypes

        public static java.lang.reflect.Type[] getElementTypes​(com.google.gson.reflect.TypeToken<?> typeToken,
                                                               java.lang.Class<?> targetType)
        Determine the actual type arguments of the given type token with regard to the given target type.
      • getExpectedTypes

        public static java.util.Collection<java.lang.reflect.Type> getExpectedTypes​(java.lang.reflect.Type type)
        Return all possible types that can be expected when an element of the given type is parsed. If the type satisfies isEither(Type), a list of the corresponding type arguments is returned, otherwise a list containg the type itself is returned. Type parameters are not resolved by this method (use getElementTypes(TypeToken, Class) to get resolved parameters).
      • isEither

        public static boolean isEither​(java.lang.reflect.Type type)
        Test whether the given type is Either.
      • isTwoTuple

        public static boolean isTwoTuple​(java.lang.reflect.Type type)
        Test whether the given type is a two-tuple (pair).