Record Class ValidationError

java.lang.Object
java.lang.Record
cloud.opencode.base.yml.schema.ValidationError

public record ValidationError(String path, String message, ValidationError.ErrorType type) extends Record
ValidationError - Represents a single validation error in YAML schema validation ValidationError - 表示 YAML 模式验证中的单个验证错误

An immutable record containing the path where the error occurred, a human-readable message, and the type of error.

一个不可变记录,包含错误发生的路径、人类可读的消息和错误类型。

Features | 主要功能:

  • Path-aware error reporting - 路径感知的错误报告
  • Typed error categorization - 类型化的错误分类
  • Immutable record type - 不可变记录类型

Usage Examples | 使用示例:

ValidationError error = new ValidationError(
    "server.port", "Expected Integer but got String", ErrorType.TYPE_MISMATCH
);
System.out.println(error.path());    // "server.port"
System.out.println(error.message()); // "Expected Integer but got String"
System.out.println(error.type());    // TYPE_MISMATCH

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
Since:
JDK 25, opencode-base-yml V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • ValidationError

      public ValidationError(String path, String message, ValidationError.ErrorType type)
      Creates an instance of a ValidationError record class.
      Parameters:
      path - the value for the path record component
      message - the value for the message record component
      type - the value for the type record component
  • Method Details

    • 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.
    • path

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

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

      Returns the value of the type record component.
      Returns:
      the value of the type record component