create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / util / Utils.java
1 package net.sf.openrocket.util;
2
3 public class Utils {
4         
5         /**
6          * Null-safe equals method.
7          * 
8          * @param first         the first object to compare
9          * @param second        the second object to compare
10          * @return                      whether the two objects are both equal or both <code>null</code>
11          */
12         public static boolean equals(Object first, Object second) {
13                 if (first == null) {
14                         return second == null;
15                 } else {
16                         return first.equals(second);
17                 }
18         }
19         
20         
21         /**
22          * Check whether an array contains a specified object.
23          * 
24          * @param array         the array to search
25          * @param search        the object to search for
26          * @return                      whether the object was in the array
27          */
28         public static boolean contains(Object[] array, Object search) {
29                 for (Object o : array) {
30                         if (equals(o, search)) {
31                                 return true;
32                         }
33                 }
34                 return false;
35         }
36         
37 }