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,CartVoucherValidationErrorConverter,CartVoucherValidationErrorConverter,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 voidafterPropertiesSet()TARGETconvert(SOURCE source)Converts the source object, creating a new instance of the destination typeTARGETconvert(SOURCE source, TARGET prototype)Convert the source object by filling the prototypeprotected TARGETcreateFromClass()protected TARGETcreateTarget()Deprecated, for removal: This API element is subject to removal in a future version.please inject the target class directly, since it's way faster than the Springapproach! java.lang.StringgetMyBeanName()abstract voidpopulate(SOURCE source, TARGET target)Override this method to populate the target from the sourcevoidsetBeanName(java.lang.String name)voidsetTargetClass(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:ConverterConverts 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:ConverterConvert the source object by filling the prototype- Specified by:
convertin 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:
populatein 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(since="ages", forRemoval=true) protected TARGET createTarget()Deprecated, for removal: This API element is subject to removal in a future version.please inject the target class directly, since it's way faster than the Springapproach!
-
setBeanName
public void setBeanName(java.lang.String name)
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
getMyBeanName
public java.lang.String getMyBeanName()
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
-