Record Class Checksum
java.lang.Object
java.lang.Record
cloud.opencode.base.io.checksum.Checksum
- Record Components:
algorithm- the algorithm name | 算法名称bytes- the checksum bytes | 校验和字节hex- the hex string | 十六进制字符串
Checksum Result
校验和结果
Immutable record representing a checksum calculation result. Contains algorithm name, raw bytes, and hex string representation.
表示校验和计算结果的不可变记录。 包含算法名称、原始字节和十六进制字符串表示。
Features | 主要功能:
- Algorithm identification - 算法标识
- Hex string format - 十六进制字符串格式
- Byte array access - 字节数组访问
Usage Examples | 使用示例:
Checksum checksum = OpenChecksum.calculateMd5(path);
String hex = checksum.hex();
byte[] bytes = checksum.bytes();
Security | 安全性:
- Thread-safe: Yes (immutable record with defensive copy) - 线程安全: 是(不可变记录,使用防御性拷贝)
- Null-safe: No, all fields validated non-null - 空值安全: 否,所有字段验证非null
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealgorithmrecord component.byte[]bytes()Gets a copy of the checksum bytes 获取校验和字节的副本booleanIndicates whether some other object is "equal to" this one.static ChecksumCreates a checksum from hex string 从十六进制字符串创建校验和inthashCode()Returns a hash code value for this object.hex()Returns the value of thehexrecord component.booleanChecks if this checksum matches another 检查此校验和是否与另一个匹配booleanChecks if this checksum matches a hex string 检查此校验和是否与十六进制字符串匹配toString()Returns a string representation of this record class.
-
Constructor Details
-
Checksum
Creates a checksum from bytes 从字节创建校验和- Parameters:
algorithm- the algorithm | 算法bytes- the checksum bytes | 校验和字节
-
Checksum
-
-
Method Details
-
bytes
public byte[] bytes()Gets a copy of the checksum bytes 获取校验和字节的副本- Returns:
- byte array copy | 字节数组副本
-
matches
Checks if this checksum matches another 检查此校验和是否与另一个匹配- Parameters:
other- the other checksum | 另一个校验和- Returns:
- true if match | 如果匹配返回true
-
matches
Checks if this checksum matches a hex string 检查此校验和是否与十六进制字符串匹配- Parameters:
hexString- the hex string | 十六进制字符串- Returns:
- true if match | 如果匹配返回true
-
fromHex
-
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). -
hashCode
-
toString
-
algorithm
-
hex
-