Package net.sourceforge.pmd.properties
Class NumericConstraints
java.lang.Object
net.sourceforge.pmd.properties.NumericConstraints
Common constraints for properties dealing with numbers.
- Author:
- Clément Fournier
- Since:
- 6.10.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <N extends Comparable<N>>
PropertyConstraint<N>above(N minInclusive) Requires the number to be greater than a lower bound.static <N extends Comparable<N>>
PropertyConstraint<N>below(N maxInclusive) Requires the number to be lower than an upper bound.static <N extends Comparable<N>>
PropertyConstraint<N>inRange(N minInclusive, N maxInclusive) Requires the number to be inside a range.static <N extends Number>
PropertyConstraint<N>positive()Requires the number to be strictly positive.
-
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
Requires the number to be greater than a lower bound.- Type Parameters:
N- Type of number- Returns:
- A range constraint
-
below
Requires the number to be lower than an upper bound.- Type Parameters:
N- Type of number- Returns:
- A range constraint
-
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
-