Class Pair<K1,​K2>


  • public final class Pair<K1,​K2>
    extends java.lang.Object
    Tuple with 2 elements
    Since:
    2.0
    Version:
    2.3
    Author:
    Pedro Oliveira, Michael Grove
    • Field Summary

      Fields 
      Modifier and Type Field Description
      K1 first  
      K2 second  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <K1 extends java.lang.Comparable<K1>,​K2 extends java.lang.Comparable<K2>>
      java.util.Comparator<Pair<K1,​K2>>
      comparator()  
      static <S,​T>
      Pair<S,​T>
      create​(S a, T b)  
      static <S,​T>
      Pair<S,​T>
      createFromFirst​(S a, java.util.function.Function<S,​T> aToB)  
      boolean equals​(java.lang.Object o)
      K1 first()  
      static <K,​V>
      java.util.function.Function<java.util.Map.Entry<K,​V>,​Pair<K,​V>>
      fromMapEntry()  
      static <K,​V>
      Pair<K,​V>
      fromMapEntry​(java.util.Map.Entry<K,​V> e)  
      int hashCode()
      static <K1_I,​K1_O,​K2>
      java.util.function.Function<Pair<K1_I,​K2>,​Pair<K1_O,​K2>>
      liftOverFirst​(java.util.function.Function<K1_I,​K1_O> mapper)  
      static <K1,​K2_I,​K2_O>
      java.util.function.Function<Pair<K1,​K2_I>,​Pair<K1,​K2_O>>
      liftOverSecond​(java.util.function.Function<? super K2_I,​? extends K2_O> mapper)  
      static <P1,​P2>
      java.util.function.Consumer<Pair<P1,​P2>>
      pairBiConsumer​(java.util.function.BiConsumer<P1,​P2> mapper)  
      static <P1,​P2,​R>
      java.util.function.Function<Pair<P1,​P2>,​R>
      pairBiFunction​(java.util.function.BiFunction<P1,​P2,​R> mapper)  
      static <P1,​P2>
      java.util.function.Predicate<Pair<P1,​P2>>
      pairBiPredicate​(java.util.function.BiPredicate<P1,​P2> mapper)  
      K2 second()  
      static <K,​V>
      java.util.stream.Stream<Pair<K,​V>>
      streamMap​(java.util.Map<K,​V> m)  
      static <K1,​K2>
      java.util.stream.Collector<Pair<K1,​K2>,​?,​java.util.Map<K1,​K2>>
      toMap()  
      static <K1,​K2>
      java.util.stream.Collector<Pair<K1,​K2>,​?,​java.util.Map<K1,​K2>>
      toMap​(java.util.function.Supplier<java.util.Map<K1,​K2>> mapSupplier)  
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • first

        public final K1 first
      • second

        public final K2 second
    • Method Detail

      • create

        public static <S,​T> Pair<S,​T> create​(S a,
                                                         T b)
      • createFromFirst

        public static <S,​T> Pair<S,​T> createFromFirst​(S a,
                                                                  java.util.function.Function<S,​T> aToB)
      • first

        public K1 first()
      • second

        public K2 second()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • comparator

        public static <K1 extends java.lang.Comparable<K1>,​K2 extends java.lang.Comparable<K2>> java.util.Comparator<Pair<K1,​K2>> comparator()
      • toMap

        public static <K1,​K2> java.util.stream.Collector<Pair<K1,​K2>,​?,​java.util.Map<K1,​K2>> toMap()
      • toMap

        public static <K1,​K2> java.util.stream.Collector<Pair<K1,​K2>,​?,​java.util.Map<K1,​K2>> toMap​(java.util.function.Supplier<java.util.Map<K1,​K2>> mapSupplier)
      • liftOverFirst

        public static <K1_I,​K1_O,​K2> java.util.function.Function<Pair<K1_I,​K2>,​Pair<K1_O,​K2>> liftOverFirst​(java.util.function.Function<K1_I,​K1_O> mapper)
      • liftOverSecond

        public static <K1,​K2_I,​K2_O> java.util.function.Function<Pair<K1,​K2_I>,​Pair<K1,​K2_O>> liftOverSecond​(java.util.function.Function<? super K2_I,​? extends K2_O> mapper)
      • pairBiFunction

        public static <P1,​P2,​R> java.util.function.Function<Pair<P1,​P2>,​R> pairBiFunction​(java.util.function.BiFunction<P1,​P2,​R> mapper)
      • pairBiPredicate

        public static <P1,​P2> java.util.function.Predicate<Pair<P1,​P2>> pairBiPredicate​(java.util.function.BiPredicate<P1,​P2> mapper)
      • pairBiConsumer

        public static <P1,​P2> java.util.function.Consumer<Pair<P1,​P2>> pairBiConsumer​(java.util.function.BiConsumer<P1,​P2> mapper)
      • fromMapEntry

        public static <K,​V> java.util.function.Function<java.util.Map.Entry<K,​V>,​Pair<K,​V>> fromMapEntry()
      • fromMapEntry

        public static <K,​V> Pair<K,​V> fromMapEntry​(java.util.Map.Entry<K,​V> e)
      • streamMap

        public static <K,​V> java.util.stream.Stream<Pair<K,​V>> streamMap​(java.util.Map<K,​V> m)