59 lines
1.9 KiB
Java
59 lines
1.9 KiB
Java
|
package com.google.common.collect;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import java.io.Serializable;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class NaturalOrdering extends Ordering<Comparable> implements Serializable {
|
||
|
static final NaturalOrdering INSTANCE = new NaturalOrdering();
|
||
|
private static final long serialVersionUID = 0;
|
||
|
private transient Ordering<Comparable> nullsFirst;
|
||
|
private transient Ordering<Comparable> nullsLast;
|
||
|
|
||
|
@Override // com.google.common.collect.Ordering, java.util.Comparator
|
||
|
public final int compare(Comparable comparable, Comparable comparable2) {
|
||
|
Preconditions.checkNotNull(comparable);
|
||
|
Preconditions.checkNotNull(comparable2);
|
||
|
return comparable.compareTo(comparable2);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Ordering
|
||
|
public final <S extends Comparable> Ordering<S> nullsFirst() {
|
||
|
Ordering<S> ordering = (Ordering<S>) this.nullsFirst;
|
||
|
if (ordering != null) {
|
||
|
return ordering;
|
||
|
}
|
||
|
Ordering<S> nullsFirst = super.nullsFirst();
|
||
|
this.nullsFirst = nullsFirst;
|
||
|
return nullsFirst;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Ordering
|
||
|
public final <S extends Comparable> Ordering<S> nullsLast() {
|
||
|
Ordering<S> ordering = (Ordering<S>) this.nullsLast;
|
||
|
if (ordering != null) {
|
||
|
return ordering;
|
||
|
}
|
||
|
Ordering<S> nullsLast = super.nullsLast();
|
||
|
this.nullsLast = nullsLast;
|
||
|
return nullsLast;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Ordering
|
||
|
public final <S extends Comparable> Ordering<S> reverse() {
|
||
|
return ReverseNaturalOrdering.INSTANCE;
|
||
|
}
|
||
|
|
||
|
private NaturalOrdering() {
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
return "Ordering.natural()";
|
||
|
}
|
||
|
|
||
|
private Object readResolve() {
|
||
|
return INSTANCE;
|
||
|
}
|
||
|
}
|