org.springmodules.validation.util.condition.bean
Class EqualPropertiesBeanCondition

java.lang.Object
  extended by org.springmodules.validation.util.condition.AbstractCondition
      extended by org.springmodules.validation.util.condition.NonNullAcceptingCondition
          extended by org.springmodules.validation.util.condition.bean.AbstractBeanCondition
              extended by org.springmodules.validation.util.condition.bean.EqualPropertiesBeanCondition
All Implemented Interfaces:
Condition

public class EqualPropertiesBeanCondition
extends AbstractBeanCondition

An AbstractBeanCondition implementation that checks whether specific properties of the checked bean have the same value.

Author:
Uri Boness

Constructor Summary
EqualPropertiesBeanCondition(String[] propertyNames)
          Constructs a new EqualPropertiesBeanCondition with a given list of names of the properties to be compared.
EqualPropertiesBeanCondition(String property1, String property2)
          Constructs a new EqualPropertiesBeanCondition with two given names of the properties to be compared.
 
Method Summary
protected  boolean checkBean(BeanWrapper bean)
          Checks whether a set of properties of the given bean have the same value.
 String[] getPropertyNames()
          Returns the property names associated with this condition.
 
Methods inherited from class org.springmodules.validation.util.condition.bean.AbstractBeanCondition
doCheck
 
Methods inherited from class org.springmodules.validation.util.condition.NonNullAcceptingCondition
beforeObjectChecked
 
Methods inherited from class org.springmodules.validation.util.condition.AbstractCondition
afterObjectChecked, and, check, or
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EqualPropertiesBeanCondition

public EqualPropertiesBeanCondition(String[] propertyNames)
Constructs a new EqualPropertiesBeanCondition with a given list of names of the properties to be compared.

Parameters:
propertyNames - The name of the properties to be compared.
Throws:
IllegalArgumentException - when the given property names array contains zero or one names.

EqualPropertiesBeanCondition

public EqualPropertiesBeanCondition(String property1,
                                    String property2)
Constructs a new EqualPropertiesBeanCondition with two given names of the properties to be compared.

Parameters:
property1 - The name of the first property.
property2 - The name of the second property.
Method Detail

checkBean

protected boolean checkBean(BeanWrapper bean)
Checks whether a set of properties of the given bean have the same value. The properties are resolved based on the property names associated with this condition.

Specified by:
checkBean in class AbstractBeanCondition
Parameters:
bean - The bean to be checked.
Returns:
true if all the compared properties are equal, false otherwise.

getPropertyNames

public String[] getPropertyNames()
Returns the property names associated with this condition.

Returns:
The property names associated with this condition.


Copyright © 2009. All Rights Reserved.