mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-04 03:28:54 +01:00
219 lines
7.3 KiB
Java
219 lines
7.3 KiB
Java
package com.google.common.hash;
|
|
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import com.google.common.annotations.Beta;
|
|
import com.google.common.base.Preconditions;
|
|
import java.io.InvalidObjectException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.Serializable;
|
|
import java.nio.charset.Charset;
|
|
import java.util.Iterator;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Beta
|
|
/* loaded from: classes8.dex */
|
|
public final class Funnels {
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum IntegerFunnel implements Funnel<Integer> {
|
|
INSTANCE;
|
|
|
|
@Override // com.google.common.hash.Funnel
|
|
public void funnel(Integer num, PrimitiveSink primitiveSink) {
|
|
primitiveSink.putInt(num.intValue());
|
|
}
|
|
|
|
@Override // java.lang.Enum
|
|
public String toString() {
|
|
return "Funnels.integerFunnel()";
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum LongFunnel implements Funnel<Long> {
|
|
INSTANCE;
|
|
|
|
@Override // com.google.common.hash.Funnel
|
|
public void funnel(Long l, PrimitiveSink primitiveSink) {
|
|
primitiveSink.putLong(l.longValue());
|
|
}
|
|
|
|
@Override // java.lang.Enum
|
|
public String toString() {
|
|
return "Funnels.longFunnel()";
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class SequentialFunnel<E> implements Funnel<Iterable<? extends E>> {
|
|
private final Funnel<E> elementFunnel;
|
|
|
|
public SequentialFunnel(Funnel<E> funnel) {
|
|
this.elementFunnel = (Funnel) Preconditions.checkNotNull(funnel);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof SequentialFunnel) {
|
|
return this.elementFunnel.equals(((SequentialFunnel) obj).elementFunnel);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.hash.Funnel
|
|
public void funnel(Iterable<? extends E> iterable, PrimitiveSink primitiveSink) {
|
|
Iterator<? extends E> it2 = iterable.iterator();
|
|
while (it2.hasNext()) {
|
|
this.elementFunnel.funnel(it2.next(), primitiveSink);
|
|
}
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.elementFunnel.hashCode() ^ SequentialFunnel.class.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return "Funnels.sequentialFunnel(" + this.elementFunnel + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
}
|
|
|
|
private Funnels() {
|
|
}
|
|
|
|
public static OutputStream asOutputStream(PrimitiveSink primitiveSink) {
|
|
return new SinkAsStream(primitiveSink);
|
|
}
|
|
|
|
public static Funnel<byte[]> byteArrayFunnel() {
|
|
return ByteArrayFunnel.INSTANCE;
|
|
}
|
|
|
|
public static Funnel<Integer> integerFunnel() {
|
|
return IntegerFunnel.INSTANCE;
|
|
}
|
|
|
|
public static Funnel<Long> longFunnel() {
|
|
return LongFunnel.INSTANCE;
|
|
}
|
|
|
|
public static <E> Funnel<Iterable<? extends E>> sequentialFunnel(Funnel<E> funnel) {
|
|
return new SequentialFunnel(funnel);
|
|
}
|
|
|
|
public static Funnel<CharSequence> stringFunnel(Charset charset) {
|
|
return new StringCharsetFunnel(charset);
|
|
}
|
|
|
|
public static Funnel<CharSequence> unencodedCharsFunnel() {
|
|
return UnencodedCharsFunnel.INSTANCE;
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum ByteArrayFunnel implements Funnel<byte[]> {
|
|
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);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class StringCharsetFunnel implements Funnel<CharSequence> {
|
|
private final Charset charset;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class SerializedForm implements Serializable {
|
|
private static final long serialVersionUID = 0;
|
|
private final String charsetCanonicalName;
|
|
|
|
public SerializedForm(Charset charset) {
|
|
this.charsetCanonicalName = charset.name();
|
|
}
|
|
|
|
private Object readResolve() {
|
|
return Funnels.stringFunnel(Charset.forName(this.charsetCanonicalName));
|
|
}
|
|
}
|
|
|
|
public StringCharsetFunnel(Charset charset) {
|
|
this.charset = (Charset) Preconditions.checkNotNull(charset);
|
|
}
|
|
|
|
private void readObject(ObjectInputStream objectInputStream) throws InvalidObjectException {
|
|
throw new InvalidObjectException("Use SerializedForm");
|
|
}
|
|
|
|
public boolean equals(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();
|
|
}
|
|
|
|
public String toString() {
|
|
return "Funnels.stringFunnel(" + this.charset.name() + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
|
|
public Object writeReplace() {
|
|
return new SerializedForm(this.charset);
|
|
}
|
|
|
|
@Override // com.google.common.hash.Funnel
|
|
public void funnel(CharSequence charSequence, PrimitiveSink primitiveSink) {
|
|
primitiveSink.putString(charSequence, this.charset);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum UnencodedCharsFunnel implements Funnel<CharSequence> {
|
|
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);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class SinkAsStream extends OutputStream {
|
|
final PrimitiveSink sink;
|
|
|
|
public SinkAsStream(PrimitiveSink primitiveSink) {
|
|
this.sink = (PrimitiveSink) Preconditions.checkNotNull(primitiveSink);
|
|
}
|
|
|
|
public String toString() {
|
|
return "Funnels.asOutputStream(" + this.sink + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
|
|
@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);
|
|
}
|
|
}
|
|
}
|