Class AbstractConverter<SOURCE,TARGET>
- java.lang.Object
-
- de.hybris.platform.converters.impl.AbstractConverter<SOURCE,TARGET>
-
- All Implemented Interfaces:
Populator<SOURCE,TARGET>
,Converter<SOURCE,TARGET>
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.InitializingBean
,org.springframework.core.convert.converter.Converter<SOURCE,TARGET>
- Direct Known Subclasses:
AbstractErrorConverter
,AbstractPopulatingConverter
,PosConverter
,ProductConverter
public abstract class AbstractConverter<SOURCE,TARGET> extends java.lang.Object implements Converter<SOURCE,TARGET>, Populator<SOURCE,TARGET>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanNameAware
Abstract implementation of the Converter interface that also supports the Populator interface. Implementations of this base type can either be used as a converter or as a populator. When used as a converter thecreateTarget()
method is called to create the target instance and then thepopulate(Object, Object)
method is called to populate the target with values from the source instance. ThecreateTarget()
method can be implemented via a spring lookup-method rather than being overridden in code.
-
-
Constructor Summary
Constructors Constructor Description AbstractConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
afterPropertiesSet()
TARGET
convert(SOURCE source)
Converts the source object, creating a new instance of the destination typeTARGET
convert(SOURCE source, TARGET prototype)
Convert the source object by filling the prototypeprotected TARGET
createFromClass()
protected TARGET
createTarget()
Deprecated.please inject the target class directly, since it's way faster than the Springapproach! java.lang.String
getMyBeanName()
abstract void
populate(SOURCE source, TARGET target)
Override this method to populate the target from the sourcevoid
setBeanName(java.lang.String name)
void
setTargetClass(java.lang.Class<TARGET> targetClass)
Allows to specify the target object class directly.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.servicelayer.dto.converter.Converter
convertAll, convertAllIgnoreExceptions, getLogger
-
-
-
-
Method Detail
-
convert
public TARGET convert(SOURCE source) throws ConversionException
Description copied from interface:Converter
Converts the source object, creating a new instance of the destination type
-
convert
public TARGET convert(SOURCE source, TARGET prototype) throws ConversionException
Description copied from interface:Converter
Convert the source object by filling the prototype- Specified by:
convert
in interfaceConverter<SOURCE,TARGET>
- Parameters:
source
- the source objectprototype
- the prototype to fill- Returns:
- the converted object, identical to the prototype
- Throws:
ConversionException
- if an error occurs
-
populate
public abstract void populate(SOURCE source, TARGET target)
Override this method to populate the target from the source- Specified by:
populate
in interfacePopulator<SOURCE,TARGET>
- Parameters:
source
- the source instancetarget
- the target instance to fill- See Also:
setTargetClass(Class)
-
setTargetClass
public void setTargetClass(java.lang.Class<TARGET> targetClass)
Allows to specify the target object class directly. Please use that instead of the deprecatedapproach, as it's way faster.
-
createFromClass
protected TARGET createFromClass()
-
createTarget
@Deprecated protected TARGET createTarget()
Deprecated.please inject the target class directly, since it's way faster than the Springapproach!
-
setBeanName
public void setBeanName(java.lang.String name)
- Specified by:
setBeanName
in interfaceorg.springframework.beans.factory.BeanNameAware
-
getMyBeanName
public java.lang.String getMyBeanName()
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
java.lang.Exception
-
-