package com.qianwen.core.tool.tuple;
|
|
import com.qianwen.core.tool.utils.StringPool;
|
|
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/tuple/Pair.class */
|
public class Pair<L, R> {
|
private static final Pair<Object, Object> EMPTY = new Pair<>(null, null);
|
private final L left;
|
private final R right;
|
|
public String toString() {
|
return "Pair(left=" + getLeft() + ", right=" + getRight() + StringPool.RIGHT_BRACKET;
|
}
|
|
public boolean equals(final Object o) {
|
if (o == this) {
|
return true;
|
}
|
if (o instanceof Pair) {
|
Pair<?, ?> other = (Pair) o;
|
if (other.canEqual(this)) {
|
Object this$left = getLeft();
|
Object other$left = other.getLeft();
|
if (this$left == null) {
|
if (other$left != null) {
|
return false;
|
}
|
} else if (!this$left.equals(other$left)) {
|
return false;
|
}
|
Object this$right = getRight();
|
Object other$right = other.getRight();
|
return this$right == null ? other$right == null : this$right.equals(other$right);
|
}
|
return false;
|
}
|
return false;
|
}
|
|
protected boolean canEqual(final Object other) {
|
return other instanceof Pair;
|
}
|
|
public int hashCode() {
|
Object $left = getLeft();
|
int result = (1 * 59) + ($left == null ? 43 : $left.hashCode());
|
Object $right = getRight();
|
return (result * 59) + ($right == null ? 43 : $right.hashCode());
|
}
|
|
public L getLeft() {
|
return this.left;
|
}
|
|
public R getRight() {
|
return this.right;
|
}
|
|
public static <L, R> Pair<L, R> empty() {
|
return (Pair<L, R>) EMPTY;
|
}
|
|
public static <L, R> Pair<L, R> createLeft(L left) {
|
if (left == null) {
|
return empty();
|
}
|
return new Pair<>(left, null);
|
}
|
|
public static <L, R> Pair<L, R> createRight(R right) {
|
if (right == null) {
|
return empty();
|
}
|
return new Pair<>(null, right);
|
}
|
|
public static <L, R> Pair<L, R> create(L left, R right) {
|
if (right == null && left == null) {
|
return empty();
|
}
|
return new Pair<>(left, right);
|
}
|
|
private Pair(L left, R right) {
|
this.left = left;
|
this.right = right;
|
}
|
}
|