Class GenericConverter<SOURCE,TARGET>
- java.lang.Object
-
- de.hybris.platform.servicelayer.dto.converter.GenericConverter<SOURCE,TARGET>
-
- All Implemented Interfaces:
Converter<SOURCE,TARGET>,org.springframework.core.convert.converter.Converter<SOURCE,TARGET>
public class GenericConverter<SOURCE,TARGET> extends java.lang.Object implements Converter<SOURCE,TARGET>
Converts all properties from source to target that have the same name and have compatible types.
-
-
Constructor Summary
Constructors Constructor Description GenericConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TARGETconvert(SOURCE source)Creates a new type of targetClass and converts all properties from source to this new instance that have the same name and have compatible types.TARGETconvert(SOURCE source, TARGET prototype)Converts all properties from source to target that have the same name and have compatible types.protected TARGETcreateDestObject()voidsetDestClass(java.lang.Class<TARGET> destClass)The class of the target.-
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
Creates a new type of targetClass and converts all properties from source to this new instance that have the same name and have compatible types.
-
convert
public TARGET convert(SOURCE source, TARGET prototype) throws ConversionException
Converts all properties from source to target that have the same name and have compatible types.- 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
-
setDestClass
public void setDestClass(java.lang.Class<TARGET> destClass)
The class of the target. Used byconvert(Object).- Parameters:
destClass-
-
createDestObject
protected TARGET createDestObject() throws ConversionException
- Throws:
ConversionException
-
-