diff --git a/src/main/java/org/apache/commons/lang3/function/Objects.java b/src/main/java/org/apache/commons/lang3/function/Objects.java index a294b2b96..59d20ab8c 100755 --- a/src/main/java/org/apache/commons/lang3/function/Objects.java +++ b/src/main/java/org/apache/commons/lang3/function/Objects.java @@ -72,10 +72,7 @@ public class Objects { * @see java.util.Objects#requireNonNull(Object) */ public static @Nonnull T requireNonNull(@Nullable T value) throws NullPointerException { - if (value == null) { - throw new NullPointerException("The value must not be null."); - } - return value; + return requireNonNull(value, "The value must not be null."); } /** @@ -90,13 +87,7 @@ public class Objects { * @see java.util.Objects#requireNonNull(Object) */ public static @Nonnull T requireNonNull(@Nullable T value, @Nonnull T defaultValue) throws NullPointerException { - if (value == null) { - if (defaultValue == null) { - throw new NullPointerException("The default value must not be null."); - } - return defaultValue; - } - return value; + return value == null ? requireNonNull(defaultValue) : value; } /**