Class HashCode.BytesHashCode

java.lang.Object
com.google.common.hash.HashCode
com.google.common.hash.HashCode.BytesHashCode
All Implemented Interfaces:
Serializable
Enclosing class:
HashCode

private static final class HashCode.BytesHashCode extends HashCode implements Serializable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final byte[]
     
    private static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BytesHashCode(byte[] bytes)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of this hash code as a byte array.
    int
    Returns the first four bytes of this hashcode's bytes, converted to an int value in little-endian order.
    long
    Returns the first eight bytes of this hashcode's bytes, converted to a long value in little-endian order.
    int
    Returns the number of bits in this hash code; a positive multiple of 8.
    (package private) boolean
    Returns whether this HashCode and that HashCode 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 given HashCode if it is a byte-based hashcode.
    long
    If this hashcode has enough bits, returns asLong(), otherwise returns a long value with asBytes() as the least-significant bytes and 0x00 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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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.
      Specified by:
      bits in class HashCode
    • 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 this HashCode object or any other arrays returned by this method.
      Specified by:
      asBytes in class HashCode
    • asInt

      public int asInt()
      Description copied from class: HashCode
      Returns the first four bytes of this hashcode's bytes, converted to an int value in little-endian order.
      Specified by:
      asInt in class HashCode
    • asLong

      public long asLong()
      Description copied from class: HashCode
      Returns the first eight bytes of this hashcode's bytes, converted to a long value in little-endian order.
      Specified by:
      asLong in class HashCode
    • padToLong

      public long padToLong()
      Description copied from class: HashCode
      If this hashcode has enough bits, returns asLong(), otherwise returns a long value with asBytes() as the least-significant bytes and 0x00 as the remaining most-significant bytes.
      Specified by:
      padToLong in class HashCode
    • writeBytesToImpl

      void writeBytesToImpl(byte[] dest, int offset, int maxLength)
      Specified by:
      writeBytesToImpl in class HashCode
    • getBytesInternal

      byte[] getBytesInternal()
      Description copied from class: HashCode
      Returns a mutable view of the underlying bytes for the given HashCode if it is a byte-based hashcode. Otherwise it returns HashCode.asBytes(). Do not mutate this array or else you will break the immutability contract of HashCode.
      Overrides:
      getBytesInternal in class HashCode
    • equalsSameBits

      boolean equalsSameBits(HashCode that)
      Description copied from class: HashCode
      Returns whether this HashCode and that HashCode have the same value, given that they have the same number of bits.
      Specified by:
      equalsSameBits in class HashCode