Class Pair<T,K>
java.lang.Object
ushiosan.jvm_utilities.lang.collection.elements.Pair<T,K>
- Type Parameters:
T- first element typeK- second element type
- Direct Known Subclasses:
Trio
Immutable object used to represent elements with 2 values (element pair).
It is an alternative to "input" type objects because its value is read-only.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCopies the content of a map entry and converts it to aPairobject.extractPairs(@NotNull Map<T, K> map) Extracts all map entries and converts them toPairobjects.extractPairs(@NotNull Properties props) Extracts all properties entries and converts them toPairobjects.of(T first, K second) Shortcut pair instancetoString()Object string representation
-
Field Details
-
first
First pair element -
second
Second pair element
-
-
Constructor Details
-
Pair
Default constructor- Parameters:
first- first elementsecond- second element
-
-
Method Details
-
of
@Contract(value="_, _ -> new", pure=true) @NotNull public static <T,K> @NotNull Pair<T,K> of(T first, K second) Shortcut pair instance- Type Parameters:
T- generic first typeK- generic second type- Parameters:
first- first valuesecond- second value- Returns:
- instance of
Pairclass
-
copyOf
@Contract("_ -> new") @NotNull public static <T,K> @NotNull Pair<T,K> copyOf(@NotNull Map.Entry<T, K> entry) Copies the content of a map entry and converts it to aPairobject.- Type Parameters:
T- first element typeK- second element type- Parameters:
entry- the entry to copy- Returns:
- an instance of
Pairwith entry content
-
extractPairs
Extracts all map entries and converts them toPairobjects.- Type Parameters:
T- first element typeK- second element type- Parameters:
map- the map to inspect- Returns:
- an array with all map pairs
-
extractPairs
Extracts all properties entries and converts them toPairobjects.- Parameters:
props- the properties to inspect- Returns:
- an array with all property pairs
-
toString
Object string representation
-