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

java.lang.Object
  extended by net.sf.staccatocommons.lang.tuple.AbstractTuple
      extended by net.sf.staccatocommons.lang.tuple.Triple<A,B,C>
Type Parameters:
A -
B -
C -
All Implemented Interfaces:
Serializable, Comparable<net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>>, net.sf.staccatocommons.defs.partial.FirstAware<A>, net.sf.staccatocommons.defs.partial.SecondAware<B>, net.sf.staccatocommons.defs.partial.ThirdAware<C>, net.sf.staccatocommons.defs.partial.ToListAware<Object>, net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>

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

Three-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
Triple(A first, B second, C third)
          Creates a new Triple
 
Method Summary
 A _0()
           
 B _1()
           
 C _2()
           
 int compareTo(net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C> other)
           
 boolean equals(Object obj)
           
 A first()
           
 int hashCode()
           
 net.sf.staccatocommons.defs.tuple.Tuple3<B,C,A> rotateLeft()
           Rotates this Triple components to left, creating a new one where the first component is placed at the third position, an the rests, shifted right.
 net.sf.staccatocommons.defs.tuple.Tuple3<C,A,B> rotateRight()
           Rotates this Triple components to right, creating a new one where the third component is placed at the first position, an the rests, shifted right.
 B second()
           
 C third()
           
 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

Triple

public Triple(A first,
              B second,
              C third)
Creates a new Triple

Parameters:
first - 1st component. Nullable
second - 2nd component. Nullable
third - 3rd component. Nullable.
Method Detail

first

public A first()
Specified by:
first 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>

third

public C third()
Specified by:
third in interface net.sf.staccatocommons.defs.partial.ThirdAware<C>

_0

public A _0()
Specified by:
_0 in interface net.sf.staccatocommons.defs.partial.FirstAware<A>

_1

public B _1()
Specified by:
_1 in interface net.sf.staccatocommons.defs.partial.SecondAware<B>

_2

public C _2()
Specified by:
_2 in interface net.sf.staccatocommons.defs.partial.ThirdAware<C>

rotateLeft

@NonNull
public net.sf.staccatocommons.defs.tuple.Tuple3<B,C,A> rotateLeft()

Rotates this Triple components to left, creating a new one where the first component is placed at the third position, an the rests, shifted right.

Given a triple whose components a, b, c implement appropriately equals method, the following is always true

_(a,b,c).rotateLeft().equals(_(b,c,a))
 
 

Specified by:
rotateLeft in interface net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>
Returns:
a new, non null Triple, with its components rotated to left

rotateRight

@NonNull
public net.sf.staccatocommons.defs.tuple.Tuple3<C,A,B> rotateRight()

Rotates this Triple components to right, creating a new one where the third component is placed at the first position, an the rests, shifted right.

Given a triple whose components a, b, c implement appropriately equals method, the following is always true

_(a,b,c).rotateLeft().equals(_(c,b,a))
 
 

Specified by:
rotateRight in interface net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>
Returns:
a new, non null Triple, with its components rotated to right

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

compareTo

public int compareTo(net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C> other)
Specified by:
compareTo in interface Comparable<net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>>


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.