tip.util
Class EqualityElement<T>

java.lang.Object
  extended by tip.util.EqualityElement<T>
Type Parameters:
T - the element type

public class EqualityElement<T>
extends Object

EqualityElement encapsulates elements of type T with an Equalitor of the same type. The class is used with EqualitySet and EqualityMap.

Author:
Johnni Winther, jw@brics.dk

Constructor Summary
EqualityElement(T element, Equalitor<T> equalitor)
          Creates a new EqualityElement encapsulating element with the Equalitor equalitor.
 
Method Summary
 boolean equals(EqualityElement<T> element)
          Returns {link Equalitor.equals(Object, Object) from the equalitor on the encapsulated element and element.
 boolean equals(Object o)
          Returns false if o is not an EqualityElement, otherwise equals(EqualityElement).
 T getElement()
          Returns the encapsulated element.
 Equalitor<T> getEqualitor()
          Returns the equalitor for the element.
 int hashCode()
          Returns the hashcode from equalitor on the encapsulated element.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EqualityElement

public EqualityElement(T element,
                       Equalitor<T> equalitor)
Creates a new EqualityElement encapsulating element with the Equalitor equalitor.

Parameters:
element - the encapsulated element
equalitor - the equalitor for the element
Method Detail

getElement

public T getElement()
Returns the encapsulated element.

Returns:
the encapsulated element

getEqualitor

public Equalitor<T> getEqualitor()
Returns the equalitor for the element.

Returns:
the equalitor for the element

equals

public boolean equals(Object o)
Returns false if o is not an EqualityElement, otherwise equals(EqualityElement).

Overrides:
equals in class Object
Returns:
true if o an equal EqualityElement

equals

public boolean equals(EqualityElement<T> element)
Returns {link Equalitor.equals(Object, Object) from the equalitor on the encapsulated element and element.

Parameters:
element - the compared element
Returns:
equals according to the equalitor

hashCode

public int hashCode()
Returns the hashcode from equalitor on the encapsulated element.

Overrides:
hashCode in class Object
Returns:
the hashcode from equalitor on the encapsulated element