public interface ValidationService
models or Pojo's (plain old java objects) agains
constraints. Use validationService.validate(yourModel) to validate this
model against all constraints in the system which ARE NOT in any group (default) or use
validationService.validate(yourModel, Collection<ConstraintGroupModel>) to validate this model
against a configured constraint groups (which contains constraints).| Modifier and Type | Field and Description |
|---|---|
static Logger |
LOG |
| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<ConstraintGroupModel> |
getActiveConstraintGroups()
Returns all active
constraint groups which are bound to the current session. |
ConstraintGroupModel |
getDefaultConstraintGroup()
Returns the default constraint group (which is created during creation of eccencial data).
|
boolean |
needReloadOfValidationEngine(AbstractConstraintModel model)
Returns
true if the given constraint was modified (see ItemModel.getModifiedtime()) after the
last reload (reloadValidationEngine()) of the validation engine. |
void |
reloadValidationEngine()
Reloads the validation engine using current validation provider.
|
void |
setActiveConstraintGroups(java.util.Collection<ConstraintGroupModel> groups)
Sets the given collection with the
ConstraintGroupModels to the current session context. |
void |
unloadValidationEngine()
Method removes all constraints available for
Validator, since it call no violation should be noticed. |
<T> java.util.Set<HybrisConstraintViolation> |
validate(T object,
java.lang.Class<?>... groups)
Validates the given
model or Pojo. |
<T> java.util.Set<HybrisConstraintViolation> |
validate(T object,
java.util.Collection<ConstraintGroupModel> groups)
Validates the given
model or Pojo. |
default void |
validateConstraint(AbstractConstraintModel model)
Creates TEST validation configuration using given constraint model.
|
<T> java.util.Set<HybrisConstraintViolation> |
validateProperty(T object,
java.lang.String propertyName,
java.lang.Class<?>... groups)
Validates all constraints placed on the property of
object named propertyName. |
<T> java.util.Set<HybrisConstraintViolation> |
validateProperty(T object,
java.lang.String propertyName,
java.util.Collection<ConstraintGroupModel> groups)
Validates all constraints placed on the property of
object named propertyName. |
<T> java.util.Set<HybrisConstraintViolation> |
validateValue(java.lang.Class<T> beanType,
java.lang.String propertyName,
java.lang.Object value,
java.lang.Class<?>... groups)
Validates all constraints placed on the property named
propertyName of the class
beanType would the property value be value. |
<T> java.util.Set<HybrisConstraintViolation> |
validateValue(java.lang.Class<T> beanType,
java.lang.String propertyName,
java.lang.Object value,
java.util.Collection<ConstraintGroupModel> groups)
Validates all constraints placed on the property named
propertyName of the class
beanType would the property value be value
ConstraintViolation objects return null for ConstraintViolation#getRootBean() and
ConstraintViolation#getLeafBean() |
void reloadValidationEngine()
<T> java.util.Set<HybrisConstraintViolation> validate(T object, java.util.Collection<ConstraintGroupModel> groups)
model or Pojo.
If groups aren't provided - this method uses for the validation all constrains which are not in any group.object - the Model or Pojo to validategroups - A collection of constraint groups. Each group contains some
constraints. Use an empty collection for validate agains the default
constraints.ConstraintViolations or an empty set if no validation was found.java.lang.IllegalArgumentException - if object is null or if null is passed to the groupsjavax.validation.ValidationException - if a non recoverable error happens during the validation process<T> java.util.Set<HybrisConstraintViolation> validate(T object, java.lang.Class<?>... groups)
model or Pojo.
Same as validate(Object, Collection) but here the constraint group interfaces must be provided. If not
constraint group interface is provided the default constraint group is asumed per default.object - the model or pojo to validategroups - a class array which contains the group marker interfaces.<T> java.util.Set<HybrisConstraintViolation> validateProperty(T object, java.lang.String propertyName, java.util.Collection<ConstraintGroupModel> groups)
object named propertyName.object - object to validatepropertyName - property to validate (i.e. field and getter constraints)groups - A collection of constraint groups. Each group contains n
constraints. Use an empty collection for validate agains the default
constraints.java.lang.IllegalArgumentException - if object is null, if propertyName null, empty or not a valid object property
or if null is passed to the varargs groupsjavax.validation.ValidationException - if a non recoverable error happens during the validation process<T> java.util.Set<HybrisConstraintViolation> validateProperty(T object, java.lang.String propertyName, java.lang.Class<?>... groups)
object named propertyName.object - object to validatepropertyName - property to validate (ie field and getter constraints)groups - group or list of groups targeted for validation (default to javax.validation.groups.Default
)java.lang.IllegalArgumentException - if object is null, if propertyName null, empty or not a valid object property
or if null is passed to the varargs groupsjavax.validation.ValidationException - if a non recoverable error happens during the validation process<T> java.util.Set<HybrisConstraintViolation> validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.util.Collection<ConstraintGroupModel> groups)
propertyName of the class
beanType would the property value be value
ConstraintViolation objects return null for ConstraintViolation#getRootBean() and
ConstraintViolation#getLeafBean()beanType - the bean typepropertyName - property to validatevalue - property value to validategroups - A collection of constraint groups. Each group contains n
constraints. Use an empty collection for validate agains the default
constraints.java.lang.IllegalArgumentException - if beanType is null, if propertyName null, empty or not a valid object
property or if null is passed to the varargs groupsjavax.validation.ValidationException - if a non recoverable error happens during the validation process<T> java.util.Set<HybrisConstraintViolation> validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.Class<?>... groups)
propertyName of the class
beanType would the property value be value.
ConstraintViolation objects return null for ConstraintViolation#getRootBean() and
ConstraintViolation#getLeafBean().beanType - the bean typepropertyName - property to validatevalue - property value to validategroups - group or list of groups targeted for validation (default to javax.validation.groups.Default
)java.lang.IllegalArgumentException - if beanType is null, if propertyName null, empty or not a valid object
property or if null is passed to the varargs groupsjavax.validation.ValidationException - if a non recoverable error happens during the validation processvoid setActiveConstraintGroups(java.util.Collection<ConstraintGroupModel> groups)
ConstraintGroupModels to the current session context. Those groups will
be used to validate any given model during modelService.save(...).groups - a collection with ConstraintGroupModeljava.util.Collection<ConstraintGroupModel> getActiveConstraintGroups()
constraint groups which are bound to the current session.void unloadValidationEngine()
Validator, since it call no violation should be noticed.ConstraintGroupModel getDefaultConstraintGroup()
ConstraintGroupModel.getConstraints()) all constraints which ARE NOT in
any group. Meaning AbstractConstraintModel.getConstraintGroups() returns an empty set. Setting any
constraint to this default group or adding this default group to any constraint results in a
ModelSavingException! The getInterfaceName() returns
always "javax.validation.groups.Default" and the Id returns always
"default". Both values cannot be modified!boolean needReloadOfValidationEngine(AbstractConstraintModel model)
true if the given constraint was modified (see ItemModel.getModifiedtime()) after the
last reload (reloadValidationEngine()) of the validation engine.model - the constraintfalse otherwisedefault void validateConstraint(AbstractConstraintModel model)
model - the constraintCopyright © 2018 SAP SE. All Rights Reserved.