net.sf.staccatocommons.lang.tuple
Class Pair<A,B>

java.lang.Object
  extended by net.sf.staccatocommons.lang.tuple.AbstractTuple
      extended by net.sf.staccatocommons.lang.tuple.Pair<A,B>
Type Parameters:
A - first component type
B - second component type
All Implemented Interfaces:
Serializable, Comparable<Tuple2<A,B>>, Map.Entry<A,B>, FirstAware<A>, SecondAware<B>, ToListAware<Object>, Tuple2<A,B>

@Value
@Conditionally(value={net.sf.staccatocommons.restrictions.value.Immutable.class,java.io.Serializable.class})
public final class Pair<A,B>
extends AbstractTuple
implements Tuple2<A,B>

Two-components AbstractTuple

Author:
flbulgarelli
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.staccatocommons.lang.tuple.AbstractTuple
AbstractTuple.TupleState<A>
 
Constructor Summary
Pair(A fist, B second)
          Creates a new pair.
 
Method Summary
 A _0()
           
 B _1()
           
 int compareTo(Tuple2<A,B> other)
           
 boolean equals(Object obj)
           
 A first()
           
 A getKey()
           
 B getValue()
           
 int hashCode()
           
 B second()
           
 B setValue(B arg0)
           
 Pair<B,A> swap()
          Creates a new tuple, with swaped components
 Object[] toArray()
          Converts this tuple into an array
 String toString()
           
 
Methods inherited from class net.sf.staccatocommons.lang.tuple.AbstractTuple
toList
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.staccatocommons.defs.partial.ToListAware
toList
 

Constructor Detail

Pair

public Pair(A fist,
            B second)
Creates a new pair.

Parameters:
fist -
second -
Method Detail

first

public A first()
Specified by:
first in interface FirstAware<A>

_0

public A _0()
Specified by:
_0 in interface FirstAware<A>

second

public B second()
Specified by:
second in interface SecondAware<B>

_1

public B _1()
Specified by:
_1 in interface SecondAware<B>

swap

@NonNull
public Pair<B,A> swap()
Creates a new tuple, with swaped components

Specified by:
swap in interface Tuple2<A,B>
Returns:
a new pair, never null.

toString

public String toString()
Overrides:
toString in class Object

toArray

@NonNull
public Object[] toArray()
Description copied from class: AbstractTuple
Converts this tuple into an array

Specified by:
toArray in interface ToListAware<Object>
Specified by:
toArray in class AbstractTuple
Returns:
an new Object[] containing each of the elements of this tuple

compareTo

public int compareTo(Tuple2<A,B> other)
Specified by:
compareTo in interface Comparable<Tuple2<A,B>>

hashCode

public int hashCode()
Specified by:
hashCode in interface Map.Entry<A,B>
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map.Entry<A,B>
Overrides:
equals in class Object

getKey

public A getKey()
Specified by:
getKey in interface Map.Entry<A,B>

getValue

public B getValue()
Specified by:
getValue in interface Map.Entry<A,B>

setValue

public B setValue(B arg0)
Specified by:
setValue in interface Map.Entry<A,B>


Get Staccatocommons at SourceForge.net. Fast, secure and Free Open Source software downloads