org.ckkloverdos.tuple
Class TupleSkeleton

java.lang.Object
  extended by org.ckkloverdos.tuple.TupleSkeleton
All Implemented Interfaces:
ITuple
Direct Known Subclasses:
ListTuple, Pair

public abstract class TupleSkeleton
extends java.lang.Object
implements ITuple

An abstract class implementing equals(Object) and hashCode(). A tuple implementation should override TupleSkeleton, so that these two methods have consistent behaviour.

Author:
Christos KK Loverdos

Constructor Summary
TupleSkeleton()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares for equality.
 int hashCode()
          Returns the hash code value for this tuple.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ckkloverdos.tuple.ITuple
get, isEmpty, isNull, size
 

Constructor Detail

TupleSkeleton

public TupleSkeleton()
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares for equality. This tuple is equal to obj iff the following conditions simultaneously hold:
  1. obj is also a ITuple.
  2. the size of the two tuples is the same.
  3. the elements of the two tuples are equal, compared one by one.
Two empty tuples are always equal. The underlying implementation of the tuples doesnot matter.

Overrides:
equals in class java.lang.Object
Parameters:
obj -

hashCode

public int hashCode()
Returns the hash code value for this tuple. An empty tuple always has a hash code zero. The computed value depends on the tuple elements and not on the tuple implementation.

Overrides:
hashCode in class java.lang.Object


Copyright © 1999-2007 Christos KK Loverdos. All Rights Reserved.