Package com.znize.platform.model.util
Class EntityReferenceUtil
- java.lang.Object
-
- com.znize.platform.model.util.EntityReferenceUtil
-
public class EntityReferenceUtil extends java.lang.ObjectEntityReference Utility.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description EntityReferenceUtil(DataAccessUnit dataAccessUnit)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T extends PersistenceEntity>
EntityTypeId<T>getEntityReference(T targetEntity)Get the reference to the target entity<T extends EntityReference,M extends PersistenceEntity>
TgetEntityWithReferenceTo(java.lang.Class<T> entityType, EntityTypeId<M> targetEntityTypeId)Get the entity of the entity type that has a reference to targetEntity.<T extends EntityReference,M extends PersistenceEntity>
TgetEntityWithReferenceTo(java.lang.Class<T> entityType, M targetEntity)Get the entity of the entity type that has a reference to targetEntity.<T extends EntityReference,M extends PersistenceEntity>
MgetReferencedTargetEntity(T entity)Get the target entity referenced by the entity.<M extends PersistenceEntity>
MgetReferenceTargetEntity(EntityTypeId<M> entityRef)Get the entity that the source is referring to.
-
-
-
Constructor Detail
-
EntityReferenceUtil
public EntityReferenceUtil(DataAccessUnit dataAccessUnit)
Constructor- Parameters:
dataAccessUnit- the associated DataAccessUnit to access entities.- Since:
- 5.13
-
-
Method Detail
-
getEntityReference
public static <T extends PersistenceEntity> EntityTypeId<T> getEntityReference(T targetEntity)
Get the reference to the target entity- Parameters:
targetEntity- a referenced entity- Returns:
- the entity reference that is the entityTypeId of the target entity
-
getEntityWithReferenceTo
public <T extends EntityReference,M extends PersistenceEntity> T getEntityWithReferenceTo(java.lang.Class<T> entityType, M targetEntity) throws SystemException
Get the entity of the entity type that has a reference to targetEntity. If there is more than one such entity, return random one of them.(returned entity).entityRef = EntityTypeId(targetEntity).
- Parameters:
entityType- the type of entity to returntargetEntity- a referenced entity- Returns:
- the entity with a reference to the sourceEntity.
- Throws:
SystemException- throw if an error occurs.
-
getEntityWithReferenceTo
public <T extends EntityReference,M extends PersistenceEntity> T getEntityWithReferenceTo(java.lang.Class<T> entityType, EntityTypeId<M> targetEntityTypeId)
Get the entity of the entity type that has a reference to targetEntity. If there is more than one such entity, return random one of them.(returned entity).entityRef = targetEntityTypeId.
- Parameters:
entityType- the type of entity to returntargetEntityTypeId- the entityTypeId of target entity- Returns:
- the entity with a reference to the sourceEntity.
-
getReferencedTargetEntity
public <T extends EntityReference,M extends PersistenceEntity> M getReferencedTargetEntity(T entity)
Get the target entity referenced by the entity.entity.entityRef = EntityTypeId(target entity)
- Parameters:
entity- sourceAware entity- Returns:
- target entity
-
getReferenceTargetEntity
public <M extends PersistenceEntity> M getReferenceTargetEntity(EntityTypeId<M> entityRef)
Get the entity that the source is referring to.- Parameters:
entityRef- entityTypeId of target entity- Returns:
- target entity
-
-