@Named public class TransferObjectUtilImpl extends TransferObjectUtilLimitedImpl implements TransferObjectUtil
TransferObjectUtil
.getInstance()
Modifier and Type | Class and Description |
---|---|
private static class |
TransferObjectUtilImpl.EtoHelper
Make
EntityTo.PersistentEntityAccess accessible. |
Modifier and Type | Field and Description |
---|---|
private ComposedValueConverter |
composedValueConverter |
private DatatypeDetector |
datatypeDetector |
private static TransferObjectUtilImpl.EtoHelper |
HELPER
The singleton instance of
TransferObjectUtilImpl.EtoHelper . |
private static TransferObjectUtil |
instance |
private ReflectionUtil |
reflectionUtil |
Constructor and Description |
---|
TransferObjectUtilImpl()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
<ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> |
convertFromEntity(ENTITY entity,
Class<TO> toType)
This method converts the given
PersistenceEntity to the corresponding transfer-object identified by the given Class . |
<ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> |
convertFromEntityList(List<ENTITY> entityList,
Class<TO> toType)
Variant of
TransferObjectUtil.convertFromEntity(PersistenceEntity, Class) for a List . |
<ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> |
convertFromEntitySet(Set<ENTITY> entitySet,
Class<TO> toType)
Variant of
TransferObjectUtil.convertFromEntity(PersistenceEntity, Class) for a Set . |
<ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> |
convertToEntity(TO transferObject,
Class<ENTITY> entityType)
This method converts the given
ETO to the corresponding PersistenceEntity
identified by the given Class . |
<ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> |
convertToEntityList(List<TO> transferObjects,
Class<ENTITY> entityType)
Variant of
TransferObjectUtil.convertToEntity(EntityTo, Class) for a List . |
<ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> |
convertToEntitySet(Set<TO> transferObjects,
Class<ENTITY> entityType)
Variant of
TransferObjectUtil.convertToEntity(EntityTo, Class) for a Set . |
protected void |
doInitialize()
This method performs the actual
initialization . |
protected ComposedValueConverter |
getComposedValueConverter() |
protected DatatypeDetector |
getDatatypeDetector() |
static TransferObjectUtil |
getInstance()
This method gets the singleton instance of this
TransferObjectUtilImpl . |
protected ReflectionUtil |
getReflectionUtil() |
void |
setComposedValueConverter(ComposedValueConverter composedValueConverter) |
void |
setDatatypeDetector(DatatypeDetector datatypeDetector) |
void |
setReflectionUtil(ReflectionUtil reflectionUtil) |
void |
updateModificationCounter(Object container,
boolean remove)
This method recursively updates all
modification counters of
the ETO s contained in the given container . |
clone, newInstance
createLogger, getLogger
doInitialized, getInitializationState, initialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clone, newInstance
private static final TransferObjectUtilImpl.EtoHelper HELPER
TransferObjectUtilImpl.EtoHelper
.private static TransferObjectUtil instance
getInstance()
private ComposedValueConverter composedValueConverter
getComposedValueConverter()
private ReflectionUtil reflectionUtil
getReflectionUtil()
private DatatypeDetector datatypeDetector
getDatatypeDetector()
public static TransferObjectUtil getInstance()
TransferObjectUtilImpl
. Cdi.GET_INSTANCE
before using.protected void doInitialize()
initialization
. It is called when
AbstractComponent.initialize()
is invoked for the first time. super.AbstractComponent.doInitialize()
.doInitialize
in class AbstractLoggableComponent
protected ComposedValueConverter getComposedValueConverter()
ComposedValueConverter
.@Inject public void setComposedValueConverter(ComposedValueConverter composedValueConverter)
composedValueConverter
- is the instance of ComposedValueConverter
to Inject
.protected DatatypeDetector getDatatypeDetector()
DatatypeDetector
instance.@Inject public void setDatatypeDetector(DatatypeDetector datatypeDetector)
datatypeDetector
- is the DatatypeDetector
to Inject
.protected ReflectionUtil getReflectionUtil()
ReflectionUtil
instance.@Inject public void setReflectionUtil(ReflectionUtil reflectionUtil)
reflectionUtil
- is the ReflectionUtil
to Inject
.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> TO convertFromEntity(ENTITY entity, Class<TO> toType)
PersistenceEntity
to the corresponding transfer-object
identified by the given Class
.convertFromEntity
in interface TransferObjectUtil
ID
- is the generic type of the ID
.ENTITY
- is the generic type of the entity
to convert.TO
- is the generic type of the transfer-object
to create.entity
- is the PersistenceEntity
to convert.toType
- is the Class
reflecting the ETO
to create.toType
with the values of the given entity
.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> List<TO> convertFromEntityList(List<ENTITY> entityList, Class<TO> toType)
TransferObjectUtil.convertFromEntity(PersistenceEntity, Class)
for a List
.convertFromEntityList
in interface TransferObjectUtil
ID
- is the generic type of the ID
.ENTITY
- is the generic type of the entity
to convert.TO
- is the generic type of the transfer-object
to create.entityList
- is the List
of entities
to convert.toType
- is the Class
reflecting the ETO
to create.List
with all entities
from entityList
converted
to the given toType
.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> Set<TO> convertFromEntitySet(Set<ENTITY> entitySet, Class<TO> toType)
TransferObjectUtil.convertFromEntity(PersistenceEntity, Class)
for a Set
.convertFromEntitySet
in interface TransferObjectUtil
ID
- is the generic type of the ID
.ENTITY
- is the generic type of the entity
to convert.TO
- is the generic type of the transfer-object
to create.entitySet
- is the Set
of entities
to convert.toType
- is the Class
reflecting the ETO
to create.Set
with all entities
from entitySet
converted
to the given toType
.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> ENTITY convertToEntity(TO transferObject, Class<ENTITY> entityType)
ETO
to the corresponding PersistenceEntity
identified by the given Class
.convertToEntity
in interface TransferObjectUtil
ID
- is the generic type of the ID
.ENTITY
- is the generic type of the entity
to create.TO
- is the generic type of the ETO
to convert.transferObject
- is the ETO
to convert.entityType
- is the Class
reflecting the PersistenceEntity
to create.entityType
with the values of the given transferObject
.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> List<ENTITY> convertToEntityList(List<TO> transferObjects, Class<ENTITY> entityType)
TransferObjectUtil.convertToEntity(EntityTo, Class)
for a List
.convertToEntityList
in interface TransferObjectUtil
ID
- is the generic type of the ID
.ENTITY
- is the generic type of the entity
to create.TO
- is the generic type of the ETO
to convert.transferObjects
- is the List
of ETO
s to convert.entityType
- is the Class
reflecting the PersistenceEntity
to create.List
with all ETO
s from transferObjects
converted
to the given entityType
.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> Set<ENTITY> convertToEntitySet(Set<TO> transferObjects, Class<ENTITY> entityType)
TransferObjectUtil.convertToEntity(EntityTo, Class)
for a Set
.convertToEntitySet
in interface TransferObjectUtil
ID
- is the generic type of the ID
.ENTITY
- is the generic type of the entity
to create.TO
- is the generic type of the ETO
to convert.transferObjects
- is the Set
of ETO
s to convert.entityType
- is the Class
reflecting the PersistenceEntity
to create.Set
with all ETO
s from transferObjects
converted
to the given entityType
.public void updateModificationCounter(Object container, boolean remove)
modification counters
of
the ETO
s contained in the given container
. TransferObjectUtil.convertFromEntity(PersistenceEntity, Class)
is typically used before the transaction
has been closed (by the logic layer of the application). However, JPA implementations like hibernate only
update the modification counter
after the transaction
has been closed and the new modification counters are available from the DB. EntityTo
and this
method offer the perfect solution to this problem. All you have to do is call this method once for the
transfer object you want to send to the client after the transaction has been committed and before the
object gets serialized. TransferObjectUtil
. Otherwise this can lead to an infinity loop. However,
having cycles in TransferObject
s is typically a design flaw. If you think different you can try
to convince us so we will add support for this.updateModificationCounter
in interface TransferObjectUtil
container
- is the EntityTo
to update or any other TransferObject
, bean,
Collection
, or Map
potentially containing an EntityTo
.remove
- - true
to remove any internal references from ETO
s so they
get dereferences and garbage-collected, false
otherwise.EntityTo.getModificationCounter()
Copyright © 2001–2014 mmm-Team. All rights reserved.