Package org.forgerock.util
Class Pair<F,S>
java.lang.Object
org.forgerock.util.Pair<F,S>
- Type Parameters:
F
- type of the first pair elementS
- type of the second pair element
Ordered pair of arbitrary objects. Use of Pair is strictly restricted to internal (non-public) APIs:
- Pair cannot be used in public APIs - Consider using dedicated classes over Pair. Dedicated classes are more readable while Pair is meaningless.
- Pair should only be used to return two values from a method, just like a tuple. If you need more than two values, create a dedicated class.
- Pair cannot be used in public APIs - Consider using dedicated classes over Pair. Dedicated classes are more readable while Pair is meaningless.
- Pair should only be used to return two values from a method, just like a tuple. If you need more than two values, create a dedicated class.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionasMap()
Get the pair as a map of key to value.static <F,
S> Pair<F, S> empty()
Returns an empty Pair matching the required types.boolean
getFirst()
Returns the first element of this pair.static <F extends Comparable<F>,
S extends Comparable<S>>
Comparator<Pair<F,S>> Returns a comparator for Pairs of comparable objects.Returns the second element of this pair.int
hashCode()
static <F,
S> Pair<F, S> of
(F first, S second) Creates a newPair
.toString()
-
Field Details
-
EMPTY
An empty Pair. -
COMPARATOR
-
-
Method Details
-
of
Creates a newPair
.- Type Parameters:
F
- type of the first pair elementS
- type of the second pair element- Parameters:
first
- the first element of the constructed pairsecond
- the second element of the constructed pair- Returns:
- A new Pair built with the provided elements
-
empty
Returns an empty Pair matching the required types.- Type Parameters:
F
- type of the first pair elementS
- type of the second pair element- Returns:
- An empty Pair matching the required types
-
getPairComparator
public static <F extends Comparable<F>,S extends Comparable<S>> Comparator<Pair<F,S>> getPairComparator()Returns a comparator for Pairs of comparable objects.- Type Parameters:
F
- type of the first pair elementS
- type of the second pair element- Returns:
- a comparator for Pairs of comparable objects.
-
getFirst
Returns the first element of this pair.- Returns:
- the first element of this pair
-
getSecond
Returns the second element of this pair.- Returns:
- the second element of this pair
-
asMap
Get the pair as a map of key to value.- Returns:
- The map.
-
hashCode
public int hashCode() -
equals
-
toString
-