Class Entity
- java.lang.Object
- 
- de.aristaflow.adept2.model.orgmodel.Entity
 
- 
- All Implemented Interfaces:
- TypedCloneable<Entity>,- Serializable,- Cloneable,- Map<String,Object>
 - Direct Known Subclasses:
- OmeEntity
 
 public class Entity extends Object implements Serializable, TypedCloneable<Entity>, Map<String,Object> This class represents an entity, i.e. instance of an entity type like Agent, OrgPosition etc.. However, anEntity-object doesn't necessarily have to contain all attributes that are defined for an entity type. In future, there might be methods that allow the caller to specify which attributes are needed.All attribute names are case insensitive, still the original case should be preserved. getAttributeNames()should reflect the insertion order of the attributes.This class not only defines methods to read but also to add and set attributes. These, however, will not be propagated to the data source! When setting values it will NOT be ensured, that they have the correct data type or any known or supported data type at all. This is simply a container class! - See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description Entity(EntityType entityType)Constructs a newDefaultEntitywith the given entity type.Entity(EntityType entityType, int attributeCount)Constructs a newDefaultEntitywith the given entity type.Entity(EntityType entityType, long id)Constructs a newDefaultEntitywith the given entity type and ID.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Entityclone()Clones this object (usually viaObject.clone()).booleancontainsAttribute(String attrName)Returns whether an attribute with the given name is contained in thisEntity-object.booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,Object>>entrySet()booleanequals(Object obj)This implementation recognises twoEntitys as equal if their ID attributes match.Objectget(Object key)Objectget(String attrName)Returns the value object for the given attribute name.intgetAttributeCount()Returns the number of attributes stored in thisEntity-object.String[]getAttributeNames()Returns the names of the attributes that are contained in thisEntity-object.DategetDate(String attrName)This method will return the attribute value asDateornull.doublegetFloat(String attrName)This method will return the attribute value as float or 0 if it isnull.longgetInteger(String attrName)This method will return the attribute value as an int or 0 if it isnull.StringgetString(String attrName)This method will return the attribute value asStringornull.EntityTypegetType()Returns the type of this entity.inthashCode()booleanhasIdAttr()Gets whether this entity has an ID attribute of integer type (Long) (notnull).booleanisEmpty()booleanisNull(String attrName)Returns whether the specified attribute is null (not set) for this entity.Set<String>keySet()Objectput(String key, Object value)voidputAll(Map<? extends String,?> m)Objectremove(Object key)voidremoveAttribute(String attrName)Removes the given attribute from this entity.booleanset(String attrName, Object value)Sets the given attribute to the given value.voidsetDate(String attrName, Date value)Sets the given attribute to the given value.voidsetFloat(String attrName, double value)Sets the given attribute to the given value.voidsetInteger(String attrName, long value)Sets the given attribute to the given value.voidsetNull(String attrName)Sets the given attribute to the given value.voidsetString(String attrName, String value)Sets the given attribute to the given value.intsize()StringtoString()Collection<Object>values()- 
Methods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
 
- 
 
- 
- 
- 
Constructor Detail- 
Entitypublic Entity(EntityType entityType) Constructs a newDefaultEntitywith the given entity type.- Parameters:
- entityType- the type of the entity
 
 - 
Entitypublic Entity(EntityType entityType, long id) Constructs a newDefaultEntitywith the given entity type and ID.- Parameters:
- entityType- the type of the entity
- id- the initial ID of this entity object
 
 - 
Entitypublic Entity(EntityType entityType, int attributeCount) Constructs a newDefaultEntitywith the given entity type. TheArrayListis initialised for the given number of attributes.- Parameters:
- entityType- the type of the entity
- attributeCount- the number of attributes this entity will hold
 
 
- 
 - 
Method Detail- 
getTypepublic EntityType getType() Returns the type of this entity.- Returns:
- the type of this entity
 
 - 
getAttributeCountpublic int getAttributeCount() Returns the number of attributes stored in thisEntity-object.- Returns:
- the number of attributes stored in this Entity-object
 
 - 
getAttributeNamespublic String[] getAttributeNames() Returns the names of the attributes that are contained in thisEntity-object.- Returns:
- a string array containing the names of the attributes that are
         contained in this Entity-object
 
 - 
containsAttributepublic boolean containsAttribute(String attrName) Returns whether an attribute with the given name is contained in thisEntity-object.- Parameters:
- attrName- the attribute name to be checked
- Returns:
- whether an attribute with the given name is contained in this
         Entity-object
 
 - 
isNullpublic boolean isNull(String attrName) throws IllegalArgumentException Returns whether the specified attribute is null (not set) for this entity.- Parameters:
- attrName- the attribute name to be checked
- Returns:
- whether the specified attribute is null (not set) for this entity
- Throws:
- IllegalArgumentException- if the- Entity-object doesn't contain an attribute with this name
 
 - 
removeAttributepublic void removeAttribute(String attrName) Removes the given attribute from this entity.- Parameters:
- attrName- the attribute to be removed from this entity
 
 - 
hasIdAttrpublic boolean hasIdAttr() Gets whether this entity has an ID attribute of integer type (Long) (notnull).- Returns:
- Whether this entity has an ID attribute of integer type (Long) (notnull).
 
 - 
getpublic Object get(String attrName) throws IllegalArgumentException Returns the value object for the given attribute name.- Parameters:
- attrName- the attribute name for which the value object should be returned
- Returns:
- the value object for the given attribute name
- Throws:
- IllegalArgumentException- if the- Entity-object doesn't contain an attribute with this name
 
 - 
getIntegerpublic long getInteger(String attrName) throws IllegalArgumentException This method will return the attribute value as an int or 0 if it isnull. Please make sure that the attribute really is an int. You will receive aClassCastExceptionif it isn't!- Parameters:
- attrName- the attribute whose value should be returned as an int
- Returns:
- the attribute as an int; or 0 if it is null
- Throws:
- IllegalArgumentException- if the- Entity-object doesn't contain an attribute with this name
 
 - 
getFloatpublic double getFloat(String attrName) throws IllegalArgumentException This method will return the attribute value as float or 0 if it isnull. Please make sure that the attribute really is a float. You will receive aClassCastExceptionif it isn't!- Parameters:
- attrName- the attribute whose value should be returned as float
- Returns:
- the attribute as float; or 0 if it is null
- Throws:
- IllegalArgumentException- if the- Entity-object doesn't contain an attribute with this name
 
 - 
getStringpublic String getString(String attrName) throws IllegalArgumentException This method will return the attribute value asStringornull. Please make sure that the attribute really is a string. You will receive aClassCastExceptionif it isn't! If you need the attribute in string representation regardless of the actual type,get(..).toString()could be used instead.- Parameters:
- attrName- the attribute whose value should be returned as- String
- Returns:
- the attribute as string; or null
- Throws:
- IllegalArgumentException- if the- Entity-object doesn't contain an attribute with this name
 
 - 
getDatepublic Date getDate(String attrName) throws IllegalArgumentException This method will return the attribute value asDateornull. Please make sure that the attribute really is a date. You will receive aClassCastExceptionif it isn't!- Parameters:
- attrName- the attribute whose value should be returned as- Date
- Returns:
- the attribute as string; or null
- Throws:
- IllegalArgumentException- if the- Entity-object doesn't contain an attribute with this name
 
 - 
setpublic boolean set(String attrName, Object value) Sets the given attribute to the given value. The attribute is added if it's not already contained in this entity-object.- Parameters:
- attrName- the attribute to be set (and added if needed)
- value- the value of the attribute
- Returns:
- Whether the designated attribute was new and therefore changed the attribute list of this entity.
 
 - 
setNullpublic void setNull(String attrName) Sets the given attribute to the given value. The attribute is added if it's not already contained in this entity-object.- Parameters:
- attrName- the attribute to be set (and added if needed)
 
 - 
setIntegerpublic void setInteger(String attrName, long value) Sets the given attribute to the given value. The attribute is added if it's not already contained in this entity-object.- Parameters:
- attrName- the attribute to be set (and added if needed)
- value- the value of the attribute
 
 - 
setFloatpublic void setFloat(String attrName, double value) Sets the given attribute to the given value. The attribute is added if it's not already contained in this entity-object.- Parameters:
- attrName- the attribute to be set (and added if needed)
- value- the value of the attribute
 
 - 
setStringpublic void setString(String attrName, String value) Sets the given attribute to the given value. The attribute is added if it's not already contained in this entity-object.- Parameters:
- attrName- the attribute to be set (and added if needed)
- value- the value of the attribute
 
 - 
setDatepublic void setDate(String attrName, Date value) Sets the given attribute to the given value. The attribute is added if it's not already contained in this entity-object.- Parameters:
- attrName- the attribute to be set (and added if needed)
- value- the value of the attribute
 
 - 
equalspublic boolean equals(Object obj) This implementation recognises twoEntitys as equal if their ID attributes match. If either one of them does not have an ID this method returns false.
 - 
hashCodepublic int hashCode() 
 - 
clonepublic Entity clone() Description copied from interface:TypedCloneableClones this object (usually viaObject.clone()).- Specified by:
- clonein interface- TypedCloneable<Entity>
- Overrides:
- clonein class- Object
- Returns:
- A clone of the implementing object.
 
 - 
containsKeypublic boolean containsKey(Object key) - Specified by:
- containsKeyin interface- Map<String,Object>
 
 - 
containsValuepublic boolean containsValue(Object value) - Specified by:
- containsValuein interface- Map<String,Object>
 
 
- 
 
-