public final class Entities
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.util.List<Entity> |
copyEntities(java.util.List<Entity> entities)
Copies the given entities, with new copied instances of all foreign key value entities.
|
static boolean |
equal(Entity entityOne,
Entity entityTwo,
java.lang.String... propertyIds)
Returns true if the values of the given properties are equal in the given entities.
|
static <T> java.util.List<T> |
getDistinctValues(java.lang.String propertyId,
java.util.Collection<Entity> entities)
Returns a Collection containing the distinct values of
propertyId from the given entities, excluding null values. |
static <T> java.util.List<T> |
getDistinctValues(java.lang.String propertyId,
java.util.Collection<Entity> entities,
boolean includeNullValue)
Returns a Collection containing the distinct values of
propertyId from the given entities. |
static java.util.List<Entity> |
getEntitiesByValue(java.util.Collection<Entity> entities,
java.util.Map<java.lang.String,java.lang.Object> values)
Finds entities according to the values of values
|
static java.util.List<Entity.Key> |
getKeys(java.util.List<Entity> entities)
Returns the primary keys of the given entities.
|
static java.util.List<Entity.Key> |
getKeys(java.util.List<Entity> entities,
boolean originalValue)
Returns the primary key values of the given entities, current or original.
|
static java.util.Collection<ColumnProperty> |
getModifiedColumnProperties(Entity entity,
Entity comparison,
boolean includeReadOnlyProperties)
Returns all
ColumnProperty s which value is missing or the original value differs from the one in the comparison
entity, returns an empty Collection if all of entity s original values match the values found in comparison |
static java.util.List<Entity> |
getModifiedEntities(java.util.Collection<Entity> entities)
Returns all of the given entities which have been modified
|
static java.lang.String[][] |
getStringValueArray(java.util.List<? extends Property> properties,
java.util.List<Entity> entities)
Creates a two dimensional array containing the values of the given properties for the given entities in string format.
|
static <T> java.util.List<T> |
getValues(java.util.List<Entity.Key> keys)
Retrieves the values of the given keys, assuming they are single column keys.
|
static <T> java.util.List<T> |
getValues(java.lang.String propertyId,
java.util.Collection<Entity> entities)
Returns the values associated with the given property from the given entities.
|
static <T> java.util.List<T> |
getValues(java.lang.String propertyId,
java.util.Collection<Entity> entities,
boolean includeNullValues)
Returns the values associated with the given property from the given entities.
|
static boolean |
isEntityNew(Entity entity)
Returns true if the entity has a null primary key or a null original primary key,
which is the best guess about an entity being new, as in, not existing in a database.
|
static boolean |
isKeyModified(java.util.Collection<Entity> entities)
Checks if the primary key of any of the given entities is modified
|
static java.util.LinkedHashMap<java.lang.String,java.util.List<Entity.Key>> |
mapKeysToEntityId(java.util.Collection<Entity.Key> keys)
Returns a LinkedHashMap containing the given entity keys mapped to their entityIds,
respecting the iteration order of the given collection
|
static java.util.LinkedHashMap<java.lang.String,java.util.List<Entity>> |
mapToEntityId(java.util.Collection<Entity> entities)
Returns a LinkedHashMap containing the given entities mapped to their entityIds,
respecting the iteration order of the given collection
|
static java.util.Map<Entity.Key,Entity> |
mapToKey(java.util.Collection<Entity> entities)
Maps the given entities to their primary key
|
static java.util.Map<Entity.Key,Entity> |
mapToOriginalPrimaryKey(java.util.List<Entity> entitiesBeforeUpdate,
java.util.List<Entity> entitiesAfterUpdate)
Maps the given entities and their updated counterparts to their original primary keys,
assumes a single copy of each entity in the given lists.
|
static <K> java.util.LinkedHashMap<K,java.util.List<Entity>> |
mapToValue(java.lang.String propertyId,
java.util.Collection<Entity> entities)
Returns a LinkedHashMap containing the given entities mapped to the value of the property with id
propertyId ,
respecting the iteration order of the given collection |
static java.util.Map<Entity.Key,java.lang.Object> |
put(java.lang.String propertyId,
java.lang.Object value,
java.util.Collection<Entity> entities)
Sets the value of the property with id
propertyId to value
in the given entities |
public static boolean isEntityNew(Entity entity)
entity
- the entitypublic static boolean isKeyModified(java.util.Collection<Entity> entities)
entities
- the entities to checkpublic static java.util.List<Entity> getModifiedEntities(java.util.Collection<Entity> entities)
entities
- the entitiesValueMap.isModified()
public static final java.util.Collection<ColumnProperty> getModifiedColumnProperties(Entity entity, Entity comparison, boolean includeReadOnlyProperties)
ColumnProperty
s which value is missing or the original value differs from the one in the comparison
entity, returns an empty Collection if all of entity
s original values match the values found in comparison
entity
- the entity instance to checkcomparison
- the entity instance to compare withincludeReadOnlyProperties
- if true then readOnly properties are included in the comparisonpublic static java.util.List<Entity.Key> getKeys(java.util.List<Entity> entities)
entities
- the entitiespublic static java.util.List<Entity.Key> getKeys(java.util.List<Entity> entities, boolean originalValue)
entities
- the entitiesoriginalValue
- if true then the original value of the primary key is returnedpublic static <T> java.util.List<T> getValues(java.util.List<Entity.Key> keys)
T
- the value typekeys
- the keyspublic static <T> java.util.List<T> getValues(java.lang.String propertyId, java.util.Collection<Entity> entities)
T
- the value typepropertyId
- the id of the property for which to retrieve the valuesentities
- the entities from which to retrieve the property valuepublic static <T> java.util.List<T> getValues(java.lang.String propertyId, java.util.Collection<Entity> entities, boolean includeNullValues)
T
- the value typepropertyId
- the id of the property for which to retrieve the valuesentities
- the entities from which to retrieve the property valueincludeNullValues
- if true then null values are includedpublic static <T> java.util.List<T> getDistinctValues(java.lang.String propertyId, java.util.Collection<Entity> entities)
propertyId
from the given entities, excluding null values.
If the entities
list is null an empty Collection is returned.T
- the value typepropertyId
- the id of the property for which to retrieve the valuesentities
- the entities from which to retrieve the valuespublic static <T> java.util.List<T> getDistinctValues(java.lang.String propertyId, java.util.Collection<Entity> entities, boolean includeNullValue)
propertyId
from the given entities.
If the entities
list is null an empty Collection is returned.T
- the value typepropertyId
- the id of the property for which to retrieve the valuesentities
- the entities from which to retrieve the valuesincludeNullValue
- if true then null is considered a valuepublic static java.util.Map<Entity.Key,java.lang.Object> put(java.lang.String propertyId, java.lang.Object value, java.util.Collection<Entity> entities)
propertyId
to value
in the given entitiespropertyId
- the id of the property for which to set the valuevalue
- the valueentities
- the entities for which to set the valuepublic static java.util.Map<Entity.Key,Entity> mapToKey(java.util.Collection<Entity> entities)
entities
- the entities to mappublic static <K> java.util.LinkedHashMap<K,java.util.List<Entity>> mapToValue(java.lang.String propertyId, java.util.Collection<Entity> entities)
propertyId
,
respecting the iteration order of the given collectionK
- the key typepropertyId
- the id of the property which value should be used for mappingentities
- the entities to map by property valuepublic static java.util.LinkedHashMap<java.lang.String,java.util.List<Entity>> mapToEntityId(java.util.Collection<Entity> entities)
entities
- the entities to map by entityIdpublic static java.util.LinkedHashMap<java.lang.String,java.util.List<Entity.Key>> mapKeysToEntityId(java.util.Collection<Entity.Key> keys)
keys
- the entity keys to map by entityIdpublic static java.util.Map<Entity.Key,Entity> mapToOriginalPrimaryKey(java.util.List<Entity> entitiesBeforeUpdate, java.util.List<Entity> entitiesAfterUpdate)
entitiesBeforeUpdate
- the entities before updateentitiesAfterUpdate
- the entities after updatepublic static java.lang.String[][] getStringValueArray(java.util.List<? extends Property> properties, java.util.List<Entity> entities)
properties
- the propertiesentities
- the entitiespublic static java.util.List<Entity> copyEntities(java.util.List<Entity> entities)
entities
- the entities to copypublic static java.util.List<Entity> getEntitiesByValue(java.util.Collection<Entity> entities, java.util.Map<java.lang.String,java.lang.Object> values)
entities
- the entities to searchvalues
- the property values to use as condition mapped to their respective propertyIdspublic static boolean equal(Entity entityOne, Entity entityTwo, java.lang.String... propertyIds)
entityOne
- the first entityentityTwo
- the second entitypropertyIds
- the ids of the properties to use