jTransfo, 0.10

org.jtransfo
Interface JTransfo

All Known Implementing Classes:
JTransfoImpl

public interface JTransfo

jTransfo main access point.


Field Summary
static String DEFAULT_TAG_WHEN_NO_TAGS
          Default tag which is activated when not tags are specified in the convert call.
 
Method Summary
 Object convert(Object source)
          Create a new domain object from the source transfer object.
<T> T
convert(Object source, T target, String... tags)
          Fill the target object with the values from the source object.
<T> List<T>
convertList(List<?> source, Class<T> targetClass, String... tags)
          Convert a list of object to the given type.
<T> T
convertTo(Object source, Class<T> targetClass, String... tags)
          Create a new domain object from the source transfer object.
<T> T
findTarget(Object source, Class<T> targetClass)
          Get the base target (domain) object for the source (transfer) object.
 Class<?> getDomainClass(Class<?> toClass)
          Get domain class for transfer object.
 Class<?> getToSubType(Class<?> toType, Object domainObject)
          Get the correct transfer object type for the given domain object.
 boolean isToClass(Class<?> toClass)
          Is the given class a transfer object class?

True when there is a DomainClass annotation on the class.

 

Field Detail

DEFAULT_TAG_WHEN_NO_TAGS

static final String DEFAULT_TAG_WHEN_NO_TAGS
Default tag which is activated when not tags are specified in the convert call.

See Also:
Constant Field Values
Method Detail

convert

<T> T convert(Object source,
              T target,
              String... tags)
Fill the target object with the values from the source object.

This will write all values from the transfer object, other fields are not touched.

Type Parameters:
T - type of object for target
Parameters:
source - source object. Should not be null.
target - target object. Should not be null.
tags - tags which indicate which fields can be converted based on MapOnly annotations. Tags are processed from left to right.
Returns:
target object

convert

Object convert(Object source)
Create a new domain object from the source transfer object.

When the source is null, the result is also null.

The object finders are used to build the object to copy to.

Parameters:
source - source transfer object
Returns:
domain object

convertTo

<T> T convertTo(Object source,
                Class<T> targetClass,
                String... tags)
Create a new domain object from the source transfer object.

When the source is null, the result is also null.

The object finders are used to build the object to copy to.

Type Parameters:
T - type of object for target
Parameters:
source - source transfer object
targetClass - target class to convert to
tags - tags which indicate which fields can be converted based on MapOnly annotations. Tags are processed from left to right.
Returns:
domain object

convertList

<T> List<T> convertList(List<?> source,
                        Class<T> targetClass,
                        String... tags)
Convert a list of object to the given type. Applies convertTo(Object, Class, String...) on each object.

When the source is null, the result is also null.

Type Parameters:
T - type of object for target
Parameters:
source - source list of objects
targetClass - target class to convert each object to
tags - tags which indicate which fields can be converted based on MapOnly annotations. Tags are processed from left to right.
Returns:
list of target objects

findTarget

<T> T findTarget(Object source,
                 Class<T> targetClass)
Get the base target (domain) object for the source (transfer) object.

When the source is null, the result is also null.

The object finders are used to build the object to copy to.

Type Parameters:
T - type of object for target
Parameters:
source - source transfer object
targetClass - target class to convert to
Returns:
domain object

getDomainClass

Class<?> getDomainClass(Class<?> toClass)
Get domain class for transfer object.

Parameters:
toClass - transfer object class
Returns:
domain class as annotated on class

isToClass

boolean isToClass(Class<?> toClass)
Is the given class a transfer object class?

True when there is a DomainClass annotation on the class.

Parameters:
toClass - object class to test
Returns:
true when object is a transfer object

getToSubType

Class<?> getToSubType(Class<?> toType,
                      Object domainObject)
Get the correct transfer object type for the given domain object.

This searches the DomainClassDelegates (if present) to see of there is a better matching transfer object than the one given as parameter.

Parameters:
toType - base transfer object type
domainObject - domain object (instance)
Returns:
proper transfer object type to use

jTransfo, 0.10

Copyright © 2013. All rights reserved.