public class JTransfoImpl extends Object implements JTransfo, ConfigurableJTransfo, ConvertSourceTarget
DEFAULT_TAG_WHEN_NO_TAGS, TAG_WHEN_READ_ONLY_DOMAIN
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<ClassReplacer> |
getClassReplacers()
Get the list of
ClassReplacer s to allow customization. |
List<ConvertInterceptor> |
getConvertInterceptors()
Get the list of
ConvertInterceptor s to allow customization. |
Class<?> |
getDomainClass(Class<?> toClass)
Get domain class for transfer object.
|
List<ObjectFinder> |
getObjectFinders()
Get the list of
ObjectFinder s to allow customization. |
List<ObjectReplacer> |
getObjectReplacers()
Get the list of
ObjectReplacer s to allow customization. |
List<PostConverter> |
getPostConverters()
Get the set of postconverters which are used by this jTransfo instance.
|
List<PreConverter> |
getPreConverters()
Get the set of preconverters which are used by this jTransfo instance.
|
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 |
updateClassReplacers()
Update the list of class replacers which is used based on the internal list
(see
ConfigurableJTransfo.getObjectReplacers() . |
void |
updateClassReplacers(List<ClassReplacer> newClassReplacers)
Update the list of class replacers which is used.
|
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 |
updatePostConverters()
Update the list of postconverters which is used based on the internal list
(see
ConfigurableJTransfo.getPostConverters() . |
void |
updatePostConverters(List<PostConverter> newConverters)
Update the list of type converters which is used.
|
void |
updatePreConverters()
Update the list of preconverters which is used based on the internal list
(see
ConfigurableJTransfo.getPreConverters() . |
void |
updatePreConverters(List<PreConverter> newConverters)
Update the list of type converters 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.
|
public List<TypeConverter> getTypeConverters()
ConfigurableJTransfo
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.updateTypeConverters()
.
getTypeConverters
in interface ConfigurableJTransfo
public void updateTypeConverters()
ConfigurableJTransfo
ConfigurableJTransfo.getTypeConverters()
.updateTypeConverters
in interface ConfigurableJTransfo
public 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 ConfigurableJTransfo
newConverters
- new list of type converterspublic List<PreConverter> getPreConverters()
ConfigurableJTransfo
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.updatePreConverters()
.
getPreConverters
in interface ConfigurableJTransfo
public void updatePreConverters()
ConfigurableJTransfo
ConfigurableJTransfo.getPreConverters()
.updatePreConverters
in interface ConfigurableJTransfo
public void updatePreConverters(List<PreConverter> newConverters)
ConfigurableJTransfo
When null is passed, this updates the changes to the internal list (see ConfigurableJTransfo.getPreConverters()
.
Alternatively, you can pass the new list explicitly.
updatePreConverters
in interface ConfigurableJTransfo
newConverters
- new list of preconverterspublic List<PostConverter> getPostConverters()
ConfigurableJTransfo
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.updatePostConverters()
.
getPostConverters
in interface ConfigurableJTransfo
public void updatePostConverters()
ConfigurableJTransfo
ConfigurableJTransfo.getPostConverters()
.updatePostConverters
in interface ConfigurableJTransfo
public void updatePostConverters(List<PostConverter> newConverters)
ConfigurableJTransfo
When null is passed, this updates the changes to the internal list (see ConfigurableJTransfo.getPostConverters()
.
Alternatively, you can pass the new list explicitly.
updatePostConverters
in interface ConfigurableJTransfo
newConverters
- new list of postconverterspublic List<ObjectFinder> getObjectFinders()
ConfigurableJTransfo
ObjectFinder
s 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 ConfigurableJTransfo
public void updateObjectFinders()
ConfigurableJTransfo
ConfigurableJTransfo.getObjectFinders()
.updateObjectFinders
in interface ConfigurableJTransfo
public 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 ConfigurableJTransfo
newObjectFinders
- new list of type converterspublic List<ObjectReplacer> getObjectReplacers()
ConfigurableJTransfo
ObjectReplacer
s 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 ConfigurableJTransfo
public void updateObjectReplacers()
ConfigurableJTransfo
ConfigurableJTransfo.getObjectReplacers()
.updateObjectReplacers
in interface ConfigurableJTransfo
public 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 ConfigurableJTransfo
newObjectReplacers
- new list of object replacerspublic List<ClassReplacer> getClassReplacers()
ConfigurableJTransfo
ClassReplacer
s 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.updateClassReplacers()
.
getClassReplacers
in interface ConfigurableJTransfo
public void updateClassReplacers()
ConfigurableJTransfo
ConfigurableJTransfo.getObjectReplacers()
.updateClassReplacers
in interface ConfigurableJTransfo
public void updateClassReplacers(List<ClassReplacer> newClassReplacers)
ConfigurableJTransfo
When null is passed, this updates the changes to the internal list (see ConfigurableJTransfo.getClassReplacers()
.
Alternatively, you can pass the new list explicitly.
updateClassReplacers
in interface ConfigurableJTransfo
newClassReplacers
- new list of class replacerspublic List<ConvertInterceptor> getConvertInterceptors()
ConvertInterceptor
s 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 ConfigurableJTransfo
public void updateConvertInterceptors()
getConvertInterceptors()
.updateConvertInterceptors
in interface ConfigurableJTransfo
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.
updateConvertInterceptors
in interface ConfigurableJTransfo
newConvertInterceptors
- new list of convert interceptorspublic <T> T convert(Object source, T target, String... tags)
JTransfo
This will write all values from the transfer object, other fields are not touched.
convert
in interface JTransfo
T
- 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)
ConvertSourceTarget
This will write all values from the transfer object, other fields are not touched.
convert
in interface ConvertSourceTarget
T
- 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)
JTransfo
When 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)
JTransfo
When the source is null, the result is also null.
The object finders are used to build the object to copy to.
convertTo
in interface JTransfo
T
- 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)
JTransfo
JTransfo.convertTo(Object, Class, String...)
on each object.
When the source is null, the result is also null.
convertList
in interface JTransfo
T
- 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)
JTransfo
When the source is null, the result is also null.
The object finders are used to build the object to copy to.
findTarget
in interface JTransfo
T
- 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)
JTransfo
getDomainClass
in interface JTransfo
toClass
- 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)
JTransfo
This searches the DomainClassDelegates (if present) to see of there is a better matching transfer object than the one given as parameter.
getToSubType
in interface JTransfo
toType
- base transfer object typedomainObject
- domain object (instance)public void clearCaches()
Copyright © 2022. All rights reserved.