From cc714d3bbb23d62d3c3239b69bc81a349b2c4c43 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 22 Mar 2019 09:44:27 -0700 Subject: [PATCH] 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 --- .../src/org/eclipse/jgit/api/Git.java | 4 ++-- .../src/org/eclipse/jgit/lib/Constants.java | 24 ------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java index 604cf1ee1..835e7b5fd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java @@ -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; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java index e724c1525..8f4468eef 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java @@ -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. - * - *

This is a briefer equivalent to - *

-	 * if (arg == null) {
-	 *   throw new NullPointerException();
-	 * }
-	 * 
- * 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 checkNotNull(T arg) { - if (arg == null) { - throw new NullPointerException(); - } - return arg; - } - /** * Create a new digest function for objects. *