ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gin...@apache.org
Subject ant-ivy git commit: More uses of isNullOrEmpty/isEmpty
Date Sat, 11 Nov 2017 09:36:52 GMT
Repository: ant-ivy
Updated Branches:
  refs/heads/master 4272bf28b -> 102907855


More uses of isNullOrEmpty/isEmpty

Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/10290785
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/10290785
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/10290785

Branch: refs/heads/master
Commit: 1029078559eec0cc515e2a9ad3ed18c83bd00dcd
Parents: 4272bf2
Author: Gintas Grigelionis <gintas@apache.org>
Authored: Sat Nov 11 10:36:31 2017 +0100
Committer: Gintas Grigelionis <gintas@apache.org>
Committed: Sat Nov 11 10:36:31 2017 +0100

----------------------------------------------------------------------
 src/java/org/apache/ivy/ant/IvyBuildNumber.java |  8 +--
 .../apache/ivy/ant/IvyExtractFromSources.java   |  2 +-
 .../org/apache/ivy/core/IvyPatternHelper.java   |  4 +-
 .../cache/DefaultRepositoryCacheManager.java    |  4 +-
 .../apache/ivy/core/report/ResolveReport.java   |  6 +--
 .../ivy/osgi/repo/AbstractOSGiResolver.java     |  4 +-
 .../org/apache/ivy/osgi/util/VersionRange.java  |  4 +-
 .../parser/m2/PomModuleDescriptorBuilder.java   | 15 ++++--
 .../parser/m2/PomModuleDescriptorWriter.java    |  4 +-
 .../parser/xml/XmlModuleDescriptorUpdater.java  | 52 ++++++++++----------
 .../ivy/plugins/resolver/BasicResolver.java     |  2 +-
 .../plugins/resolver/RepositoryResolver.java    |  4 +-
 .../apache/ivy/plugins/trigger/LogTrigger.java  |  6 ++-
 src/java/org/apache/ivy/util/Credentials.java   |  7 +--
 src/java/org/apache/ivy/util/StringUtils.java   |  6 +--
 test/java/org/apache/ivy/ant/IvyInfoTest.java   |  1 -
 16 files changed, 73 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/ant/IvyBuildNumber.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/ant/IvyBuildNumber.java b/src/java/org/apache/ivy/ant/IvyBuildNumber.java
index 8673585..e5d1637 100644
--- a/src/java/org/apache/ivy/ant/IvyBuildNumber.java
+++ b/src/java/org/apache/ivy/ant/IvyBuildNumber.java
@@ -38,6 +38,8 @@ import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.version.VersionMatcher;
 import org.apache.tools.ant.BuildException;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 /**
  * Look for the latest module in the repository matching the given criteria, and sets a set
of
  * properties according to what was found.
@@ -151,12 +153,12 @@ public class IvyBuildNumber extends IvyTask {
         if (branch == null) {
             branch = settings.getDefaultBranch(new ModuleId(organisation, module));
         }
-        if (revision == null || revision.length() == 0) {
+        if (isNullOrEmpty(revision)) {
             revision = "latest.integration";
         } else if (!revision.endsWith("+")) {
             revision += "+";
         }
-        if (!prefix.endsWith(".") && prefix.length() > 0) {
+        if (!prefix.endsWith(".") && !prefix.isEmpty()) {
             prefix += ".";
         }
 
@@ -312,7 +314,7 @@ public class IvyBuildNumber extends IvyTask {
         while (endNumberIndex >= 0 && !Character.isDigit(str.charAt(endNumberIndex)))
{
             endNumberIndex--;
         }
-        int startNumberIndex = endNumberIndex == -1 ? -1 : endNumberIndex - 1;
+        int startNumberIndex = (endNumberIndex == -1) ? -1 : endNumberIndex - 1;
         while (startNumberIndex >= 0 && Character.isDigit(str.charAt(startNumberIndex)))
{
             startNumberIndex--;
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/ant/IvyExtractFromSources.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/ant/IvyExtractFromSources.java b/src/java/org/apache/ivy/ant/IvyExtractFromSources.java
index 7943f37..fef8109 100644
--- a/src/java/org/apache/ivy/ant/IvyExtractFromSources.java
+++ b/src/java/org/apache/ivy/ant/IvyExtractFromSources.java
@@ -170,7 +170,7 @@ public class IvyExtractFromSources extends Task {
     private ModuleRevisionId getMapping(String pack) {
         String askedPack = pack;
         ModuleRevisionId ret = null;
-        while (ret == null && pack.length() > 0) {
+        while (ret == null && !pack.isEmpty()) {
             if (ignoredPackaged.contains(pack)) {
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/core/IvyPatternHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/IvyPatternHelper.java b/src/java/org/apache/ivy/core/IvyPatternHelper.java
index 268be30..9247846 100644
--- a/src/java/org/apache/ivy/core/IvyPatternHelper.java
+++ b/src/java/org/apache/ivy/core/IvyPatternHelper.java
@@ -34,6 +34,8 @@ import org.apache.ivy.core.settings.IvyVariableContainer;
 import org.apache.ivy.core.settings.IvyVariableContainerImpl;
 import org.apache.ivy.util.Message;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 /**
  */
 public final class IvyPatternHelper {
@@ -298,7 +300,7 @@ public final class IvyPatternHelper {
                     String value = (tokenValue == null) ? null : tokenValue.toString();
 
                     if (insideOptionalPart) {
-                        tokenHadValue = (value != null) && (value.length() > 0);
+                        tokenHadValue = !isNullOrEmpty(value);
                         optionalPart.append(value);
                     } else {
                         if (value == null) { // the token wasn't set, it's kept as is

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
index aca7718..b2ca78c 100644
--- a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
+++ b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
@@ -77,6 +77,8 @@ import org.apache.ivy.util.HexEncoder;
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.PropertiesFile;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 public class DefaultRepositoryCacheManager implements RepositoryCacheManager, IvySettingsAware
{
     private static final String DEFAULT_ARTIFACT_PATTERN = "[organisation]/[module](/[branch])/[type]s/[artifact]-[revision](-[classifier])(.[ext])";
 
@@ -317,7 +319,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager,
Iv
 
     private int getGroupIntValue(java.util.regex.Matcher m, int groupNumber) {
         String g = m.group(groupNumber);
-        return g == null || g.length() == 0 ? 0 : Integer.parseInt(g);
+        return isNullOrEmpty(g) ? 0 : Integer.parseInt(g);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/core/report/ResolveReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/report/ResolveReport.java b/src/java/org/apache/ivy/core/report/ResolveReport.java
index 1b40769..40d5d1b 100644
--- a/src/java/org/apache/ivy/core/report/ResolveReport.java
+++ b/src/java/org/apache/ivy/core/report/ResolveReport.java
@@ -210,10 +210,10 @@ public class ResolveReport {
         for (ConfigurationResolveReport r : confReports.values()) {
             for (IvyNode unresolved : r.getUnresolvedDependencies()) {
                 String errMsg = unresolved.getProblemMessage();
-                if (errMsg.length() > 0) {
-                    ret.add("unresolved dependency: " + unresolved.getId() + ": " + errMsg);
-                } else {
+                if (errMsg.isEmpty()) {
                     ret.add("unresolved dependency: " + unresolved.getId());
+                } else {
+                    ret.add("unresolved dependency: " + unresolved.getId() + ": " + errMsg);
                 }
             }
             for (ArtifactDownloadReport adr : r.getFailedArtifactsReports()) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
index e38172d..fc0b6b8 100644
--- a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
+++ b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
@@ -56,6 +56,8 @@ import org.apache.ivy.plugins.resolver.util.ResolvedResource;
 import org.apache.ivy.plugins.resolver.util.ResourceMDParser;
 import org.apache.ivy.util.Message;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 public abstract class AbstractOSGiResolver extends BasicResolver {
 
     private static final String CAPABILITY_EXTRA_ATTR = "osgi_bundle";
@@ -322,7 +324,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
         }
 
         String osgiType = tokenValues.get(IvyPatternHelper.ORGANISATION_KEY);
-        if (osgiType == null || osgiType.length() == 0) {
+        if (isNullOrEmpty(osgiType)) {
             return Collections.emptyList();
         }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/osgi/util/VersionRange.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/util/VersionRange.java b/src/java/org/apache/ivy/osgi/util/VersionRange.java
index 9af6213..06a49e3 100644
--- a/src/java/org/apache/ivy/osgi/util/VersionRange.java
+++ b/src/java/org/apache/ivy/osgi/util/VersionRange.java
@@ -19,6 +19,8 @@ package org.apache.ivy.osgi.util;
 
 import java.text.ParseException;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 /**
  * Provides version range support.
  */
@@ -33,7 +35,7 @@ public class VersionRange {
     private Version endVersion;
 
     public VersionRange(String versionStr) throws ParseException {
-        if (versionStr == null || versionStr.length() == 0) {
+        if (isNullOrEmpty(versionStr)) {
             startExclusive = false;
             startVersion = new Version(0, 0, 0, null);
             endExclusive = true;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
index a7b58c7..de73b24 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
@@ -56,6 +56,7 @@ import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.util.Message;
 
 import static org.apache.ivy.core.module.descriptor.Configuration.Visibility.PUBLIC;
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
 
 /**
  * Build a module descriptor. This class handle the complexity of the structure of an ivy
@@ -268,20 +269,22 @@ public class PomModuleDescriptorBuilder {
 
     public void addDependency(Resource res, PomDependencyData dep) {
         String scope = dep.getScope();
-        if ((scope != null) && (scope.length() > 0) && !MAVEN2_CONF_MAPPING.containsKey(scope))
{
+        if (!isNullOrEmpty(scope) && !MAVEN2_CONF_MAPPING.containsKey(scope)) {
             // unknown scope, defaulting to 'compile'
             scope = "compile";
         }
 
         String version = dep.getVersion();
-        version = (version == null || version.length() == 0) ? getDefaultVersion(dep) : version;
+        if (isNullOrEmpty(version)) {
+            version = getDefaultVersion(dep);
+        }
         ModuleRevisionId moduleRevId = ModuleRevisionId.newInstance(dep.getGroupId(),
             dep.getArtifactId(), version);
 
         // Some POMs depend on themselves; Ivy doesn't allow this. Don't add this dependency!
         // Example: https://repo1.maven.org/maven2/net/jini/jsk-platform/2.1/jsk-platform-2.1.pom
         ModuleRevisionId mRevId = ivyModuleDescriptor.getModuleRevisionId();
-        if ((mRevId != null) && mRevId.getModuleId().equals(moduleRevId.getModuleId()))
{
+        if (mRevId != null && mRevId.getModuleId().equals(moduleRevId.getModuleId()))
{
             return;
         }
         // experimentation shows the following, excluded modules are
@@ -296,12 +299,14 @@ public class PomModuleDescriptorBuilder {
         final boolean excludeAllTransitiveDeps = shouldExcludeAllTransitiveDeps(excluded);
         DefaultDependencyDescriptor dd = new PomDependencyDescriptor(dep, ivyModuleDescriptor,
                 moduleRevId, !excludeAllTransitiveDeps);
-        scope = (scope == null || scope.length() == 0) ? getDefaultScope(dep) : scope;
+        if (isNullOrEmpty(scope)) {
+            scope = getDefaultScope(dep);
+        }
         ConfMapper mapping = MAVEN2_CONF_MAPPING.get(scope);
         mapping.addMappingConfs(dd, dep.isOptional());
         Map<String, String> extraAtt = new HashMap<>();
         if ((dep.getClassifier() != null)
-                || ((dep.getType() != null) && !"jar".equals(dep.getType()))) {
+                || (dep.getType() != null && !"jar".equals(dep.getType()))) {
             String type = "jar";
             if (dep.getType() != null) {
                 type = dep.getType();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
index 52a7813..9fc759c 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
@@ -46,6 +46,8 @@ import org.apache.ivy.plugins.parser.m2.PomWriterOptions.ConfigurationScopeMappi
 import org.apache.ivy.plugins.parser.m2.PomWriterOptions.ExtraDependency;
 import org.apache.ivy.util.ConfigurationUtils;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 public final class PomModuleDescriptorWriter {
 
     private static final String SKIP_LINE = "SKIP_LINE";
@@ -179,7 +181,7 @@ public final class PomModuleDescriptorWriter {
         }
         if (options.getDescription() != null) {
             variables.setVariable("ivy.pom.description", options.getDescription(), true);
-        } else if (md.getDescription() != null && md.getDescription().length() >
0) {
+        } else if (!isNullOrEmpty(md.getDescription())) {
             variables.setVariable("ivy.pom.description", md.getDescription(), true);
         }
         if (md.getHomePage() != null) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
index a1b8dba..46828d8 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
@@ -355,13 +355,13 @@ public final class XmlModuleDescriptorUpdater {
                 confAttributeBuffers.push(buffer);
                 write("<" + qName);
                 buffer.setDefaultPrint(attributes.getValue("conf") == null
-                        && (newDefaultConf == null || newDefaultConf.length() >
0));
+                        && (newDefaultConf == null || !newDefaultConf.isEmpty()));
                 for (int i = 0; i < attributes.getLength(); i++) {
                     String attName = attributes.getQName(i);
                     if ("conf".equals(attName)) {
                         String confName = substitute(settings, attributes.getValue("conf"));
-                        String newConf = removeConfigurationsFromList(confName, confs);
-                        if (newConf.length() > 0) {
+                        String newConf = removeConfigurationsFromList(confName);
+                        if (!newConf.isEmpty()) {
                             write(" " + attName + "=\"" + newConf + "\"");
                             buffers.peek().setPrint(true);
                         }
@@ -380,8 +380,8 @@ public final class XmlModuleDescriptorUpdater {
                     String attName = attributes.getQName(i);
                     if ("conf".equals(attName)) {
                         String confName = substitute(settings, attributes.getValue("conf"));
-                        String newConf = removeConfigurationsFromList(confName, confs);
-                        if (newConf.length() > 0) {
+                        String newConf = removeConfigurationsFromList(confName);
+                        if (!newConf.isEmpty()) {
                             write(" " + attName + "=\"" + newConf + "\"");
                             buffers.peek().setPrint(true);
                         }
@@ -490,8 +490,8 @@ public final class XmlModuleDescriptorUpdater {
                 String attName = attributes.getQName(i);
                 if ("defaultconf".equals(attName) || "defaultconfmapping".equals(attName))
{
                     String newMapping = removeConfigurationsFromMapping(
-                        substitute(settings, attributes.getValue(attName)), confs);
-                    if (newMapping.length() > 0) {
+                        substitute(settings, attributes.getValue(attName)));
+                    if (!newMapping.isEmpty()) {
                         write(" " + attName + "=\"" + newMapping + "\"");
                     }
                 } else {
@@ -501,15 +501,15 @@ public final class XmlModuleDescriptorUpdater {
             }
             // add default conf if needed
             if (defaultConf != null && attributes.getValue("defaultconf") == null)
{
-                String newConf = removeConfigurationsFromMapping(defaultConf, confs);
-                if (newConf.length() > 0) {
+                String newConf = removeConfigurationsFromMapping(defaultConf);
+                if (!newConf.isEmpty()) {
                     write(" defaultconf=\"" + newConf + "\"");
                 }
             }
             // add default conf mapping if needed
             if (defaultConfMapping != null && attributes.getValue("defaultconfmapping")
== null) {
-                String newMapping = removeConfigurationsFromMapping(defaultConfMapping, confs);
-                if (newMapping.length() > 0) {
+                String newMapping = removeConfigurationsFromMapping(defaultConfMapping);
+                if (!newMapping.isEmpty()) {
                     write(" defaultconfmapping=\"" + newMapping + "\"");
                 }
             }
@@ -525,8 +525,8 @@ public final class XmlModuleDescriptorUpdater {
                 String attName = attributes.getQName(i);
                 if ("defaultconf".equals(attName)) {
                     newDefaultConf = removeConfigurationsFromList(
-                        substitute(settings, attributes.getValue("defaultconf")), confs);
-                    if (newDefaultConf.length() > 0) {
+                        substitute(settings, attributes.getValue("defaultconf")));
+                    if (!newDefaultConf.isEmpty()) {
                         write(" " + attName + "=\"" + newDefaultConf + "\"");
                     }
                 } else {
@@ -612,9 +612,9 @@ public final class XmlModuleDescriptorUpdater {
                     write(" branchConstraint=\"" + branchConstraint + "\"");
                 } else if ("conf".equals(attName)) {
                     String oldMapping = substitute(settings, attributes.getValue("conf"));
-                    if (oldMapping.length() > 0) {
-                        String newMapping = removeConfigurationsFromMapping(oldMapping, confs);
-                        if (newMapping.length() > 0) {
+                    if (!oldMapping.isEmpty()) {
+                        String newMapping = removeConfigurationsFromMapping(oldMapping);
+                        if (!newMapping.isEmpty()) {
                             write(" conf=\"" + newMapping + "\"");
                             buffers.peek().setPrint(true);
                         }
@@ -831,7 +831,7 @@ public final class XmlModuleDescriptorUpdater {
             return XMLHelper.escape(result);
         }
 
-        private String removeConfigurationsFromMapping(String mapping, List<String>
confsToRemove) {
+        private String removeConfigurationsFromMapping(String mapping) {
             StringBuilder newMapping = new StringBuilder();
             String mappingSep = "";
             for (String groups : mapping.split(";")) {
@@ -845,7 +845,7 @@ public final class XmlModuleDescriptorUpdater {
                 if (!confsToWrite.isEmpty()) {
                     newMapping.append(mappingSep);
                     String sep = "";
-                    String listSep = groups.contains(" ") ? ", " : ",";
+                    String listSep = groups.contains(", ") ? ", " : ",";
                     for (String confToWrite : confsToWrite) {
                         newMapping.append(sep).append(confToWrite);
                         sep = listSep;
@@ -859,12 +859,12 @@ public final class XmlModuleDescriptorUpdater {
             return newMapping.toString();
         }
 
-        private String removeConfigurationsFromList(String list, List<String> confsToRemove)
{
+        private String removeConfigurationsFromList(String list) {
             StringBuilder newList = new StringBuilder();
             String sep = "";
-            String listSep = list.contains(" ") ? ", " : ",";
+            String listSep = list.contains(", ") ? ", " : ",";
             for (String current : splitToArray(list)) {
-                if (!confsToRemove.contains(current)) {
+                if (!confs.contains(current)) {
                     newList.append(sep).append(current);
                     sep = listSep;
                 }
@@ -977,12 +977,12 @@ public final class XmlModuleDescriptorUpdater {
                     out.print(getIndent());
                 }
                 String newConf = (defaultConf == null) ? "" :
-                        removeConfigurationsFromMapping(defaultConf, confs);
+                        removeConfigurationsFromMapping(defaultConf);
                 String newMapping = (defaultConfMapping == null) ? "" :
-                        removeConfigurationsFromMapping(defaultConfMapping, confs);
+                        removeConfigurationsFromMapping(defaultConfMapping);
                 out.print(String.format("<%s%s%s%s>", itemName,
-                        (newConf.length() > 0) ? " defaultconf=\"" + newConf + "\"" :
"",
-                        (newMapping.length() > 0) ? " defaultconfmapping=\"" + newMapping
+ "\"" : "",
+                        newConf.isEmpty() ? "" : " defaultconf=\"" + newConf + "\"",
+                        newMapping.isEmpty() ? "" : " defaultconfmapping=\"" + newMapping
+ "\"",
                         (confMappingOverride != null) ? " confmappingoverride=\"" + confMappingOverride
+ "\"" : ""));
                 context.push(itemName);
                 justOpen = null;
@@ -1058,7 +1058,7 @@ public final class XmlModuleDescriptorUpdater {
             if (!hasDescription) {
                 hasDescription = true;
                 String description = merged.getDescription();
-                if ((description != null) && (description.length() > 0)) {
+                if (!isNullOrEmpty(description)) {
                     PrintWriter writer = getWriter();
                     if (justOpen != null) {
                         writer.println(">");

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
index 8ddfc7d..71e7bd5 100644
--- a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
@@ -317,7 +317,7 @@ public abstract class BasicResolver extends AbstractResolver {
 
             return checkLatest(systemDd, checkForcedResolvedModuleRevision(rmr), data);
         } catch (UnresolvedDependencyException ex) {
-            if (ex.getMessage().length() > 0) {
+            if (!ex.getMessage().isEmpty()) {
                 if (ex.isError()) {
                     Message.error(ex.getMessage());
                 } else {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java b/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
index 10c4483..a553f61 100644
--- a/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
@@ -50,6 +50,8 @@ import org.apache.ivy.util.ChecksumHelper;
 import org.apache.ivy.util.FileUtil;
 import org.apache.ivy.util.Message;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 /**
  *
  */
@@ -112,7 +114,7 @@ public class RepositoryResolver extends AbstractPatternsBasedResolver
{
                             ModuleDescriptor md = parser.parseDescriptor(getParserSettings(),
temp
                                     .toURI().toURL(), res, false);
                             revision = md.getRevision();
-                            if ((revision == null) || (revision.length() == 0)) {
+                            if (isNullOrEmpty(revision)) {
                                 revision = "working@" + name;
                             }
                         } else {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java b/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
index 96c8924..e30eaf1 100644
--- a/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
+++ b/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
@@ -30,6 +30,8 @@ import org.apache.ivy.core.event.IvyEvent;
 import org.apache.ivy.core.resolve.ResolveProcessException;
 import org.apache.ivy.util.Message;
 
+import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+
 /**
  * A trigger performing logging.
  * <p>
@@ -46,7 +48,7 @@ public class LogTrigger extends AbstractTrigger {
     private boolean append = true;
 
     /** encoding; set to null or empty means 'default' */
-    private String encoding = "";
+    private String encoding;
 
     public void progress(IvyEvent event) {
         log(IvyPatternHelper.substituteVariables(message, event.getAttributes()));
@@ -69,7 +71,7 @@ public class LogTrigger extends AbstractTrigger {
                 // we use the system dependent line separator to ease reading the log file
                 message += LINE_SEPARATOR;
                 String filename = file.getAbsolutePath();
-                if (encoding == null || encoding.length() == 0) {
+                if (isNullOrEmpty(encoding)) {
                     out = new FileWriter(filename, append);
                 } else {
                     out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename,

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/util/Credentials.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/Credentials.java b/src/java/org/apache/ivy/util/Credentials.java
index 7d27f88..b53a372 100644
--- a/src/java/org/apache/ivy/util/Credentials.java
+++ b/src/java/org/apache/ivy/util/Credentials.java
@@ -18,6 +18,7 @@
 package org.apache.ivy.util;
 
 import static org.apache.ivy.util.StringUtils.isNullOrEmpty;
+import static org.apache.ivy.util.StringUtils.repeat;
 
 /**
  *
@@ -75,11 +76,7 @@ public class Credentials {
         if (passwd == null) {
             return null;
         }
-        StringBuilder sb = new StringBuilder();
-        for (int i = passwd.length(); i > 0; i--) {
-            sb.append('*');
-        }
-        return sb.toString();
+        return repeat("*", passwd.length());
     }
 
     public boolean equals(Object o) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/src/java/org/apache/ivy/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/StringUtils.java b/src/java/org/apache/ivy/util/StringUtils.java
index 2cd5ffc..099437c 100644
--- a/src/java/org/apache/ivy/util/StringUtils.java
+++ b/src/java/org/apache/ivy/util/StringUtils.java
@@ -33,7 +33,7 @@ public final class StringUtils {
     }
 
     public static String uncapitalize(String string) {
-        if (string == null || string.length() == 0) {
+        if (isNullOrEmpty(string)) {
             return string;
         }
         if (string.length() == 1) {
@@ -58,8 +58,8 @@ public final class StringUtils {
             InvocationTargetException ex = (InvocationTargetException) t;
             t = ex.getTargetException();
         }
-        String errMsg = t instanceof RuntimeException ? t.getMessage() : t.toString();
-        if (errMsg == null || errMsg.length() == 0 || "null".equals(errMsg)) {
+        String errMsg = (t instanceof RuntimeException) ? t.getMessage() : t.toString();
+        if (isNullOrEmpty(errMsg) || "null".equals(errMsg)) {
             errMsg = t.getClass().getName() + " at " + t.getStackTrace()[0].toString();
         }
         return errMsg;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/10290785/test/java/org/apache/ivy/ant/IvyInfoTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyInfoTest.java b/test/java/org/apache/ivy/ant/IvyInfoTest.java
index 0ddcad7..0d6b225 100644
--- a/test/java/org/apache/ivy/ant/IvyInfoTest.java
+++ b/test/java/org/apache/ivy/ant/IvyInfoTest.java
@@ -28,7 +28,6 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 
 public class IvyInfoTest {
     private IvyInfo info;


Mime
View raw message