File tree Expand file tree Collapse file tree
rollbar-java/src/main/java/com/rollbar/notifier/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 * Helper class that provides Java 7 features.
1212 */
1313public class ObjectsUtils {
14-
14+
1515 private static Logger logger = LoggerFactory .getLogger (ObjectsUtils .class );
16-
16+
1717 public static boolean equals (Object object1 , Object object2 ) {
1818 return object1 == object2 || object1 != null && object1 .equals (object2 );
1919 }
20-
20+
2121 public static int hash (Object ... objects ) {
2222 return Arrays .hashCode (objects );
2323 }
24-
24+
25+ /**
26+ * Checks that the specified object reference is not null.
27+ *
28+ * @param object the object reference to check for nullity
29+ * @param errorMessage detail message to be used in the event that a NullPointerException is thrown
30+ * @param <T> the type of the reference
31+ * @return object if not null
32+ */
2533 public static <T > T requireNonNull (T object , String errorMessage ) {
2634 if (object == null ) {
2735 throw new NullPointerException (errorMessage );
2836 } else {
29- return object ;
37+ return object ;
3038 }
3139 }
32-
40+
41+ /**
42+ * Closes stream if possible.
43+ *
44+ * @param closeable the closable implementation to close
45+ */
3346 public static void close (final Closeable closeable ) {
34- try {
35- if (closeable != null ) {
36- closeable .close ();
37- }
38- } catch (IOException e ) {
39- logger .error ("Unable to close stream." , e );
40- }
47+ try {
48+ if (closeable != null ) {
49+ closeable .close ();
50+ }
51+ } catch (IOException e ) {
52+ logger .error ("Unable to close stream." , e );
53+ }
4154 }
4255}
You can’t perform that action at this time.
0 commit comments