Record Class SBHash

java.lang.Object
java.lang.Record
com.io7m.sunburst.model.SBHash
Record Components:
algorithm - The hash algorithm
value - The hash value
All Implemented Interfaces:
Comparable<SBHash>

public record SBHash(SBHashAlgorithm algorithm, byte[] value) extends Record implements Comparable<SBHash>
A hash value.
  • Constructor Details

    • SBHash

      public SBHash(SBHashAlgorithm algorithm, byte[] value)
      Creates an instance of a SBHash record class.
      Parameters:
      algorithm - the value for the algorithm record component
      value - the value for the value record component
  • Method Details

    • compareTo

      public int compareTo(SBHash other)
      Specified by:
      compareTo in interface Comparable<SBHash>
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • hashOf

      public static SBHash hashOf(SBHashAlgorithm algorithm, InputStream stream) throws IOException
      Produce a hash of the given input stream.
      Parameters:
      algorithm - The algorithm
      stream - The input stream
      Returns:
      A hash value
      Throws:
      IOException - On errors
    • algorithm

      public SBHashAlgorithm algorithm()
      Returns the value of the algorithm record component.
      Returns:
      the value of the algorithm record component
    • value

      public byte[] value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component