public class JTransfoImpl extends Object implements JTransfo, ConfigurableJTransfo, 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,
String... tags)
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
ConfigurableJTransfo.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
ConfigurableJTransfo.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
ConfigurableJTransfo.getTypeConverters(). |
void |
updateTypeConverters(List<TypeConverter> newConverters)
Update the list of type converters which is used.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwith, with, with, withpublic List<TypeConverter> getTypeConverters()
ConfigurableJTransfoYou 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 ConfigurableJTransfo.updateTypeConverters().
getTypeConverters in interface ConfigurableJTransfopublic void updateTypeConverters()
ConfigurableJTransfoConfigurableJTransfo.getTypeConverters().updateTypeConverters in interface ConfigurableJTransfopublic void updateTypeConverters(List<TypeConverter> newConverters)
ConfigurableJTransfo
When null is passed, this updates the changes to the internal list (see ConfigurableJTransfo.getTypeConverters().
Alternatively, you can pass the new list explicitly.
updateTypeConverters in interface ConfigurableJTransfonewConverters - new list of type converterspublic List<ObjectFinder> getObjectFinders()
ConfigurableJTransfoObjectFinders 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 ConfigurableJTransfo.updateObjectFinders().
getObjectFinders in interface ConfigurableJTransfopublic void updateObjectFinders()
ConfigurableJTransfoConfigurableJTransfo.getObjectFinders().updateObjectFinders in interface ConfigurableJTransfopublic void updateObjectFinders(List<ObjectFinder> newObjectFinders)
ConfigurableJTransfo
When null is passed, this updates the changes to the internal list (see ConfigurableJTransfo.getObjectFinders().
Alternatively, you can pass the new list explicitly.
updateObjectFinders in interface ConfigurableJTransfonewObjectFinders - new list of type converterspublic List<ObjectReplacer> getObjectReplacers()
ConfigurableJTransfoObjectReplacers 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 ConfigurableJTransfo.updateObjectReplacers().
getObjectReplacers in interface ConfigurableJTransfopublic void updateObjectReplacers()
ConfigurableJTransfoConfigurableJTransfo.getObjectReplacers().updateObjectReplacers in interface ConfigurableJTransfopublic void updateObjectReplacers(List<ObjectReplacer> newObjectReplacers)
ConfigurableJTransfo
When null is passed, this updates the changes to the internal list (see ConfigurableJTransfo.getObjectReplacers().
Alternatively, you can pass the new list explicitly.
updateObjectReplacers in interface ConfigurableJTransfonewObjectReplacers - 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().
getConvertInterceptors in interface ConfigurableJTransfopublic void updateConvertInterceptors()
getConvertInterceptors().updateConvertInterceptors in interface ConfigurableJTransfopublic 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.
updateConvertInterceptors in interface ConfigurableJTransfonewConvertInterceptors - 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, String... tags)
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 totags - tags which indicate how objects need to be foundpublic 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 © 2017. All rights reserved.