what-the-bank/sources/com/google/common/collect/ReverseOrdering.java

91 lines
2.9 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Iterator;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class ReverseOrdering<T> extends Ordering<T> implements Serializable {
private static final long serialVersionUID = 0;
final Ordering<? super T> forwardOrder;
/* JADX INFO: Access modifiers changed from: package-private */
public ReverseOrdering(Ordering<? super T> ordering) {
this.forwardOrder = (Ordering) Preconditions.checkNotNull(ordering);
}
@Override // com.google.common.collect.Ordering, java.util.Comparator
public final int compare(T t, T t2) {
return this.forwardOrder.compare(t2, t);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E min(E e, E e2) {
return (E) this.forwardOrder.max(e, e2);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E min(E e, E e2, E e3, E... eArr) {
return (E) this.forwardOrder.max(e, e2, e3, eArr);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E min(Iterator<E> it) {
return (E) this.forwardOrder.max(it);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E min(Iterable<E> iterable) {
return (E) this.forwardOrder.max(iterable);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E max(E e, E e2) {
return (E) this.forwardOrder.min(e, e2);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E max(E e, E e2, E e3, E... eArr) {
return (E) this.forwardOrder.min(e, e2, e3, eArr);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E max(Iterator<E> it) {
return (E) this.forwardOrder.min(it);
}
@Override // com.google.common.collect.Ordering
public final <E extends T> E max(Iterable<E> iterable) {
return (E) this.forwardOrder.min(iterable);
}
public final int hashCode() {
return -this.forwardOrder.hashCode();
}
@Override // java.util.Comparator
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof ReverseOrdering) {
return this.forwardOrder.equals(((ReverseOrdering) obj).forwardOrder);
}
return false;
}
public final String toString() {
String valueOf = String.valueOf(this.forwardOrder);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 10);
sb.append(valueOf);
sb.append(".reverse()");
return sb.toString();
}
@Override // com.google.common.collect.Ordering
public final <S extends T> Ordering<S> reverse() {
return this.forwardOrder;
}
}