Class Pair<L,R>

java.lang.Object
software.amazon.smithy.utils.Pair<L,R>
Type Parameters:
L - Left value type.
R - Right value type.
All Implemented Interfaces:
Map.Entry<L,R>

public final class Pair<L,R> extends Object implements Map.Entry<L,R>
Generic immutable pair of values.
  • Field Details

    • left

      public final L left
  • Constructor Details

    • Pair

      public Pair(L left, R right)
  • Method Details

    • of

      public static <L, R> Pair<L,R> of(L left, R right)
      Creates a Pair from the given values.
      Type Parameters:
      L - Left value type.
      R - Right value type.
      Parameters:
      left - Left value.
      right - Right value.
      Returns:
      Returns the created Pair.
    • flatMapStream

      public static <L, R> Stream<Pair<L,R>> flatMapStream(L left, Function<L,Optional<R>> f)
      Creates a Stream of zero or one Pairs if the mapping function returns a non-empty Optional.
      Type Parameters:
      L - Left value type.
      R - Right value type.
      Parameters:
      left - Value to set as the left side of the pair.
      f - Mapping function that accepts the left value and returns an Optional value.
      Returns:
      Returns a Stream that contains either a single Pair if the Optional is not empty, or an empty Stream.
    • flatMapStream

      public static <L, R> Stream<Pair<L,R>> flatMapStream(L left, Supplier<Optional<R>> f)
    • getLeft

      public L getLeft()
    • getRight

      public R getRight()
    • getKey

      public L getKey()
      Specified by:
      getKey in interface Map.Entry<L,R>
    • getValue

      public R getValue()
      Specified by:
      getValue in interface Map.Entry<L,R>
    • setValue

      public R setValue(R value)
      Specified by:
      setValue in interface Map.Entry<L,R>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Map.Entry<L,R>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map.Entry<L,R>
      Overrides:
      hashCode in class Object