01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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 org.kuali.core.util;
17:
18: /**
19: *
20: */
21: public class NumberUtils extends
22: org.apache.commons.lang.math.NumberUtils {
23: /**
24: * @param i
25: * @param defaultValue
26: * @return intValue of i, or defaultValue if i is null
27: */
28: public static int intValue(Integer i, int defaultValue) {
29: int value = defaultValue;
30:
31: if (i != null) {
32: value = i.intValue();
33: }
34:
35: return value;
36: }
37:
38: /**
39: * @param i
40: * @param j
41: * @return true if both of the integers are null, or point to instances with the same mathematical value
42: */
43: public static boolean equals(Integer i, Integer j) {
44: boolean equal = false;
45:
46: if ((i == null) && (j == null)) {
47: equal = true;
48: } else if (i != null) {
49: equal = i.equals(j);
50: }
51:
52: return equal;
53: }
54:
55: /**
56: * @param i
57: * @param j
58: * @return true if both of the given KualiDecimals are null, or point to instances with the same mathematical value
59: */
60: public static boolean equals(KualiDecimal j, KualiDecimal k) {
61: boolean equal = false;
62:
63: if ((j == null) && (k == null)) {
64: equal = true;
65: } else if (j != null) {
66: equal = j.equals(k);
67: }
68:
69: return equal;
70: }
71: }
|