类 Pair<A,B>

java.lang.Object
cn.taketoday.core.Pair<A,B>
类型参数:
A - type of the first value.
B - type of the second value.
所有已实现的接口:
Serializable, Map.Entry<A,B>

@Experimental public class Pair<A,B> extends Object implements Map.Entry<A,B>, Serializable
Represents a generic pair of two values. There is no meaning attached to values in this class, it can be used for any purpose. Pair exhibits value semantics, i.e. two pairs are equal if both components are equal. An example of decomposing it into values:
从以下版本开始:
4.0 2023/8/24 14:45
作者:
Harry Yang
另请参阅:
  • 字段详细资料

    • EMPTY

      public static final Pair EMPTY
    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • first

      public final A first
    • second

      public final B second
  • 构造器详细资料

    • Pair

      private Pair(A first, B second)
  • 方法详细资料

    • getFirst

      public final A getFirst()
    • getSecond

      public final B getSecond()
    • getKey

      public A getKey()
      指定者:
      getKey 在接口中 Map.Entry<A,B>
    • getValue

      public B getValue()
      指定者:
      getValue 在接口中 Map.Entry<A,B>
    • setValue

      public B setValue(B value)
      指定者:
      setValue 在接口中 Map.Entry<A,B>
    • withFirst

      public Pair<A,B> withFirst(A first)
    • withSecond

      public Pair<A,B> withSecond(B second)
    • first

      public Optional<A> first()
    • second

      public Optional<B> second()
    • equals

      public boolean equals(Object o)
      指定者:
      equals 在接口中 Map.Entry<A,B>
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      指定者:
      hashCode 在接口中 Map.Entry<A,B>
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      Returns string representation of the [Pair] including its [first] and [second] values.
      覆盖:
      toString 在类中 Object
    • empty

      public static <A, B> Pair<A,B> empty()
    • of

      public static <A, B> Pair<A,B> of(@Nullable A first, @Nullable B second)
    • getFirst

      @Nullable public static <T> T getFirst(@Nullable Pair<T,?> pair)
    • getSecond

      @Nullable public static <T> T getSecond(@Nullable Pair<?,T> pair)
    • comparingFirst

      public static <A extends Comparable<? super A>, B> Comparator<Pair<A,B>> comparingFirst()
      类型参数:
      A - first value type (Comparable)
      B - second value type
      返回:
      a comparator that compares pair values by first value
    • comparingSecond

      public static <A, B extends Comparable<? super B>> Comparator<Pair<A,B>> comparingSecond()
      类型参数:
      A - first value type
      B - second value type (Comparable)
      返回:
      a comparator that compares pair values by second value