Skip to content

Commit 54b86dc

Browse files
committed
proper code formatting for ObjectsUtils
1 parent 27805fa commit 54b86dc

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

rollbar-java/src/main/java/com/rollbar/notifier/util/ObjectsUtils.java

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,45 @@
1111
* Helper class that provides Java 7 features.
1212
*/
1313
public 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
}

0 commit comments

Comments
 (0)