|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.properties.spi.core.constraint.AbstractPropertyConstraint<T> de.smartics.properties.spi.core.constraint.jsr303.GenericPropertyConstraint<A,T>
A
- the constraint annotation.
T
- the type of the property that is validated.
public class GenericPropertyConstraint<A extends Annotation,T>
Generic wrapper for JSR-303 constraints.
Constructor Summary | |
---|---|
GenericPropertyConstraint(A constraintAnnotation, Class<?> propertyType) Convenience constructor if the validator can be derived from the constraintAnnotation . |
|
GenericPropertyConstraint(javax.validation.ConstraintValidator<A,T> validator, A constraintAnnotation) Default constructor. |
Method Summary | |
---|---|
String |
getDescription(Locale locale) Returns a localized description of the defined constraints. |
String |
getViolationMessage(Locale locale, Object actualValue) Returns a localized description of the violation message adding the actual value. |
boolean |
isMandatoryConstraint() Determines if the constraint is a check that evaluates if a property is present or not and fails if a value is not present. |
boolean |
isValid(T value, Class<?> group) Checks if the given value is valid only if the constraint is in the given group. |
Methods inherited from class de.smartics.properties.spi.core.constraint.AbstractPropertyConstraint |
---|
getDescription, isValid, toString, validate, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GenericPropertyConstraint(A constraintAnnotation, Class<?> propertyType) throws de.smartics.util.lang.NullArgumentException
constraintAnnotation
.
constraintAnnotation
- the JSR-303 constraint annotation.
propertyType
- the type of the property selects the validator if more than on validator is referenced by the constraint annotation.
de.smartics.util.lang.NullArgumentException
- if
constraintAnnotation
is
null
.
public GenericPropertyConstraint(javax.validation.ConstraintValidator<A,T> validator, A constraintAnnotation) throws de.smartics.util.lang.NullArgumentException
validator
- the validator to validate values.
constraintAnnotation
- the JSR-303 constraint annotation.
de.smartics.util.lang.NullArgumentException
- if either
validator
or
constraintAnnotation
is
null
.
Method Detail |
---|
public String getDescription(Locale locale)
Override to provide more specific information the the string representation of the constraint annotation.
locale
- the locale to use to fetch a localized description.
PropertyConstraint.getDescription(java.util.Locale)
public String getViolationMessage(Locale locale, Object actualValue)
PropertyConstraint
getViolationMessage
in interface
PropertyConstraint<T>
getViolationMessage
in class
AbstractPropertyConstraint<T>
locale
- the locale to use for the message.
actualValue
- the value that has violated the constraint.
public final boolean isValid(T value, Class<?> group)
PropertyConstraint
value
- the value to be checked.
group
- the validation only takes place if this constraint is in this group or the argument is
null
.
true
if the
value
is valid,
false
otherwise.
public final boolean isMandatoryConstraint()
PropertyConstraint
isMandatoryConstraint
in interface
PropertyConstraint<T>
isMandatoryConstraint
in class
AbstractPropertyConstraint<T>
true
if the constraint is a check for value presence,
false
if it is any regular constraint.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |