KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > core > constraint > IsLessThan


1 /* Copyright (c) 2000-2004 jMock.org
2  */

3 package org.jmock.core.constraint;
4
5 import org.jmock.core.Constraint;
6
7
8 /**
9  * Is the value less than another {@link java.lang.Comparable} value?
10  */

11 public class IsLessThan implements Constraint
12 {
13     private Comparable JavaDoc upperLimit;
14
15     public IsLessThan( Comparable JavaDoc upperLimit ) {
16         this.upperLimit = upperLimit;
17     }
18
19     public boolean eval( Object JavaDoc arg ) {
20         return upperLimit.compareTo(arg) > 0;
21     }
22
23     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
24         return buffer.append("a value less than <")
25                 .append(upperLimit)
26                 .append(">");
27     }
28 }
29
Popular Tags