Record Class TreeResult.Violation

java.lang.Object
java.lang.Record
cloud.opencode.base.tree.result.TreeResult.Violation
Record Components:
field - the field name that violated | 违规的字段名
message - the violation message | 违规消息
code - the violation code | 违规代码
severity - the violation severity | 违规严重程度
value - the invalid value | 无效值
Enclosing interface:
TreeResult<T>

public static record TreeResult.Violation(String field, String message, String code, TreeResult.Violation.Severity severity, Object value) extends Record
Violation 违规

Represents a validation violation with details about the error.

表示带有错误详情的验证违规。

Since:
JDK 25, opencode-base-tree V1.0.0
Author:
Leon Soo
  • Constructor Details

  • Method Details

    • of

      public static TreeResult.Violation of(String message)
      Create a simple violation 创建简单违规
      Parameters:
      message - the violation message | 违规消息
      Returns:
      the violation | 违规
    • of

      public static TreeResult.Violation of(String field, String message)
      Create a violation with field 创建带字段的违规
      Parameters:
      field - the field name | 字段名
      message - the violation message | 违规消息
      Returns:
      the violation | 违规
    • of

      public static TreeResult.Violation of(String field, String message, String code)
      Create a violation with field and code 创建带字段和代码的违规
      Parameters:
      field - the field name | 字段名
      message - the violation message | 违规消息
      code - the violation code | 违规代码
      Returns:
      the violation | 违规
    • error

      public static TreeResult.Violation error(String field, String message)
      Create an error violation 创建错误违规
      Parameters:
      field - the field name | 字段名
      message - the violation message | 违规消息
      Returns:
      the violation | 违规
    • warning

      public static TreeResult.Violation warning(String field, String message)
      Create a warning violation 创建警告违规
      Parameters:
      field - the field name | 字段名
      message - the violation message | 违规消息
      Returns:
      the violation | 违规
    • info

      public static TreeResult.Violation info(String field, String message)
      Create an info violation 创建信息违规
      Parameters:
      field - the field name | 字段名
      message - the violation message | 违规消息
      Returns:
      the violation | 违规
    • withValue

      public static TreeResult.Violation withValue(String field, String message, Object value)
      Create a violation with value 创建带值的违规
      Parameters:
      field - the field name | 字段名
      message - the violation message | 违规消息
      value - the invalid value | 无效值
      Returns:
      the violation | 违规
    • isError

      public boolean isError()
      Check if this is an error 检查是否为错误
      Returns:
      true if error | 如果为错误返回true
    • isWarning

      public boolean isWarning()
      Check if this is a warning 检查是否为警告
      Returns:
      true if warning | 如果为警告返回true
    • isInfo

      public boolean isInfo()
      Check if this is info 检查是否为信息
      Returns:
      true if info | 如果为信息返回true
    • toString

      public 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.
    • field

      public String field()
      Returns the value of the field record component.
      Returns:
      the value of the field record component
    • message

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

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

      public TreeResult.Violation.Severity severity()
      Returns the value of the severity record component.
      Returns:
      the value of the severity record component
    • value

      public Object value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component