Class TypeTokenStringConverter

java.lang.Object
org.joda.convert.TypeTokenStringConverter
All Implemented Interfaces:
FromStringConverter<Object>, StringConverter<Object>, ToStringConverter<Object>, TypedFromStringConverter<Object>, TypedStringConverter<Object>

final class TypeTokenStringConverter extends Object implements TypedStringConverter<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 Details

    • TYPE_TOKEN_CLASS

      static final Class<?> TYPE_TOKEN_CLASS
    • TYPE_TOKEN_METHOD_OF

      static final Method TYPE_TOKEN_METHOD_OF
  • Constructor Details

    • TypeTokenStringConverter

      TypeTokenStringConverter()
  • Method Details

    • convertToString

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

      public Object convertFromString(Class<?> cls, String str)
      Description copied from interface: FromStringConverter
      Converts the specified object from a String.
      Specified by:
      convertFromString in interface FromStringConverter<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 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<Object>
      Specified by:
      getEffectiveType in interface TypedStringConverter<Object>
      Returns:
      the effective type