Class NumericIntervalConstraint

java.lang.Object
org.nuxeo.ecm.core.schema.types.constraints.AbstractConstraint
org.nuxeo.ecm.core.schema.types.constraints.NumericIntervalConstraint
All Implemented Interfaces:
Serializable, Constraint

public class NumericIntervalConstraint extends AbstractConstraint
This constraint ensures a numeric is in an interval.

This constraint can validate any Number.

Since:
7.1
See Also:
  • Constructor Details

    • NumericIntervalConstraint

      public NumericIntervalConstraint(Object min, boolean includingMin, Object max, boolean includingMax)
      Use null value to disable a bound.

      Bounds could be any object having toString representating a number.

      Parameters:
      min - The lower bound of the interval
      includingMin - true if the lower bound is included in the interval
      max - The upper bound of the interval
      includingMax - true if the upper bound is included in the interval
  • Method Details

    • validate

      public boolean validate(Object object)
      Description copied from interface: Constraint
      Validates the given object against this constraint.

      If some object is null. Constraint should return true while validating unless the constraint deals with nullable state.

      Parameters:
      object - the object to validate
      Returns:
      true if the object was successfully validated, false otherwise
    • getDescription

      public Constraint.Description getDescription()
      Here, value is :
      name = "NumericIntervalConstraint"
      parameters =
      • "Minimum" : -125.87 // only if bounded
      • "MinimumInclusive" : true // only if bounded
      • "Maximum" : 232 // only if bounded
      • "MaximumInclusive" : false // only if bounded
      Returns:
      The constraint description.
    • getMin

      public BigDecimal getMin()
    • getMax

      public BigDecimal getMax()
    • isIncludingMin

      public boolean isIncludingMin()
    • isIncludingMax

      public boolean isIncludingMax()
    • getErrorMessage

      public String getErrorMessage(Object invalidValue, Locale locale)
      Description copied from interface: Constraint
      Provides an error message to display when some invalid value does not match existing entity.
      Specified by:
      getErrorMessage in interface Constraint
      Overrides:
      getErrorMessage in class AbstractConstraint
      Parameters:
      invalidValue - The invalid value that don't match any entity.
      locale - The language in which the message should be generated.
      Returns:
      A message in the specified language or
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object