org.fuin.utils4j
Class Property

java.lang.Object
  extended by org.fuin.utils4j.Property
All Implemented Interfaces:
java.lang.Comparable

public class Property
extends java.lang.Object
implements java.lang.Comparable

A key value pair that maintains an additional change state. The state contains the information if the value has been changed since construction of the instance. The methods hashCode() and equals(Object) are based on the key attribute. The attributes key and initialValue are immutable.


Constructor Summary
Property(java.lang.String key, java.lang.String initialValue, java.lang.String value)
          Constructor with all values.
 
Method Summary
 int compareTo(java.lang.Object o)
          
 boolean equals(java.lang.Object obj)
          
 java.lang.String getInitialValue()
          Returns the initial value of the property.
 java.lang.String getKey()
          Returns the key of the property.
 java.lang.String getStatus()
          Returns a 3-code status text.
 java.lang.String getValue()
          Returns the current value of the property.
 boolean hasChanged()
          Returns if the value has changed since construction.
 int hashCode()
          
 boolean isDeleted()
          Returns if the value has been deleted since construction.
 boolean isNew()
          Returns if the value has been created since construction.
 void setValue(java.lang.String value)
          Sets the current value of the property.
 java.lang.String toKeyValue()
          Returns the key and value separated by an equal sign.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Property

public Property(java.lang.String key,
                java.lang.String initialValue,
                java.lang.String value)
Constructor with all values.

Parameters:
key - Unique name - Cannot be null.
initialValue - Initial value.
value - Value.
Method Detail

getValue

public final java.lang.String getValue()
Returns the current value of the property.

Returns:
Actual value.

setValue

public final void setValue(java.lang.String value)
Sets the current value of the property.

Parameters:
value - Value to set.

getInitialValue

public final java.lang.String getInitialValue()
Returns the initial value of the property.

Returns:
Value at construction time.

getKey

public final java.lang.String getKey()
Returns the key of the property.

Returns:
Unique name.

hasChanged

public final boolean hasChanged()
Returns if the value has changed since construction.

Returns:
If the value has changed true else false.

isDeleted

public final boolean isDeleted()
Returns if the value has been deleted since construction.

Returns:
If the value has been set to null true else false.

isNew

public final boolean isNew()
Returns if the value has been created since construction.

Returns:
If the property has been set to a non-null value true else false.

hashCode

public final int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public final boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

compareTo

public final int compareTo(java.lang.Object o)

Specified by:
compareTo in interface java.lang.Comparable

toKeyValue

public final java.lang.String toKeyValue()
Returns the key and value separated by an equal sign.

Returns:
A text like "key=value".

getStatus

public final java.lang.String getStatus()
Returns a 3-code status text.

Returns:
"NEW" (new), "DEL" (deleted), "CHG" (changed) or "---" (unchanged).

toString

public final java.lang.String toString()

Overrides:
toString in class java.lang.Object


Copyright © 2009 Future Invent Informationsmanagement GmbH. All Rights Reserved.