Class TypeTokenStringConverter

  • All Implemented Interfaces:
    FromStringConverter<java.lang.Object>, StringConverter<java.lang.Object>, ToStringConverter<java.lang.Object>, TypedFromStringConverter<java.lang.Object>, TypedStringConverter<java.lang.Object>

    final class TypeTokenStringConverter
    extends java.lang.Object
    implements TypedStringConverter<java.lang.Object>
    Parse the string format of Guava TypeToken.

    This is loaded by reflection only when Guava is on the classpath. It relies on internal methods in Guava that could change in any release.

    This parser is incomplete, but handles common cases. It does not handle union types or multi-dimensional arrays.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.Class<?> TYPE_TOKEN_CLASS  
      (package private) static java.lang.reflect.Method TYPE_TOKEN_METHOD_OF  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object convertFromString​(java.lang.Class<?> cls, java.lang.String str)
      Converts the specified object from a String.
      java.lang.String convertToString​(java.lang.Object object)
      Converts the specified object to a String.
      java.lang.Class<?> getEffectiveType()
      Gets the effective type that the converter works on.
      • Methods inherited from class java.lang.Object

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

      • TYPE_TOKEN_CLASS

        static final java.lang.Class<?> TYPE_TOKEN_CLASS
      • TYPE_TOKEN_METHOD_OF

        static final java.lang.reflect.Method TYPE_TOKEN_METHOD_OF
    • Constructor Detail

      • TypeTokenStringConverter

        TypeTokenStringConverter()
    • Method Detail

      • convertToString

        public java.lang.String convertToString​(java.lang.Object object)
        Description copied from interface: ToStringConverter
        Converts the specified object to a String.
        Specified by:
        convertToString in interface ToStringConverter<java.lang.Object>
        Parameters:
        object - the object to convert, not null
        Returns:
        the converted string, may be null but generally not
      • convertFromString

        public java.lang.Object convertFromString​(java.lang.Class<?> cls,
                                                  java.lang.String str)
        Description copied from interface: FromStringConverter
        Converts the specified object from a String.
        Specified by:
        convertFromString in interface FromStringConverter<java.lang.Object>
        Parameters:
        cls - the class to convert to, not null
        str - the string to convert, not null
        Returns:
        the converted object, may be null but generally not
      • getEffectiveType

        public java.lang.Class<?> getEffectiveType()
        Description copied from interface: TypedStringConverter
        Gets the effective type that the converter works on.

        For example, if a class declares the FromString and ToString then the effective type of the converter is that class. If a subclass is queried for a converter, then the effective type is that of the superclass.

        Specified by:
        getEffectiveType in interface TypedFromStringConverter<java.lang.Object>
        Specified by:
        getEffectiveType in interface TypedStringConverter<java.lang.Object>
        Returns:
        the effective type