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 class
RuntimeHash.Builder
Builds instances of typeRuntimeHash
. -
Field Summary
Fields inherited from interface com.io7m.coffeepick.runtime.RuntimeHashType
ALGORITHM_PATTERN, HASH_PATTERN
-
Method Summary
Modifier and Type Method Description java.lang.String
algorithm()
static RuntimeHash.Builder
builder()
Creates a builder forRuntimeHash
.static RuntimeHash
copyOf(RuntimeHashType instance)
Creates an immutable copy of aRuntimeHashType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofRuntimeHash
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:algorithm
,value
.static RuntimeHash
of(java.lang.String algorithm, java.lang.String value)
Construct a new immutableRuntimeHash
instance.java.lang.String
toString()
Prints the immutable valueRuntimeHash
with attribute values.java.lang.String
value()
RuntimeHash
withAlgorithm(java.lang.String value)
Copy the current immutable object by setting a value for thealgorithm
attribute.RuntimeHash
withValue(java.lang.String value)
Copy the current immutable object by setting a value for thevalue
attribute.
-
Method Details
-
algorithm
public java.lang.String algorithm()- Specified by:
algorithm
in interfaceRuntimeHashType
- Returns:
- The algorithm name (eg. "SHA-256")
-
value
public java.lang.String value()- Specified by:
value
in interfaceRuntimeHashType
- Returns:
- The hexadecimal, ASCII-encoded hash value
-
withAlgorithm
Copy the current immutable object by setting a value for thealgorithm
attribute. 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
this
object
-
withValue
Copy the current immutable object by setting a value for thevalue
attribute. 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
this
object
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofRuntimeHash
that have equal attribute values.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifthis
is equal toanother
instance
-
hashCode
public int hashCode()Computes a hash code from attributes:algorithm
,value
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueRuntimeHash
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
Construct a new immutableRuntimeHash
instance.- Parameters:
algorithm
- The value for thealgorithm
attributevalue
- The value for thevalue
attribute- Returns:
- An immutable RuntimeHash instance
-
copyOf
Creates an immutable copy of aRuntimeHashType
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
Creates a builder forRuntimeHash
.RuntimeHash.builder() .setAlgorithm(String) // required
algorithm
.setValue(String) // requiredvalue
.build();- Returns:
- A new RuntimeHash builder
-