Package org.joda.convert
Class AnnotationStringConverterFactory
java.lang.Object
org.joda.convert.AnnotationStringConverterFactory
- All Implemented Interfaces:
StringConverterFactory
Factory for
StringConverter looking up annotations.
This class is immutable and thread-safe.
- Since:
- 1.5
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final AnnotationStringConverterFactorySingleton instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Class<?> eliminateEnumSubclass(Class<?> cls) private <T> StringConverter<T> findAnnotatedConverter(Class<T> cls) Finds a converter searching annotated.private <T> TypedFromStringConverter<T> Finds a from-string converter.findConverter(Class<?> cls) Finds a converter by type.private MethodfindFromString(Class<?> cls) Finds the conversion method.private <T> TypedFromStringConverter<T> findFromStringConstructor(Class<T> cls) Finds the conversion method.(package private) <T> TypedFromStringConverter<T> findFromStringConverter(Class<T> cls) Finds a from-string converter by type.private <T> TypedFromStringConverter<T> findFromStringMethod(Class<T> cls, boolean searchSuperclasses) Finds the conversion method.private MethodfindToStringMethod(Class<?> cls) Finds the conversion method.toString()
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Constructor Details
-
AnnotationStringConverterFactory
private AnnotationStringConverterFactory()Restricted constructor.
-
-
Method Details
-
findConverter
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:
RuntimeException- (or subclass) if source code is invalid
-
findAnnotatedConverter
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
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
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
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
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 nullsearchSuperclasses- whether to search superclasses- Returns:
- the method to call, null means not found
- Throws:
RuntimeException- if invalid
-
findFromString
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:
RuntimeException- if invalid
-
eliminateEnumSubclass
-
toString
-