Package com.io7m.coffeepick.runtime
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRuntimeHash.BuilderBuilds instances of typeRuntimeHash.
-
Field Summary
-
Fields inherited from interface com.io7m.coffeepick.runtime.RuntimeHashType
ALGORITHM_PATTERN, HASH_PATTERN
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringalgorithm()static RuntimeHash.Builderbuilder()Creates a builder forRuntimeHash.static RuntimeHashcopyOf(RuntimeHashType instance)Creates an immutable copy of aRuntimeHashTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofRuntimeHashthat have equal attribute values.inthashCode()Computes a hash code from attributes:algorithm,value.static RuntimeHashof(java.lang.String algorithm, java.lang.String value)Construct a new immutableRuntimeHashinstance.java.lang.StringtoString()Prints the immutable valueRuntimeHashwith attribute values.java.lang.Stringvalue()RuntimeHashwithAlgorithm(java.lang.String value)Copy the current immutable object by setting a value for thealgorithmattribute.RuntimeHashwithValue(java.lang.String value)Copy the current immutable object by setting a value for thevalueattribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.coffeepick.runtime.RuntimeHashType
checkPreconditions
-
-
-
-
Method Detail
-
algorithm
public java.lang.String algorithm()
- Specified by:
algorithmin interfaceRuntimeHashType- Returns:
- The algorithm name (eg. "SHA-256")
-
value
public java.lang.String value()
- Specified by:
valuein interfaceRuntimeHashType- 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 thealgorithmattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for algorithm- Returns:
- A modified copy of the
thisobject
-
withValue
public final RuntimeHash withValue(java.lang.String value)
Copy the current immutable object by setting a value for thevalueattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for value- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofRuntimeHashthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:algorithm,value.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueRuntimeHashwith attribute values.- Overrides:
toStringin classjava.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 immutableRuntimeHashinstance.- Parameters:
algorithm- The value for thealgorithmattributevalue- The value for thevalueattribute- Returns:
- An immutable RuntimeHash instance
-
copyOf
public static RuntimeHash copyOf(RuntimeHashType instance)
Creates an immutable copy of aRuntimeHashTypevalue. 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 forRuntimeHash.RuntimeHash.builder() .setAlgorithm(String) // requiredalgorithm.setValue(String) // requiredvalue.build();- Returns:
- A new RuntimeHash builder
-
-