Class ConstraintViolationImpl<T>

    • Method Detail

      • getMessage

        public final String getMessage()
        Specified by:
        getMessage in interface ConstraintViolation<T>
        Returns:
        the interpolated error message for this constraint violation
      • getRootBean

        public final T getRootBean()
        Description copied from interface: ConstraintViolation
        Returns the root bean being validated. For method validation, returns the object the method is executed on.

        Returns null when:

        Specified by:
        getRootBean in interface ConstraintViolation<T>
        Returns:
        the validated object, the object hosting the validated element or null
      • getRootBeanClass

        public final Class<T> getRootBeanClass()
        Description copied from interface: ConstraintViolation
        Returns the class of the root bean being validated. For method validation, this is the object class the method is executed on. For constructor validation, this is the class the constructor is declared on.
        Specified by:
        getRootBeanClass in interface ConstraintViolation<T>
        Returns:
        the class of the root bean or of the object hosting the validated element
      • getLeafBean

        public final Object getLeafBean()
        Description copied from interface: ConstraintViolation
        Returns:
        • the bean instance the constraint is applied on if it is a bean constraint
        • the bean instance hosting the property the constraint is applied on if it is a property constraint or a container element constraint hosted on a property
        • null when the ConstraintViolation is returned after calling Validator.validateValue(Class, String, Object, Class[])
        • the object the method is executed on if it is a method parameter, cross-parameter or return value constraint or a container element constraint hosted on a method parameter or return value
        • null if it is a constructor parameter or cross-parameter constraint or a container element constraint hosted on a constructor parameter
        • the object the constructor has created if it is a constructor return value constraint
        Specified by:
        getLeafBean in interface ConstraintViolation<T>
        Returns:
        the leaf bean
      • getInvalidValue

        public final Object getInvalidValue()
        Description copied from interface: ConstraintViolation
        Returns the value failing to pass the constraint. For cross-parameter constraints, an Object[] representing the method invocation arguments is returned.
        Specified by:
        getInvalidValue in interface ConstraintViolation<T>
        Returns:
        the value failing to pass the constraint
      • unwrap

        public <C> C unwrap​(Class<C> type)
        Description copied from interface: ConstraintViolation
        Returns an instance of the specified type allowing access to provider-specific APIs. If the Jakarta Bean Validation provider implementation does not support the specified class, ValidationException is thrown.
        Specified by:
        unwrap in interface ConstraintViolation<T>
        Type Parameters:
        C - the type of the object to be returned
        Parameters:
        type - the class of the object to be returned
        Returns:
        an instance of the specified class
      • getExecutableParameters

        public Object[] getExecutableParameters()
        Description copied from interface: ConstraintViolation
        Returns an Object[] representing the constructor or method invocation arguments if the ConstraintViolation is returned after validating the method or constructor parameters. Returns null otherwise.
        Specified by:
        getExecutableParameters in interface ConstraintViolation<T>
        Returns:
        parameters of the method or constructor invocation or null
      • getExecutableReturnValue

        public Object getExecutableReturnValue()
        Description copied from interface: ConstraintViolation
        Returns the return value of the constructor or method invocation if the ConstraintViolation is returned after validating the method or constructor return value.

        Returns null if the method has no return value. Returns null otherwise.

        Specified by:
        getExecutableReturnValue in interface ConstraintViolation<T>
        Returns:
        the method or constructor return value or null
      • equals

        public boolean equals​(Object o)
        IMPORTANT - some behaviour of Validator depends on the correct implementation of this equals method! (HF)

        messageParameters, expressionVariables and dynamicPayload are not taken into account for equality. These variables solely enrich the actual Constraint Violation with additional information e.g how we actually got to this CV.

        Overrides:
        equals in class Object
        Returns:
        true if the two ConstraintViolation's are considered equals; false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object