org.springframework.rules.constraint.property
Class RequiredIfTrue
java.lang.Object
org.springframework.rules.constraint.property.AbstractPropertyConstraint
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
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)
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.