mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 10:27:17 +01:00
321 lines
11 KiB
Java
321 lines
11 KiB
Java
package com.google.common.base;
|
|
|
|
import androidx.biometric.ErrorUtils$$ExternalSyntheticOutline0;
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import com.google.common.annotations.GwtCompatible;
|
|
import com.google.common.annotations.GwtIncompatible;
|
|
import com.google.common.annotations.J2ktIncompatible;
|
|
import java.io.Serializable;
|
|
import java.util.Map;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@GwtCompatible
|
|
/* loaded from: classes8.dex */
|
|
public final class Functions {
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class ConstantFunction<E> implements Function<Object, E>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
|
|
@ParametricNullness
|
|
private final E value;
|
|
|
|
public ConstantFunction(@ParametricNullness E e) {
|
|
this.value = e;
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
@ParametricNullness
|
|
public E apply(Object obj) {
|
|
return this.value;
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof ConstantFunction) {
|
|
return Objects.equal(this.value, ((ConstantFunction) obj).value);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
E e = this.value;
|
|
if (e == null) {
|
|
return 0;
|
|
}
|
|
return e.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(new StringBuilder("Functions.constant("), MarkdownConstants.RIGHT_PARENTHESIS, this.value);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class ForMapWithDefault<K, V> implements Function<K, V>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
|
|
@ParametricNullness
|
|
final V defaultValue;
|
|
final Map<K, ? extends V> map;
|
|
|
|
public ForMapWithDefault(Map<K, ? extends V> map, @ParametricNullness V v) {
|
|
this.map = (Map) Preconditions.checkNotNull(map);
|
|
this.defaultValue = v;
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
@ParametricNullness
|
|
public V apply(@ParametricNullness K k) {
|
|
V v = this.map.get(k);
|
|
return (v != null || this.map.containsKey(k)) ? (V) NullnessCasts.uncheckedCastNullableTToT(v) : this.defaultValue;
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof ForMapWithDefault) {
|
|
ForMapWithDefault forMapWithDefault = (ForMapWithDefault) obj;
|
|
if (this.map.equals(forMapWithDefault.map) && Objects.equal(this.defaultValue, forMapWithDefault.defaultValue)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Objects.hashCode(this.map, this.defaultValue);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder("Functions.forMap(");
|
|
sb.append(this.map);
|
|
sb.append(", defaultValue=");
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(sb, MarkdownConstants.RIGHT_PARENTHESIS, this.defaultValue);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class FunctionComposition<A, B, C> implements Function<A, C>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
private final Function<A, ? extends B> f;
|
|
private final Function<B, C> g;
|
|
|
|
public FunctionComposition(Function<B, C> function, Function<A, ? extends B> function2) {
|
|
this.g = (Function) Preconditions.checkNotNull(function);
|
|
this.f = (Function) Preconditions.checkNotNull(function2);
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
@ParametricNullness
|
|
public C apply(@ParametricNullness A a2) {
|
|
return (C) this.g.apply(this.f.apply(a2));
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof FunctionComposition) {
|
|
FunctionComposition functionComposition = (FunctionComposition) obj;
|
|
if (this.f.equals(functionComposition.f) && this.g.equals(functionComposition.g)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.g.hashCode() ^ this.f.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return this.g + MarkdownConstants.LEFT_PARENTHESIS + this.f + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class FunctionForMapNoDefault<K, V> implements Function<K, V>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
final Map<K, V> map;
|
|
|
|
public FunctionForMapNoDefault(Map<K, V> map) {
|
|
this.map = (Map) Preconditions.checkNotNull(map);
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
@ParametricNullness
|
|
public V apply(@ParametricNullness K k) {
|
|
V v = this.map.get(k);
|
|
Preconditions.checkArgument(v != null || this.map.containsKey(k), "Key '%s' not present in map", k);
|
|
return (V) NullnessCasts.uncheckedCastNullableTToT(v);
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof FunctionForMapNoDefault) {
|
|
return this.map.equals(((FunctionForMapNoDefault) obj).map);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.map.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(new StringBuilder("Functions.forMap("), this.map, MarkdownConstants.RIGHT_PARENTHESIS);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class SupplierFunction<F, T> implements Function<F, T>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
private final Supplier<T> supplier;
|
|
|
|
private SupplierFunction(Supplier<T> supplier) {
|
|
this.supplier = (Supplier) Preconditions.checkNotNull(supplier);
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
@ParametricNullness
|
|
public T apply(@ParametricNullness F f) {
|
|
return this.supplier.get();
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof SupplierFunction) {
|
|
return this.supplier.equals(((SupplierFunction) obj).supplier);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.supplier.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return "Functions.forSupplier(" + this.supplier + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum ToStringFunction implements Function<Object, String> {
|
|
INSTANCE;
|
|
|
|
@Override // com.google.common.base.Function
|
|
public String apply(Object obj) {
|
|
Preconditions.checkNotNull(obj);
|
|
return obj.toString();
|
|
}
|
|
|
|
@Override // java.lang.Enum
|
|
public String toString() {
|
|
return "Functions.toStringFunction()";
|
|
}
|
|
}
|
|
|
|
private Functions() {
|
|
}
|
|
|
|
public static <A, B, C> Function<A, C> compose(Function<B, C> function, Function<A, ? extends B> function2) {
|
|
return new FunctionComposition(function, function2);
|
|
}
|
|
|
|
public static <E> Function<Object, E> constant(@ParametricNullness E e) {
|
|
return new ConstantFunction(e);
|
|
}
|
|
|
|
public static <K, V> Function<K, V> forMap(Map<K, V> map) {
|
|
return new FunctionForMapNoDefault(map);
|
|
}
|
|
|
|
public static <T> Function<T, Boolean> forPredicate(Predicate<T> predicate) {
|
|
return new PredicateFunction(predicate);
|
|
}
|
|
|
|
public static <F, T> Function<F, T> forSupplier(Supplier<T> supplier) {
|
|
return new SupplierFunction(supplier);
|
|
}
|
|
|
|
public static <E> Function<E, E> identity() {
|
|
return IdentityFunction.INSTANCE;
|
|
}
|
|
|
|
public static Function<Object, String> toStringFunction() {
|
|
return ToStringFunction.INSTANCE;
|
|
}
|
|
|
|
public static <K, V> Function<K, V> forMap(Map<K, ? extends V> map, @ParametricNullness V v) {
|
|
return new ForMapWithDefault(map, v);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PredicateFunction<T> implements Function<T, Boolean>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
private final Predicate<T> predicate;
|
|
|
|
private PredicateFunction(Predicate<T> predicate) {
|
|
this.predicate = (Predicate) Preconditions.checkNotNull(predicate);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // com.google.common.base.Function
|
|
public Boolean apply(@ParametricNullness T t) {
|
|
return Boolean.valueOf(this.predicate.apply(t));
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof PredicateFunction) {
|
|
return this.predicate.equals(((PredicateFunction) obj).predicate);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.predicate.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return "Functions.forPredicate(" + this.predicate + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // com.google.common.base.Function
|
|
public /* bridge */ /* synthetic */ Boolean apply(@ParametricNullness Object obj) {
|
|
return apply((PredicateFunction<T>) obj);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum IdentityFunction implements Function<Object, Object> {
|
|
INSTANCE;
|
|
|
|
@Override // java.lang.Enum
|
|
public String toString() {
|
|
return "Functions.identity()";
|
|
}
|
|
|
|
@Override // com.google.common.base.Function
|
|
public Object apply(Object obj) {
|
|
return obj;
|
|
}
|
|
}
|
|
}
|