Record Class FieldErrorNode.FlattenedError

java.lang.Object
java.lang.Record
name.martingeisse.grumpyjson.FieldErrorNode.FlattenedError
Record Components:
message - the error message
fieldPath - the field names, from root to leaf
Enclosing class:
FieldErrorNode

public static record FieldErrorNode.FlattenedError(String message, List<String> fieldPath) extends Record
This structure represents a single error, i.e. a leaf node, and contains the error message of the FieldErrorNode.Message node as well as the field path as a list of the field names of all FieldErrorNode.Field nodes on the way from the root to the message leaf node.

Since every FieldErrorNode.Siblings node allows for two different paths to take, a whole tree must be represented as a _list_ of flattened errors.

  • Constructor Details

    • FlattenedError

      public FlattenedError(String message, List<String> fieldPath)
      Constructor
      Parameters:
      message - the error message
      fieldPath - the field names, from root to leaf
    • FlattenedError

      public FlattenedError(String message, String... pathSegments)
      this constructor is very useful in unit tests
      Parameters:
      message - the error message
      pathSegments - the field names, from root to leaf
  • Method Details

    • getPathAsString

      public String getPathAsString()
      Returns the field path as a dot-separated string
      Returns:
      the field path
    • 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.
    • message

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

      public List<String> fieldPath()
      Returns the value of the fieldPath record component.
      Returns:
      the value of the fieldPath record component