mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 17:42:33 -06:00
53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.collect.Ordering;
|
|
import java.io.Serializable;
|
|
import java.util.List;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
public final class ExplicitOrdering<T> extends Ordering<T> implements Serializable {
|
|
private static final long serialVersionUID = 0;
|
|
final ImmutableMap<T, Integer> rankMap;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ExplicitOrdering(List<T> list) {
|
|
this(Maps.indexMap(list));
|
|
}
|
|
|
|
ExplicitOrdering(ImmutableMap<T, Integer> immutableMap) {
|
|
this.rankMap = immutableMap;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Ordering, java.util.Comparator
|
|
public int compare(T t, T t2) {
|
|
return rank(t) - rank(t2);
|
|
}
|
|
|
|
private int rank(T t) {
|
|
Integer num = this.rankMap.get(t);
|
|
if (num == null) {
|
|
throw new Ordering.IncomparableValueException(t);
|
|
}
|
|
return num.intValue();
|
|
}
|
|
|
|
@Override // java.util.Comparator
|
|
public boolean equals(@CheckForNull Object obj) {
|
|
if (obj instanceof ExplicitOrdering) {
|
|
return this.rankMap.equals(((ExplicitOrdering) obj).rankMap);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.rankMap.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
String valueOf = String.valueOf(this.rankMap.keySet());
|
|
return new StringBuilder(String.valueOf(valueOf).length() + 19).append("Ordering.explicit(").append(valueOf).append(")").toString();
|
|
}
|
|
}
|