Use Objects.requireNonNull instead of a custom helper

This simplifies the API surface and makes JGit internals into less of
a custom Java dialect.

Change-Id: Idbb7d4d1037c5336341088385b8e0a59c8b4c952
This commit is contained in:
Jonathan Nieder 2019-03-22 09:44:27 -07:00
parent 3551e443fc
commit cc714d3bbb
2 changed files with 2 additions and 26 deletions

View File

@ -43,7 +43,7 @@
*/
package org.eclipse.jgit.api;
import static org.eclipse.jgit.lib.Constants.checkNotNull;
import static java.util.Objects.requireNonNull;
import java.io.File;
import java.io.IOException;
@ -222,7 +222,7 @@ public Git(Repository repo) {
}
Git(Repository repo, boolean closeRepo) {
this.repo = checkNotNull(repo);
this.repo = requireNonNull(repo);
this.closeRepo = closeRepo;
}

View File

@ -465,30 +465,6 @@ public final class Constants {
*/
public static final String ATTR_BUILTIN_BINARY_MERGER = "binary"; //$NON-NLS-1$
/**
* Null checker for a {@code @NonNull} parameter.
*
* <p>This is a briefer equivalent to
* <pre>
* if (arg == null) {
* throw new NullPointerException();
* }
* </pre>
* with the added benefit that it does not trigger nullness warnings when
* {@code arg} is declared as {@code @NonNull}.
*
* @param arg a non-null object reference
* @return arg
* @throws NullPointerException if {@code arg} is null
* @since 5.4
*/
public static <T> T checkNotNull(T arg) {
if (arg == null) {
throw new NullPointerException();
}
return arg;
}
/**
* Create a new digest function for objects.
*