Class RuntimeHash

java.lang.Object
com.io7m.coffeepick.runtime.RuntimeHash
All Implemented Interfaces:
RuntimeHashType

public final class RuntimeHash
extends java.lang.Object
implements RuntimeHashType
A hash value.
  • Method Details

    • algorithm

      public java.lang.String algorithm()
      Specified by:
      algorithm in interface RuntimeHashType
      Returns:
      The algorithm name (eg. "SHA-256")
    • value

      public java.lang.String value()
      Specified by:
      value in interface RuntimeHashType
      Returns:
      The hexadecimal, ASCII-encoded hash value
    • withAlgorithm

      public final RuntimeHash withAlgorithm​(java.lang.String value)
      Copy the current immutable object by setting a value for the algorithm attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for algorithm
      Returns:
      A modified copy of the this object
    • withValue

      public final RuntimeHash withValue​(java.lang.String value)
      Copy the current immutable object by setting a value for the value attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for value
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals​(java.lang.Object another)
      This instance is equal to all instances of RuntimeHash that have equal attribute values.
      Overrides:
      equals in class java.lang.Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: algorithm, value.
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      hashCode value
    • toString

      public java.lang.String toString()
      Prints the immutable value RuntimeHash with attribute values.
      Overrides:
      toString in class java.lang.Object
      Returns:
      A string representation of the value
    • of

      public static RuntimeHash of​(java.lang.String algorithm, java.lang.String value)
      Construct a new immutable RuntimeHash instance.
      Parameters:
      algorithm - The value for the algorithm attribute
      value - The value for the value attribute
      Returns:
      An immutable RuntimeHash instance
    • copyOf

      public static RuntimeHash copyOf​(RuntimeHashType instance)
      Creates an immutable copy of a RuntimeHashType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable RuntimeHash instance
    • builder

      public static RuntimeHash.Builder builder()
      Creates a builder for RuntimeHash.
       RuntimeHash.builder()
          .setAlgorithm(String) // required algorithm
          .setValue(String) // required value
          .build();
       
      Returns:
      A new RuntimeHash builder