62 lines
2.0 KiB
Java
62 lines
2.0 KiB
Java
|
package com.google.common.collect;
|
||
|
|
||
|
import java.io.Serializable;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.Comparator;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
final class CompoundOrdering<T> extends Ordering<T> implements Serializable {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
final Comparator<? super T>[] comparators;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public CompoundOrdering(Comparator<? super T> comparator, Comparator<? super T> comparator2) {
|
||
|
this.comparators = new Comparator[]{comparator, comparator2};
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public CompoundOrdering(Iterable<? extends Comparator<? super T>> iterable) {
|
||
|
this.comparators = (Comparator[]) Iterables.toArray(iterable, new Comparator[0]);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Ordering, java.util.Comparator
|
||
|
public final int compare(T t, T t2) {
|
||
|
int i = 0;
|
||
|
while (true) {
|
||
|
Comparator<? super T>[] comparatorArr = this.comparators;
|
||
|
if (i >= comparatorArr.length) {
|
||
|
return 0;
|
||
|
}
|
||
|
int compare = comparatorArr[i].compare(t, t2);
|
||
|
if (compare != 0) {
|
||
|
return compare;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Comparator
|
||
|
public final boolean equals(Object obj) {
|
||
|
if (obj == this) {
|
||
|
return true;
|
||
|
}
|
||
|
if (obj instanceof CompoundOrdering) {
|
||
|
return Arrays.equals(this.comparators, ((CompoundOrdering) obj).comparators);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public final int hashCode() {
|
||
|
return Arrays.hashCode(this.comparators);
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
String arrays = Arrays.toString(this.comparators);
|
||
|
StringBuilder sb = new StringBuilder(String.valueOf(arrays).length() + 19);
|
||
|
sb.append("Ordering.compound(");
|
||
|
sb.append(arrays);
|
||
|
sb.append(")");
|
||
|
return sb.toString();
|
||
|
}
|
||
|
}
|