org.planx.msd.lang
Class Reference<T>

java.lang.Object
  extended by org.planx.msd.lang.Reference<T>
All Implemented Interfaces:
EquivalenceClassDiscriminable

public class Reference<T>
extends Object
implements EquivalenceClassDiscriminable

Represents a discriminable reference to an object.

Author:
Thomas Ambus

Constructor Summary
Reference(T obj)
          Creates a new discriminable reference belonging to its own EquivalenceClass.
Reference(T obj, EquivalenceClass eqCls)
          Creates a new discriminable reference belonging to the specified EquivalenceClass.
 
Method Summary
 boolean equals(Object o)
          Returns true if and only if the specified object is also an EquivalenceClassDiscriminable and that EquivalenceClassDiscriminable points to the same EquivalenceClass object as this Reference.
 T get()
          Returns the Object pointed to by this Reference.
 EquivalenceClass getEquivalenceClass()
          Returns the EquivalenceClass that this object belongs to.
 int hashCode()
          Returns the result of invoking hashCode on the EquivalenceClass of this Reference.
 void setEquivalenceClass(EquivalenceClass eqCls)
          Changes the EquivalenceClass of this object to the specified EquivalenceClass (optional operation).
 String toString()
          Returns the result of invoking the toString method on the object pointed to by this Reference.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Reference

public Reference(T obj)
Creates a new discriminable reference belonging to its own EquivalenceClass. Other references can later by added to this EquivalenceClass by using the Reference(Object, EquivalenceClass) constructor and getting this reference's EquivalenceClass using the getEquivalenceClass method.


Reference

public Reference(T obj,
                 EquivalenceClass eqCls)
Creates a new discriminable reference belonging to the specified EquivalenceClass. If eqCls is null a new EquivalenceClass will be created and this Reference will be the only member. Other references can later be added to this EquivalenceClass.

Method Detail

get

public T get()
Returns the Object pointed to by this Reference.


getEquivalenceClass

public EquivalenceClass getEquivalenceClass()
Description copied from interface: EquivalenceClassDiscriminable
Returns the EquivalenceClass that this object belongs to.

Specified by:
getEquivalenceClass in interface EquivalenceClassDiscriminable

setEquivalenceClass

public void setEquivalenceClass(EquivalenceClass eqCls)
Description copied from interface: EquivalenceClassDiscriminable
Changes the EquivalenceClass of this object to the specified EquivalenceClass (optional operation). If this operation is not supported an UnsupportedOperationException will be thrown.

Specified by:
setEquivalenceClass in interface EquivalenceClassDiscriminable

equals

public boolean equals(Object o)
Returns true if and only if the specified object is also an EquivalenceClassDiscriminable and that EquivalenceClassDiscriminable points to the same EquivalenceClass object as this Reference.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the result of invoking hashCode on the EquivalenceClass of this Reference. The reason for this is that if two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.

Overrides:
hashCode in class Object

toString

public String toString()
Returns the result of invoking the toString method on the object pointed to by this Reference.

Overrides:
toString in class Object


Copyright © 2010. All Rights Reserved.