View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 org.kuali.rice.kns.util;
17  
18  /**
19   * 
20   */
21  public class NumberUtils extends org.apache.commons.lang.math.NumberUtils {
22      /**
23       * @param i
24       * @param defaultValue
25       * @return intValue of i, or defaultValue if i is null
26       */
27      public static int intValue(Integer i, int defaultValue) {
28          int value = defaultValue;
29  
30          if (i != null) {
31              value = i.intValue();
32          }
33  
34          return value;
35      }
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          }
49          else if (i != null) {
50              equal = i.equals(j);
51          }
52  
53          return equal;
54      }
55  
56  
57      /**
58       * @param i
59       * @param j
60       * @return true if both of the given KualiDecimals are null, or point to instances with the same mathematical value
61       */
62      public static boolean equals(KualiDecimal j, KualiDecimal k) {
63          boolean equal = false;
64  
65          if ((j == null) && (k == null)) {
66              equal = true;
67          }
68          else if (j != null) {
69              equal = j.equals(k);
70          }
71  
72          return equal;
73      }
74  }