Record Class EncryptedResult

java.lang.Object
java.lang.Record
cloud.opencode.base.web.crypto.EncryptedResult
Record Components:
code - the result code | 响应码
encryptedData - the encrypted data | 加密数据
algorithm - the encryption algorithm | 加密算法
timestamp - the timestamp | 时间戳
traceId - the trace ID | 追踪ID

public record EncryptedResult(String code, String encryptedData, String algorithm, Instant timestamp, String traceId) extends Record
Encrypted Result 加密响应

Response with encrypted data payload.

带加密数据负载的响应。

Features | 主要功能:

  • Immutable encrypted result record - 不可变加密结果记录
  • Algorithm and trace ID metadata - 算法和追踪ID元数据
  • Timestamp tracking - 时间戳跟踪

Usage Examples | 使用示例:

EncryptedResult result = EncryptedResult.of("00000", encData, "AES-GCM");
boolean ok = result.isSuccess();
String data = result.encryptedData();

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 是(不可变记录)
  • Null-safe: No (code and data should not be null) - 否(响应码和数据不应为null)
Since:
JDK 25, opencode-base-web V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • EncryptedResult

      public EncryptedResult(String code, String encryptedData, String algorithm, Instant timestamp, String traceId)
      Creates an instance of a EncryptedResult record class.
      Parameters:
      code - the value for the code record component
      encryptedData - the value for the encryptedData record component
      algorithm - the value for the algorithm record component
      timestamp - the value for the timestamp record component
      traceId - the value for the traceId record component
  • Method Details

    • of

      public static EncryptedResult of(String code, String encryptedData, String algorithm)
      Create encrypted result 创建加密响应
      Parameters:
      code - the result code | 响应码
      encryptedData - the encrypted data | 加密数据
      algorithm - the encryption algorithm | 加密算法
      Returns:
      the encrypted result | 加密响应
    • of

      public static EncryptedResult of(String code, String encryptedData, String algorithm, String traceId)
      Create encrypted result with trace ID 创建带追踪ID的加密响应
      Parameters:
      code - the result code | 响应码
      encryptedData - the encrypted data | 加密数据
      algorithm - the encryption algorithm | 加密算法
      traceId - the trace ID | 追踪ID
      Returns:
      the encrypted result | 加密响应
    • isSuccess

      public boolean isSuccess()
      Check if success 检查是否成功
      Returns:
      true if success | 如果成功返回true
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • code

      public String code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • encryptedData

      public String encryptedData()
      Returns the value of the encryptedData record component.
      Returns:
      the value of the encryptedData record component
    • algorithm

      public String algorithm()
      Returns the value of the algorithm record component.
      Returns:
      the value of the algorithm record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • traceId

      public String traceId()
      Returns the value of the traceId record component.
      Returns:
      the value of the traceId record component