package com.google.common.hash; import com.google.common.base.Preconditions; import java.io.OutputStream; import java.io.Serializable; import java.nio.charset.Charset; import java.util.Iterator; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public final class Funnels { private Funnels() { } public static Funnel byteArrayFunnel() { return ByteArrayFunnel.INSTANCE; } /* loaded from: classes3.dex */ private enum ByteArrayFunnel implements Funnel { INSTANCE; @Override // java.lang.Enum public String toString() { return "Funnels.byteArrayFunnel()"; } @Override // com.google.common.hash.Funnel public void funnel(byte[] bArr, PrimitiveSink primitiveSink) { primitiveSink.putBytes(bArr); } } public static Funnel unencodedCharsFunnel() { return UnencodedCharsFunnel.INSTANCE; } /* loaded from: classes3.dex */ private enum UnencodedCharsFunnel implements Funnel { INSTANCE; @Override // java.lang.Enum public String toString() { return "Funnels.unencodedCharsFunnel()"; } @Override // com.google.common.hash.Funnel public void funnel(CharSequence charSequence, PrimitiveSink primitiveSink) { primitiveSink.putUnencodedChars(charSequence); } } public static Funnel stringFunnel(Charset charset) { return new StringCharsetFunnel(charset); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static class StringCharsetFunnel implements Funnel, Serializable { private final Charset charset; StringCharsetFunnel(Charset charset) { this.charset = (Charset) Preconditions.checkNotNull(charset); } @Override // com.google.common.hash.Funnel public void funnel(CharSequence charSequence, PrimitiveSink primitiveSink) { primitiveSink.putString(charSequence, this.charset); } public String toString() { String name = this.charset.name(); return new StringBuilder(String.valueOf(name).length() + 22).append("Funnels.stringFunnel(").append(name).append(")").toString(); } public boolean equals(@CheckForNull Object obj) { if (obj instanceof StringCharsetFunnel) { return this.charset.equals(((StringCharsetFunnel) obj).charset); } return false; } public int hashCode() { return this.charset.hashCode() ^ StringCharsetFunnel.class.hashCode(); } Object writeReplace() { return new SerializedForm(this.charset); } /* loaded from: classes3.dex */ private static class SerializedForm implements Serializable { private static final long serialVersionUID = 0; private final String charsetCanonicalName; SerializedForm(Charset charset) { this.charsetCanonicalName = charset.name(); } private Object readResolve() { return Funnels.stringFunnel(Charset.forName(this.charsetCanonicalName)); } } } public static Funnel integerFunnel() { return IntegerFunnel.INSTANCE; } /* loaded from: classes3.dex */ private enum IntegerFunnel implements Funnel { INSTANCE; @Override // java.lang.Enum public String toString() { return "Funnels.integerFunnel()"; } @Override // com.google.common.hash.Funnel public void funnel(Integer num, PrimitiveSink primitiveSink) { primitiveSink.putInt(num.intValue()); } } public static Funnel> sequentialFunnel(Funnel funnel) { return new SequentialFunnel(funnel); } /* loaded from: classes3.dex */ private static class SequentialFunnel implements Funnel>, Serializable { private final Funnel elementFunnel; SequentialFunnel(Funnel funnel) { this.elementFunnel = (Funnel) Preconditions.checkNotNull(funnel); } @Override // com.google.common.hash.Funnel public void funnel(Iterable iterable, PrimitiveSink primitiveSink) { Iterator it = iterable.iterator(); while (it.hasNext()) { this.elementFunnel.funnel(it.next(), primitiveSink); } } public String toString() { String valueOf = String.valueOf(this.elementFunnel); return new StringBuilder(String.valueOf(valueOf).length() + 26).append("Funnels.sequentialFunnel(").append(valueOf).append(")").toString(); } public boolean equals(@CheckForNull Object obj) { if (obj instanceof SequentialFunnel) { return this.elementFunnel.equals(((SequentialFunnel) obj).elementFunnel); } return false; } public int hashCode() { return this.elementFunnel.hashCode() ^ SequentialFunnel.class.hashCode(); } } public static Funnel longFunnel() { return LongFunnel.INSTANCE; } /* loaded from: classes3.dex */ private enum LongFunnel implements Funnel { INSTANCE; @Override // java.lang.Enum public String toString() { return "Funnels.longFunnel()"; } @Override // com.google.common.hash.Funnel public void funnel(Long l, PrimitiveSink primitiveSink) { primitiveSink.putLong(l.longValue()); } } public static OutputStream asOutputStream(PrimitiveSink primitiveSink) { return new SinkAsStream(primitiveSink); } /* loaded from: classes3.dex */ private static class SinkAsStream extends OutputStream { final PrimitiveSink sink; SinkAsStream(PrimitiveSink primitiveSink) { this.sink = (PrimitiveSink) Preconditions.checkNotNull(primitiveSink); } @Override // java.io.OutputStream public void write(int i) { this.sink.putByte((byte) i); } @Override // java.io.OutputStream public void write(byte[] bArr) { this.sink.putBytes(bArr); } @Override // java.io.OutputStream public void write(byte[] bArr, int i, int i2) { this.sink.putBytes(bArr, i, i2); } public String toString() { String valueOf = String.valueOf(this.sink); return new StringBuilder(String.valueOf(valueOf).length() + 24).append("Funnels.asOutputStream(").append(valueOf).append(")").toString(); } } }