public abstract class AbstractConstraint extends Object implements Constraint
| Modifier and Type | Field and Description |
|---|---|
protected String |
classShortName |
protected Class<?> |
constraintOwningClass |
protected Object |
constraintParameter |
protected String |
constraintPropertyName |
protected MessageSource |
messageSource |
EXCEEDED_SUFFIX, INVALID_SUFFIX, NOT_PREFIX, NOTMET_SUFFIX, TOOBIG_SUFFIX, TOOLONG_SUFFIX, TOOSHORT_SUFFIX, TOOSMALL_SUFFIX| Constructor and Description |
|---|
AbstractConstraint() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkState() |
protected String |
getDefaultMessage(String code)
Returns the default message for the given message code in the
current locale.
|
Object |
getParameter() |
String |
getPropertyName() |
boolean |
isValid()
Return whether the constraint is valid for the owning class
|
protected abstract void |
processValidate(Object target,
Object propertyValue,
Errors errors) |
void |
rejectValue(Object target,
Errors errors,
String defaultMessageCode,
Object[] args) |
void |
rejectValue(Object target,
Errors errors,
String code,
Object[] args,
String defaultMessage) |
void |
rejectValue(Object target,
Errors errors,
String code,
String defaultMessage) |
void |
rejectValue(Object target,
Errors errors,
String defaultMessageCode,
String[] codes,
Object[] args) |
void |
rejectValue(Object target,
Errors errors,
String defaultMessageCode,
String code,
Object[] args) |
void |
rejectValueWithDefaultMessage(Object target,
Errors errors,
String defaultMessage,
String[] codes,
Object[] args) |
void |
setMessageSource(MessageSource source)
The message source to evaluate the default messages from
|
void |
setOwningClass(Class constraintOwningClass)
The class the constraint applies to
|
void |
setParameter(Object constraintParameter)
The parameter which the constraint is validated against.
|
void |
setPropertyName(String constraintPropertyName)
The name of the property the constraint applies to
|
protected boolean |
skipBlankValues() |
protected boolean |
skipNullValues() |
String |
toString() |
void |
validate(Object target,
Object propertyValue,
Errors errors)
Validate this constraint against a property value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, supportsprotected String constraintPropertyName
protected Class<?> constraintOwningClass
protected Object constraintParameter
protected String classShortName
protected MessageSource messageSource
public void setMessageSource(@Nonnull MessageSource source)
ConstraintsetMessageSource in interface Constraint@Nonnull public String getPropertyName()
getPropertyName in interface Constraintpublic void setOwningClass(@Nonnull Class constraintOwningClass)
ConstraintsetOwningClass in interface Constraintpublic void setPropertyName(@Nonnull String constraintPropertyName)
ConstraintsetPropertyName in interface ConstraintconstraintPropertyName - The constraintPropertyName to set.public void setParameter(@Nonnull Object constraintParameter)
ConstraintsetParameter in interface ConstraintconstraintParameter - The constraintParameter to set.@Nonnull public Object getParameter()
getParameter in interface Constraintprotected void checkState()
public void validate(@Nonnull Object target, @Nullable Object propertyValue, @Nonnull Errors errors)
Constraintvalidate in interface ConstraintpropertyValue - The property value to validateerrors - The errors instance to record errors againstprotected boolean skipNullValues()
protected boolean skipBlankValues()
public void rejectValue(@Nonnull Object target, @Nonnull Errors errors, String defaultMessageCode, Object[] args)
public void rejectValue(@Nonnull Object target, @Nonnull Errors errors, String defaultMessageCode, String code, Object[] args)
public void rejectValue(@Nonnull Object target, @Nonnull Errors errors, String defaultMessageCode, String[] codes, Object[] args)
public void rejectValueWithDefaultMessage(@Nonnull Object target, @Nonnull Errors errors, String defaultMessage, String[] codes, Object[] args)
public void rejectValue(@Nonnull Object target, @Nonnull Errors errors, String code, String defaultMessage)
public void rejectValue(@Nonnull Object target, @Nonnull Errors errors, String code, Object[] args, String defaultMessage)
protected String getDefaultMessage(String code)
code - The i18n message code to look up.protected abstract void processValidate(@Nonnull Object target, Object propertyValue, @Nonnull Errors errors)
public boolean isValid()
isValid in interface Constraint