public class JTransfoImpl extends Object implements JTransfo, ConvertSourceTarget
DEFAULT_TAG_WHEN_NO_TAGS| Constructor and Description |
|---|
JTransfoImpl()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearCaches()
Clear cache with converters.
|
Object |
convert(Object source)
Create a new domain object from the source transfer object.
|
<T> T |
convert(Object source,
T target,
boolean targetIsTo,
String... tags)
Fill the target object with the values from the source 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.
|
List<ConvertInterceptor> |
getConvertInterceptors()
Get the list of
ConvertInterceptors to allow customization. |
Class<?> |
getDomainClass(Class<?> toClass)
Get domain class for transfer object.
|
List<ObjectFinder> |
getObjectFinders()
Get the list of
ObjectFinders to allow customization. |
List<ObjectReplacer> |
getObjectReplacers()
Get the list of
ObjectReplacers to allow customization. |
Class<?> |
getToSubType(Class<?> toType,
Object domainObject)
Get the correct transfer object type for the given domain object.
|
List<TypeConverter> |
getTypeConverters()
Get the set of type converters which are used by this jTransfo instance.
|
boolean |
isToClass(Class<?> toClass)
Is the given class a transfer object class?
|
void |
updateConvertInterceptors()
Update the list of convert interceptors which is used based on the internal list
(see
getConvertInterceptors(). |
void |
updateConvertInterceptors(List<ConvertInterceptor> newConvertInterceptors)
Update the list of convert interceptors which is used.
|
void |
updateObjectFinders()
Update the list of object finders which is used based on the internal list (see
getObjectFinders(). |
void |
updateObjectFinders(List<ObjectFinder> newObjectFinders)
Update the list of object finders which is used.
|
void |
updateObjectReplacers()
Update the list of object replacers which is used based on the internal list
(see
getObjectReplacers(). |
void |
updateObjectReplacers(List<ObjectReplacer> newObjectReplacers)
Update the list of object replacers which is used.
|
void |
updateTypeConverters()
Update the list of type converters which is used based on the internal list (see
getTypeConverters(). |
void |
updateTypeConverters(List<TypeConverter> newConverters)
Update the list of type converters which is used.
|
public List<TypeConverter> getTypeConverters()
You are explicitly allowed to change this list, but beware to do this from one thread only.
Changes in the list are not used until you call updateTypeConverters().
public void updateTypeConverters()
getTypeConverters().public void updateTypeConverters(List<TypeConverter> newConverters)
When null is passed, this updates the changes to the internal list (see getTypeConverters().
Alternatively, you can pass the new list explicitly.
newConverters - new list of type converterspublic List<ObjectFinder> getObjectFinders()
ObjectFinders to allow customization.
The elements are tried in reverse order (from end to start of list).
You are explicitly allowed to change this list, but beware to do this from one thread only.
Changes in the list are not used until you call updateObjectFinders().
public void updateObjectFinders()
getObjectFinders().public void updateObjectFinders(List<ObjectFinder> newObjectFinders)
When null is passed, this updates the changes to the internal list (see getObjectFinders().
Alternatively, you can pass the new list explicitly.
newObjectFinders - new list of type converterspublic List<ObjectReplacer> getObjectReplacers()
ObjectReplacers to allow customization.
The elements are tried in order (from start to end of list).
You are explicitly allowed to change this list, but beware to do this from one thread only.
Changes in the list are not used until you call updateObjectReplacers().
public void updateObjectReplacers()
getObjectReplacers().public void updateObjectReplacers(List<ObjectReplacer> newObjectReplacers)
When null is passed, this updates the changes to the internal list (see getObjectReplacers().
Alternatively, you can pass the new list explicitly.
newObjectReplacers - new list of type converterspublic List<ConvertInterceptor> getConvertInterceptors()
ConvertInterceptors to allow customization.
The elements are tried in reverse order (from end to start of list).
You are explicitly allowed to change this list, but beware to do this from one thread only.
Changes in the list are not used until you call updateConvertInterceptors().
public void updateConvertInterceptors()
getConvertInterceptors().public void updateConvertInterceptors(List<ConvertInterceptor> newConvertInterceptors)
When null is passed, this updates the changes to the internal list (see getConvertInterceptors().
Alternatively, you can pass the new list explicitly.
newConvertInterceptors - new list of convert interceptorspublic <T> T convert(Object source, T target, String... tags)
JTransfoThis will write all values from the transfer object, other fields are not touched.
convert in interface JTransfoT - type of object for targetsource - 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.public <T> T convert(Object source, T target, boolean targetIsTo, String... tags)
ConvertSourceTargetThis will write all values from the transfer object, other fields are not touched.
convert in interface ConvertSourceTargetT - type of object for targetsource - source object. Should not be null.target - target object. Should not be null.targetIsTo - is the target class the transfer object?tags - tags which indicate which fields can be converted based on MapOnly annotations.
Tags are processed from left to right.public Object convert(Object source)
JTransfoWhen the source is null, the result is also null.
The object finders are used to build the object to copy to.
public <T> T convertTo(Object source, Class<T> targetClass, String... tags)
JTransfoWhen the source is null, the result is also null.
The object finders are used to build the object to copy to.
convertTo in interface JTransfoT - type of object for targetsource - source transfer objecttargetClass - target class to convert totags - tags which indicate which fields can be converted based on MapOnly annotations.
Tags are processed from left to right.public <T> List<T> convertList(List<?> source, Class<T> targetClass, String... tags)
JTransfoJTransfo.convertTo(Object, Class, String...) on each object.
When the source is null, the result is also null.
convertList in interface JTransfoT - type of object for targetsource - source list of objectstargetClass - target class to convert each object totags - tags which indicate which fields can be converted based on MapOnly annotations.
Tags are processed from left to right.public <T> T findTarget(Object source, Class<T> targetClass)
JTransfoWhen the source is null, the result is also null.
The object finders are used to build the object to copy to.
findTarget in interface JTransfoT - type of object for targetsource - source transfer objecttargetClass - target class to convert topublic Class<?> getDomainClass(Class<?> toClass)
JTransfogetDomainClass in interface JTransfotoClass - transfer object classpublic boolean isToClass(Class<?> toClass)
JTransfo
True when there is a DomainClass annotation on the class.
public Class<?> getToSubType(Class<?> toType, Object domainObject)
JTransfoThis searches the DomainClassDelegates (if present) to see of there is a better matching transfer object than the one given as parameter.
getToSubType in interface JTransfotoType - base transfer object typedomainObject - domain object (instance)public void clearCaches()
Copyright © 2016. All rights reserved.