Class AnnotationStringConverterFactory

java.lang.Object
org.joda.convert.AnnotationStringConverterFactory
All Implemented Interfaces:
StringConverterFactory

final class AnnotationStringConverterFactory extends Object implements StringConverterFactory
Factory for StringConverter looking up annotations.

This class is immutable and thread-safe.

Since:
1.5
  • Field Details

  • Constructor Details

    • AnnotationStringConverterFactory

      private AnnotationStringConverterFactory()
      Restricted constructor.
  • Method Details

    • findConverter

      public StringConverter<?> findConverter(Class<?> cls)
      Finds a converter by type.
      Specified by:
      findConverter in interface StringConverterFactory
      Parameters:
      cls - the type to lookup, not null
      Returns:
      the converter, null if not found
      Throws:
      RuntimeException - (or subclass) if source code is invalid
    • findAnnotatedConverter

      private <T> StringConverter<T> findAnnotatedConverter(Class<T> cls)
      Finds a converter searching annotated.
      Type Parameters:
      T - the type of the converter
      Parameters:
      cls - the class to find a method for, not null
      Returns:
      the converter, not null
      Throws:
      RuntimeException - if none found
    • findFromStringConverter

      <T> TypedFromStringConverter<T> findFromStringConverter(Class<T> cls)
      Finds a from-string converter by type.
      Type Parameters:
      T - the type of the converter
      Parameters:
      cls - the type to lookup, not null
      Returns:
      the converter, null if not found
      Throws:
      RuntimeException - (or subclass) if source code is invalid
    • findAnnotatedFromStringConverter

      private <T> TypedFromStringConverter<T> findAnnotatedFromStringConverter(Class<T> cls)
      Finds a from-string converter.
      Type Parameters:
      T - the type of the converter
      Parameters:
      cls - the class to find a method for, not null
      Returns:
      the converter, null if not found
      Throws:
      RuntimeException - if none found
    • findToStringMethod

      private Method findToStringMethod(Class<?> cls)
      Finds the conversion method.
      Parameters:
      cls - the class to find a method for, not null
      Returns:
      the method to call, null means use toString
      Throws:
      RuntimeException - if invalid
    • findFromStringConstructor

      private <T> TypedFromStringConverter<T> findFromStringConstructor(Class<T> cls)
      Finds the conversion method.
      Type Parameters:
      T - the type of the converter
      Parameters:
      cls - the class to find a method for, not null
      Returns:
      the method to call, null means none found
      Throws:
      RuntimeException - if invalid
    • findFromStringMethod

      private <T> TypedFromStringConverter<T> findFromStringMethod(Class<T> cls, boolean searchSuperclasses)
      Finds the conversion method.
      Parameters:
      cls - the class to find a method for, not null
      searchSuperclasses - whether to search superclasses
      Returns:
      the method to call, null means not found
      Throws:
      RuntimeException - if invalid
    • findFromString

      private Method findFromString(Class<?> cls)
      Finds the conversion method.
      Parameters:
      cls - the class to find a method for, not null
      matched - the matched method, may be null
      Returns:
      the method to call, null means not found
      Throws:
      RuntimeException - if invalid
    • eliminateEnumSubclass

      private Class<?> eliminateEnumSubclass(Class<?> cls)
    • toString

      public String toString()
      Overrides:
      toString in class Object