L - the left element typeR - the right element type@ThreadSafe public abstract class Pair<L,R> extends Object implements Map.Entry<L,R>, Comparable<Pair<L,R>>, Serializable
这个类是一个定义基本API的抽象实现
它表示元素为“left”和“right” 它还实现了
Map.Entry接口,其中键为'left',值为'right'.
子类实现可以是可变的,也可以是不可变的
但是,对可能存储的存储对象的类型没有限制
如果可变对象存储在对中,那么对本身就会有效地变成可变的
| Constructor and Description |
|---|
Pair() |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Pair<L,R> other)
比较基于左元素和右元素的对。类型必须是
Comparable |
boolean |
equals(Object obj)
据这两个元素,将这一对与另一对进行比较
|
L |
getKey()
从这对中获取密钥
|
abstract L |
getLeft()
从这一对中获取左元素
|
abstract R |
getRight()
从这一对中获取右元素
|
R |
getValue()
从这对中获取值
|
int |
hashCode() |
static <L,R> Pair<L,R> |
of(L left,
R right)
获取两个推断泛型类型的对象的不可变对
这个工厂允许使用推理来创建对,以获得泛型类型
|
String |
toString() |
String |
toString(String format) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcomparingByKey, comparingByKey, comparingByValue, comparingByValue, setValuepublic static <L,R> Pair<L,R> of(L left, R right)
L - 左元素类型R - 右元素类型left - 左值可以为nullright - 右值可以为nullpublic abstract L getLeft()
public abstract R getRight()
public final L getKey()
public R getValue()
public int compareTo(Pair<L,R> other)
ComparablecompareTo in interface Comparable<Pair<L,R>>other - 另一对,不为空public boolean equals(Object obj)
public int hashCode()
Copyright © 2020. All rights reserved.