Package org.joda.convert
Class AnnotationStringConverterFactory
- java.lang.Object
-
- org.joda.convert.AnnotationStringConverterFactory
-
- All Implemented Interfaces:
StringConverterFactory
final class AnnotationStringConverterFactory extends java.lang.Object implements StringConverterFactory
Factory forStringConverterlooking up annotations.This class is immutable and thread-safe.
- Since:
- 1.5
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static StringConverterFactoryINSTANCESingleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description privateAnnotationStringConverterFactory()Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.Class<?>eliminateEnumSubclass(java.lang.Class<?> cls)private <T> StringConverter<T>findAnnotatedConverter(java.lang.Class<T> cls)Finds a converter searching annotated.StringConverter<?>findConverter(java.lang.Class<?> cls)Finds a converter by type.private java.lang.reflect.MethodfindFromString(java.lang.Class<?> cls)Finds the conversion method.private <T> MethodConstructorStringConverter<T>findFromStringConstructor(java.lang.Class<T> cls, java.lang.reflect.Method toString)Finds the conversion method.private <T> MethodsStringConverter<T>findFromStringMethod(java.lang.Class<T> cls, java.lang.reflect.Method toString, boolean searchSuperclasses)Finds the conversion method.private java.lang.reflect.MethodfindToStringMethod(java.lang.Class<?> cls)Finds the conversion method.java.lang.StringtoString()
-
-
-
Field Detail
-
INSTANCE
static final StringConverterFactory INSTANCE
Singleton instance.
-
-
Method Detail
-
findConverter
public StringConverter<?> findConverter(java.lang.Class<?> cls)
Finds a converter by type.- Specified by:
findConverterin interfaceStringConverterFactory- Parameters:
cls- the type to lookup, not null- Returns:
- the converter, null if not found
- Throws:
java.lang.RuntimeException- (or subclass) if source code is invalid
-
findAnnotatedConverter
private <T> StringConverter<T> findAnnotatedConverter(java.lang.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:
java.lang.RuntimeException- if none found
-
findToStringMethod
private java.lang.reflect.Method findToStringMethod(java.lang.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:
java.lang.RuntimeException- if invalid
-
findFromStringConstructor
private <T> MethodConstructorStringConverter<T> findFromStringConstructor(java.lang.Class<T> cls, java.lang.reflect.Method toString)
Finds the conversion method.- Type Parameters:
T- the type of the converter- Parameters:
cls- the class to find a method for, not nulltoString- the toString method, not null- Returns:
- the method to call, null means none found
- Throws:
java.lang.RuntimeException- if invalid
-
findFromStringMethod
private <T> MethodsStringConverter<T> findFromStringMethod(java.lang.Class<T> cls, java.lang.reflect.Method toString, boolean searchSuperclasses)
Finds the conversion method.- Parameters:
cls- the class to find a method for, not nulltoString- the toString method, not nullsearchSuperclasses- whether to search superclasses- Returns:
- the method to call, null means not found
- Throws:
java.lang.RuntimeException- if invalid
-
findFromString
private java.lang.reflect.Method findFromString(java.lang.Class<?> cls)
Finds the conversion method.- Parameters:
cls- the class to find a method for, not nullmatched- the matched method, may be null- Returns:
- the method to call, null means not found
- Throws:
java.lang.RuntimeException- if invalid
-
eliminateEnumSubclass
private java.lang.Class<?> eliminateEnumSubclass(java.lang.Class<?> cls)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-