Package org.apache.ofbiz.base.conversion
Class Converters.PassThruConverter<S,T>
- java.lang.Object
-
- org.apache.ofbiz.base.conversion.Converters.PassThruConverter<S,T>
-
- All Implemented Interfaces:
Converter<S,T>
- Enclosing class:
- Converters
protected static class Converters.PassThruConverter<S,T> extends java.lang.Object implements Converter<S,T>
Pass thru converter used when the source and target java object types are the same. Theconvert
method returns the source object.
-
-
Constructor Summary
Constructors Constructor Description PassThruConverter(java.lang.Class<S> sourceClass, java.lang.Class<T> targetClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
Returnstrue
if this object can convertsourceClass
totargetClass
.T
convert(java.lang.Class<? extends T> targetClass, S obj)
Convertsobj
toT
.T
convert(S obj)
Convertsobj
toT
.java.lang.Class<?>
getSourceClass()
Returns the sourceClass
for this converter.java.lang.Class<?>
getTargetClass()
Returns the targetClass
for this converter.
-
-
-
Method Detail
-
canConvert
public boolean canConvert(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
Description copied from interface:Converter
Returnstrue
if this object can convertsourceClass
totargetClass
.Implementations can accomodate class hierarchy ranges by converting super classes or interfaces.
- Specified by:
canConvert
in interfaceConverter<S,T>
- Parameters:
sourceClass
- The sourceClass
targetClass
- The targetClass
- Returns:
true
if this object can convertsourceClass
totargetClass
.
-
convert
public T convert(S obj) throws ConversionException
Description copied from interface:Converter
Convertsobj
toT
.- Specified by:
convert
in interfaceConverter<S,T>
- Parameters:
obj
- The sourceObject
to convert- Returns:
- The converted
Object
- Throws:
ConversionException
-
convert
public T convert(java.lang.Class<? extends T> targetClass, S obj) throws ConversionException
Description copied from interface:Converter
Convertsobj
toT
.- Specified by:
convert
in interfaceConverter<S,T>
- Parameters:
targetClass
- TheClass
to convert toobj
- The sourceObject
to convert- Returns:
- The converted
Object
- Throws:
ConversionException
-
getSourceClass
public java.lang.Class<?> getSourceClass()
Description copied from interface:Converter
Returns the sourceClass
for this converter.- Specified by:
getSourceClass
in interfaceConverter<S,T>
- Returns:
- The source
Class
for this converter
-
getTargetClass
public java.lang.Class<?> getTargetClass()
Description copied from interface:Converter
Returns the targetClass
for this converter.- Specified by:
getTargetClass
in interfaceConverter<S,T>
- Returns:
- The target
Class
for this converter
-
-