org.springframework.rules.constraint
Class ComparisonBinaryPredicate

Show UML class diagram
java.lang.Object
  extended by org.springframework.rules.closure.support.AlgorithmsAccessor
      extended by org.springframework.rules.constraint.ConstraintsAccessor
          extended by org.springframework.rules.constraint.AbstractBinaryConstraint
              extended by org.springframework.rules.constraint.ComparisonBinaryPredicate
All Implemented Interfaces:
BinaryConstraint, Constraint
Direct Known Subclasses:
EqualTo, GreaterThan, GreaterThanEqualTo, LessThan, LessThanEqualTo

public abstract class ComparisonBinaryPredicate
extends AbstractBinaryConstraint

Abstract helper superclass for binary predicates involved in comparison operations.

Author:
Keith Donald

Constructor Summary
protected ComparisonBinaryPredicate()
          Creates a comparing binary predicate which operates on Comparable objects.
protected ComparisonBinaryPredicate(Comparator comparator)
          Creates a comparing binary predicate which compares using the provided Comparator.
 
Method Summary
 Comparator getComparator()
          Returns the comparator which is used to compare the arguments
 boolean test(Object argument1, Object argument2)
          Tests two arguments against a comparsion expression.
protected abstract  boolean testCompareResult(int result)
          Template method for evaluating the compare result.
 
Methods inherited from class org.springframework.rules.constraint.AbstractBinaryConstraint
test
 
Methods inherited from class org.springframework.rules.constraint.ConstraintsAccessor
all, all, and, any, any, bind, bind, bind, bind, bind, conjunction, disjunction, eq, eq, eq, eq, eq, eqProperty, eqProperty, getConstraints, gt, gt, gt, gt, gt, gt, gt, gte, gte, gte, gte, gte, gte, gte, gteProperty, gteProperty, gtProperty, gtProperty, ifTrue, ifTrueElse, inGroup, inGroup, inGroup, inRange, inRange, inRangeProperties, inRangeProperties, like, like, lt, lt, lt, lt, lt, lt, lt, lte, lte, lte, lte, lte, lte, lte, lteProperty, lteProperty, ltProperty, ltProperty, maxLength, method, minLength, not, not, or, present, present, range, range, range, range, range, range, range, regexp, regexp, required, required, testResultOf, unique, value
 
Methods inherited from class org.springframework.rules.closure.support.AlgorithmsAccessor
allTrue, allTrue, anyTrue, anyTrue, findAll, findAll, findFirst, findFirst, forEach, forEach, getAlgorithms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComparisonBinaryPredicate

protected ComparisonBinaryPredicate()
Creates a comparing binary predicate which operates on Comparable objects.


ComparisonBinaryPredicate

protected ComparisonBinaryPredicate(Comparator comparator)
Creates a comparing binary predicate which compares using the provided Comparator.

Parameters:
comparator - the comparator, may be null
Method Detail

getComparator

public Comparator getComparator()
Returns the comparator which is used to compare the arguments

Returns:
null if no custom comparator is defined

test

public boolean test(Object argument1,
                    Object argument2)
Tests two arguments against a comparsion expression. This method delegates to the testCompareResult(int)template method to evaluate the compareTo result.

Parameters:
argument1 - the first argument
argument2 - the second argument
Returns:
true if the comparsion result passes, false otherwise

testCompareResult

protected abstract boolean testCompareResult(int result)
Template method for evaluating the compare result.

Parameters:
result - The compare result
Returns:
true or false


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