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

53 lines
1.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import com.google.common.base.Function;
import com.google.common.base.Objects;
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 ByFunctionOrdering<F, T> extends Ordering<F> implements Serializable {
private static final long serialVersionUID = 0;
final Function<F, ? extends T> function;
final Ordering<T> ordering;
/* JADX INFO: Access modifiers changed from: package-private */
public ByFunctionOrdering(Function<F, ? extends T> function, Ordering<T> ordering) {
this.function = (Function) Preconditions.checkNotNull(function);
this.ordering = (Ordering) Preconditions.checkNotNull(ordering);
}
@Override // com.google.common.collect.Ordering, java.util.Comparator
public final int compare(F f, F f2) {
return this.ordering.compare(this.function.apply(f), this.function.apply(f2));
}
@Override // java.util.Comparator
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ByFunctionOrdering)) {
return false;
}
ByFunctionOrdering byFunctionOrdering = (ByFunctionOrdering) obj;
return this.function.equals(byFunctionOrdering.function) && this.ordering.equals(byFunctionOrdering.ordering);
}
public final int hashCode() {
return Objects.hashCode(this.function, this.ordering);
}
public final String toString() {
String valueOf = String.valueOf(this.ordering);
String valueOf2 = String.valueOf(this.function);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 13 + String.valueOf(valueOf2).length());
sb.append(valueOf);
sb.append(".onResultOf(");
sb.append(valueOf2);
sb.append(")");
return sb.toString();
}
}