jimu-decompiled/sources/com/google/common/collect/GeneralRange.java
2025-05-13 19:24:51 +02:00

177 lines
5.3 KiB
Java

package com.google.common.collect;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Comparator;
/* loaded from: classes.dex */
final class GeneralRange<T> implements Serializable {
private final Comparator<? super T> a;
private final boolean b;
private final T c;
private final BoundType d;
private final boolean e;
private final T f;
private final BoundType g;
/* JADX WARN: Multi-variable type inference failed */
private GeneralRange(Comparator<? super T> comparator, boolean z, T t, BoundType boundType, boolean z2, T t2, BoundType boundType2) {
Preconditions.a(comparator);
this.a = comparator;
this.b = z;
this.e = z2;
this.c = t;
Preconditions.a(boundType);
this.d = boundType;
this.f = t2;
Preconditions.a(boundType2);
this.g = boundType2;
if (z) {
comparator.compare(t, t);
}
if (z2) {
comparator.compare(t2, t2);
}
if (z && z2) {
int compare = comparator.compare(t, t2);
Preconditions.a(compare <= 0, "lowerEndpoint (%s) > upperEndpoint (%s)", t, t2);
if (compare == 0) {
Preconditions.a((boundType != BoundType.OPEN) | (boundType2 != BoundType.OPEN));
}
}
}
static <T> GeneralRange<T> a(Comparator<? super T> comparator) {
BoundType boundType = BoundType.OPEN;
return new GeneralRange<>(comparator, false, null, boundType, false, null, boundType);
}
static <T> GeneralRange<T> b(Comparator<? super T> comparator, T t, BoundType boundType) {
return new GeneralRange<>(comparator, false, null, BoundType.OPEN, true, t, boundType);
}
boolean c(T t) {
if (!f()) {
return false;
}
int compare = this.a.compare(t, c());
return ((compare == 0) & (b() == BoundType.OPEN)) | (compare < 0);
}
BoundType d() {
return this.g;
}
T e() {
return this.f;
}
public boolean equals(Object obj) {
if (!(obj instanceof GeneralRange)) {
return false;
}
GeneralRange generalRange = (GeneralRange) obj;
return this.a.equals(generalRange.a) && this.b == generalRange.b && this.e == generalRange.e && b().equals(generalRange.b()) && d().equals(generalRange.d()) && Objects.a(c(), generalRange.c()) && Objects.a(e(), generalRange.e());
}
boolean f() {
return this.b;
}
boolean g() {
return this.e;
}
public int hashCode() {
return Objects.a(this.a, c(), b(), e(), d());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.a);
sb.append(":");
sb.append(this.d == BoundType.CLOSED ? '[' : '(');
sb.append(this.b ? this.c : "-∞");
sb.append(',');
sb.append(this.e ? this.f : "");
sb.append(this.g == BoundType.CLOSED ? ']' : ')');
return sb.toString();
}
static <T> GeneralRange<T> a(Comparator<? super T> comparator, T t, BoundType boundType) {
return new GeneralRange<>(comparator, true, t, boundType, false, null, BoundType.OPEN);
}
boolean b(T t) {
if (!g()) {
return false;
}
int compare = this.a.compare(t, e());
return ((compare == 0) & (d() == BoundType.OPEN)) | (compare > 0);
}
Comparator<? super T> a() {
return this.a;
}
boolean a(T t) {
return (c(t) || b(t)) ? false : true;
}
GeneralRange<T> a(GeneralRange<T> generalRange) {
int compare;
int compare2;
BoundType boundType;
BoundType boundType2;
T t;
int compare3;
BoundType boundType3;
Preconditions.a(generalRange);
Preconditions.a(this.a.equals(generalRange.a));
boolean z = this.b;
T c = c();
BoundType b = b();
if (!f()) {
z = generalRange.b;
c = generalRange.c();
b = generalRange.b();
} else if (generalRange.f() && ((compare = this.a.compare(c(), generalRange.c())) < 0 || (compare == 0 && generalRange.b() == BoundType.OPEN))) {
c = generalRange.c();
b = generalRange.b();
}
boolean z2 = z;
boolean z3 = this.e;
T e = e();
BoundType d = d();
if (!g()) {
z3 = generalRange.e;
e = generalRange.e();
d = generalRange.d();
} else if (generalRange.g() && ((compare2 = this.a.compare(e(), generalRange.e())) > 0 || (compare2 == 0 && generalRange.d() == BoundType.OPEN))) {
e = generalRange.e();
d = generalRange.d();
}
boolean z4 = z3;
T t2 = e;
if (z2 && z4 && ((compare3 = this.a.compare(c, t2)) > 0 || (compare3 == 0 && b == (boundType3 = BoundType.OPEN) && d == boundType3))) {
boundType = BoundType.OPEN;
boundType2 = BoundType.CLOSED;
t = t2;
} else {
boundType = b;
boundType2 = d;
t = c;
}
return new GeneralRange<>(this.a, z2, t, boundType, z4, t2, boundType2);
}
T c() {
return this.c;
}
BoundType b() {
return this.d;
}
}