org.springframework.rules.constraint.property
Class RequiredIfOthersPresent

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

public class RequiredIfOthersPresent
extends RequiredIfTrue

Author:
Keith Donald

Constructor Summary
RequiredIfOthersPresent(String propertyName, String otherPropertyNames)
          Tests that the property is required if all "other properties" are present.
RequiredIfOthersPresent(String propertyName, String[] otherPropertyNames)
          Tests that the property is required if all "other properties" are present.
RequiredIfOthersPresent(String propertyName, String[] otherPropertyNames, LogicalOperator operator)
          Tests that the property is required if "other properties" are present.
RequiredIfOthersPresent(String propertyName, String otherPropertyNames, LogicalOperator operator)
          Tests that the property is required if all or any of the "other properties" are present.
 
Method Summary
 boolean isCompoundRule()
          Does this property constraint effect more than one property?
 boolean isDependentOn(String propertyName)
          Determine if this rule is dependent on the given property name.
 
Methods inherited from class org.springframework.rules.constraint.property.RequiredIfTrue
getConstraint, setConstraint, test, toString
 
Methods inherited from class org.springframework.rules.constraint.property.AbstractPropertyConstraint
getPropertyName, setPropertyName, test
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequiredIfOthersPresent

public RequiredIfOthersPresent(String propertyName,
                               String[] otherPropertyNames)
Tests that the property is required if all "other properties" are present. Present means they are "non null."

Parameters:
otherPropertyNames - to test

RequiredIfOthersPresent

public RequiredIfOthersPresent(String propertyName,
                               String[] otherPropertyNames,
                               LogicalOperator operator)
Tests that the property is required if "other properties" are present. Present means they are "non null." The operator parameter determines how the set of other property names is handled. If AND, then all must be present before the primary proeprty will be required. If OR, then if any of the other properties are present, then the primary property will be required. the logical operator, either AND or OR.

Parameters:
otherPropertyNames - to test
operator - Either AND or OR.

RequiredIfOthersPresent

public RequiredIfOthersPresent(String propertyName,
                               String otherPropertyNames)
Tests that the property is required if all "other properties" are present. Present means they are "non null."

Parameters:
otherPropertyNames - one or more other properties, delimited by commas.

RequiredIfOthersPresent

public RequiredIfOthersPresent(String propertyName,
                               String otherPropertyNames,
                               LogicalOperator operator)
Tests that the property is required if all or any of the "other properties" are present.

Parameters:
otherPropertyNames - one or more other properties, delimited by commas.
operator - the logical operator, either AND or OR.
Method Detail

isDependentOn

public boolean isDependentOn(String propertyName)
Description copied from class: RequiredIfTrue
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 RequiredIfTrue
Returns:
true if this rule is dependent on the given property

isCompoundRule

public boolean isCompoundRule()
Description copied from interface: PropertyConstraint
Does this property constraint effect more than one property?

Specified by:
isCompoundRule in interface PropertyConstraint
Overrides:
isCompoundRule in class AbstractPropertyConstraint
Returns:
true if yes, false otherwise


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