org.springmodules.validation.util.condition
Class AbstractCondition

java.lang.Object
  extended by org.springmodules.validation.util.condition.AbstractCondition
All Implemented Interfaces:
Condition
Direct Known Subclasses:
AbstractCompoundCondition, AlwaysFalseCondition, AlwaysTrueCondition, CommonsPredicateCondition, ConditionProxyCondition, InstanceOfCondition, IsNullCondition, NonNullAcceptingCondition, NotCondition, OgnlCondition, PropertyValidationRule.DefaultApplicabilityCondition, TypeSpecificCondition, ValangCondition

public abstract class AbstractCondition
extends Object
implements Condition

An abstract implementation of the Condition interface. This class takes care of the logical operation of the condition. It is highly recommended for condition implementation to sub-class this class when possible.

Author:
Uri Boness

Constructor Summary
AbstractCondition()
           
 
Method Summary
protected  boolean afterObjectChecked(Object object, boolean originalResult)
          A callback method that enables sub-classes to intercept the object checking after it was checked.
 Condition and(Condition condition)
          See Condition.and(Condition)
protected  void beforeObjectChecked(Object object)
          A callback method that enables sub-classes intercept the object checking before it is being checked.
 boolean check(Object object)
          See Condition.check(Object).
abstract  boolean doCheck(Object object)
          Performs the actual checking of this condition on the checked object.
 Condition or(Condition condition)
          See Condition.or(Condition)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCondition

public AbstractCondition()
Method Detail

check

public final boolean check(Object object)
See Condition.check(Object).

Delegates to the doCheck(Object). Provides callback methods for sub-classes to intercept the checking.

Specified by:
check in interface Condition
Parameters:
object - The checked object.
Returns:
true if the object adheres to this condition, false otherwise.

doCheck

public abstract boolean doCheck(Object object)
Performs the actual checking of this condition on the checked object.

Parameters:
object - The object to be checked.
Returns:
true if the given object adheres to this condition, false otherwise.

and

public Condition and(Condition condition)
See Condition.and(Condition)

Specified by:
and in interface Condition
Parameters:
condition - The condition to intersect with this condition.
Returns:
A new condition that represents the logical AND of this condition and the given one.

or

public Condition or(Condition condition)
See Condition.or(Condition)

Specified by:
or in interface Condition
Parameters:
condition - The condition to unite with this condition.
Returns:
A new condition that represents the logical OR of this condition and the given one.

beforeObjectChecked

protected void beforeObjectChecked(Object object)
                            throws IllegalArgumentException
A callback method that enables sub-classes intercept the object checking before it is being checked. Sub-classes may override this method and perform custom assertions and prevent the checking by throwing an IllegalArgumentException;

Parameters:
object -
Throws:
IllegalArgumentException

afterObjectChecked

protected boolean afterObjectChecked(Object object,
                                     boolean originalResult)
A callback method that enables sub-classes to intercept the object checking after it was checked. Sub-classes can override this method and change the check result. By default, this method returns the original check result.

Parameters:
object - The checked object.
originalResult - The original check result as returned by the specific condition implementation.
Returns:
The final check result.


Copyright © 2009. All Rights Reserved.