Package com.google.common.hash
Class HashCode.BytesHashCode
- java.lang.Object
-
- com.google.common.hash.HashCode
-
- com.google.common.hash.HashCode.BytesHashCode
-
-
Field Summary
Fields Modifier and Type Field Description (package private) byte[]bytesprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description BytesHashCode(byte[] bytes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]asBytes()Returns the value of this hash code as a byte array.intasInt()Returns the first four bytes of this hashcode's bytes, converted to anintvalue in little-endian order.longasLong()Returns the first eight bytes of this hashcode's bytes, converted to alongvalue in little-endian order.intbits()Returns the number of bits in this hash code; a positive multiple of 8.(package private) booleanequalsSameBits(HashCode that)Returns whether thisHashCodeand thatHashCodehave the same value, given that they have the same number of bits.(package private) byte[]getBytesInternal()Returns a mutable view of the underlying bytes for the givenHashCodeif it is a byte-based hashcode.longpadToLong()If this hashcode has enough bits, returnsasLong(), otherwise returns alongvalue withasBytes()as the least-significant bytes and0x00as the remaining most-significant bytes.(package private) voidwriteBytesToImpl(byte[] dest, int offset, int maxLength)-
Methods inherited from class com.google.common.hash.HashCode
equals, fromBytes, fromBytesNoCopy, fromInt, fromLong, fromString, hashCode, toString, writeBytesTo
-
-
-
-
Field Detail
-
bytes
final byte[] bytes
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
bits
public int bits()
Description copied from class:HashCodeReturns the number of bits in this hash code; a positive multiple of 8.
-
asBytes
public byte[] asBytes()
Description copied from class:HashCodeReturns the value of this hash code as a byte array. The caller may modify the byte array; changes to it will not be reflected in thisHashCodeobject or any other arrays returned by this method.
-
asInt
public int asInt()
Description copied from class:HashCodeReturns the first four bytes of this hashcode's bytes, converted to anintvalue in little-endian order.
-
asLong
public long asLong()
Description copied from class:HashCodeReturns the first eight bytes of this hashcode's bytes, converted to alongvalue in little-endian order.
-
padToLong
public long padToLong()
Description copied from class:HashCodeIf this hashcode has enough bits, returnsasLong(), otherwise returns alongvalue withasBytes()as the least-significant bytes and0x00as the remaining most-significant bytes.
-
writeBytesToImpl
void writeBytesToImpl(byte[] dest, int offset, int maxLength)- Specified by:
writeBytesToImplin classHashCode
-
getBytesInternal
byte[] getBytesInternal()
Description copied from class:HashCodeReturns a mutable view of the underlying bytes for the givenHashCodeif it is a byte-based hashcode. Otherwise it returnsHashCode.asBytes(). Do not mutate this array or else you will break the immutability contract ofHashCode.- Overrides:
getBytesInternalin classHashCode
-
equalsSameBits
boolean equalsSameBits(HashCode that)
Description copied from class:HashCodeReturns whether thisHashCodeand thatHashCodehave the same value, given that they have the same number of bits.- Specified by:
equalsSameBitsin classHashCode
-
-