com.tzavellas.validation
Class BeanValidator

java.lang.Object
  extended by com.tzavellas.validation.BeanValidator

public class BeanValidator
extends Object

A class used to validate the properties of JavaBean objects using a collection of specified PropertyValidators.

Thread safety: This class is thread safe.

Author:
Spiros Tzavellas
See Also:
PropertyValidator

Constructor Summary
BeanValidator(PropertyValidator<?>... validators)
          Construct a BeanValidator with the specified collection of PropertyValidators.
 
Method Summary
 void add(PropertyValidator<?> v)
          Add a PropertyValidator to be used when validating objects.
 boolean isValid(Object bean)
          Validate the specified object.
 ValidationResult validate(Object bean)
          Validate the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanValidator

public BeanValidator(PropertyValidator<?>... validators)
Construct a BeanValidator with the specified collection of PropertyValidators.

Method Detail

add

public void add(PropertyValidator<?> v)
Add a PropertyValidator to be used when validating objects.

Parameters:
v - the PropertyValidator to add

isValid

public boolean isValid(Object bean)
Validate the specified object.

Parameters:
bean - the JavaBean to validate
Returns:
true if all validations pass else false

validate

public ValidationResult validate(Object bean)
Validate the specified object.

Parameters:
bean - the JavaBean to validate
Returns:
a Collection of errors if the validation fails. An empty Collection otherwise.


Copyright © 2007-2009 spiros.blog(). All Rights Reserved.