package com.google.common.hash; import com.google.common.base.Preconditions; import java.io.Serializable; /* loaded from: classes.dex */ public abstract class HashCode { private static final char[] a = "0123456789abcdef".toCharArray(); private static final class BytesHashCode extends HashCode implements Serializable { final byte[] b; BytesHashCode(byte[] bArr) { Preconditions.a(bArr); this.b = bArr; } @Override // com.google.common.hash.HashCode public byte[] a() { return (byte[]) this.b.clone(); } @Override // com.google.common.hash.HashCode public int b() { Preconditions.b(this.b.length >= 4, "HashCode#asInt() requires >= 4 bytes (it only has %s bytes).", this.b.length); byte[] bArr = this.b; return ((bArr[3] & 255) << 24) | ((bArr[1] & 255) << 8) | (bArr[0] & 255) | ((bArr[2] & 255) << 16); } @Override // com.google.common.hash.HashCode public long c() { Preconditions.b(this.b.length >= 8, "HashCode#asLong() requires >= 8 bytes (it only has %s bytes).", this.b.length); return f(); } @Override // com.google.common.hash.HashCode public int d() { return this.b.length * 8; } @Override // com.google.common.hash.HashCode byte[] e() { return this.b; } public long f() { long j = this.b[0] & 255; for (int i = 1; i < Math.min(this.b.length, 8); i++) { j |= (this.b[i] & 255) << (i * 8); } return j; } @Override // com.google.common.hash.HashCode boolean a(HashCode hashCode) { if (this.b.length != hashCode.e().length) { return false; } int i = 0; boolean z = true; while (true) { byte[] bArr = this.b; if (i >= bArr.length) { return z; } z &= bArr[i] == hashCode.e()[i]; i++; } } } HashCode() { } static HashCode a(byte[] bArr) { return new BytesHashCode(bArr); } abstract boolean a(HashCode hashCode); public abstract byte[] a(); public abstract int b(); public abstract long c(); public abstract int d(); byte[] e() { return a(); } public final boolean equals(Object obj) { if (!(obj instanceof HashCode)) { return false; } HashCode hashCode = (HashCode) obj; return d() == hashCode.d() && a(hashCode); } public final int hashCode() { if (d() >= 32) { return b(); } byte[] e = e(); int i = e[0] & 255; for (int i2 = 1; i2 < e.length; i2++) { i |= (e[i2] & 255) << (i2 * 8); } return i; } public final String toString() { byte[] e = e(); StringBuilder sb = new StringBuilder(e.length * 2); for (byte b : e) { sb.append(a[(b >> 4) & 15]); sb.append(a[b & 15]); } return sb.toString(); } }