AnyLogic
Expand
Font size
All Implemented Interfaces:
Serializable

public final class Pair<FIRST,SECOND>
extends Object
implements Serializable
A pair of two (possibly null) elements, may be used as key in maps.
Overrides equals(Object) and hashCode().
Objects of this class are immutable: they have no setter methods.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

ConstructorDescription
Pair(FIRST first, SECOND second)
Creates a new pair of two elements

Method Summary

Modifier and TypeMethodDescription
Objectclone() 
booleanequals(Object obj) 
FIRSTgetFirst()
Returns the first (left) element from this pair
SECONDgetSecond()
Returns the second (right) element from this pair
inthashCode() 
static <F, S> Pair<F,S>of(F first, S second)
Creates and returns new pair of two elements
StringtoString() 

Methods inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait

Constructor Details

Pair

public Pair(FIRST first,
 SECOND second)
Creates a new pair of two elements
Parameters:
first - the first (left) element, may be null
second - the second (right) element, may be null

Method Details

of

public static <F,
S> Pair<F,S> of(F first,
 S second)
Creates and returns new pair of two elements
Parameters:
first - the first (left) element, may be null
second - the second (right) element, may be null
Returns:
a pair, never null

getFirst

public FIRST getFirst()
Returns the first (left) element from this pair
Returns:
the first element from this pair, may be null

getSecond

public SECOND getSecond()
Returns the second (right) element from this pair
Returns:
the second element from this pair, may be null

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

clone

public Object clone()
             throws CloneNotSupportedException
Throws:
CloneNotSupportedException

toString

public String toString()
Overrides:
toString in class Object