Interface PropertyConstraint<T>

  • Type Parameters:
    T - Type of value to handle

    public interface PropertyConstraint<T>
    Validates the value of a property.

    This interface will change a lot with PMD 7.0.0, because of the switch to Java 8. Please use only the ready-made validators in NumericConstraints for now.

    Clément Fournier
    • Method Detail

      • test

        boolean test​(T value)
      • validate

        String validate​(T value)
        Returns a diagnostic message if the value has a problem. Otherwise returns an empty optional.
        value - The value to validate
        An optional diagnostic message
      • getConstraintDescription

        String getConstraintDescription()
        Returns a description of the constraint imposed by this validator on the values. E.g. "Should be positive", or "Should be one of A | B | C."

        This is used to generate documentation.

        A description of the constraint
      • toCollectionConstraint

        PropertyConstraint<Iterable<? extends T>> toCollectionConstraint()
        Returns a constraint that validates a collection of Ts by checking each component conforms to this conforms.
        A collection validator