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 PojoUtil |
pojoUtil |
| 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 PojoUtil |
getPojoUtil() |
void |
setComposedValueConverter(ComposedValueConverter composedValueConverter) |
void |
setDatatypeDetector(DatatypeDetector datatypeDetector) |
void |
setReflectionUtil(PojoUtil pojoUtil) |
void |
updateModificationCounter(Object container,
boolean remove)
This method recursively updates all
modification counters of the
ETOs contained in the given container. |
clone, newInstancecreateLogger, getLoggerdoInitialized, getInitializationState, initializeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclone, newInstanceprivate static final TransferObjectUtilImpl.EtoHelper HELPER
TransferObjectUtilImpl.EtoHelper.private static TransferObjectUtil instance
private ComposedValueConverter composedValueConverter
private PojoUtil pojoUtil
private DatatypeDetector datatypeDetector
public static TransferObjectUtil getInstance()
TransferObjectUtilImpl. Cdi.GET_INSTANCE before using.protected void doInitialize()
AbstractComponentinitialization. It is called when AbstractComponent.initialize() is
invoked for the first time. super.AbstractComponent.doInitialize().doInitialize in class AbstractLoggableComponentprotected 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 PojoUtil getPojoUtil()
ReflectionUtil instance.@Inject public void setReflectionUtil(PojoUtil pojoUtil)
pojoUtil - is the PojoUtil to Inject.public <ID,ENTITY extends PersistenceEntity<ID>,TO extends EntityTo<ID>> TO convertFromEntity(ENTITY entity, Class<TO> toType)
TransferObjectUtilPersistenceEntity to the corresponding transfer-object
identified by the given Class.convertFromEntity in interface TransferObjectUtilID - 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)
TransferObjectUtilTransferObjectUtil.convertFromEntity(PersistenceEntity, Class) for a List.convertFromEntityList in interface TransferObjectUtilID - 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)
TransferObjectUtilTransferObjectUtil.convertFromEntity(PersistenceEntity, Class) for a Set.convertFromEntitySet in interface TransferObjectUtilID - 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)
TransferObjectUtilETO to the corresponding PersistenceEntity identified by
the given Class.convertToEntity in interface TransferObjectUtilID - 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)
TransferObjectUtilTransferObjectUtil.convertToEntity(EntityTo, Class) for a List.convertToEntityList in interface TransferObjectUtilID - 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 ETOs to convert.entityType - is the Class reflecting the PersistenceEntity to create.List with all ETOs 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)
TransferObjectUtilTransferObjectUtil.convertToEntity(EntityTo, Class) for a Set.convertToEntitySet in interface TransferObjectUtilID - 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 ETOs to convert.entityType - is the Class reflecting the PersistenceEntity to create.Set with all ETOs from transferObjects
converted to the given entityType.public void updateModificationCounter(Object container, boolean remove)
TransferObjectUtilmodification counters of the
ETOs 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
TransferObjects 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 TransferObjectUtilcontainer - 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 ETOs so they get dereferences
and garbage-collected, false otherwise.EntityTo.getModificationCounter()Copyright © 2001–2016 mmm-Team. All rights reserved.