org.jminor.framework.domain
Interface Entity

All Superinterfaces:
Comparable<Entity>, ValueAsStringProvider<String>, ValueChangeMap<String,Object>, ValueCollectionProvider<Object>, ValueMap<String,Object>, ValueProvider<String,Object>

public interface Entity
extends ValueChangeMap<String,Object>, Comparable<Entity>

An ORM entity interface, providing access to the property values via the ValueMap interface.


Nested Class Summary
static interface Entity.BackgroundColorProvider
          Provides background colors for entities.
static interface Entity.Comparator
          Provides comparisons for entities.
static interface Entity.Definition
          Specifies a entity definition.
static interface Entity.Key
          A class representing a primary key.
static interface Entity.Validator
          Responsible for providing validation for entities.
 
Nested classes/interfaces inherited from interface org.jminor.common.model.valuemap.ValueMap
ValueMap.ToString<K>
 
Method Summary
 boolean containsValue(Property property)
           
 Color getBackgroundColor(Property property)
           
 Boolean getBooleanValue(String propertyID)
           
 Character getCharValue(String propertyID)
           
 Date getDateValue(String propertyID)
           
 Double getDoubleValue(String propertyID)
           
 String getEntityID()
           
 Entity getForeignKeyValue(String foreignKeyPropertyID)
           
 String getFormattedValue(Property property)
           
 String getFormattedValue(Property property, Format format)
           
 String getFormattedValue(String propertyID)
           
 String getFormattedValue(String propertyID, Format format)
           
 Integer getIntValue(String propertyID)
           
 Entity.Key getOriginalPrimaryKey()
           
 Entity.Key getPrimaryKey()
           
 Property getProperty(String propertyID)
          Retrieves the property identified by propertyID from the entity repository
 Entity.Key getReferencedPrimaryKey(Property.ForeignKeyProperty foreignKeyProperty)
          Returns the primary key of the entity referenced by the given ForeignKeyProperty, if the reference is null this method returns null.
 String getStringValue(String propertyID)
           
 Timestamp getTimestampValue(String propertyID)
           
 Object getValue(Property property)
           
 String getValueAsString(Property property)
          This method returns a String representation of the value associated with the given property, if the property has a format it is used.
 void initializeValue(Property property, Object value)
          Initializes the given value assuming it has no previously set value.
 boolean is(String entityID)
           
 boolean isForeignKeyNull(Property.ForeignKeyProperty foreignKeyProperty)
          Returns true if the value of the given foreign key is null, in case of composite foreign keys a single null value is enough.
 boolean isLoaded(String foreignKeyPropertyID)
          Returns true if the entity referenced via the given foreign key property has been loaded
 boolean isPrimaryKeyNull()
           
 boolean isValueNull(Property property)
           
 boolean propertyValuesEqual(Entity entity)
           
 Object setValue(Property property, Object value)
          Sets the value of the given property
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueChangeMap
addValueListener, getCopy, getInstance, getModifiedState, getOriginalCopy, getOriginalValue, getOriginalValueKeys, getValueChangeObserver, initializeValue, isModified, isModified, removeValueListener, revertAll, revertValue, saveAll, saveValue, setAs
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueMap
clear, containsValue, copyValue, getValueKeys, getValues, isValueNull, removeValue, setValue, size
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueProvider
getValue
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueAsStringProvider
getValueAsString
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getEntityID

String getEntityID()
Returns:
the entity ID

getPrimaryKey

Entity.Key getPrimaryKey()
Returns:
the primary key of this entity

getOriginalPrimaryKey

Entity.Key getOriginalPrimaryKey()
Returns:
the primary key of this entity in it's original state

getProperty

Property getProperty(String propertyID)
Retrieves the property identified by propertyID from the entity repository

Parameters:
propertyID - the ID of the property to retrieve
Returns:
the property identified by propertyID

getValue

Object getValue(Property property)
Parameters:
property - the property for which to retrieve the value
Returns:
the value of the given property

getStringValue

String getStringValue(String propertyID)
Parameters:
propertyID - the ID of the property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is a String
Throws:
ClassCastException - if the value is not a String instance

getIntValue

Integer getIntValue(String propertyID)
Parameters:
propertyID - the ID of the property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is an Integer
Throws:
ClassCastException - if the value is not a Integer instance

getCharValue

Character getCharValue(String propertyID)
Parameters:
propertyID - the ID of the property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is a Character
Throws:
ClassCastException - if the value is not a Character instance

getDoubleValue

Double getDoubleValue(String propertyID)
Parameters:
propertyID - the ID of the property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is a Double
Throws:
ClassCastException - if the value is not a Double instance

getDateValue

Date getDateValue(String propertyID)
Parameters:
propertyID - the ID of the date property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is a Date
Throws:
ClassCastException - if the value is not a Date instance

getTimestampValue

Timestamp getTimestampValue(String propertyID)
Parameters:
propertyID - the ID of the date property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is a Timestamp
Throws:
ClassCastException - if the value is not a Timestamp instance

getBooleanValue

Boolean getBooleanValue(String propertyID)
Parameters:
propertyID - the ID of the property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is a Boolean
Throws:
ClassCastException - if the value is not a Boolean instance

getFormattedValue

String getFormattedValue(String propertyID)
Parameters:
propertyID - the ID of the property for which to retrieve the formatted value
Returns:
the value of the property identified by propertyID, formatting it with the format object associated with the property

getFormattedValue

String getFormattedValue(String propertyID,
                         Format format)
Parameters:
propertyID - the ID of the property for which to retrieve the formatted value
format - the format object
Returns:
the value of the property identified by propertyID, formatted with format

getFormattedValue

String getFormattedValue(Property property)
Parameters:
property - the property for which to retrieve the formatted value
Returns:
the value of the given property formatted with the format object associated with the property

getFormattedValue

String getFormattedValue(Property property,
                         Format format)
Parameters:
property - the property for which to retrieve the formatted value
format - the format object
Returns:
the value of the given property, formatted with format

getValueAsString

String getValueAsString(Property property)
This method returns a String representation of the value associated with the given property, if the property has a format it is used.

Parameters:
property - the property for which to retrieve the value
Returns:
a String representation of the value of property
See Also:
getFormattedValue(Property, java.text.Format)

getForeignKeyValue

Entity getForeignKeyValue(String foreignKeyPropertyID)
Parameters:
foreignKeyPropertyID - the ID of the property for which to retrieve the value
Returns:
the value of the property identified by propertyID, assuming it is an Entity
Throws:
RuntimeException - if the property is not a foreign key property

getReferencedPrimaryKey

Entity.Key getReferencedPrimaryKey(Property.ForeignKeyProperty foreignKeyProperty)
Returns the primary key of the entity referenced by the given ForeignKeyProperty, if the reference is null this method returns null.

Parameters:
foreignKeyProperty - the foreign key property for which to retrieve the underlying EntityKey
Returns:
the primary key of the underlying entity, null if no entity is referenced

isForeignKeyNull

boolean isForeignKeyNull(Property.ForeignKeyProperty foreignKeyProperty)
Returns true if the value of the given foreign key is null, in case of composite foreign keys a single null value is enough.

Parameters:
foreignKeyProperty - the foreign key property
Returns:
true if the foreign key value is null

setValue

Object setValue(Property property,
                Object value)
Sets the value of the given property

Parameters:
property - the property
value - the value
Returns:
the previous value

isPrimaryKeyNull

boolean isPrimaryKeyNull()
Returns:
true if the this entity instance has a null primary key

isValueNull

boolean isValueNull(Property property)
Parameters:
property - the property
Returns:
true if the given property has a null value

containsValue

boolean containsValue(Property property)
Parameters:
property - the property
Returns:
true if this entity contains a value for the given property

initializeValue

void initializeValue(Property property,
                     Object value)
Initializes the given value assuming it has no previously set value. This method does not propagate foreign key values nor set denormalized values. This method should be used with care, if at all.

Parameters:
property - the property for which to initialize the value
value - the value

is

boolean is(String entityID)
Parameters:
entityID - the entityID
Returns:
true if this entity is of the given type

propertyValuesEqual

boolean propertyValuesEqual(Entity entity)
Parameters:
entity - the entity to compare to
Returns:
true if all property values are equal

isLoaded

boolean isLoaded(String foreignKeyPropertyID)
Returns true if the entity referenced via the given foreign key property has been loaded

Parameters:
foreignKeyPropertyID - the property id
Returns:
true if the reference entity has been loaded

getBackgroundColor

Color getBackgroundColor(Property property)
Parameters:
property - the property for which to retrieve the background color
Returns:
the background color to use when displaying this property in a table