Record Class ModuleHash
java.lang.Object
java.lang.Record
com.netflix.module.ModuleHash
- Record Components:
type- the kind of content represented by the hashalgorithm- the lowercase digest algorithm namedigest- the encoded digest
Content identity of a resolved module or module patch.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe kind of module content represented by a hash. -
Constructor Summary
ConstructorsConstructorDescriptionModuleHash(ModuleHash.Type type, String algorithm, String digest) Validates and creates a module hash. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealgorithmrecord component.digest()Returns the value of thedigestrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static ModuleHashmoduleSha256(ModuleReference reference) Computes a SHA-256 identity from the names and bytes of a module's resources using theModuleHashesalgorithm in JDK 15.static ModuleHashParses thetype:algorithm:digestexternal form.static ModuleHashpatchSha256(Path path) Computes a SHA-256 identity for a patch archive or directory.static ModuleHashReads a hash in external form from a single-line file.toString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.voidWrites this hash in external form followed by a line terminator.
-
Constructor Details
-
ModuleHash
Validates and creates a module hash.
-
-
Method Details
-
parse
Parses thetype:algorithm:digestexternal form.- Parameters:
value- the external form- Returns:
- the parsed hash
- Throws:
IllegalArgumentException- if the value is not a valid module hash
-
moduleSha256
Computes a SHA-256 identity from the names and bytes of a module's resources using theModuleHashesalgorithm in JDK 15. Resource names are ordered, encoded as UTF-8, and followed directly by their content. Directory names participate in the hash, but are not opened so exploded modules can be hashed.- Parameters:
reference- the module to hash- Returns:
- the module hash
- Throws:
IOException- if the module or one of its resources cannot be read
-
patchSha256
Computes a SHA-256 identity for a patch archive or directory.- Parameters:
path- the patch archive or directory- Returns:
- the patch hash
- Throws:
IOException- if the path does not exist or cannot be read
-
read
Reads a hash in external form from a single-line file.- Parameters:
path- the file to read- Returns:
- the parsed hash
- Throws:
IOException- if the file cannot be read or does not contain one valid hash
-
write
Writes this hash in external form followed by a line terminator.- Parameters:
path- the destination file- Throws:
IOException- if the hash cannot be written
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
type
-
algorithm
-
digest
-