Class Pair<L,R>

java.lang.Object
nz.org.riskscape.engine.util.Pair<L,R>

public final class Pair<L,R> extends Object

General purpose pair type

  • Constructor Details

    • Pair

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

    • of

      public static <L, R> Pair<L,R> of(L l, R r)

      Construct a new pair in a slightly nicer way that using the constructor e.g. Pair.of(foo, bar) vs new Pair<>(foo, bar)

    • toMap

      public static <K, V> Collector<Pair<K,V>,?,Map<K,V>> toMap()

      Returns a collector that can be used to reduce a stream of Pairs to a map, throwing an exception on duplicates.

      Type Parameters:
      K - the type of keys
      V - the type of values
      Returns:
      a map that is the result of mapping every pair's left side to its right side
    • getLeft

      public L getLeft()
    • getRight

      public R getRight()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object