Class WorkflowBeanValidator
- java.lang.Object
-
- de.xima.fc.workflow.processor.logic.validation.WorkflowBeanValidator
-
- All Implemented Interfaces:
IWorkflowBeanValidator
public final class WorkflowBeanValidator extends Object implements IWorkflowBeanValidator
Implementation of theIWorkflowBeanValidator
to validate workflow models via the bean validation API.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WorkflowBeanValidator
create(javax.validation.ValidatorFactory defaultValidatorFactory, IResourceBundleLocator locator, Locale locale, javax.validation.ClockProvider clockProvider, String messageTemplate)
Creates a new instance of the validator for the given parameters.Class<?>[]
findAllValidationGroups(Class<?> beanClass)
Finds all validation groups defined on any property, method, or constructor of the given bean class.javax.validation.Validator
getBeanValidator()
String
interpolateMessage(javax.validation.ConstraintViolation<?> violation)
Given a constraint violation, creates the localized message for that constraint.IWorkflowElementValidationResult
validateModel(Object data, Class<?>... groups)
Uses theIWorkflowBeanValidator.getBeanValidator()
to perform a validation of bean instance, usually the properties model of a workflow node or trigger.
-
-
-
Method Detail
-
findAllValidationGroups
public Class<?>[] findAllValidationGroups(Class<?> beanClass) throws WorkflowValidationException
Description copied from interface:IWorkflowBeanValidator
Finds all validation groups defined on any property, method, or constructor of the given bean class. Walks the entire object graph, i.e. also finds validation groups on referenced elements.- Specified by:
findAllValidationGroups
in interfaceIWorkflowBeanValidator
- Parameters:
beanClass
- Bean class to analyze.- Returns:
- All validation groups of the given bean class.
- Throws:
WorkflowValidationException
- When the class could not be analyzed.
-
getBeanValidator
public javax.validation.Validator getBeanValidator()
- Specified by:
getBeanValidator
in interfaceIWorkflowBeanValidator
- Returns:
- A bean validator instance that may be used to validate workflow elements. Usually you should just use
IWorkflowBeanValidator.validateModel(Object, Class...)
.
-
interpolateMessage
public String interpolateMessage(javax.validation.ConstraintViolation<?> violation)
Description copied from interface:IWorkflowBeanValidator
Given a constraint violation, creates the localized message for that constraint. Uses the localized message of the constraint, and adds the label for the property from the current resource bundle. Usually you should just useIWorkflowBeanValidator.validateModel(Object, Class...)
.- Specified by:
interpolateMessage
in interfaceIWorkflowBeanValidator
- Parameters:
violation
- Violation for which to create the localized validation message.- Returns:
- The localized validation message.
-
validateModel
public final IWorkflowElementValidationResult validateModel(Object data, Class<?>... groups) throws WorkflowValidationException
Description copied from interface:IWorkflowBeanValidator
Uses theIWorkflowBeanValidator.getBeanValidator()
to perform a validation of bean instance, usually the properties model of a workflow node or trigger.- Specified by:
validateModel
in interfaceIWorkflowBeanValidator
- Parameters:
data
- The bean instance to validate.groups
- A list of validation groups to validate, see the second argument ofValidator.validate(Object, Class...)
.- Returns:
- The validation result with all error and warning messages.
- Throws:
WorkflowValidationException
- When an error occurred during validation.
-
create
public static WorkflowBeanValidator create(javax.validation.ValidatorFactory defaultValidatorFactory, IResourceBundleLocator locator, Locale locale, javax.validation.ClockProvider clockProvider, String messageTemplate) throws WorkflowValidationException
Creates a new instance of the validator for the given parameters.- Parameters:
defaultValidatorFactory
- Validator factory for the bean validation API.locator
- For finding resource bundle from handlers and plugins.locale
- The current locale to use for error and info messages.clockProvider
- The clock provider to use. Defaults to the system clock when not given.messageTemplate
- Template for validation constraint failure messages.- Returns:
- A new bean validator wrapper.
- Throws:
WorkflowValidationException
- When the bean validator could not be created from the given factory.
-
-