Package org.projectnessie.versioned
Class Hash
java.lang.Object
org.projectnessie.versioned.Hash
- All Implemented Interfaces:
Ref
Describes a specific point in time/history. Internally is a binary value but a string
representation is available.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.projectnessie.nessie.relocated.protobuf.ByteStringasBytes()Gets the bytes representation of the hash.abstract StringasString()Generates a string representation of the hash suitable to be used withof(String).abstract intnibbleAt(int nibbleIndex) Retrieve the nibble (4 bit part) at the given index.static HashCreates a hash instance from its string representation.static Hashof(org.projectnessie.nessie.relocated.protobuf.ByteString bytes) Creates a hash instance from its bytes' representation.abstract intsize()Return the size of the hash in bytes.toString()
-
Constructor Details
-
Hash
public Hash()
-
-
Method Details
-
asString
Generates a string representation of the hash suitable to be used withof(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
Creates a hash instance from its string representation.- Parameters:
hash- the string representation of the hash- Returns:
- a
Hashinstance - Throws:
IllegalArgumentException- ifhashis not a valid representation of a hashNullPointerException- ifhashisnull
-
of
Creates a hash instance from its bytes' representation.- Parameters:
bytes- the bytes' representation of the hash- Returns:
- a
Hashinstance - Throws:
NullPointerException- ifhashisnull
-
toString
-