Package org.apache.ofbiz.base.conversion
Class Converters
java.lang.Object
org.apache.ofbiz.base.conversion.Converters
A
Converter
factory and repository.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Pass thru converter used when the source and target java object types are the same.protected static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic <S,
T> Converter<S, T> getConverter
(Class<S> sourceClass, Class<T> targetClass) Returns an appropriateConverter
instance forsourceClass
andtargetClass
.static void
loadContainedConverters
(Class<?> containerClass) Load all classes that implementConverter
and are contained incontainerClass
.static <S,
T> void registerConverter
(Converter<S, T> converter) Registers aConverter
instance to be used by thegetConverter(Class, Class)
method.
-
Method Details
-
getConverter
public static <S,T> Converter<S,T> getConverter(Class<S> sourceClass, Class<T> targetClass) throws ClassNotFoundException Returns an appropriateConverter
instance forsourceClass
andtargetClass
. If no matchingConverter
is found, the method throwsClassNotFoundException
.This method is intended to be used when the source or target
Object
types are unknown at compile time. If the source and targetObject
types are known at compile time, then one of the "ready made" converters should be used.- Parameters:
sourceClass
- The object class to convert fromtargetClass
- The object class to convert to- Returns:
- A matching
Converter
instance - Throws:
ClassNotFoundException
-
loadContainedConverters
Load all classes that implementConverter
and are contained incontainerClass
.- Parameters:
containerClass
-
-
registerConverter
Registers aConverter
instance to be used by thegetConverter(Class, Class)
method.- Type Parameters:
S
- The source object typeT
- The target object type- Parameters:
converter
- TheConverter
instance to register
-