Class HashCode.BytesHashCode

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    HashCode

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

      Fields 
      Modifier and Type Field Description
      (package private) byte[] bytes  
      private static long serialVersionUID  
    • 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.
      int asInt()
      Returns the first four bytes of this hashcode's bytes, converted to an int value in little-endian order.
      long asLong()
      Returns the first eight bytes of this hashcode's bytes, converted to a long 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 this HashCode and that HashCode have 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 given HashCode if it is a byte-based hashcode.
      long padToLong()
      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 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • bytes

        final byte[] bytes
    • Constructor Detail

      • BytesHashCode

        BytesHashCode​(byte[] bytes)
    • Method Detail

      • 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