Package jline.util
Class Pair<T,U>
java.lang.Object
jline.util.Pair<T,U>
- Type Parameters:
T- the type of the left elementU- the type of the right element
- All Implemented Interfaces:
Serializable,Comparable<Pair<T,U>>
A generic pair container that holds two objects of potentially different types.
This utility class provides a simple way to group two related values together.
It implements Comparable for ordering pairs and Serializable for
persistence. The comparison is based on the left element if it's comparable,
otherwise on the right element.
Common use cases:
- Returning multiple values from methods
- Storing coordinate pairs or ranges
- Key-value associations where Map is not suitable
- Temporary grouping of related objects
- Since:
- 1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Pair
Constructs a new pair with the specified left and right elements.- Parameters:
left- the left element of the pairright- the right element of the pair
-
Pair
Copy constructor that creates a new pair with the same elements as another pair.- Parameters:
other- the pair to copy from
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-
getLeft
-
setLeft
-
getRight
-
setRight
-
getFirst
Kotlin-style alias forgetLeft(). -
getSecond
Kotlin-style alias forgetRight().
-