Rabbit-R1/switch port/java/sources/com/google/common/collect/ReverseOrdering.java
2024-05-21 17:08:36 -04:00

89 lines
3.1 KiB
Java

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