java.lang.Object
net.luis.utils.util.Pair<F,S>
- Type Parameters:
F
- The type of the first valueS
- The type of the second value
Tuple like class that holds two values of different types.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
getFirst()
Returns the first value of the pair.Returns the second value of the pair.int
hashCode()
Maps the first value of the pair to a new value using the specified mapper.Maps the second value of the pair to a new value using the specified mapper.static <T,
U> @NotNull Pair <T, U> of
(T first, U second) Creates a new pair with the specified first and second value.swap()
Swaps the first and second value of the pair.toString()
withFirst
(T first) Creates a new pair with the specified first value.withSecond
(T second) Creates a new pair with the specified second value.
-
Field Details
-
first
The first value of the pair. -
second
The second value of the pair.
-
-
Constructor Details
-
Pair
Constructs a new pair with the specified first and second value.- Parameters:
first
- The first valuesecond
- The second value- See Also:
-
-
Method Details
-
of
Creates a new pair with the specified first and second value.- Type Parameters:
T
- The type of the first valueU
- The type of the second value- Parameters:
first
- The first valuesecond
- The second value- Returns:
- The created pair instance
-
getFirst
Returns the first value of the pair.- Returns:
- The first value
-
getSecond
Returns the second value of the pair.- Returns:
- The second value
-
swap
Swaps the first and second value of the pair.- Returns:
- A new pair with the swapped values
-
mapFirst
@NotNull public <T> @NotNull Pair<T,S> mapFirst(@NotNull @NotNull Function<? super F, ? extends T> mapper) Maps the first value of the pair to a new value using the specified mapper.- Type Parameters:
T
- The new type of the first value- Parameters:
mapper
- The mapper function- Returns:
- A new pair with the mapped first value
-
mapSecond
@NotNull public <T> @NotNull Pair<F,T> mapSecond(@NotNull @NotNull Function<? super S, ? extends T> mapper) Maps the second value of the pair to a new value using the specified mapper.- Type Parameters:
T
- The new type of the second value- Parameters:
mapper
- The mapper function- Returns:
- A new pair with the mapped second value
-
withFirst
Creates a new pair with the specified first value.- Type Parameters:
T
- The new type of the first value- Parameters:
first
- The new first value replacing the old one- Returns:
- A new pair with the specified first value
-
withSecond
Creates a new pair with the specified second value.- Type Parameters:
T
- The new type of the second value- Parameters:
second
- The new second value replacing the old one- Returns:
- A new pair with the specified second value
-
equals
-
hashCode
public int hashCode() -
toString
-