org.ckkloverdos.tuple
Class Pair

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

public class Pair
extends TupleSkeleton
implements IPair

Implements IPair.

Author:
Christos KK Loverdos

Field Summary
protected  java.lang.Object a
           
protected  java.lang.Object b
           
 
Constructor Summary
Pair(java.lang.Object a, java.lang.Object b)
          Contsructs the pair from the two objects.
 
Method Summary
 java.lang.Object get(int n)
          Returns the nth element of the tuple.
 java.lang.Object getA()
          Returns the first element.
 java.lang.Object getB()
          Returns the second element.
 boolean isEmpty()
          Always returns false, since a pair contains exactly two elements, even if they are null.
 boolean isNull(int n)
          Returns true iff the nth element of the tuple is null.
 int size()
          Returns the size of the pair, which is always two.
 
Methods inherited from class org.ckkloverdos.tuple.TupleSkeleton
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

protected java.lang.Object a

b

protected java.lang.Object b
Constructor Detail

Pair

public Pair(java.lang.Object a,
            java.lang.Object b)
Contsructs the pair from the two objects.

Parameters:
a -
b -
Method Detail

getA

public java.lang.Object getA()
Returns the first element. This is equivalent to get(0).

Specified by:
getA in interface IPair

getB

public java.lang.Object getB()
Returns the second element. This is equivalent to get(1).

Specified by:
getB in interface IPair

get

public java.lang.Object get(int n)
Returns the nth element of the tuple. The first element is at index zero, the second element is at index one.

Specified by:
get in interface ITuple
Parameters:
n -
Throws:
java.lang.IndexOutOfBoundsException - if the index n is other than zero or one.

size

public int size()
Returns the size of the pair, which is always two.

Specified by:
size in interface ITuple

isNull

public boolean isNull(int n)
Returns true iff the nth element of the tuple is null. The first element is at index zero, the second element is at index one.

Specified by:
isNull in interface ITuple
Parameters:
n -
Throws:
java.lang.IndexOutOfBoundsException - if the index n is other than zero or one.

isEmpty

public boolean isEmpty()
Always returns false, since a pair contains exactly two elements, even if they are null.

Specified by:
isEmpty in interface ITuple


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