jTransfo, 0.14

org.jtransfo
Class AbstractToDomainTypeConverter

java.lang.Object
  extended by org.jtransfo.AbstractToDomainTypeConverter
All Implemented Interfaces:
NeedsJTransfo, TypeConverter<Object,Object>
Direct Known Subclasses:
ReadOnlyDomainTypeConverter, ToDomainTypeConverter

public abstract class AbstractToDomainTypeConverter
extends Object
implements TypeConverter<Object,Object>, NeedsJTransfo

Recursively use jTransfo to convert fields which are themselves a transfer object.


Constructor Summary
AbstractToDomainTypeConverter()
           
 
Method Summary
 boolean canConvert(Class<?> realToType, Class<?> realDomainType)
          Can this type converter handle conversions between the given transfer and domain object types?
 Object convert(Object toObject, SyntheticField domainField, Object domainObject, String... tags)
          Convert a transfer object field value to the value for the domain object.
abstract  Object doConvert(JTransfo jTransfo, Object toObject, SyntheticField domainField, String... tags)
          Do the actual conversion.
 Object reverse(Object domainObject, SyntheticField toField, Object toObject, String... tags)
          Convert a domain object field value to the value for the transfer object.
 void setJTransfo(JTransfo jTransfo)
          Set jTransfo instance which can be used recursively.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractToDomainTypeConverter

public AbstractToDomainTypeConverter()
Method Detail

setJTransfo

public void setJTransfo(JTransfo jTransfo)
Description copied from interface: NeedsJTransfo
Set jTransfo instance which can be used recursively.

Specified by:
setJTransfo in interface NeedsJTransfo
Parameters:
jTransfo - jTransfo instance

canConvert

public boolean canConvert(Class<?> realToType,
                          Class<?> realDomainType)
Description copied from interface: TypeConverter
Can this type converter handle conversions between the given transfer and domain object types?

Specified by:
canConvert in interface TypeConverter<Object,Object>
Parameters:
realToType - real class for the type in the transfer object
realDomainType - real class for the type in the domain object
Returns:
true is this type converter can handle the type conversions

doConvert

public abstract Object doConvert(JTransfo jTransfo,
                                 Object toObject,
                                 SyntheticField domainField,
                                 String... tags)
                          throws JTransfoException
Do the actual conversion.

Parameters:
jTransfo - jTransfo instance in use
toObject - transfer object
domainField - domain object field
tags - tags which indicate which fields can be converted based on MapOnly annotations.
Returns:
domain object
Throws:
JTransfoException - oops, cannot convert

convert

public Object convert(Object toObject,
                      SyntheticField domainField,
                      Object domainObject,
                      String... tags)
               throws JTransfoException
Description copied from interface: TypeConverter
Convert a transfer object field value to the value for the domain object.

Specified by:
convert in interface TypeConverter<Object,Object>
Parameters:
toObject - object to convert
domainField - target domain field
domainObject - target domain object
tags - tags which indicate which fields can be converted based on MapOnly annotations.
Returns:
converted object
Throws:
JTransfoException - problem during type conversion

reverse

public Object reverse(Object domainObject,
                      SyntheticField toField,
                      Object toObject,
                      String... tags)
               throws JTransfoException
Description copied from interface: TypeConverter
Convert a domain object field value to the value for the transfer object.

Specified by:
reverse in interface TypeConverter<Object,Object>
Parameters:
domainObject - object to convert
toField - target transfer object field
toObject - target transfer object
tags - tags which indicate which fields can be converted based on MapOnly annotations.
Returns:
converted object
Throws:
JTransfoException - problem during type conversion

jTransfo, 0.14

Copyright © 2014. All rights reserved.