Browse Source

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
tags/v5.4.0.201905081430-m2
Jonathan Nieder 5 years ago
parent
commit
cc714d3bbb

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java 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 class Git implements AutoCloseable {
}

Git(Repository repo, boolean closeRepo) {
this.repo = checkNotNull(repo);
this.repo = requireNonNull(repo);
this.closeRepo = closeRepo;
}


+ 0
- 24
org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java 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.
*

Loading…
Cancel
Save