Class ConstraintFailure


  • public final class ConstraintFailure
    extends java.lang.Object
    • Constructor Detail

      • ConstraintFailure

        public ConstraintFailure​(java.lang.String message,
                                 java.lang.String name,
                                 ConstraintFailure.PathElement[][] paths)
        Initialize a new ConstraintFailure instance. Queries that fail a check or unique constraint return a constraint failure.
        Parameters:
        message - Human-readable description of the constraint failure.
        name - Name of the failed constraint.
        paths - A list of paths where the constraint failure occurred.
    • Method Detail

      • createPath

        public static ConstraintFailure.PathElement[] createPath​(java.lang.Object... elements)
        Constructs a PathElement[] from the provided objects. Supported types are String and Integer.
        Parameters:
        elements - The String objects or Integer objects to use.
        Returns:
        A array of PathElement instances.
      • parse

        public static ConstraintFailure parse​(com.fasterxml.jackson.core.JsonParser parser)
                                       throws java.io.IOException
        Builds a ConstraintFailure instance from the provided JsonParser.
        Parameters:
        parser - The JsonParser to consume.
        Returns:
        A new ConstraintFailure instance.
        Throws:
        java.io.IOException - Thrown if an error is encountered while reading the parser.
      • getMessage

        public java.lang.String getMessage()
        Gets the constraint failure message.
        Returns:
        A string representation of the message.
      • getName

        public java.util.Optional<java.lang.String> getName()
        Gets the constraint failure name.
        Returns:
        A string representation of the name.
      • getPaths

        public java.util.Optional<ConstraintFailure.PathElement[][]> getPaths()
        Gets an optional path elements related to the constraint failure.
        Returns:
        An array of arrays of PathElements.
      • getPathStrings

        public java.util.Optional<java.util.List<java.lang.String>> getPathStrings()
        Gets a list of string representations of the constraint failure paths.
        Returns:
        A list of string representations of constraint failure paths.
      • pathsAreEqual

        public boolean pathsAreEqual​(ConstraintFailure otherFailure)
        Tests path equality with another ConstraintFailure.
        Parameters:
        otherFailure - The other ConstraintFailure.
        Returns:
        True if the paths are equal.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object