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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumViolation Severity 违规严重程度 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.final booleanIndicates whether some other object is "equal to" this one.static TreeResult.ViolationCreate an error violation 创建错误违规field()Returns the value of thefieldrecord component.final inthashCode()Returns a hash code value for this object.static TreeResult.ViolationCreate an info violation 创建信息违规booleanisError()Check if this is an error 检查是否为错误booleanisInfo()Check if this is info 检查是否为信息booleanCheck if this is a warning 检查是否为警告message()Returns the value of themessagerecord component.static TreeResult.ViolationCreate a simple violation 创建简单违规static TreeResult.ViolationCreate a violation with field 创建带字段的违规static TreeResult.ViolationCreate a violation with field and code 创建带字段和代码的违规severity()Returns the value of theseverityrecord component.toString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.static TreeResult.ViolationCreate a warning violation 创建警告违规static TreeResult.ViolationCreate a violation with value 创建带值的违规
-
Constructor Details
-
Violation
public Violation(String field, String message, String code, TreeResult.Violation.Severity severity, Object value) Compact constructor 紧凑构造函数
-
-
Method Details
-
of
Create a simple violation 创建简单违规- Parameters:
message- the violation message | 违规消息- Returns:
- the violation | 违规
-
of
Create a violation with field 创建带字段的违规- Parameters:
field- the field name | 字段名message- the violation message | 违规消息- Returns:
- the violation | 违规
-
of
Create a violation with field and code 创建带字段和代码的违规- Parameters:
field- the field name | 字段名message- the violation message | 违规消息code- the violation code | 违规代码- Returns:
- the violation | 违规
-
error
Create an error violation 创建错误违规- Parameters:
field- the field name | 字段名message- the violation message | 违规消息- Returns:
- the violation | 违规
-
warning
Create a warning violation 创建警告违规- Parameters:
field- the field name | 字段名message- the violation message | 违规消息- Returns:
- the violation | 违规
-
info
Create an info violation 创建信息违规- Parameters:
field- the field name | 字段名message- the violation message | 违规消息- Returns:
- the violation | 违规
-
withValue
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
-
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). -
field
-
message
-
code
-
severity
-
value
-