public final class ConstraintValidationListener<T> extends Object implements ValidationListener
ValidationListener.Error
Constructor and Description |
---|
ConstraintValidationListener(T aRootBean,
Class<T> rootBeanType)
Create a new ConstraintValidationListener instance.
|
Modifier and Type | Method and Description |
---|---|
<VL extends ValidationListener> |
addError(String reason,
ValidationContext<VL> context)
Simple API to add an error reason during validation.
|
<VL extends ValidationListener> |
addError(ValidationListener.Error error,
ValidationContext<VL> context)
Alternative method to add a fully initialized
ValidationListener.Error object. |
boolean |
beginReportAsSingle()
Signify the beginning of a report-as-single-violation composite validation.
|
boolean |
endReportAsSingle()
Signify the end of a report-as-single-violation composite validation.
|
Set<javax.validation.ConstraintViolation<T>> |
getConstraintViolations()
Get the
ConstraintViolation s accumulated by this ConstraintValidationListener . |
T |
getRootBean()
Get the root bean.
|
Class<T> |
getRootBeanType()
Get the root bean type of this
ConstraintValidationListener . |
boolean |
hasViolations()
Learn whether there are violations available.
|
boolean |
isEmpty()
Learn whether no violations were found.
|
int |
violationsSize()
Get the count of encountered violations.
|
public <VL extends ValidationListener> void addError(String reason, ValidationContext<VL> context)
Validation
with context information
taken from the given ValidationContext
.addError
in interface ValidationListener
reason
- a constant describing the reason. This is normally the key of the
feature that was violated in the object 'owner' for property 'propertyName'context
- - contains
bean = the object that contains the error (owner)
propertyName = the Name of the attribute that caused the errorpublic <VL extends ValidationListener> void addError(ValidationListener.Error error, ValidationContext<VL> context)
ValidationListener.Error
object.addError
in interface ValidationListener
public Set<javax.validation.ConstraintViolation<T>> getConstraintViolations()
ConstraintViolation
s accumulated by this ConstraintValidationListener
.Set
of ConstraintViolation
public boolean isEmpty()
public T getRootBean()
public Class<T> getRootBeanType()
ConstraintValidationListener
.public int violationsSize()
public boolean hasViolations()
public boolean beginReportAsSingle()
true
as this call caused the listener to enter report-as-single-violation modepublic boolean endReportAsSingle()
true
as this call caused the listener to exit report-as-single-violation modeCopyright © 2010–2016 The Apache Software Foundation. All rights reserved.