org.springframework.rules.constraint.property
Class ParameterizedPropertyConstraint

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

public class ParameterizedPropertyConstraint
extends Object
implements PropertyConstraint

A constraint that returns the result of a boolean expression that tests a variable bean property value against a constant parameter value. For example: pet.age > 5

Author:
Keith Donald

Constructor Summary
ParameterizedPropertyConstraint(String propertyName, BinaryConstraint expression, Object parameter)
          Creates a BeanPropertyExpressionTester.
ParameterizedPropertyConstraint(String propertyName, Constraint parameterizedExpression)
           
 
Method Summary
 BinaryConstraint getConstraint()
           
 Object getParameter()
           
 String getPropertyName()
          Returns the constrained property name.
 boolean isCompoundRule()
          Does this property constraint effect more than one property?
 boolean isDependentOn(String propertyName)
          Returns true if this property constraint is dependent on the provided propertyName for test evaluation; that is, it should be retested when propertyName changes.
 boolean test(Object bean)
          Tests the value of the configured propertyName for this bean against the configured parameter value using the configured binary predicate.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParameterizedPropertyConstraint

public ParameterizedPropertyConstraint(String propertyName,
                                       BinaryConstraint expression,
                                       Object parameter)
Creates a BeanPropertyExpressionTester.

Parameters:
propertyName - The property participating in the expression.
expression - The expression predicate (tester).
parameter - The constant parameter value participating in the expression.

ParameterizedPropertyConstraint

public ParameterizedPropertyConstraint(String propertyName,
                                       Constraint parameterizedExpression)
Method Detail

getPropertyName

public String getPropertyName()
Description copied from interface: PropertyConstraint
Returns the constrained property name.

Specified by:
getPropertyName in interface PropertyConstraint
Returns:
The property name

isDependentOn

public boolean isDependentOn(String propertyName)
Description copied from interface: PropertyConstraint
Returns true if this property constraint is dependent on the provided propertyName for test evaluation; that is, it should be retested when propertyName changes.

Specified by:
isDependentOn in interface PropertyConstraint
Returns:
true or false

isCompoundRule

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

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

getConstraint

public BinaryConstraint getConstraint()

getParameter

public Object getParameter()

test

public boolean test(Object bean)
Tests the value of the configured propertyName for this bean against the configured parameter value using the configured binary predicate.

Specified by:
test in interface Constraint
Parameters:
bean - the argument value
Returns:
true if the condition was satisfied, false otherwise
See Also:
Constraint.test(java.lang.Object)

toString

public String toString()
Overrides:
toString in class Object


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