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 2019/04/25 03:49:22 UTC

[maven-resolver] 03/08: [MRESOLVER-88] Replace equals with Object.equals

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

slachiewicz pushed a commit to branch MRESOLVER-88
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit b081fe35384812c0a24b624ac15b59c3f6495efa
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Dec 28 23:14:54 2018 +0100

    [MRESOLVER-88] Replace equals with Object.equals
---
 .../eclipse/aether/artifact/AbstractArtifact.java  | 19 ++++++------
 .../java/org/eclipse/aether/graph/Dependency.java  | 13 +++-----
 .../eclipse/aether/metadata/AbstractMetadata.java  | 19 ++++++------
 .../eclipse/aether/repository/LocalRepository.java |  8 ++---
 .../java/org/eclipse/aether/repository/Proxy.java  | 11 +++----
 .../aether/repository/RemoteRepository.java        | 19 ++++++------
 .../eclipse/aether/internal/impl/CacheUtils.java   |  7 +++--
 .../aether/internal/impl/collect/DataPool.java     | 12 +++-----
 .../internal/test/util/TestVersionConstraint.java  | 10 +++---
 .../internal/test/util/TestVersionRange.java       | 10 +++---
 .../eclipse/aether/transport/http/SslConfig.java   | 12 +++-----
 .../aether/util/artifact/ArtifactIdUtils.java      | 36 ++++++++++------------
 .../eclipse/aether/util/artifact/SubArtifact.java  |  4 ++-
 .../filter/AbstractPatternDependencyFilter.java    |  6 ++--
 .../graph/selector/ScopeDependencySelector.java    |  9 ++----
 .../util/repository/SecretAuthentication.java      |  9 ++----
 .../util/repository/StringAuthentication.java      | 10 +++---
 .../util/version/GenericVersionConstraint.java     |  9 ++----
 .../aether/util/version/GenericVersionRange.java   | 10 +++---
 19 files changed, 99 insertions(+), 134 deletions(-)

diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
index 7f065cd..65b4b56 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
@@ -23,6 +23,7 @@ import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -115,7 +116,7 @@ public abstract class AbstractArtifact
     public Artifact setFile( File file )
     {
         File current = getFile();
-        if ( ( current == null ) ? file == null : current.equals( file ) )
+        if ( Objects.equals( current, file ) )
         {
             return this;
         }
@@ -193,15 +194,13 @@ public abstract class AbstractArtifact
 
         Artifact that = (Artifact) obj;
 
-        return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
-            && getVersion().equals( that.getVersion() ) && getExtension().equals( that.getExtension() )
-            && getClassifier().equals( that.getClassifier() ) && eq( getFile(), that.getFile() )
-            && getProperties().equals( that.getProperties() );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( getArtifactId(), that.getArtifactId() )
+                && Objects.equals( getGroupId(), that.getGroupId() )
+                && Objects.equals( getVersion(), that.getVersion() )
+                && Objects.equals( getExtension(), that.getExtension() )
+                && Objects.equals( getClassifier(), that.getClassifier() )
+                && Objects.equals( getFile(), that.getFile() )
+                && Objects.equals( getProperties(), that.getProperties() );
     }
 
     /**
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java b/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java
index 039b8fa..cd43e6e 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java
@@ -26,6 +26,8 @@ import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.NoSuchElementException;
 import static java.util.Objects.requireNonNull;
+
+import java.util.Objects;
 import java.util.Set;
 
 import org.eclipse.aether.artifact.Artifact;
@@ -170,7 +172,7 @@ public final class Dependency
      */
     public Dependency setOptional( Boolean optional )
     {
-        if ( eq( this.optional, optional ) )
+        if ( Objects.equals( this.optional, optional ) )
         {
             return this;
         }
@@ -237,13 +239,8 @@ public final class Dependency
 
         Dependency that = (Dependency) obj;
 
-        return artifact.equals( that.artifact ) && scope.equals( that.scope ) && eq( optional, that.optional )
-            && exclusions.equals( that.exclusions );
-    }
-
-    private static <T> boolean eq( T o1, T o2 )
-    {
-        return ( o1 != null ) ? o1.equals( o2 ) : o2 == null;
+        return Objects.equals( artifact, that.artifact ) && Objects.equals( scope, that.scope )
+                && Objects.equals( optional, that.optional ) && Objects.equals( exclusions, that.exclusions );
     }
 
     @Override
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/AbstractMetadata.java b/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/AbstractMetadata.java
index 66dab74..3c0706a 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/AbstractMetadata.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/AbstractMetadata.java
@@ -23,6 +23,7 @@ import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * A skeleton class for metadata.
@@ -40,7 +41,7 @@ public abstract class AbstractMetadata
     public Metadata setFile( File file )
     {
         File current = getFile();
-        if ( ( current == null ) ? file == null : current.equals( file ) )
+        if ( Objects.equals( current, file ) )
         {
             return this;
         }
@@ -123,15 +124,13 @@ public abstract class AbstractMetadata
 
         Metadata that = (Metadata) obj;
 
-        return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
-            && getVersion().equals( that.getVersion() ) && getType().equals( that.getType() )
-            && getNature().equals( that.getNature() ) && eq( getFile(), that.getFile() )
-            && eq( getProperties(), that.getProperties() );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( getArtifactId(), that.getArtifactId() )
+                && Objects.equals( getGroupId(), that.getGroupId() )
+                && Objects.equals( getVersion(), that.getVersion() )
+                && Objects.equals( getType(), that.getType() )
+                && Objects.equals( getNature(), that.getNature() )
+                && Objects.equals( getFile(), that.getFile() )
+                && Objects.equals( getProperties(), that.getProperties() );
     }
 
     /**
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalRepository.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalRepository.java
index 32dce73..0ef9ccd 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalRepository.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalRepository.java
@@ -20,6 +20,7 @@ package org.eclipse.aether.repository;
  */
 
 import java.io.File;
+import java.util.Objects;
 
 /**
  * A repository on the local file system used to cache contents of remote repositories and to store locally installed
@@ -107,12 +108,7 @@ public final class LocalRepository
 
         LocalRepository that = (LocalRepository) obj;
 
-        return eq( basedir, that.basedir ) && eq( type, that.type );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( basedir, that.basedir ) && Objects.equals( type, that.type );
     }
 
     @Override
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/Proxy.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/Proxy.java
index 8e8cba1..25807a8 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/Proxy.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/Proxy.java
@@ -19,6 +19,8 @@ package org.eclipse.aether.repository;
  * under the License.
  */
 
+import java.util.Objects;
+
 /**
  * A proxy to use for connections to a repository.
  */
@@ -131,12 +133,9 @@ public final class Proxy
 
         Proxy that = (Proxy) obj;
 
-        return eq( type, that.type ) && eq( host, that.host ) && port == that.port && eq( auth, that.auth );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( type, that.type )
+                && Objects.equals( host, that.host ) && port == that.port
+                && Objects.equals( auth, that.auth );
     }
 
     @Override
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
index 75aa03b..f20461e 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
@@ -24,6 +24,8 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import static java.util.Objects.requireNonNull;
+
+import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -253,15 +255,12 @@ public final class RemoteRepository
 
         RemoteRepository that = (RemoteRepository) obj;
 
-        return eq( url, that.url ) && eq( type, that.type ) && eq( id, that.id )
-            && eq( releasePolicy, that.releasePolicy ) && eq( snapshotPolicy, that.snapshotPolicy )
-            && eq( proxy, that.proxy ) && eq( authentication, that.authentication )
-            && eq( mirroredRepositories, that.mirroredRepositories ) && repositoryManager == that.repositoryManager;
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( url, that.url ) && Objects.equals( type, that.type )
+                && Objects.equals( id, that.id ) && Objects.equals( releasePolicy, that.releasePolicy )
+                && Objects.equals( snapshotPolicy, that.snapshotPolicy ) && Objects.equals( proxy, that.proxy )
+                && Objects.equals( authentication, that.authentication )
+                && Objects.equals( mirroredRepositories, that.mirroredRepositories )
+                && repositoryManager == that.repositoryManager;
     }
 
     @Override
@@ -361,7 +360,7 @@ public final class RemoteRepository
 
         private <T> void delta( int flag, T builder, T prototype )
         {
-            boolean equal = ( builder != null ) ? builder.equals( prototype ) : prototype == null;
+            boolean equal = Objects.equals( builder, prototype );
             if ( equal )
             {
                 delta &= ~flag;
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java
index d7e8f01..4db436b 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java
@@ -21,6 +21,7 @@ package org.eclipse.aether.internal.impl;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.Objects;
 
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.repository.ArtifactRepository;
@@ -39,7 +40,7 @@ public final class CacheUtils
 
     public static <T> boolean eq( T s1, T s2 )
     {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( s1, s2 );
     }
 
     public static int hash( Object obj )
@@ -71,7 +72,7 @@ public final class CacheUtils
             return true;
         }
 
-        return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() )
+        return Objects.equals( r1.getId(), r2.getId() ) && Objects.equals( r1.getUrl(), r2.getUrl() )
             && policyEquals( r1.getPolicy( false ), r2.getPolicy( false ) )
             && policyEquals( r1.getPolicy( true ), r2.getPolicy( true ) );
     }
@@ -83,7 +84,7 @@ public final class CacheUtils
             return true;
         }
         // update policy doesn't affect contents
-        return p1.isEnabled() == p2.isEnabled() && eq( p1.getChecksumPolicy(), p2.getChecksumPolicy() );
+        return p1.isEnabled() == p2.isEnabled() && Objects.equals( p1.getChecksumPolicy(), p2.getChecksumPolicy() );
     }
 
     public static boolean repositoriesEquals( List<RemoteRepository> r1, List<RemoteRepository> r2 )
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java
index b2390bb..780c10c 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.WeakHashMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -423,9 +424,9 @@ final class DataPool
                 return false;
             }
             GraphKey that = (GraphKey) obj;
-            return artifact.equals( that.artifact ) && repositories.equals( that.repositories )
-                && eq( selector, that.selector ) && eq( manager, that.manager ) && eq( traverser, that.traverser )
-                && eq( filter, that.filter );
+            return Objects.equals( artifact, that.artifact ) && Objects.equals( repositories, that.repositories )
+                && Objects.equals( selector, that.selector ) && Objects.equals( manager, that.manager )
+                && Objects.equals( traverser, that.traverser ) && Objects.equals( filter, that.filter );
         }
 
         @Override
@@ -434,11 +435,6 @@ final class DataPool
             return hashCode;
         }
 
-        private static <T> boolean eq( T o1, T o2 )
-        {
-            return ( o1 != null ) ? o1.equals( o2 ) : o2 == null;
-        }
-
         private static int hash( Object o )
         {
             return ( o != null ) ? o.hashCode() : 0;
diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java
index 04ede73..0f93a59 100644
--- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java
+++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java
@@ -25,6 +25,8 @@ import org.eclipse.aether.version.Version;
 import org.eclipse.aether.version.VersionConstraint;
 import org.eclipse.aether.version.VersionRange;
 
+import java.util.Objects;
+
 /**
  * A constraint on versions for a dependency.
  */
@@ -100,12 +102,8 @@ final class TestVersionConstraint
 
         TestVersionConstraint that = (TestVersionConstraint) obj;
 
-        return eq( range, that.range ) && eq( version, that.getVersion() );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( range, that.range )
+                && Objects.equals( version, that.getVersion() );
     }
 
     @Override
diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionRange.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionRange.java
index dfff78a..52fb45d 100644
--- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionRange.java
+++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionRange.java
@@ -23,6 +23,8 @@ import org.eclipse.aether.version.InvalidVersionSpecificationException;
 import org.eclipse.aether.version.Version;
 import org.eclipse.aether.version.VersionRange;
 
+import java.util.Objects;
+
 /**
  * A version range inspired by mathematical range syntax. For example, "[1.0,2.0)", "[1.0,)" or "[1.0]".
  */
@@ -202,12 +204,8 @@ final class TestVersionRange
         TestVersionRange that = (TestVersionRange) obj;
 
         return upperBoundInclusive == that.upperBoundInclusive && lowerBoundInclusive == that.lowerBoundInclusive
-            && eq( upperBound, that.upperBound ) && eq( lowerBound, that.lowerBound );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+            && Objects.equals( upperBound, that.upperBound )
+            && Objects.equals( lowerBound, that.lowerBound );
     }
 
     @Override
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslConfig.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslConfig.java
index 4c252a2..5655b75 100644
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslConfig.java
+++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslConfig.java
@@ -20,6 +20,7 @@ package org.eclipse.aether.transport.http;
  */
 
 import java.util.Arrays;
+import java.util.Objects;
 
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLContext;
@@ -89,13 +90,10 @@ final class SslConfig
             return false;
         }
         SslConfig that = (SslConfig) obj;
-        return eq( context, that.context ) && eq( verifier, that.verifier )
-            && Arrays.equals( cipherSuites, that.cipherSuites ) && Arrays.equals( protocols, that.protocols );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( context, that.context )
+                && Objects.equals( verifier, that.verifier )
+                && Arrays.equals( cipherSuites, that.cipherSuites )
+                && Arrays.equals( protocols, that.protocols );
     }
 
     @Override
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java
index 54ffc64..27a1f0d 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java
@@ -21,6 +21,8 @@ package org.eclipse.aether.util.artifact;
 
 import org.eclipse.aether.artifact.Artifact;
 
+import java.util.Objects;
+
 /**
  * A utility class for artifact identifiers.
  */
@@ -165,23 +167,23 @@ public final class ArtifactIdUtils
         {
             return false;
         }
-        if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) )
+        if ( !Objects.equals( artifact1.getArtifactId(), artifact2.getArtifactId() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) )
+        if ( !Objects.equals( artifact1.getGroupId(), artifact2.getGroupId() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) )
+        if ( !Objects.equals( artifact1.getExtension(), artifact2.getExtension() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) )
+        if ( !Objects.equals( artifact1.getClassifier(), artifact2.getClassifier() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getVersion(), artifact2.getVersion() ) )
+        if ( !Objects.equals( artifact1.getVersion(), artifact2.getVersion() ) )
         {
             return false;
         }
@@ -203,23 +205,23 @@ public final class ArtifactIdUtils
         {
             return false;
         }
-        if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) )
+        if ( !Objects.equals( artifact1.getArtifactId(), artifact2.getArtifactId() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) )
+        if ( !Objects.equals( artifact1.getGroupId(), artifact2.getGroupId() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) )
+        if ( !Objects.equals( artifact1.getExtension(), artifact2.getExtension() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) )
+        if ( !Objects.equals( artifact1.getClassifier(), artifact2.getClassifier() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getBaseVersion(), artifact2.getBaseVersion() ) )
+        if ( !Objects.equals( artifact1.getBaseVersion(), artifact2.getBaseVersion() ) )
         {
             return false;
         }
@@ -242,28 +244,22 @@ public final class ArtifactIdUtils
         {
             return false;
         }
-        if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) )
+        if ( !Objects.equals( artifact1.getArtifactId(), artifact2.getArtifactId() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) )
+        if ( !Objects.equals( artifact1.getGroupId(), artifact2.getGroupId() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) )
+        if ( !Objects.equals( artifact1.getExtension(), artifact2.getExtension() ) )
         {
             return false;
         }
-        if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) )
+        if ( !Objects.equals( artifact1.getClassifier(), artifact2.getClassifier() ) )
         {
             return false;
         }
         return true;
     }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
 }
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java
index e0beb21..83dd3a5 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java
@@ -21,6 +21,8 @@ package org.eclipse.aether.util.artifact;
 
 import java.io.File;
 import java.util.Map;
+import java.util.Objects;
+
 import static java.util.Objects.requireNonNull;
 
 import org.eclipse.aether.artifact.AbstractArtifact;
@@ -166,7 +168,7 @@ public final class SubArtifact
 
     public Artifact setFile( File file )
     {
-        if ( ( this.file == null ) ? file == null : this.file.equals( file ) )
+        if ( Objects.equals( this.file, file ) )
         {
             return this;
         }
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java
index 1628363..f7a3fc2 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 import org.eclipse.aether.artifact.Artifact;
@@ -215,9 +216,8 @@ class AbstractPatternDependencyFilter
 
         final AbstractPatternDependencyFilter that = (AbstractPatternDependencyFilter) obj;
 
-        return this.patterns.equals( that.patterns )
-            && ( this.versionScheme == null ? that.versionScheme == null
-                            : this.versionScheme.equals( that.versionScheme ) );
+        return Objects.equals( this.patterns, that.patterns )
+            && Objects.equals( this.versionScheme, that.versionScheme );
     }
 
     @Override
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
index 13bfda1..ab5d311 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.TreeSet;
 
 import org.eclipse.aether.collection.DependencyCollectionContext;
@@ -130,12 +131,8 @@ public final class ScopeDependencySelector
         }
 
         ScopeDependencySelector that = (ScopeDependencySelector) obj;
-        return transitive == that.transitive && eq( included, that.included ) && eq( excluded, that.excluded );
-    }
-
-    private static <T> boolean eq( T o1, T o2 )
-    {
-        return ( o1 != null ) ? o1.equals( o2 ) : o2 == null;
+        return transitive == that.transitive && Objects.equals( included, that.included )
+                && Objects.equals( excluded, that.excluded );
     }
 
     @Override
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java
index 819f82f..95a9471 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java
@@ -21,6 +21,8 @@ package org.eclipse.aether.util.repository;
 
 import java.util.Arrays;
 import java.util.Map;
+import java.util.Objects;
+
 import static java.util.Objects.requireNonNull;
 
 import org.eclipse.aether.repository.Authentication;
@@ -140,7 +142,7 @@ final class SecretAuthentication
             return false;
         }
         SecretAuthentication that = (SecretAuthentication) obj;
-        if ( !eq( key, that.key ) || secretHash != that.secretHash )
+        if ( !Objects.equals( key, that.key ) || secretHash != that.secretHash )
         {
             return false;
         }
@@ -159,11 +161,6 @@ final class SecretAuthentication
         }
     }
 
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
     @Override
     public int hashCode()
     {
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java
index bb87b02..5012744 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java
@@ -20,6 +20,8 @@ package org.eclipse.aether.util.repository;
  */
 
 import java.util.Map;
+import java.util.Objects;
+
 import static java.util.Objects.requireNonNull;
 
 import org.eclipse.aether.repository.Authentication;
@@ -69,12 +71,8 @@ final class StringAuthentication
             return false;
         }
         StringAuthentication that = (StringAuthentication) obj;
-        return eq( key, that.key ) && eq( value, that.value );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( key, that.key )
+                && Objects.equals( value, that.value );
     }
 
     @Override
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java
index 8cf66b0..8186941 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java
@@ -25,6 +25,8 @@ import org.eclipse.aether.version.Version;
 import org.eclipse.aether.version.VersionConstraint;
 import org.eclipse.aether.version.VersionRange;
 
+import java.util.Objects;
+
 /**
  * A constraint on versions for a dependency.
  */
@@ -100,12 +102,7 @@ final class GenericVersionConstraint
 
         GenericVersionConstraint that = (GenericVersionConstraint) obj;
 
-        return eq( range, that.range ) && eq( version, that.getVersion() );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( range, that.range ) && Objects.equals( version, that.getVersion() );
     }
 
     @Override
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java
index ef1f012..660cc7a 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java
@@ -23,6 +23,8 @@ import org.eclipse.aether.version.InvalidVersionSpecificationException;
 import org.eclipse.aether.version.Version;
 import org.eclipse.aether.version.VersionRange;
 
+import java.util.Objects;
+
 /**
  * A version range inspired by mathematical range syntax. For example, "[1.0,2.0)", "[1.0,)" or "[1.0]".
  */
@@ -191,12 +193,8 @@ final class GenericVersionRange
 
         GenericVersionRange that = (GenericVersionRange) obj;
 
-        return eq( upperBound, that.upperBound ) && eq( lowerBound, that.lowerBound );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
+        return Objects.equals( upperBound, that.upperBound )
+                && Objects.equals( lowerBound, that.lowerBound );
     }
 
     @Override