Package com.google.common.hash
Class HashCode.BytesHashCode
java.lang.Object
com.google.common.hash.HashCode
com.google.common.hash.HashCode.BytesHashCode
- All Implemented Interfaces:
Serializable
- Enclosing class:
HashCode
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final byte[]
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
asBytes()
Returns the value of this hash code as a byte array.int
asInt()
Returns the first four bytes of this hashcode's bytes, converted to anint
value in little-endian order.long
asLong()
Returns the first eight bytes of this hashcode's bytes, converted to along
value in little-endian order.int
bits()
Returns the number of bits in this hash code; a positive multiple of 8.(package private) boolean
equalsSameBits
(HashCode that) Returns whether thisHashCode
and thatHashCode
have the same value, given that they have the same number of bits.(package private) byte[]
Returns a mutable view of the underlying bytes for the givenHashCode
if it is a byte-based hashcode.long
If this hashcode has enough bits, returnsasLong()
, otherwise returns along
value withasBytes()
as the least-significant bytes and0x00
as the remaining most-significant bytes.(package private) void
writeBytesToImpl
(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 Details
-
bytes
final byte[] bytes -
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
BytesHashCode
BytesHashCode(byte[] bytes)
-
-
Method Details
-
bits
public int bits()Description copied from class:HashCode
Returns the number of bits in this hash code; a positive multiple of 8. -
asBytes
public byte[] asBytes()Description copied from class:HashCode
Returns 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 thisHashCode
object or any other arrays returned by this method. -
asInt
public int asInt()Description copied from class:HashCode
Returns the first four bytes of this hashcode's bytes, converted to anint
value in little-endian order. -
asLong
public long asLong()Description copied from class:HashCode
Returns the first eight bytes of this hashcode's bytes, converted to along
value in little-endian order. -
padToLong
public long padToLong()Description copied from class:HashCode
If this hashcode has enough bits, returnsasLong()
, otherwise returns along
value withasBytes()
as the least-significant bytes and0x00
as the remaining most-significant bytes. -
writeBytesToImpl
void writeBytesToImpl(byte[] dest, int offset, int maxLength) - Specified by:
writeBytesToImpl
in classHashCode
-
getBytesInternal
byte[] getBytesInternal()Description copied from class:HashCode
Returns a mutable view of the underlying bytes for the givenHashCode
if 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:
getBytesInternal
in classHashCode
-
equalsSameBits
Description copied from class:HashCode
Returns whether thisHashCode
and thatHashCode
have the same value, given that they have the same number of bits.- Specified by:
equalsSameBits
in classHashCode
-