co.cask.common
Class ImmutablePair<A,B>

java.lang.Object
  extended by co.cask.common.ImmutablePair<A,B>
Type Parameters:
A - type A
B - type B

public final class ImmutablePair<A,B>
extends Object

An ImmutablePair consists of two elements within. The elements once set in the ImmutablePair cannot be modified. The class itself is final, so that it cannot be subclassed. This is general norm for creating Immutable classes. Please note that the ImmutablePair cannot be modified once set, but the objects within them can be, so in general it means that if there are mutable objects within the pair then the pair itself is effectively mutable.

   ImmutablePair tupleStreamPair= new
    ImmutablePair (tuple, identifier);
   ...
   ...
   Tuple t = tupleStreamPair.getFirst();
   TupleInputStreamIdentifier identifier = tupleStreamPair.getSecond();
   ...
 


Constructor Summary
ImmutablePair(A first, B second)
          Constructs a Immutable Pair.
 
Method Summary
 boolean equals(Object o)
          Returns whether some other object "is equal" to this object.
 A getFirst()
          Returns first object from pair.
 B getSecond()
          Return second object from pair.
 int hashCode()
          Returns a hash code value for this object.
static
<A,B> ImmutablePair<A,B>
of(A first, B second)
           
 String toString()
          Returns a string representation of ImmutablePair object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImmutablePair

public ImmutablePair(A first,
                     B second)
Constructs a Immutable Pair.

Parameters:
first - object in pair
second - object in pair
Method Detail

of

public static <A,B> ImmutablePair<A,B> of(A first,
                                          B second)

getFirst

public A getFirst()
Returns first object from pair.

Returns:
first object from pair.

getSecond

public B getSecond()
Return second object from pair.

Returns:
second object from pair.

toString

public String toString()
Returns a string representation of ImmutablePair object.

Overrides:
toString in class Object
Returns:
string representation of this object.

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object
Returns:
hash code value of this object.

equals

public boolean equals(Object o)
Returns whether some other object "is equal" to this object.

Overrides:
equals in class Object
Parameters:
o - reference object with which to compare
Returns:
true if object is the same as the obj argument; false otherwise.


Copyright © 2015 Cask Data, Inc. Licensed under the Apache License, Version 2.0.