jTransfo, 0.14

org.jtransfo
Class StringEnumTypeConverter<ENUM_TYPE extends Enum>

java.lang.Object
  extended by org.jtransfo.StringEnumTypeConverter<ENUM_TYPE>
Type Parameters:
ENUM_TYPE - enum type to convert with
All Implemented Interfaces:
TypeConverter<String,ENUM_TYPE>

public class StringEnumTypeConverter<ENUM_TYPE extends Enum>
extends Object
implements TypeConverter<String,ENUM_TYPE>

Type converter for representing enums as string in the transfer object.


Constructor Summary
StringEnumTypeConverter(Class<ENUM_TYPE> enumClass)
          Construct a new type converter for the given enum type.
 
Method Summary
 boolean canConvert(Class<?> realToType, Class<?> realDomainType)
          Can this type converter handle conversions between the given transfer and domain object types?
 ENUM_TYPE convert(String object, SyntheticField domainField, Object domainObject, String... tags)
          Convert a transfer object field value to the value for the domain object.
 String reverse(ENUM_TYPE object, SyntheticField toField, Object toObject, String... tags)
          Convert a domain object field value to the value for the transfer object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringEnumTypeConverter

public StringEnumTypeConverter(Class<ENUM_TYPE> enumClass)
Construct a new type converter for the given enum type.

Parameters:
enumClass - enum type class
Method Detail

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<String,ENUM_TYPE extends Enum>
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

convert

public ENUM_TYPE convert(String object,
                         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<String,ENUM_TYPE extends Enum>
Parameters:
object - 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 String reverse(ENUM_TYPE object,
                      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<String,ENUM_TYPE extends Enum>
Parameters:
object - 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.