public class ValidationResults extends Object implements ValidationListener, Serializable
ValidationListener.Error
Constructor and Description |
---|
ValidationResults() |
Modifier and Type | Method and Description |
---|---|
void |
addError(String reason,
Object bean,
String propertyName)
Old API to add an error to the validation results when no context is available.
|
<T extends ValidationListener> |
addError(String reason,
ValidationContext<T> context)
API to add an error to the validation results.
|
<T extends ValidationListener> |
addError(ValidationListener.Error error,
ValidationContext<T> context)
API to add an error to the validation results.
|
protected void |
addToOwnerBucket(ValidationListener.Error error)
Add an Error to the property-keyed map of Errors maintained for this Error's owner.
|
protected void |
addToReasonBucket(ValidationListener.Error error)
Add an Error to the set of Errors shared by a particular "reason."
|
protected ValidationListener.Error |
createError(String reason,
Object owner,
String propertyName)
Create an Error object.
|
Map<Object,Map<String,List<ValidationListener.Error>>> |
getErrorsByOwner()
Get the map of Errors by owner;
key = owner, value = map with:
key = propertyName, value = list of errors for this owner.propertyName |
Map<String,List<ValidationListener.Error>> |
getErrorsByReason()
Get the map of Errors by reason;
key = reason, value = list of errors for this reason
|
boolean |
hasError(Object bean,
String propertyName)
Learn whether
bean has any errors keyed to property propertyName . |
boolean |
hasErrorForReason(String reason)
Learn whether there is an Error keyed to a specified reason description.
|
protected void |
initialize()
initialize the error-buckets now when needed and
not on instance creation to save memory garbage.
|
boolean |
isEmpty()
Learn whether these results are empty/error-free.
|
String |
toString() |
public <T extends ValidationListener> void addError(String reason, ValidationContext<T> context)
addError
in interface ValidationListener
reason
- - Features from Features.Property
or custom reason of validation errorcontext
- - context information (bean, propertyName, value, ...)public <T extends ValidationListener> void addError(ValidationListener.Error error, ValidationContext<T> context)
addError
in interface ValidationListener
error
- - holding the description of reason and object to describe
the validation errorcontext
- - null or the context to provide additional informationpublic void addError(String reason, Object bean, String propertyName)
reason
- - Features from Features.Property
or custom validation reasonbean
- - (optional) owner bean or nullpropertyName
- - (optional) propertyName where valiation error occurred or nullprotected ValidationListener.Error createError(String reason, Object owner, String propertyName)
reason
- owner
- propertyName
- Error
protected void initialize()
protected void addToReasonBucket(ValidationListener.Error error)
error
- Error#getReason()}
protected void addToOwnerBucket(ValidationListener.Error error)
error
- Error#getOwner()}
public Map<String,List<ValidationListener.Error>> getErrorsByReason()
public Map<Object,Map<String,List<ValidationListener.Error>>> getErrorsByOwner()
public boolean isEmpty()
public boolean hasErrorForReason(String reason)
reason
- Error#getReason()}
public boolean hasError(Object bean, String propertyName)
bean
has any errors keyed to property propertyName
.bean
- propertyName
- - may be null: any property is checked
OR the name of the property to checkCopyright © 2010–2018 The Apache Software Foundation. All rights reserved.