1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springmodules.validation.valang.predicates;
18
19 import java.math.BigDecimal;
20 import java.util.Date;
21
22 import org.springmodules.validation.valang.functions.Function;
23
24 /**
25 * Tests if a value is less than to another.
26 *
27 * @author David Winterfeldt
28 */
29 public class LessThanTestPredicate extends AbstractCompareTestPredicate {
30
31 /**
32 * <p>Constructor taking two functions and an operator.
33 *
34 * @param leftFunction the left function
35 * @param operator the operator.
36 */
37 public LessThanTestPredicate(Function leftFunction, Operator operator, Function rightFunction, int line, int column) {
38 super(leftFunction, operator, rightFunction, line, column, "<");
39 }
40
41 /**
42 * Evaluates a <code>BigDecimal</code> and is called by
43 * <code>evaluate</code>.
44 */
45 @Override
46 protected boolean doEvaluate(BigDecimal leftValue, BigDecimal rightValue) {
47 return (leftValue.compareTo(rightValue) < 0);
48 }
49
50 /**
51 * Evaluates a <code>BigDecimal</code> and is called by
52 * <code>evaluate</code>.
53 */
54 @Override
55 protected boolean doEvaluate(Date leftValue, Date rightValue) {
56 return (leftValue.getTime() < rightValue.getTime());
57 }
58
59 }