org.javalid.core
Interface JavalidValidationCallbackHandler<T>


public interface JavalidValidationCallbackHandler<T>

Any class can implement this interface if it wishes to function as a callback handler. When using the annotationValidator, you can pass an implementing class as parameter. The framework will then call the methods of the interface as defined in their descriptions. Which will allow you to change certain aspects or validationPath mappings and so on (or even implement custom logic yourself).

For an example check out the unit test TestJavalidValidationHandler.

Since:
1.1 TODO: Add support for this in the JSF xml validation!
Version:
1.0
Author:
M.Reuvers

Method Summary
 void afterValidation(T object, java.lang.String currentGroup, java.lang.String currentValidationPath, java.util.List<ValidationMessage> messages)
          After the validation is completed (everything), this method is called by the validator.
 void afterValidationRound(java.lang.Object object, java.lang.String currentGroup, java.lang.String currentValidationPath, int currentLevelDeep, int maxLevelDeep, java.util.List<ValidationMessage> messages)
          Same as beforeValidationRound, except it is called *after* validation of this object by the framework.
 void beforeValidation(T object, java.lang.String currentGroup, java.lang.String currentValidationPath, java.util.List<ValidationMessage> messages)
          Before validation is even started at all, this method is called by the validator.
 void beforeValidationRound(java.lang.Object object, java.lang.String currentGroup, java.lang.String currentValidationPath, int currentLevelDeep, int maxLevelDeep, java.util.List<ValidationMessage> messages)
          Before each new validation round the framework will call this method and specify what it is about to *consider* for validation.
 

Method Detail

beforeValidation

void beforeValidation(T object,
                      java.lang.String currentGroup,
                      java.lang.String currentValidationPath,
                      java.util.List<ValidationMessage> messages)
Before validation is even started at all, this method is called by the validator.

Parameters:
object - The object that will be validated (will be the object you gave it in the first place)
currentGroup - The group you specified
currentValidationPath - The starting validationpath (might be with prefix if you gave that along)
messages - The messages list that will be used

afterValidation

void afterValidation(T object,
                     java.lang.String currentGroup,
                     java.lang.String currentValidationPath,
                     java.util.List<ValidationMessage> messages)
After the validation is completed (everything), this method is called by the validator. This method might be very useful if you need to remap some validation paths (especially useful when you use JSF, as you can change paths to existing component paths)

Parameters:
object - The object that was validated (will be the object you gave it in the first place)
currentGroup - The group you specified
currentValidationPath - The starting validationpath (might be with prefix if you gave that along)
messages - The messages list that was used, may contain messages.

beforeValidationRound

void beforeValidationRound(java.lang.Object object,
                           java.lang.String currentGroup,
                           java.lang.String currentValidationPath,
                           int currentLevelDeep,
                           int maxLevelDeep,
                           java.util.List<ValidationMessage> messages)
Before each new validation round the framework will call this method and specify what it is about to *consider* for validation. For a simple non-recursive call this method is only called once (currentLevelDeep and maxLevelDeep will both be 1). However if you validate say 2 levels deep instead of 1, for each association of the object you passed for validation this method is called. For instance:
 A {
   private B bObject;
 }
 
Assuming that both A and B have @ValidateDefinition annotation, and you pass for validation an instance of A, the validator will call this method with instance A, and later on with bObject. Were bObject null, it would not be called of course. In other words you can change things in any round here if required.

Parameters:
object - The current object under validation
currentGroup - The current group
currentValidationPath - The current validation path that is used
currentLevelDeep - The current level depth of the validation (1 means the object you originally passed, 2 its associations and so on).
maxLevelDeep - The maximum level depth allowed (if currentLevelDeep matches this one the validator is at maximum depth for this object).
messages - The current messages list, you may alter it if needed.

afterValidationRound

void afterValidationRound(java.lang.Object object,
                          java.lang.String currentGroup,
                          java.lang.String currentValidationPath,
                          int currentLevelDeep,
                          int maxLevelDeep,
                          java.util.List<ValidationMessage> messages)
Same as beforeValidationRound, except it is called *after* validation of this object by the framework.

Parameters:
object - The current object under validation
currentGroup - The current group
currentValidationPath - The current validation path that is used
currentLevelDeep - The current level depth of the validation (1 means the object you originally passed, 2 its associations and so on).
maxLevelDeep - The maximum level depth allowed (if currentLevelDeep matches this one the validator is at maximum depth for this object).
messages - The current messages list, you may alter it if needed.