Class ValidatorImpl
- java.lang.Object
 - 
- org.apache.openjpa.validation.AbstractValidator
 - 
- org.apache.openjpa.persistence.validation.ValidatorImpl
 
 
 
- 
- All Implemented Interfaces:
 Validator
public class ValidatorImpl extends AbstractValidator
 
- 
- 
Constructor Summary
Constructors Constructor Description ValidatorImpl()Default constructor.ValidatorImpl(jakarta.validation.ValidatorFactory validatorFactory, jakarta.persistence.ValidationMode mode)Type-specific constructor Returns an Exception if a Validator could not be created.ValidatorImpl(Configuration conf) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddValidationGroup(Integer event, Class<?>... validationGroup)Add a validation group for a specified event.voidaddValidationGroup(String validationGroupName, Class<?>... vgs)Add a validation group for the specific property.voidaddValidationGroup(String validationGroupName, String group)Add the validation group(s) for the specified event.jakarta.validation.metadata.BeanDescriptorgetConstraintsForClass(Class<?> cls)Returns the validation constraints for the specified classClass<?>[]getValidationGroup(Integer event)Return the validation groups to be validated for a specified eventbooleanisValidating(Integer event)Returns whether the Validator is validating for the specified event.<T> ValidationExceptionvalidate(T arg0, int event)Validates a given instance<T> ValidationExceptionvalidateProperty(T arg0, String property, int event)Validates a property of a given instance<T> ValidationExceptionvalidateValue(Class<T> arg0, String arg1, Object arg2, int event)Validates a value based upon the constraints applied to a given class attribute.<T> booleanvalidating(T arg0, int event)Returns whether validation is active for the given event. 
 - 
 
- 
- 
Constructor Detail
- 
ValidatorImpl
public ValidatorImpl()
Default constructor. Builds a default validator factory, if available and creates the validator. Returns an Exception if a Validator could not be created. 
- 
ValidatorImpl
public ValidatorImpl(Configuration conf)
 
- 
ValidatorImpl
public ValidatorImpl(jakarta.validation.ValidatorFactory validatorFactory, jakarta.persistence.ValidationMode mode)Type-specific constructor Returns an Exception if a Validator could not be created.- Parameters:
 validatorFactory- Instance of validator factory to use. Specify null to use the default factory.mode- ValdiationMode enum value
 
 - 
 
- 
Method Detail
- 
addValidationGroup
public void addValidationGroup(String validationGroupName, Class<?>... vgs)
Add a validation group for the specific property. The properties map to a specific lifecycle event. To disable validation for a group, set the validation group to null.- Parameters:
 validationGroupName-vgs-
 
- 
addValidationGroup
public void addValidationGroup(Integer event, Class<?>... validationGroup)
Add a validation group for a specified event. Event definitions are defined in LifecycleEvent. To disable validation for a group, set the validation group to null.- Parameters:
 event-validationGroup-
 
- 
addValidationGroup
public void addValidationGroup(String validationGroupName, String group)
Add the validation group(s) for the specified event. Event definitions are defined in LifecycleEvent- Parameters:
 event-group-
 
- 
getValidationGroup
public Class<?>[] getValidationGroup(Integer event)
Return the validation groups to be validated for a specified event- Parameters:
 event- Lifecycle event id- Returns:
 - An array of validation groups
 
 
- 
isValidating
public boolean isValidating(Integer event)
Returns whether the Validator is validating for the specified event. Based on whether validation groups are specified for the event.- Parameters:
 event- the event to check for validation- Returns:
 - returns true if validating for this particular event
 
 
- 
getConstraintsForClass
public jakarta.validation.metadata.BeanDescriptor getConstraintsForClass(Class<?> cls)
Returns the validation constraints for the specified class- Parameters:
 cls- Class for which constraints to return- Returns:
 - The validation bean descriptor
 
 
- 
validate
public <T> ValidationException validate(T arg0, int event)
Validates a given instance- Specified by:
 validatein interfaceValidator- Specified by:
 validatein classAbstractValidator- Type Parameters:
 T- The instance to validate- Parameters:
 arg0- The class, of type T to validateevent- The event id- Returns:
 - ValidationException if the validator produces one or more constraint violations.
 
 
- 
validateProperty
public <T> ValidationException validateProperty(T arg0, String property, int event)
Validates a property of a given instance- Specified by:
 validatePropertyin interfaceValidator- Specified by:
 validatePropertyin classAbstractValidator- Type Parameters:
 T- The instance to validate- Parameters:
 arg0- The property to validateproperty- The property to validateevent- The event id- Returns:
 - ValidationException if the validator produces one or more constraint violations.
 
 
- 
validateValue
public <T> ValidationException validateValue(Class<T> arg0, String arg1, Object arg2, int event)
Validates a value based upon the constraints applied to a given class attribute.- Specified by:
 validateValuein interfaceValidator- Specified by:
 validateValuein classAbstractValidator- Type Parameters:
 T- The instance type to base validation upon- Parameters:
 arg0- The class of type T to validatearg1- The property to validatearg2- The property value to validateevent- The event id- Returns:
 - ValidationException if the validator produces one or more constraint violations.
 
 
- 
validating
public <T> boolean validating(T arg0, int event)Returns whether validation is active for the given event.- Specified by:
 validatingin interfaceValidator- Overrides:
 validatingin classAbstractValidator- Type Parameters:
 T-- Parameters:
 arg0- Type being validatedevent- event type- Returns:
 - true if validation is active for the specified event
 
 
 - 
 
 -