Class UPair<F,S>

java.lang.Object
ushiosan.jvm.content.UPair<F,S>
Type Parameters:
F - first element type
S - second element type
Direct Known Subclasses:
UTrio

public class UPair<F,S> extends Object
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 Details

    • first

      public final F first
      First pair element
    • second

      public final S second
      Second pair element
  • Constructor Details

    • UPair

      public UPair(F first, S second)
      Default constructor
      Parameters:
      first - first element
      second - second element
  • Method Details

    • make

      @Contract(value="_, _ -> new", pure=true) @NotNull public static <T, K> @NotNull UPair<T,K> make(T first, K second)
      Shortcut pair instance
      Type Parameters:
      T - generic first type
      K - generic second type
      Parameters:
      first - first value
      second - second value
      Returns:
      instance of UPair class
    • copyOf

      @Contract("_ -> new") @NotNull public static <T, K> @NotNull UPair<T,K> copyOf(@NotNull Map.Entry<T,K> entry)
      Copies the content of a map entry and converts it to a UPair object.
      Type Parameters:
      T - first element type
      K - second element type
      Parameters:
      entry - the entry to copy
      Returns:
      an instance of UPair with entry content
    • extractPairs

      public static <T, K> UPair<T,K> @NotNull [] extractPairs(@NotNull @NotNull Map<T,K> map)
      Extracts all map entries and converts them to UPair objects.
      Type Parameters:
      T - first element type
      K - second element type
      Parameters:
      map - the map to inspect
      Returns:
      an array with all map pairs
    • extractPairs

      public static UPair<String,String> @NotNull [] extractPairs(@NotNull @NotNull Properties properties)
      Extracts all-properties entries and converts them to UPair objects.
      Parameters:
      properties - the properties to inspect
      Returns:
      an array with all property pairs
    • hashCode

      public int hashCode()
      Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one.

      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.