net.sf.staccatocommons.lang.tuple
Class Pair<A,B>
java.lang.Object
net.sf.staccatocommons.lang.tuple.AbstractTuple
net.sf.staccatocommons.lang.tuple.Pair<A,B>
- Type Parameters:
A - first component typeB - second component type
- All Implemented Interfaces:
- Serializable, Comparable<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>>, Map.Entry<A,B>, net.sf.staccatocommons.defs.partial.FirstAware<A>, net.sf.staccatocommons.defs.partial.SecondAware<B>, net.sf.staccatocommons.defs.partial.ToListAware<Object>, net.sf.staccatocommons.defs.tuple.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 net.sf.staccatocommons.defs.tuple.Tuple2<A,B>
Two-components AbstractTuple
- Author:
- flbulgarelli
- See Also:
- Serialized Form
|
Constructor Summary |
Pair(A fist,
B second)
Creates a new pair. |
| Methods inherited from interface net.sf.staccatocommons.defs.partial.ToListAware |
toList |
Pair
public Pair(A fist,
B second)
- Creates a new pair.
- Parameters:
fist - second -
first
public A first()
- Specified by:
first in interface net.sf.staccatocommons.defs.partial.FirstAware<A>
_0
public A _0()
- Specified by:
_0 in interface net.sf.staccatocommons.defs.partial.FirstAware<A>
second
public B second()
- Specified by:
second in interface net.sf.staccatocommons.defs.partial.SecondAware<B>
_1
public B _1()
- Specified by:
_1 in interface net.sf.staccatocommons.defs.partial.SecondAware<B>
swap
@NonNull
public Pair<B,A> swap()
- Creates a new tuple, with swaped components
- Specified by:
swap in interface net.sf.staccatocommons.defs.tuple.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 net.sf.staccatocommons.defs.partial.ToListAware<Object>- Specified by:
toArray in class AbstractTuple
- Returns:
- an new Object[] containing each of the elements of this tuple
compareTo
public int compareTo(net.sf.staccatocommons.defs.tuple.Tuple2<A,B> other)
- Specified by:
compareTo in interface Comparable<net.sf.staccatocommons.defs.tuple.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>
Copyright © 2010-2012 Staccatocommons. All Rights Reserved.