Class NumericConstraints

java.lang.Object
net.sourceforge.pmd.properties.NumericConstraints

public final class NumericConstraints extends Object
Common constraints for properties dealing with numbers.
Author:
Clément Fournier
Since:
6.10.0
See Also:
  • Method Details

    • inRange

      public static <N extends Comparable<N>> PropertyConstraint<N> inRange(N minInclusive, N maxInclusive)
      Requires the number to be inside a range.
      Type Parameters:
      N - Type of number
      Returns:
      A range constraint
    • above

      public static <N extends Comparable<N>> PropertyConstraint<N> above(N minInclusive)
      Requires the number to be greater than a lower bound.
      Type Parameters:
      N - Type of number
      Returns:
      A range constraint
    • below

      public static <N extends Comparable<N>> PropertyConstraint<N> below(N maxInclusive)
      Requires the number to be lower than an upper bound.
      Type Parameters:
      N - Type of number
      Returns:
      A range constraint
    • positive

      public static <N extends Number> PropertyConstraint<N> positive()
      Requires the number to be strictly positive. The int values of the number is used for comparison so there may be some unexpected behaviour with decimal numbers.

      Note: This constraint cannot be expressed in a XML ruleset.

      Type Parameters:
      N - Type of number
      Returns:
      A positivity constraint