Class DateIntervalConstraint
java.lang.Object
org.nuxeo.ecm.core.schema.types.constraints.AbstractConstraint
org.nuxeo.ecm.core.schema.types.constraints.DateIntervalConstraint
- All Implemented Interfaces:
Serializable
,Constraint
This constraint ensures a date is in an interval.
This constraint can validate any Date
or Calendar
. This constraint also support Number
types
whose long value is recognised as number of milliseconds since January 1, 1970, 00:00:00 GMT. The constraint finally
supports String having YYYY-MM-DD format.
- Since:
- 7.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.schema.types.constraints.Constraint
Constraint.Description
-
Field Summary
Fields inherited from interface org.nuxeo.ecm.core.schema.types.constraints.Constraint
MESSAGES_BUNDLE, MESSAGES_DEFAULT_LANG, MESSAGES_KEY
-
Constructor Summary
ConstructorDescriptionDateIntervalConstraint
(Object minDate, boolean includingMin, Object maxDate, boolean includingMax) Use null value to disable a bound. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Here, value is :
name = "DateIntervalConstraint".getErrorMessage
(Object invalidValue, Locale locale) Provides an error message to display when some invalid value does not match existing entity.int
hashCode()
boolean
boolean
boolean
Validates the given object against this constraint.Methods inherited from class org.nuxeo.ecm.core.schema.types.constraints.AbstractConstraint
getMessageKey, getMessageString, toString
-
Constructor Details
-
DateIntervalConstraint
public DateIntervalConstraint(Object minDate, boolean includingMin, Object maxDate, boolean includingMax) Use null value to disable a bound.Bounds could be any
Date
orCalendar
. Bounds also supportNumber
types whose long value is recognised as number of milliseconds since January 1, 1970, 00:00:00 GMT. Bounds finally supports String having YYYY-MM-DD format.Invalid bound (wrong format) would be ignored with log warning.
- Parameters:
minDate
- The lower bound of the intervalincludingMin
- true if the lower bound is included in the intervalmaxDate
- The upper bound of the intervalincludingMax
- true if the upper bound is included in the interval
-
-
Method Details
-
validate
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
Here, value is :
name = "DateIntervalConstraint".
parameters =- "Minimum" : 2014-11-05 // only if bounded
- "MinimumInclusive" : true // only if bounded
- "Maximum" : 2014-11-25 // only if bounded
- "MaximumInclusive" : false // only if bounded
- Returns:
- The constraint description.
-
getMinTime
-
getMaxTime
-
isIncludingMin
public boolean isIncludingMin() -
isIncludingMax
public boolean isIncludingMax() -
getErrorMessage
Description copied from interface:Constraint
Provides an error message to display when some invalid value does not match existing entity.- Specified by:
getErrorMessage
in interfaceConstraint
- Overrides:
getErrorMessage
in classAbstractConstraint
- 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() -
equals
-