|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jminor.framework.domain.EntityUtil
public final class EntityUtil
A static utility class containing helper methods for working with Entity instances.
Method Summary | |
---|---|
static List<Entity> |
copyEntities(List<Entity> entities)
|
static Entity |
createEntity(String entityID,
ValueProvider<Property,Object> valueProvider)
|
static Entity |
createRandomEntity(String entityID,
Map<String,Entity> referenceEntities)
|
static Collection<Object> |
getDistinctPropertyValues(String propertyID,
List<Entity> entities)
Returns a Collection containing the distinct values of propertyID from the given entities. |
static Deserializer<Entity> |
getEntityDeserializer()
|
static Serializer<Entity> |
getEntitySerializer()
|
static List<Entity> |
getModifiedEntities(Collection<Entity> entities)
|
static List<Entity.Key> |
getPrimaryKeys(Collection<Entity> entities)
|
static List<Entity.Key> |
getPrimaryKeys(Collection<Entity> entities,
boolean originalValue)
|
static List<Property> |
getProperties(String entityID,
Collection<String> propertyIDs)
|
static List<Object> |
getPropertyValues(List<Entity.Key> keys)
Retrieves the values of the given keys, assuming they are single column keys. |
static List<Object> |
getPropertyValues(Property property,
List<Entity> entities)
|
static List<Object> |
getPropertyValues(Property property,
List<Entity> entities,
boolean includeNullValues)
|
static List<Object> |
getPropertyValues(String propertyID,
List<Entity> entities)
|
static List<Object> |
getPropertyValues(String propertyID,
List<Entity> entities,
boolean includeNullValues)
|
static Object |
getRandomValue(Property property,
Map<String,Entity> referenceEntities)
|
static List<Property> |
getSortedProperties(String entityID,
Collection<String> propertyIDs)
|
static List<Property> |
getUpdatableProperties(String entityID)
|
static Map<String,Collection<Entity>> |
hashByEntityID(Collection<Entity> entities)
Returns a Map containing the given entities hashed by their entityIDs |
static Map<Entity.Key,Entity> |
hashByPrimaryKey(List<Entity> entities)
Hashes the given entities by their primary key |
static Map<Object,Collection<Entity>> |
hashByPropertyValue(String propertyID,
Collection<Entity> entities)
Returns a Map containing the given entities hashed by the value of the property with ID propertyID |
static Map<String,Collection<Entity.Key>> |
hashKeysByEntityID(Collection<Entity.Key> keys)
Returns a Map containing the given entity keys hashed by their entityIDs |
static boolean |
isPrimaryKeyModified(Collection<Entity> entities)
|
static Entity |
randomize(Entity entity,
boolean includePrimaryKey,
Map<String,Entity> referenceEntities)
|
static Map<Entity.Key,Object> |
setPropertyValue(String propertyID,
Object value,
Collection<Entity> entities)
Sets the value of the property with ID propertyID to value
in the given entities |
static void |
sort(List<? extends Property> properties)
Sorts the given properties by caption, or if that is not available, property ID |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static List<Entity> getModifiedEntities(Collection<Entity> entities)
entities
- the entities
public static Map<Entity.Key,Entity> hashByPrimaryKey(List<Entity> entities)
entities
- the entities to hash
public static List<Entity.Key> getPrimaryKeys(Collection<Entity> entities)
entities
- the entities
public static List<Entity.Key> getPrimaryKeys(Collection<Entity> entities, boolean originalValue)
entities
- the entitiesoriginalValue
- if true then the original value of the primary key is used
public static List<Object> getPropertyValues(List<Entity.Key> keys)
keys
- the keys
public static List<Object> getPropertyValues(String propertyID, List<Entity> entities)
propertyID
- the ID of the property for which to retrieve the valuesentities
- the entities from which to retrieve the property value
public static List<Object> getPropertyValues(String propertyID, List<Entity> entities, boolean includeNullValues)
propertyID
- 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 included
public static List<Object> getPropertyValues(Property property, List<Entity> entities)
property
- the the property for which to retrieve the valuesentities
- the entities from which to retrieve the property value
public static List<Object> getPropertyValues(Property property, List<Entity> entities, boolean includeNullValues)
property
- the the property for which to retrieve the valuesentities
- the entities from which to retrieve the property valueincludeNullValues
- if true then null values are included
public static Collection<Object> getDistinctPropertyValues(String propertyID, List<Entity> entities)
propertyID
from the given entities.
If the entities
list is null an empty Collection is returned.
propertyID
- the ID of the property for which to retrieve the valuesentities
- the entities from which to retrieve the values
public static Map<Entity.Key,Object> setPropertyValue(String propertyID, Object value, Collection<Entity> entities)
propertyID
to value
in the given entities
propertyID
- the ID of the property for which to set the valuevalue
- the valueentities
- the entities for which to set the value
public static Map<Object,Collection<Entity>> hashByPropertyValue(String propertyID, Collection<Entity> entities)
propertyID
propertyID
- the ID of the property which value should be used for mappingentities
- the entities to map by property value
public static Map<String,Collection<Entity>> hashByEntityID(Collection<Entity> entities)
entities
- the entities to map by entityID
public static Map<String,Collection<Entity.Key>> hashKeysByEntityID(Collection<Entity.Key> keys)
keys
- the entity keys to map by entityID
public static List<Property> getProperties(String entityID, Collection<String> propertyIDs)
entityID
- the entity IDpropertyIDs
- the property IDs
public static List<Property> getSortedProperties(String entityID, Collection<String> propertyIDs)
entityID
- the entity IDpropertyIDs
- the property IDs
public static void sort(List<? extends Property> properties)
properties
- the properties to sortpublic static List<Property> getUpdatableProperties(String entityID)
entityID
- the entity ID
public static List<Entity> copyEntities(List<Entity> entities)
entities
- the entities to copy
public static Entity createRandomEntity(String entityID, Map<String,Entity> referenceEntities)
entityID
- the entity IDreferenceEntities
- entities referenced by the given entity ID
public static Entity createEntity(String entityID, ValueProvider<Property,Object> valueProvider)
entityID
- the entity IDvalueProvider
- the value provider
public static Entity randomize(Entity entity, boolean includePrimaryKey, Map<String,Entity> referenceEntities)
entity
- the entity to randomizeincludePrimaryKey
- if true then the primary key values are includereferenceEntities
- entities referenced by the given entity
public static Object getRandomValue(Property property, Map<String,Entity> referenceEntities)
property
- the propertyreferenceEntities
- entities referenced by the given property
public static Serializer<Entity> getEntitySerializer()
public static Deserializer<Entity> getEntityDeserializer()
public static boolean isPrimaryKeyModified(Collection<Entity> entities)
entities
- the entities to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |