KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nl > hippo > asserts > IntegerAsserts


1 /*
2  * Copyright 2004 Hippo Webworks.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package nl.hippo.asserts;
17
18 public class IntegerAsserts extends Asserts
19 {
20     
21     public static void equal(int first, int second, ExceptionFactory exceptionFactory, String JavaDoc firstIdentifier, String JavaDoc secondIdentifier)
22     {
23         if (first != second)
24         {
25             throw createException(exceptionFactory, firstIdentifier + " must be equal to " + secondIdentifier);
26         }
27     }
28     
29     public static void notEqual(int first, int second, ExceptionFactory exceptionFactory, String JavaDoc firstIdentifier, String JavaDoc secondIdentifier)
30     {
31         if (first == second)
32         {
33             throw createException(exceptionFactory, firstIdentifier + " must not be equal to " + secondIdentifier);
34         }
35     }
36     
37     public static void lessThan(int first, int second, ExceptionFactory exceptionFactory, String JavaDoc firstIdentifier, String JavaDoc secondIdentifier)
38     {
39         if (first >= second)
40         {
41             throw createException(exceptionFactory, firstIdentifier + " must be less than " + secondIdentifier);
42         }
43     }
44
45     public static void lessThanOrEqual(int first, int second, ExceptionFactory exceptionFactory, String JavaDoc firstIdentifier, String JavaDoc secondIdentifier)
46     {
47         if (first > second)
48         {
49             throw createException(exceptionFactory, firstIdentifier + " must be less than or equal to " + secondIdentifier);
50         }
51     }
52
53     public static void greaterThan(int first, int second, ExceptionFactory exceptionFactory, String JavaDoc firstIdentifier, String JavaDoc secondIdentifier)
54     {
55         if (first <= second)
56         {
57             throw createException(exceptionFactory, firstIdentifier + " must be greater than " + secondIdentifier);
58         }
59     }
60
61     public static void greaterThanOrEqual(int first, int second, ExceptionFactory exceptionFactory, String JavaDoc firstIdentifier, String JavaDoc secondIdentifier)
62     {
63         if (first < second)
64         {
65             throw createException(exceptionFactory, firstIdentifier + " must be greater than or equal to " + secondIdentifier);
66         }
67     }
68
69     private IntegerAsserts()
70     {
71         super();
72     }
73
74 }
75
Popular Tags