eu.beesoft.gaia.util
Class ValueObject

java.lang.Object
  extended by eu.beesoft.gaia.util.AbstractBean
      extended by eu.beesoft.gaia.util.ValueObject

public class ValueObject
extends AbstractBean

General value object that holds its values as properties in the internal map. This object has no getters / setters for individual properties, there is one getProperty(String) method and one setProperty(String, Object) method. The setProperty() method generates property change event (in parent class AbstractBean ).


Constructor Summary
ValueObject()
          Creates a new value object.
ValueObject(java.lang.Object source)
          Creates a new value object for given (data) source object.
 
Method Summary
static java.lang.Long createTemporaryId(java.lang.Object object)
          Creates a temporary ID for given object.
 boolean equals(java.lang.Object object)
          Overrides method from java.lang.Object
 java.lang.String getClassName()
          Gets the class name of the original data object.
 java.lang.Long getId()
          Returns the ID of this value object.
 java.util.Collection<java.lang.String> getNames()
          Returns the names of all properties stored in this value object.
 java.lang.Object getProperty(java.lang.String name)
          Gets property with given name or null if no such property exists.
 int hashCode()
          Overrides method from java.lang.Object
 boolean hasProperty(java.lang.String name)
          Checks if this value object holds property with given name.
static boolean isTemporaryId(java.lang.Long id)
          Checks if given long matches a temporary ID (see createTemporaryId(Object)).
 void setClassName(java.lang.String className)
          Sets the class name of the original data object.
 void setId(java.lang.Long id)
          Sets the ID of this value object.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets property with given name and value.
 
Methods inherited from class eu.beesoft.gaia.util.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueObject

public ValueObject()
Creates a new value object.


ValueObject

public ValueObject(java.lang.Object source)
Creates a new value object for given (data) source object. If the source is the instance of ValueObject, it takes class name and id from this value object. Otherwise it gets class name of the object and stores it inside. If object is instanceof Persistent, it gets an ID from it and stores it inside.

Parameters:
source - - (data) object for this value object
Method Detail

createTemporaryId

public static java.lang.Long createTemporaryId(java.lang.Object object)
Creates a temporary ID for given object. Returned ID is a long with lower bits equal to the object system identity hash code and the 16 high bits set to 1.

Parameters:
object - - object to compute temporary ID
Returns:
temporary ID for given object

isTemporaryId

public static boolean isTemporaryId(java.lang.Long id)
Checks if given long matches a temporary ID (see createTemporaryId(Object)).

Parameters:
id - - id to check
Returns:
true if given id matches a temporary ID

getId

public java.lang.Long getId()
Returns the ID of this value object.

Returns:
id of this value object

setId

public void setId(java.lang.Long id)
Sets the ID of this value object.

Parameters:
id - - id to set

getClassName

public java.lang.String getClassName()
Gets the class name of the original data object.

Returns:
className of the data object

setClassName

public void setClassName(java.lang.String className)
Sets the class name of the original data object.

Parameters:
className - - class name to set

getNames

public java.util.Collection<java.lang.String> getNames()
Returns the names of all properties stored in this value object.

Returns:
names of all properties

hasProperty

public boolean hasProperty(java.lang.String name)
Checks if this value object holds property with given name.

Parameters:
name - - name of the property
Returns:
true if value object has property with given name

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Sets property with given name and value. Property change event is generated.

Parameters:
name - - name of the property
value - - value of the property

getProperty

public java.lang.Object getProperty(java.lang.String name)
Gets property with given name or null if no such property exists.

Parameters:
name - - name of the property
Returns:
value of the property

hashCode

public int hashCode()
Overrides method from java.lang.Object

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides method from java.lang.Object

Overrides:
equals in class java.lang.Object