You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/02/02 19:29:44 UTC

[maven-indexer] branch pull/45 created (now 7cee2d5)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch pull/45
in repository https://gitbox.apache.org/repos/asf/maven-indexer.git.


      at 7cee2d5  Replace null checks with Objects.requireNonNull

This branch includes the following new commits:

     new 7cee2d5  Replace null checks with Objects.requireNonNull

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-indexer] 01/01: Replace null checks with Objects.requireNonNull

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch pull/45
in repository https://gitbox.apache.org/repos/asf/maven-indexer.git

commit 7cee2d5b2e21f7c844eb6b77bb49f3f2053b46ae
Author: sixcorners <si...@gmail.com>
AuthorDate: Sun Feb 2 09:59:04 2020 -0600

    Replace null checks with Objects.requireNonNull
    
    Closes #45
---
 .../main/java/org/apache/maven/index/reader/IndexReader.java  |  6 ++----
 .../main/java/org/apache/maven/index/reader/IndexWriter.java  | 11 +++--------
 .../src/main/java/org/apache/maven/index/reader/Record.java   | 11 +++--------
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexReader.java b/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexReader.java
index 54a5c92..b2c11f9 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexReader.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexReader.java
@@ -29,6 +29,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Objects;
 import java.util.Properties;
 
 import static org.apache.maven.index.reader.Utils.loadProperties;
@@ -62,10 +63,7 @@ public class IndexReader
     public IndexReader( final WritableResourceHandler local, final ResourceHandler remote )
         throws IOException
     {
-        if ( remote == null )
-        {
-            throw new NullPointerException( "remote resource handler null" );
-        }
+        Objects.requireNonNull( remote, "remote resource handler null" );
         this.local = local;
         this.remote = remote;
         remoteIndexProperties = loadProperties( remote.locate( Utils.INDEX_FILE_PREFIX + ".properties" ) );
diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexWriter.java b/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexWriter.java
index dd91510..6dbae48 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexWriter.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/IndexWriter.java
@@ -27,6 +27,7 @@ import java.text.ParseException;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.UUID;
 
@@ -59,14 +60,8 @@ public class IndexWriter
     public IndexWriter( final WritableResourceHandler local, final String indexId, final boolean incrementalSupported )
         throws IOException
     {
-        if ( local == null )
-        {
-            throw new NullPointerException( "local resource handler null" );
-        }
-        if ( indexId == null )
-        {
-            throw new NullPointerException( "indexId null" );
-        }
+        Objects.requireNonNull( local, "local resource handler null" );
+        Objects.requireNonNull( indexId, "indexId null" );
         this.local = local;
         Properties indexProperties = loadProperties( local.locate( Utils.INDEX_FILE_PREFIX + ".properties" ) );
         if ( incrementalSupported && indexProperties != null )
diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/Record.java b/indexer-reader/src/main/java/org/apache/maven/index/reader/Record.java
index 6b502b5..046ff9b 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/Record.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/Record.java
@@ -20,6 +20,7 @@ package org.apache.maven.index.reader;
  */
 
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Maven 2 Index record.
@@ -41,14 +42,8 @@ public final class Record
 
         public EntryKey( final String name, final Class<T> proto )
         {
-            if ( name == null )
-            {
-                throw new NullPointerException( "name is null" );
-            }
-            if ( proto == null )
-            {
-                throw new NullPointerException( "proto is null" );
-            }
+            Objects.requireNonNull( name, "name is null" );
+            Objects.requireNonNull( proto, "proto is null" );
             this.name = name;
             this.proto = proto;
         }