Eat own dog food.

This commit is contained in:
Gary Gregory 2021-02-07 10:32:58 -05:00
parent 56dd87e8b8
commit 1131a0c933
1 changed files with 2 additions and 11 deletions

View File

@ -72,10 +72,7 @@ public class Objects {
* @see java.util.Objects#requireNonNull(Object)
*/
public static <T> @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 <T> @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;
}
/**