Rabbit-R1/android (non root)/java/sources/com/google/common/hash/AbstractCompositeHashFunction.java
2024-05-21 17:08:36 -04:00

168 lines
6.2 KiB
Java

package com.google.common.hash;
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
@Immutable
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
abstract class AbstractCompositeHashFunction extends AbstractHashFunction {
private static final long serialVersionUID = 0;
final HashFunction[] functions;
abstract HashCode makeHash(Hasher[] hasherArr);
/* JADX INFO: Access modifiers changed from: package-private */
public AbstractCompositeHashFunction(HashFunction... hashFunctionArr) {
for (HashFunction hashFunction : hashFunctionArr) {
Preconditions.checkNotNull(hashFunction);
}
this.functions = hashFunctionArr;
}
@Override // com.google.common.hash.HashFunction
public Hasher newHasher() {
int length = this.functions.length;
Hasher[] hasherArr = new Hasher[length];
for (int i = 0; i < length; i++) {
hasherArr[i] = this.functions[i].newHasher();
}
return fromHashers(hasherArr);
}
@Override // com.google.common.hash.AbstractHashFunction, com.google.common.hash.HashFunction
public Hasher newHasher(int i) {
Preconditions.checkArgument(i >= 0);
int length = this.functions.length;
Hasher[] hasherArr = new Hasher[length];
for (int i2 = 0; i2 < length; i2++) {
hasherArr[i2] = this.functions[i2].newHasher(i);
}
return fromHashers(hasherArr);
}
private Hasher fromHashers(final Hasher[] hasherArr) {
return new Hasher() { // from class: com.google.common.hash.AbstractCompositeHashFunction.1
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putByte(byte b) {
for (Hasher hasher : hasherArr) {
hasher.putByte(b);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putBytes(byte[] bArr) {
for (Hasher hasher : hasherArr) {
hasher.putBytes(bArr);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putBytes(byte[] bArr, int i, int i2) {
for (Hasher hasher : hasherArr) {
hasher.putBytes(bArr, i, i2);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putBytes(ByteBuffer byteBuffer) {
int position = byteBuffer.position();
for (Hasher hasher : hasherArr) {
Java8Compatibility.position(byteBuffer, position);
hasher.putBytes(byteBuffer);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putShort(short s) {
for (Hasher hasher : hasherArr) {
hasher.putShort(s);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putInt(int i) {
for (Hasher hasher : hasherArr) {
hasher.putInt(i);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putLong(long j) {
for (Hasher hasher : hasherArr) {
hasher.putLong(j);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putFloat(float f) {
for (Hasher hasher : hasherArr) {
hasher.putFloat(f);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putDouble(double d) {
for (Hasher hasher : hasherArr) {
hasher.putDouble(d);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putBoolean(boolean z) {
for (Hasher hasher : hasherArr) {
hasher.putBoolean(z);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putChar(char c) {
for (Hasher hasher : hasherArr) {
hasher.putChar(c);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putUnencodedChars(CharSequence charSequence) {
for (Hasher hasher : hasherArr) {
hasher.putUnencodedChars(charSequence);
}
return this;
}
@Override // com.google.common.hash.Hasher, com.google.common.hash.PrimitiveSink
public Hasher putString(CharSequence charSequence, Charset charset) {
for (Hasher hasher : hasherArr) {
hasher.putString(charSequence, charset);
}
return this;
}
@Override // com.google.common.hash.Hasher
public <T> Hasher putObject(@ParametricNullness T t, Funnel<? super T> funnel) {
for (Hasher hasher : hasherArr) {
hasher.putObject(t, funnel);
}
return this;
}
@Override // com.google.common.hash.Hasher
public HashCode hash() {
return AbstractCompositeHashFunction.this.makeHash(hasherArr);
}
};
}
}