]> source.dussan.org Git - jgit.git/commitdiff
Use Objects.requireNonNull instead of a custom helper 46/139346/1
authorJonathan Nieder <jrn@google.com>
Fri, 22 Mar 2019 16:44:27 +0000 (09:44 -0700)
committerJonathan Nieder <jrn@google.com>
Fri, 22 Mar 2019 16:45:05 +0000 (09:45 -0700)
This simplifies the API surface and makes JGit internals into less of
a custom Java dialect.

Change-Id: Idbb7d4d1037c5336341088385b8e0a59c8b4c952

org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java

index 604cf1ee161eb7120aa10ca8932f1983e602232a..835e7b5fd204780bde6c0e40dfbbe28eb8839f17 100644 (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;
        }
 
index e724c1525c35b53baaa9cbbb13a84bdc8aeae09e..8f4468eef202f5ab9a7cb23821a85c7de6546fcd 100644 (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.
         *