Skip to content

Commit 22c9b2b

Browse files
author
Vincent Potucek
committed
Pull #2287: use Objects#requireNonNull
1 parent 746d2b1 commit 22c9b2b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

impl/maven-impl/src/main/java/org/apache/maven/impl/ImplUtils.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ class ImplUtils {
3131
*/
3232
@Deprecated
3333
public static <T> T nonNull(T t) {
34-
if (t == null) {
35-
throw new IllegalArgumentException();
36-
}
37-
return t;
34+
return Objects.requireNonNull(t);
3835
}
3936

37+
/**
38+
* @deprecated Use {@link Objects#requireNonNull(Object, String)} instead.
39+
*/
40+
@Deprecated
4041
public static <T> T nonNull(T t, String name) {
41-
if (t == null) {
42-
throw new IllegalArgumentException(name + " cannot be null");
43-
}
44-
return t;
42+
return Objects.requireNonNull(t, name);
4543
}
4644

4745
public static <T> T cast(Class<T> clazz, Object o, String name) {

0 commit comments

Comments
 (0)