public class PropertyGatherer.PropertyValidatorListener extends java.lang.Object implements ValidatorListener, java.lang.AutoCloseable
CLASS_VERSION
Constructor and Description |
---|
PropertyValidatorListener(ValidatorContext pContext,
java.lang.String pPropertyName)
Create a new property validator listener, registered
as a listener to pContext.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
On close, remove ourself as a listener on the validator.
|
protected void |
doInterPropertyValidation(ValidatorContext pContext)
Actually do the inter-property validation, by calling
validateBean on our bean validator.
|
void |
errorAdded(ValidatorContext pContext,
Validator<?> pValidator,
java.lang.String pMessage,
java.lang.String pPropertyName,
java.lang.Throwable pRootCause)
Called just after an error was added to ValidatorContext.
|
boolean |
forceValidationOfExistingProperty(ValidatorContext pContext,
java.lang.String pPropertyName,
java.lang.Object pSource,
java.lang.Object pDestination)
Give all listeners a chance to say whether a property should be
validated.
|
int |
getCurrentDepth()
Get the current ancestor depth count, compared to where we started.
|
protected java.lang.String |
getEffectivePropertyName(java.lang.String pPropertyName)
Get the effective property name of the given property.
|
protected boolean |
isCorrectDepth()
Return whether or not we are the correct depth to be interested
in properties.
|
void |
validateBeanPropertyCalled(ValidatorContext pContext,
Validator pValidator,
java.lang.String pPropertyName,
java.lang.Object pBean,
java.lang.Object pResult)
Called after a beanProperty has been validated.
|
public PropertyValidatorListener(ValidatorContext pContext, java.lang.String pPropertyName)
pContext
- the validator context to listen onpPropertyName
- the specific property name we are being
created for (may be null)public void errorAdded(ValidatorContext pContext, Validator<?> pValidator, java.lang.String pMessage, java.lang.String pPropertyName, java.lang.Throwable pRootCause)
ValidatorListener
errorAdded
in interface ValidatorListener
pValidator
- the validator on whose behalf the exception
was added (can provide an errorCode to use).pMessage
- the user visible message (should be localized)pPropertyName
- the property name to append to the pushed
property path on the context. May be null if there is nothing to add.pRootCause
- the throwable to use as a root cause. If non-null,
then pRootCause becomes the nested/caused-by exception.public void validateBeanPropertyCalled(ValidatorContext pContext, Validator pValidator, java.lang.String pPropertyName, java.lang.Object pBean, java.lang.Object pResult)
ValidatorListener
Note that callers of validateBeanProperty() must invoke ValidatorContext.validateBeanPropertyCalled() in order for listeners to get this notification. ValidatorManager (the core bean-property validator) already does so, but not every validator may do so.
validateBeanPropertyCalled
in interface ValidatorListener
pContext
- the current validation context.pValidator
- the validator that did the validation.pPropertyName
- the name of the property that was validated.pBean
- the bean whose property was validated.public boolean forceValidationOfExistingProperty(ValidatorContext pContext, java.lang.String pPropertyName, java.lang.Object pSource, java.lang.Object pDestination)
ValidatorListener
forceValidationOfExistingProperty
in interface ValidatorListener
pContext
- the current validation context.pPropertyName
- the name of the property to be validated.pSource
- the bean containing new property values.pDestination
- the bean containing original property values.protected void doInterPropertyValidation(ValidatorContext pContext)
pContext
- the current validator context.public void close()
close
in interface java.lang.AutoCloseable
protected boolean isCorrectDepth()
public int getCurrentDepth()
protected java.lang.String getEffectivePropertyName(java.lang.String pPropertyName)
pPropertyName
- the property name (possibly) remap.