what-the-bank/sources/com/google/common/hash/ChecksumHashFunction.java

67 lines
2.4 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.hash;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.zip.Checksum;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private static final long serialVersionUID = 0;
private final int bits;
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final String toString;
/* JADX INFO: Access modifiers changed from: package-private */
public ChecksumHashFunction(ImmutableSupplier<? extends Checksum> immutableSupplier, int i, String str) {
this.checksumSupplier = (ImmutableSupplier) Preconditions.checkNotNull(immutableSupplier);
Preconditions.checkArgument(i == 32 || i == 64, "bits (%s) must be either 32 or 64", i);
this.bits = i;
this.toString = (String) Preconditions.checkNotNull(str);
}
@Override // com.google.common.hash.HashFunction
public final Hasher newHasher() {
return new ChecksumHasher(this.checksumSupplier.get());
}
/* loaded from: classes2.dex */
final class ChecksumHasher extends AbstractByteHasher {
private final Checksum checksum;
final ChecksumHashFunction this$0;
private ChecksumHasher(ChecksumHashFunction checksumHashFunction, Checksum checksum) {
this.this$0 = checksumHashFunction;
this.checksum = (Checksum) Preconditions.checkNotNull(checksum);
}
@Override // com.google.common.hash.AbstractByteHasher
protected final void update(byte b) {
this.checksum.update(b);
}
@Override // com.google.common.hash.AbstractByteHasher
protected final void update(byte[] bArr, int i, int i2) {
this.checksum.update(bArr, i, i2);
}
@Override // com.google.common.hash.Hasher
public final HashCode hash() {
long value = this.checksum.getValue();
if (this.this$0.bits == 32) {
return HashCode.fromInt((int) value);
}
return HashCode.fromLong(value);
}
}
public final String toString() {
return this.toString;
}
@Override // com.google.common.hash.HashFunction
public final int bits() {
return this.bits;
}
}