Class Hash

java.lang.Object
org.projectnessie.versioned.Hash
All Implemented Interfaces:
Ref

public abstract class Hash extends Object implements Ref
Describes a specific point in time/history. Internally is a binary value but a string representation is available.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.projectnessie.nessie.relocated.protobuf.ByteString
    Gets the bytes representation of the hash.
    abstract String
    Generates a string representation of the hash suitable to be used with of(String).
    abstract int
    nibbleAt(int nibbleIndex)
    Retrieve the nibble (4 bit part) at the given index.
    static Hash
    of(String hash)
    Creates a hash instance from its string representation.
    static Hash
    of(org.projectnessie.nessie.relocated.protobuf.ByteString bytes)
    Creates a hash instance from its bytes' representation.
    abstract int
    Return the size of the hash in bytes.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Hash

      public Hash()
  • Method Details

    • asString

      public abstract String asString()
      Generates a string representation of the hash suitable to be used with of(String).
    • asBytes

      public abstract org.projectnessie.nessie.relocated.protobuf.ByteString asBytes()
      Gets the bytes representation of the hash.
      Returns:
      the hash's bytes
    • nibbleAt

      public abstract int nibbleAt(int nibbleIndex)
      Retrieve the nibble (4 bit part) at the given index.

      This retrieves the 4-bit value of the hex character from asString() at the same index..

    • size

      public abstract int size()
      Return the size of the hash in bytes.
    • of

      public static Hash of(@Nonnull String hash)
      Creates a hash instance from its string representation.
      Parameters:
      hash - the string representation of the hash
      Returns:
      a Hash instance
      Throws:
      IllegalArgumentException - if hash is not a valid representation of a hash
      NullPointerException - if hash is null
    • of

      public static Hash of(@Nonnull org.projectnessie.nessie.relocated.protobuf.ByteString bytes)
      Creates a hash instance from its bytes' representation.
      Parameters:
      bytes - the bytes' representation of the hash
      Returns:
      a Hash instance
      Throws:
      NullPointerException - if hash is null
    • toString

      public String toString()
      Overrides:
      toString in class Object