From 38efe8444c91e7c1dbf489bc672841c9458ae9ec Mon Sep 17 00:00:00 2001 From: rfscholte Date: Tue, 10 Sep 2019 18:51:18 +0200 Subject: [PATCH] Fix checkstyle reported errors --- .../artifact/versioning/VersionRange.java | 7 ++---- .../resolver/DebugResolutionListener.java | 2 +- .../repository/MavenArtifactRepository.java | 2 +- .../resolver/filter/ScopeArtifactFilter.java | 7 +----- .../org/apache/maven/plugin/CacheUtils.java | 2 +- .../plugin/DefaultPluginDescriptorCache.java | 13 ++++------ .../apache/maven/project/MavenProject.java | 10 +++----- .../artifact/DefaultMavenMetadataCache.java | 24 ++++++++----------- .../maven/toolchain/DefaultToolchain.java | 9 ++----- 9 files changed, 26 insertions(+), 50 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java index af37d181f2..bbc6523607 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java @@ -593,11 +593,8 @@ public class VersionRange } VersionRange other = (VersionRange) obj; - boolean equals = - Objects.equals(recommendedVersion, other.recommendedVersion); - equals &= - Objects.equals(restrictions, other.restrictions); - return equals; + return Objects.equals( recommendedVersion, other.recommendedVersion ) + && Objects.equals( restrictions, other.restrictions ); } public int hashCode() diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java index e011760216..56c1805cd2 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java @@ -70,7 +70,7 @@ public class DebugResolutionListener String omittedVersion = omitted.getVersion(); String keptVersion = kept.getVersion(); - if (!Objects.equals(omittedVersion, keptVersion)) + if ( !Objects.equals( omittedVersion, keptVersion ) ) { logger.debug( indent + omitted + " (removed - nearer found: " + keptVersion + ")" ); } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java index 4c081a17d2..c330fda428 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java @@ -354,7 +354,7 @@ public class MavenArtifactRepository protected static boolean eq( T s1, T s2 ) { - return Objects.equals(s1, s2); + return Objects.equals( s1, s2 ); } public Authentication getAuthentication() diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilter.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilter.java index 651acb4b7e..d87ee85e71 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilter.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilter.java @@ -69,12 +69,7 @@ public class ScopeArtifactFilter ScopeArtifactFilter other = (ScopeArtifactFilter) obj; - return equals( scope, other.scope ); - } - - private static boolean equals( T str1, T str2 ) - { - return Objects.equals(str1, str2); + return Objects.equals( scope, other.scope ); } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java index ec874c6cca..118db83119 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java @@ -39,7 +39,7 @@ class CacheUtils @Deprecated public static boolean eq( T s1, T s2 ) { - return Objects.equals(s1, s2); + return Objects.equals( s1, s2 ); } /** diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java index ba62888c95..0da9935351 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java @@ -194,9 +194,11 @@ public class DefaultPluginDescriptorCache CacheKey that = (CacheKey) obj; - return eq( this.artifactId, that.artifactId ) && eq( this.groupId, that.groupId ) - && eq( this.version, that.version ) && eq( this.localRepo, that.localRepo ) - && eq( this.workspace, that.workspace ) + return Objects.equals( this.artifactId, that.artifactId ) + && Objects.equals( this.groupId, that.groupId ) + && Objects.equals( this.version, that.version ) + && Objects.equals( this.localRepo, that.localRepo ) + && Objects.equals( this.workspace, that.workspace ) && RepositoryUtils.repositoriesEquals( this.repositories, that.repositories ); } @@ -211,11 +213,6 @@ public class DefaultPluginDescriptorCache return obj != null ? obj.hashCode() : 0; } - private static boolean eq( T s1, T s2 ) - { - return Objects.equals(s1, s2); - } - } } diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 17bf836f9a..ceb39e21a2 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -1056,13 +1056,9 @@ public class MavenProject MavenProject that = (MavenProject) other; - return eq( getArtifactId(), that.getArtifactId() ) && eq( getGroupId(), that.getGroupId() ) - && eq( getVersion(), that.getVersion() ); - } - - private static boolean eq( T s1, T s2 ) - { - return Objects.equals(s1, s2); + return Objects.equals( getArtifactId(), that.getArtifactId() ) + && Objects.equals( getGroupId(), that.getGroupId() ) + && Objects.equals( getVersion(), that.getVersion() ); } @Override diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultMavenMetadataCache.java b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultMavenMetadataCache.java index 0b9c577558..6f2eb08cd3 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultMavenMetadataCache.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultMavenMetadataCache.java @@ -133,13 +133,13 @@ public class DefaultMavenMetadataCache return true; } - return eq( a1.getGroupId(), a2.getGroupId() ) - && eq( a1.getArtifactId(), a2.getArtifactId() ) - && eq( a1.getType(), a2.getType() ) - && eq( a1.getVersion(), a2.getVersion() ) - && eq( a1.getClassifier(), a2.getClassifier() ) - && eq( a1.getScope(), a2.getScope() ) - && eq( a1.getDependencyFilter(), a2.getDependencyFilter() ) + return Objects.equals( a1.getGroupId(), a2.getGroupId() ) + && Objects.equals( a1.getArtifactId(), a2.getArtifactId() ) + && Objects.equals( a1.getType(), a2.getType() ) + && Objects.equals( a1.getVersion(), a2.getVersion() ) + && Objects.equals( a1.getClassifier(), a2.getClassifier() ) + && Objects.equals( a1.getScope(), a2.getScope() ) + && Objects.equals( a1.getDependencyFilter(), a2.getDependencyFilter() ) && a1.isOptional() == a2.isOptional(); } @@ -167,7 +167,8 @@ public class DefaultMavenMetadataCache 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() ) && repositoryPolicyEquals( r1.getReleases(), r2.getReleases() ) && repositoryPolicyEquals( r1.getSnapshots(), r2.getSnapshots() ); } @@ -179,7 +180,7 @@ public class DefaultMavenMetadataCache return true; } - return p1.isEnabled() == p2.isEnabled() && eq( p1.getUpdatePolicy(), p2.getUpdatePolicy() ); + return p1.isEnabled() == p2.isEnabled() && Objects.equals( p1.getUpdatePolicy(), p2.getUpdatePolicy() ); } private static boolean repositoriesEquals( List r1, List r2 ) @@ -200,11 +201,6 @@ public class DefaultMavenMetadataCache return true; } - private static boolean eq( T s1, T s2 ) - { - return Objects.equals(s1, s2); - } - /** * CacheRecord */ diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java index a32f87e94f..37823db511 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java @@ -138,7 +138,7 @@ public abstract class DefaultToolchain // should have been AbstractToolchain... DefaultToolchain other = (DefaultToolchain) obj; - if (!Objects.equals(type, other.type)) + if ( !Objects.equals( type, other.type ) ) { return false; } @@ -146,12 +146,7 @@ public abstract class DefaultToolchain // should have been AbstractToolchain... Properties thisProvides = this.getModel().getProvides(); Properties otherProvides = other.getModel().getProvides(); - if (!Objects.equals(thisProvides, otherProvides)) - { - return false; - } - - return true; + return Objects.equals( thisProvides, otherProvides ); } @Override