From 14bdf34a9bb5f2b93205c2972d54889d4fd2aae9 Mon Sep 17 00:00:00 2001 From: Gintas Grigelionis Date: Tue, 5 Dec 2017 12:36:37 +0100 Subject: [PATCH] tersify logic ;-> --- .../module/descriptor/DefaultModuleDescriptor.java | 9 +-------- .../ivy/core/report/ArtifactDownloadReport.java | 9 +-------- .../org/apache/ivy/osgi/core/BundleCapability.java | 9 +-------- src/java/org/apache/ivy/osgi/core/BundleInfo.java | 13 ++----------- .../org/apache/ivy/osgi/core/BundleRequirement.java | 9 +-------- .../ivy/osgi/core/ExecutionEnvironmentProfile.java | 9 +-------- .../org/apache/ivy/osgi/core/ExportPackage.java | 9 +-------- .../org/apache/ivy/osgi/filter/CompareFilter.java | 9 +-------- .../apache/ivy/osgi/filter/MultiOperatorFilter.java | 12 +++--------- .../apache/ivy/osgi/filter/UniOperatorFilter.java | 9 +-------- .../ivy/osgi/repo/EditableRepoDescriptor.java | 9 +-------- src/java/org/apache/ivy/osgi/util/Version.java | 13 ++----------- src/java/org/apache/ivy/osgi/util/VersionRange.java | 13 ++----------- .../ivy/plugins/repository/sftp/SFTPRepository.java | 6 ++---- 14 files changed, 20 insertions(+), 118 deletions(-) diff --git a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java index 99d92e22..6b528e0a 100644 --- a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java +++ b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java @@ -571,14 +571,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor { return false; } DefaultModuleDescriptor other = (DefaultModuleDescriptor) obj; - if (revId == null) { - if (other.revId != null) { - return false; - } - } else if (!revId.equals(other.revId)) { - return false; - } - return true; + return revId == null ? other.revId == null : revId.equals(other.revId); } @Override diff --git a/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java b/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java index 6ca13ca6..8fb72bdf 100644 --- a/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java +++ b/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java @@ -189,14 +189,7 @@ public class ArtifactDownloadReport { return true; } ArtifactDownloadReport other = (ArtifactDownloadReport) obj; - if (artifact == null) { - if (other.artifact != null) { - return false; - } - } else if (!artifact.equals(other.artifact)) { - return false; - } - return true; + return artifact == null ? other.artifact == null : artifact.equals(other.artifact); } } diff --git a/src/java/org/apache/ivy/osgi/core/BundleCapability.java b/src/java/org/apache/ivy/osgi/core/BundleCapability.java index a4abc76b..54c190a5 100644 --- a/src/java/org/apache/ivy/osgi/core/BundleCapability.java +++ b/src/java/org/apache/ivy/osgi/core/BundleCapability.java @@ -79,14 +79,7 @@ public class BundleCapability { } else if (!name.equals(other.name)) { return false; } - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; + return version == null ? other.version == null : version.equals(other.version); } } diff --git a/src/java/org/apache/ivy/osgi/core/BundleInfo.java b/src/java/org/apache/ivy/osgi/core/BundleInfo.java index 661848c9..b2c19f8d 100644 --- a/src/java/org/apache/ivy/osgi/core/BundleInfo.java +++ b/src/java/org/apache/ivy/osgi/core/BundleInfo.java @@ -325,17 +325,8 @@ public class BundleInfo { } else if (!versionTarget.equals(other.versionTarget)) { return false; } - if (hasInnerClasspath != other.hasInnerClasspath) { - return false; - } - if (classpath == null) { - if (other.classpath != null) { - return false; - } - } else if (!classpath.equals(other.classpath)) { - return false; - } - return true; + return hasInnerClasspath == other.hasInnerClasspath + && (classpath == null ? other.classpath == null : classpath.equals(other.classpath)); } public Set getRequires() { diff --git a/src/java/org/apache/ivy/osgi/core/BundleRequirement.java b/src/java/org/apache/ivy/osgi/core/BundleRequirement.java index d25021c9..d41fb38c 100644 --- a/src/java/org/apache/ivy/osgi/core/BundleRequirement.java +++ b/src/java/org/apache/ivy/osgi/core/BundleRequirement.java @@ -99,13 +99,6 @@ public class BundleRequirement { } else if (!resolution.equals(other.resolution)) { return false; } - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; + return version == null ? other.version == null : version.equals(other.version); } } diff --git a/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java b/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java index e0722857..6c8438ba 100644 --- a/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java +++ b/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java @@ -64,14 +64,7 @@ public class ExecutionEnvironmentProfile { } else if (!name.equals(other.name)) { return false; } - if (pkgNames == null) { - if (other.pkgNames != null) { - return false; - } - } else if (!pkgNames.equals(other.pkgNames)) { - return false; - } - return true; + return pkgNames == null ? other.pkgNames == null : pkgNames.equals(other.pkgNames); } public String toString() { diff --git a/src/java/org/apache/ivy/osgi/core/ExportPackage.java b/src/java/org/apache/ivy/osgi/core/ExportPackage.java index 7227c872..329ff332 100644 --- a/src/java/org/apache/ivy/osgi/core/ExportPackage.java +++ b/src/java/org/apache/ivy/osgi/core/ExportPackage.java @@ -57,14 +57,7 @@ public class ExportPackage extends BundleCapability { return false; } ExportPackage other = (ExportPackage) obj; - if (uses == null) { - if (other.uses != null) { - return false; - } - } else if (!uses.equals(other.uses)) { - return false; - } - return true; + return uses == null ? other.uses == null : uses.equals(other.uses); } } diff --git a/src/java/org/apache/ivy/osgi/filter/CompareFilter.java b/src/java/org/apache/ivy/osgi/filter/CompareFilter.java index d3b43cac..840ec453 100644 --- a/src/java/org/apache/ivy/osgi/filter/CompareFilter.java +++ b/src/java/org/apache/ivy/osgi/filter/CompareFilter.java @@ -144,13 +144,6 @@ public class CompareFilter extends OSGiFilter { } else if (!operator.equals(other.operator)) { return false; } - if (rightValue == null) { - if (other.rightValue != null) { - return false; - } - } else if (!rightValue.equals(other.rightValue)) { - return false; - } - return true; + return rightValue == null ? other.rightValue == null : rightValue.equals(other.rightValue); } } diff --git a/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java b/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java index 483f76d4..b91ddd20 100644 --- a/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java +++ b/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java @@ -73,14 +73,8 @@ public abstract class MultiOperatorFilter extends OSGiFilter { return false; } MultiOperatorFilter other = (MultiOperatorFilter) obj; - if (subFilters == null) { - if (other.subFilters != null) { - return false; - } - } else if (other.subFilters == null || subFilters.size() != other.subFilters.size() - || !subFilters.containsAll(other.subFilters)) { - return false; - } - return true; + return subFilters == null ? other.subFilters == null + : other.subFilters != null && subFilters.size() == other.subFilters.size() + && subFilters.containsAll(other.subFilters); } } diff --git a/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java b/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java index 19f15567..efc4bc48 100644 --- a/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java +++ b/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java @@ -59,13 +59,6 @@ public abstract class UniOperatorFilter extends OSGiFilter { return false; } UniOperatorFilter other = (UniOperatorFilter) obj; - if (subFilter == null) { - if (other.subFilter != null) { - return false; - } - } else if (!subFilter.equals(other.subFilter)) { - return false; - } - return true; + return subFilter == null ? other.subFilter == null : subFilter.equals(other.subFilter); } } diff --git a/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java b/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java index 8890a903..be203971 100644 --- a/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java +++ b/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java @@ -157,14 +157,7 @@ public class EditableRepoDescriptor extends RepoDescriptor { return true; } EditableRepoDescriptor other = (EditableRepoDescriptor) obj; - if (modules == null) { - if (other.modules != null) { - return false; - } - } else if (!modules.equals(other.modules)) { - return false; - } - return true; + return modules == null ? other.modules == null : modules.equals(other.modules); } } diff --git a/src/java/org/apache/ivy/osgi/util/Version.java b/src/java/org/apache/ivy/osgi/util/Version.java index e48df1a6..7c469cad 100644 --- a/src/java/org/apache/ivy/osgi/util/Version.java +++ b/src/java/org/apache/ivy/osgi/util/Version.java @@ -151,17 +151,8 @@ public class Version implements Comparable { Version other = (Version) obj; ensureSplit(); other.ensureSplit(); - if (major != other.major || minor != other.minor || patch != other.patch) { - return false; - } - if (qualifier == null) { - if (other.qualifier != null) { - return false; - } - } else if (!qualifier.equals(other.qualifier)) { - return false; - } - return true; + return major == other.major && minor == other.minor && patch == other.patch + && (qualifier == null ? other.qualifier == null : qualifier.equals(other.qualifier)); } public Version withNudgedPatch() { diff --git a/src/java/org/apache/ivy/osgi/util/VersionRange.java b/src/java/org/apache/ivy/osgi/util/VersionRange.java index 06a49e3e..0e84e32d 100644 --- a/src/java/org/apache/ivy/osgi/util/VersionRange.java +++ b/src/java/org/apache/ivy/osgi/util/VersionRange.java @@ -340,17 +340,8 @@ public class VersionRange { } else if (!endVersion.equals(other.endVersion)) { return false; } - if (startExclusive != other.startExclusive) { - return false; - } - if (startVersion == null) { - if (other.startVersion != null) { - return false; - } - } else if (!startVersion.equals(other.startVersion)) { - return false; - } - return true; + return startExclusive == other.startExclusive + && (startVersion == null ? other.startVersion == null : startVersion.equals(other.startVersion)); } } diff --git a/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java b/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java index b18e2129..596846a8 100644 --- a/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java +++ b/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java @@ -150,10 +150,8 @@ public class SFTPRepository extends AbstractSshBasedRepository { private void mkdirs(String directory, ChannelSftp c) throws SftpException { try { SftpATTRS att = c.stat(directory); - if (att != null) { - if (att.isDir()) { - return; - } + if (att != null && att.isDir()) { + return; } } catch (SftpException ex) { if (directory.indexOf('/') != -1) {