org.springframework.rules.constraint.property
Class RequiredIfTrue

java.lang.Object
  extended by org.springframework.rules.constraint.property.AbstractPropertyConstraint
      extended by org.springframework.rules.constraint.property.RequiredIfTrue
All Implemented Interfaces:
Constraint, PropertyConstraint
Direct Known Subclasses:
RequiredIfOthersPresent

public class RequiredIfTrue
extends AbstractPropertyConstraint

Validates a property value as 'required' if some other condition is true.

Author:
Seth Ladd, Keith Donald

Constructor Summary
protected RequiredIfTrue(String propertyName)
           
  RequiredIfTrue(String propertyName, Constraint predicate)
          Tests that the property is present if the provided predicate is satisified.
 
Method Summary
 Constraint getConstraint()
           
 boolean isDependentOn(String propertyName)
          Determine if this rule is dependent on the given property name.
protected  void setConstraint(Constraint predicate)
           
protected  boolean test(PropertyAccessStrategy domainObjectAccessStrategy)
           
 String toString()
           
 
Methods inherited from class org.springframework.rules.constraint.property.AbstractPropertyConstraint
getPropertyName, isCompoundRule, setPropertyName, test
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequiredIfTrue

public RequiredIfTrue(String propertyName,
                      Constraint predicate)
Tests that the property is present if the provided predicate is satisified.

Parameters:
predicate - the condition

RequiredIfTrue

protected RequiredIfTrue(String propertyName)
Method Detail

getConstraint

public Constraint getConstraint()

setConstraint

protected void setConstraint(Constraint predicate)

isDependentOn

public boolean isDependentOn(String propertyName)
Determine if this rule is dependent on the given property name. True if either the direct poperty (from the contstructor) is equal to the given name, or if the "if true" predicate is a PropertyConstraint and it is dependent on the given property.

Specified by:
isDependentOn in interface PropertyConstraint
Overrides:
isDependentOn in class AbstractPropertyConstraint
Returns:
true if this rule is dependent on the given property

test

protected boolean test(PropertyAccessStrategy domainObjectAccessStrategy)
Specified by:
test in class AbstractPropertyConstraint

toString

public String toString()
Overrides:
toString in class AbstractPropertyConstraint


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.