Class LengthConstraint
- java.lang.Object
-
- org.nuxeo.ecm.core.schema.types.constraints.AbstractConstraint
-
- org.nuxeo.ecm.core.schema.types.constraints.LengthConstraint
-
- All Implemented Interfaces:
Serializable
,Constraint
public class LengthConstraint extends AbstractConstraint
This constraints checks whether an object's String representation size is in some interval.This constraint's bounds are not strict (i.e. >= and <=).
- Since:
- 7.1
- See Also:
- Serialized Form
-
-
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
Constructors Constructor Description LengthConstraint(Object min, Object max)
For a fixed length, use min = max values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Constraint.Description
getDescription()
Here, value is :
name = "LengthConstraint"
parameters = "Minimum" : 5 // only is bounded "Maximum" : 10 // only if boundedString
getErrorMessage(Object invalidValue, Locale locale)
Provides an error message to display when some invalid value does not match existing entity.Long
getMax()
Long
getMin()
int
hashCode()
boolean
validate(Object object)
Validates the given object against this constraint.-
Methods inherited from class org.nuxeo.ecm.core.schema.types.constraints.AbstractConstraint
getMessageKey, getMessageString, toString
-
-
-
-
Constructor Detail
-
LengthConstraint
public LengthConstraint(Object min, Object max)
For a fixed length, use min = max values.Bounds could be any object having toString representating an integer.
- Parameters:
min
- Minimum length for the validated String, use a null value to get unbounded length.max
- Maximum length for the validated String, use a null value to get unbounded length.
-
-
Method Detail
-
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()
- Returns:
- The constraint description.
-
getMin
public Long getMin()
- Returns:
- This constraints minimum length if bounded, null otherwise.
- Since:
- 7.1
-
getMax
public Long getMax()
- Returns:
- This constraints maximum length if bounded, null otherwise.
- Since:
- 7.1
-
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 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
-
-