diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index 7c821fefb..dcda2ecd0 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -1167,7 +1167,6 @@ public class PropertyHelper implements GetProperty { */ private static boolean nullOrEmpty(Object value) { return value == null || "".equals(value); - } /** diff --git a/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java b/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java index 384476c8d..1bb9c0238 100644 --- a/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java +++ b/src/main/org/apache/tools/ant/attribute/IfBlankAttribute.java @@ -34,6 +34,6 @@ public class IfBlankAttribute extends BaseIfAttribute { * {@inheritDoc} */ public boolean isEnabled(UnknownElement el, String value) { - return convertResult((value == null || "".equals(value))); + return convertResult(value == null || value.isEmpty()); } } diff --git a/src/main/org/apache/tools/ant/launch/Launcher.java b/src/main/org/apache/tools/ant/launch/Launcher.java index 2e964e934..8501004a4 100644 --- a/src/main/org/apache/tools/ant/launch/Launcher.java +++ b/src/main/org/apache/tools/ant/launch/Launcher.java @@ -344,7 +344,7 @@ public class Launcher { if (antLibDirProperty != null) { antLibDir = new File(antLibDirProperty); } - if ((antLibDir == null) || !antLibDir.exists()) { + if (antLibDir == null || !antLibDir.exists()) { antLibDir = antLauncherDir; setProperty(ANTLIBDIR_PROPERTY, antLibDir.getAbsolutePath()); } diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java index dbc1e9d4e..0a644a868 100644 --- a/src/main/org/apache/tools/ant/launch/Locator.java +++ b/src/main/org/apache/tools/ant/launch/Locator.java @@ -247,7 +247,7 @@ public final class Locator { int posi = cwd.indexOf(':'); boolean pathStartsWithFileSeparator = path.startsWith(File.separator); boolean pathStartsWithUNC = path.startsWith("" + File.separator + File.separator); - if ((posi > 0) && pathStartsWithFileSeparator && !pathStartsWithUNC) { + if (posi > 0 && pathStartsWithFileSeparator && !pathStartsWithUNC) { path = cwd.substring(0, posi + 1) + path; } } catch (UnsupportedEncodingException exc) { @@ -470,6 +470,7 @@ public final class Locator { * @exception MalformedURLException if the URLs for the files cannot be * formed. */ + @SuppressWarnings("deprecated") public static URL[] getLocationURLs(File location, final String... extensions) throws MalformedURLException { diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index 559be016a..cdac0d238 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -468,7 +468,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { switch (ch) { case '\r': ch = reader.read(); - if ((char) (ch) == '\n') { + if ((char) ch == '\n') { eolcount += 2; eolStr.append("\r\n"); } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java index 6982064e7..4240bd52c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Property.java +++ b/src/main/org/apache/tools/ant/taskdefs/Property.java @@ -515,7 +515,7 @@ public class Property extends Task { loadEnvironment(env); } - if ((name != null) && (ref != null)) { + if (name != null && ref != null) { try { addProperty(name, ref.getReferencedObject(getProject()).toString()); diff --git a/src/main/org/apache/tools/ant/taskdefs/Redirector.java b/src/main/org/apache/tools/ant/taskdefs/Redirector.java index d5d01dbfd..6bb740e44 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Redirector.java +++ b/src/main/org/apache/tools/ant/taskdefs/Redirector.java @@ -585,7 +585,7 @@ public class Redirector { } if ((outputFilterChains != null && outputFilterChains.size() > 0) - || !(outputEncoding.equalsIgnoreCase(inputEncoding))) { + || !outputEncoding.equalsIgnoreCase(inputEncoding)) { try { final LeadPipeInputStream snk = new LeadPipeInputStream(); snk.setManagingComponent(managingTask); @@ -627,7 +627,7 @@ public class Redirector { } if ((errorFilterChains != null && errorFilterChains.size() > 0) - || !(errorEncoding.equalsIgnoreCase(inputEncoding))) { + || !errorEncoding.equalsIgnoreCase(inputEncoding)) { try { final LeadPipeInputStream snk = new LeadPipeInputStream(); snk.setManagingComponent(managingTask); diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java index adbd35d9f..976211ac9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -155,12 +155,12 @@ public class Replace extends MatchingTask { } //value and property are mutually exclusive attributes - if ((value != null) && (property != null)) { + if (value != null && property != null) { throw new BuildException( "Either value or property can be specified, but a replacefilter element cannot have both."); } - if ((property != null)) { + if (property != null) { //the property attribute must have access to a property file if (propertyResource == null) { throw new BuildException( @@ -305,7 +305,7 @@ public class Replace extends MatchingTask { String t = getToken(); if (inputBuffer.length() > t.length()) { int pos = replace(); - pos = Math.max((inputBuffer.length() - t.length()), pos); + pos = Math.max(inputBuffer.length() - t.length(), pos); outputBuffer.append(inputBuffer.substring(0, pos)); inputBuffer.delete(0, pos); return true; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java index e4271ff49..ce99b5a38 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java @@ -404,7 +404,7 @@ public class ReplaceRegExp extends Task { linebuf = new StringBuilder(); } else { // any other char - if ((hasCR) || (c < 0)) { + if (hasCR || c < 0) { // Mac-style linebreak or EOF (or both) changes |= replaceAndWrite(linebuf.toString(), w, options); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java index 795a09824..a25109473 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java @@ -219,7 +219,7 @@ public class CCCheckout extends ClearCase { String result = runS(cmdl); - return (result != null && result.length() > 0); + return result != null && !result.isEmpty(); } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 1c7283773..24554a40d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -884,7 +884,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { */ @Override public void validateConfigured() throws BuildException { - if ((destDir == null) || (!destDir.isDirectory())) { + if (destDir == null || !destDir.isDirectory()) { throw new BuildException( "A valid destination directory must be specified using the \"destdir\" attribute.", getLocation()); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java index b4e23a05d..6e3b55c96 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java @@ -211,12 +211,12 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { File iasDescriptor = new File(getConfig().descriptorDir, getIasDescriptorName()); - if ((!iasDescriptor.exists()) || (!iasDescriptor.isFile())) { + if (!iasDescriptor.exists() || !iasDescriptor.isFile()) { throw new BuildException("The iAS-specific EJB descriptor (" + iasDescriptor + ") was not found.", getLocation()); } - if ((iashome != null) && (!iashome.isDirectory())) { + if (iashome != null && !iashome.isDirectory()) { throw new BuildException( "If \"iashome\" is specified, it must be a valid directory (it was set to " + iashome + ").", diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java index 436ee7ddc..03ce33133 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java @@ -253,7 +253,7 @@ public class IPlanetEjbc { boolean retainSource = false; IPlanetEjbc ejbc; - if ((args.length < MIN_NUM_ARGS) || (args.length > MAX_NUM_ARGS)) { + if (args.length < MIN_NUM_ARGS || args.length > MAX_NUM_ARGS) { usage(); return; } @@ -663,7 +663,7 @@ public class IPlanetEjbc { */ public void registerDTD(String publicID, String location) { log("Registering: " + location); - if ((publicID == null) || (location == null)) { + if (publicID == null || location == null) { return; } @@ -742,7 +742,7 @@ public class IPlanetEjbc { iasDescriptor = true; } - if (("session".equals(name)) || ("entity".equals(name))) { + if ("session".equals(name) || "entity".equals(name)) { ejbType = name; } } @@ -1033,20 +1033,20 @@ public class IPlanetEjbc { + " EJB."); } - if ((!beantype.equals(ENTITY_BEAN)) - && (!beantype.equals(STATELESS_SESSION)) - && (!beantype.equals(STATEFUL_SESSION))) { + if (!beantype.equals(ENTITY_BEAN) + && !beantype.equals(STATELESS_SESSION) + && !beantype.equals(STATEFUL_SESSION)) { throw new EjbcException("The beantype found (" + beantype + ") isn't valid in the " + name + " EJB."); } - if (cmp && (!beantype.equals(ENTITY_BEAN))) { + if (cmp && !beantype.equals(ENTITY_BEAN)) { System.out.println( "CMP stubs and skeletons may not be generated for a Session Bean -- the \"cmp\" attribute will be ignoredfor the " + name + " EJB."); } - if (hasession && (!beantype.equals(STATEFUL_SESSION))) { + if (hasession && !beantype.equals(STATEFUL_SESSION)) { System.out.println( "Highly available stubs and skeletons may only be generated for a Stateful Session Bean" + "-- the \"hasession\" attribute will be ignored for the " diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java index e18c59b41..b52150916 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java @@ -207,7 +207,7 @@ public class IPlanetEjbcTask extends Task { "The standard EJB descriptor must be specified using the \"ejbdescriptor\" attribute."; throw new BuildException(msg, getLocation()); } - if ((!ejbdescriptor.exists()) || (!ejbdescriptor.isFile())) { + if (!ejbdescriptor.exists() || !ejbdescriptor.isFile()) { String msg = "The standard EJB descriptor (" + ejbdescriptor + ") was not found or isn't a file."; throw new BuildException(msg, getLocation()); @@ -218,7 +218,7 @@ public class IPlanetEjbcTask extends Task { "The iAS-speific XML descriptor must be specified using the \"iasdescriptor\" attribute."; throw new BuildException(msg, getLocation()); } - if ((!iasdescriptor.exists()) || (!iasdescriptor.isFile())) { + if (!iasdescriptor.exists() || !iasdescriptor.isFile()) { String msg = "The iAS-specific XML descriptor (" + iasdescriptor + ") was not found or isn't a file."; throw new BuildException(msg, getLocation()); @@ -229,13 +229,13 @@ public class IPlanetEjbcTask extends Task { "The destination directory must be specified using the \"dest\" attribute."; throw new BuildException(msg, getLocation()); } - if ((!dest.exists()) || (!dest.isDirectory())) { + if (!dest.exists() || !dest.isDirectory()) { String msg = "The destination directory (" + dest + ") was not found or isn't a directory."; throw new BuildException(msg, getLocation()); } - if ((iashome != null) && (!iashome.isDirectory())) { + if (iashome != null && !iashome.isDirectory()) { String msg = "If \"iashome\" is specified, it must be a valid directory (it was set to " + iashome + ")."; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java index d2ae38bea..e8a868e2f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java @@ -713,8 +713,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { JarEntry genericEntry = genericEntries.get(filepath); JarEntry wlEntry = wlEntries.get(filepath); - if ((genericEntry.getCrc() != wlEntry.getCrc()) - || (genericEntry.getSize() != wlEntry.getSize())) { + if (genericEntry.getCrc() != wlEntry.getCrc() + || genericEntry.getSize() != wlEntry.getSize()) { if (genericEntry.getName().endsWith(".class")) { //File are different see if its an object or an interface diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java index 0aaf5caa3..40cdc23e8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java @@ -696,8 +696,8 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { JarEntry genericEntry = genericEntries.get(filepath); JarEntry wasEntry = wasEntries.get(filepath); - if ((genericEntry.getCrc() != wasEntry.getCrc()) - || (genericEntry.getSize() != wasEntry.getSize())) { + if (genericEntry.getCrc() != wasEntry.getCrc() + || genericEntry.getSize() != wasEntry.getSize()) { if (genericEntry.getName().endsWith(".class")) { //File are different see if its an object or an interface diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java index 2838c2d94..78897d34a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java @@ -88,7 +88,7 @@ public class WebLogicHotDeploymentTool extends AbstractHotDeploymentTool String action = getTask().getAction(); // check that the password has been set - if ((getPassword() == null)) { + if (getPassword() == null) { throw new BuildException("The password attribute must be set."); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java index 506d63e84..58333488b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java @@ -191,7 +191,7 @@ public class JJDoc extends Task { suffix = DEFAULT_SUFFIX_TEXT; } - if ((optionalOutputFile == null) || optionalOutputFile.isEmpty()) { + if (optionalOutputFile == null || optionalOutputFile.isEmpty()) { int filePos = javaccFile.lastIndexOf('/'); if (filePos >= 0) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java index 9b9fa5b66..1b85f2875 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java @@ -302,7 +302,7 @@ public class JJTree extends Task { outputDir); String jjtreeFile = destFile.getAbsolutePath().replace('\\', '/'); - if ((optionalOutputFile == null) || optionalOutputFile.isEmpty()) { + if (optionalOutputFile == null || optionalOutputFile.isEmpty()) { int filePos = jjtreeFile.lastIndexOf('/'); if (filePos >= 0) { @@ -325,7 +325,7 @@ public class JJTree extends Task { } } - if ((outputDir == null) || outputDir.isEmpty()) { + if (outputDir == null || outputDir.isEmpty()) { outputDir = getDefaultOutputDirectory(); } @@ -350,7 +350,7 @@ public class JJTree extends Task { return null; } - if ((outputDir == null) + if (outputDir == null && (destFile.startsWith("/") || destFile.startsWith("\\"))) { String relativeOutputFile = makeOutputFileRelative(destFile); setOutputfile(relativeOutputFile); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 060f7487d..235cc7d4b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -2168,7 +2168,7 @@ public class JUnitTask extends Task { if (test.shouldRun(getProject())) { /* with multi-threaded runs need to defer execution of even */ /* individual tests so the threads can pick tests off the queue. */ - if ((runIndividual || !test.getFork()) && (threads == 1)) { + if ((runIndividual || !test.getFork()) && threads == 1) { execute(test, 0); } else { testConfigurations diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java index fe74be1b1..e041e3069 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java @@ -221,7 +221,7 @@ public class JUnitTest extends BaseTest implements Cloneable { * @since 1.8.2 */ String getMethodsString() { - if ((methodsList == null) && methodsSpecified) { + if (methodsList == null && methodsSpecified) { if (methods.length == 0) { methodsList = ""; } else if (methods.length == 1) { @@ -246,7 +246,7 @@ public class JUnitTest extends BaseTest implements Cloneable { * @since 1.8.2 */ void resolveMethods() { - if ((methods == null) && methodsSpecified) { + if (methods == null && methodsSpecified) { try { methods = parseTestMethodNamesList(methodsList); } catch (IllegalArgumentException ex) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 4dfbce5c2..3765ea3da 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -1708,7 +1708,7 @@ public class FTP extends Task implements FTPTaskConfig { throw new BuildException("password attribute must be set!"); } - if ((action == LIST_FILES) && (listing == null)) { + if (action == LIST_FILES && listing == null) { throw new BuildException( "listing attribute must be set for list action!"); } @@ -1783,12 +1783,12 @@ public class FTP extends Task implements FTPTaskConfig { } String dir = null; - if ((ds.getBasedir() == null) - && ((action == SEND_FILES) || (action == GET_FILES))) { + if (ds.getBasedir() == null + && (action == SEND_FILES || action == GET_FILES)) { throw new BuildException( "the dir attribute must be set for send and get actions"); } - if ((action == SEND_FILES) || (action == GET_FILES)) { + if (action == SEND_FILES || action == GET_FILES) { dir = ds.getBasedir().getAbsolutePath(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java index c96d16aaf..87535d23d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java @@ -744,7 +744,7 @@ public class FTPTask extends Task implements FTPTaskConfig { throw new BuildException("password attribute must be set!"); } - if ((action == LIST_FILES) && (listing == null)) { + if (action == LIST_FILES && listing == null) { throw new BuildException( "listing attribute must be set for list action!"); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java index f89d0f0d8..f45f9be4a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java @@ -1158,15 +1158,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { dsfiles = ds.getIncludedFiles(); } - if ((ds.getBasedir() == null) - && ((task.getAction() == FTPTask.SEND_FILES) - || (task.getAction() == FTPTask.GET_FILES))) { + if (ds.getBasedir() == null + && (task.getAction() == FTPTask.SEND_FILES || task.getAction() == FTPTask.GET_FILES)) { throw new BuildException( "the dir attribute must be set for send and get actions"); } String dir = null; - if ((task.getAction() == FTPTask.SEND_FILES) - || (task.getAction() == FTPTask.GET_FILES)) { + if (task.getAction() == FTPTask.SEND_FILES || task.getAction() == FTPTask.GET_FILES) { dir = ds.getBasedir().getAbsolutePath(); } diff --git a/src/main/org/apache/tools/ant/types/FileList.java b/src/main/org/apache/tools/ant/types/FileList.java index c286329e6..1461563f1 100644 --- a/src/main/org/apache/tools/ant/types/FileList.java +++ b/src/main/org/apache/tools/ant/types/FileList.java @@ -70,7 +70,7 @@ public class FileList extends DataType implements ResourceCollection { */ @Override public void setRefid(Reference r) throws BuildException { - if ((dir != null) || (!filenames.isEmpty())) { + if (dir != null || !filenames.isEmpty()) { throw tooManyAttributes(); } super.setRefid(r); diff --git a/src/main/org/apache/tools/ant/types/PatternSet.java b/src/main/org/apache/tools/ant/types/PatternSet.java index ffa35249a..dbb3bc2f4 100644 --- a/src/main/org/apache/tools/ant/types/PatternSet.java +++ b/src/main/org/apache/tools/ant/types/PatternSet.java @@ -159,7 +159,7 @@ public class PatternSet extends DataType implements Cloneable { } else { buf.append(name); } - if ((ifCond != null) || (unlessCond != null)) { + if (ifCond != null || unlessCond != null) { buf.append(":"); String connector = ""; diff --git a/src/main/org/apache/tools/ant/types/XMLCatalog.java b/src/main/org/apache/tools/ant/types/XMLCatalog.java index acfdd067b..528ba606d 100644 --- a/src/main/org/apache/tools/ant/types/XMLCatalog.java +++ b/src/main/org/apache/tools/ant/types/XMLCatalog.java @@ -435,7 +435,7 @@ public class XMLCatalog extends DataType } else { baseURL = new URL(base); } - URL url = (uri.length() == 0 ? baseURL : new URL(baseURL, uri)); + URL url = uri.isEmpty() ? baseURL : new URL(baseURL, uri); source.setInputSource(new InputSource(url.toString())); } catch (MalformedURLException ex) { // At this point we are probably in failure mode, but diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java index d75dbccb9..67a3a3946 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java @@ -117,7 +117,7 @@ public class DigestAlgorithm implements Algorithm { return; } - if ((provider != null) && !"".equals(provider) && !"null".equals(provider)) { + if (provider != null && !provider.isEmpty() && !"null".equals(provider)) { try { messageDigest = MessageDigest.getInstance(algorithm, provider); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java index 93580a69e..ae52dc951 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java @@ -130,7 +130,7 @@ public class PropertiesfileCache implements Cache { */ @Override public void load() { - if ((cachefile != null) && cachefile.isFile() && cachefile.canRead()) { + if (cachefile != null && cachefile.isFile() && cachefile.canRead()) { try (BufferedInputStream bis = new BufferedInputStream( Files.newInputStream(cachefile.toPath()))) { cache.load(bis); @@ -155,7 +155,7 @@ public class PropertiesfileCache implements Cache { if (!cacheDirty) { return; } - if ((cachefile != null) && cache.propertyNames().hasMoreElements()) { + if (cachefile != null && cache.propertyNames().hasMoreElements()) { try (BufferedOutputStream bos = new BufferedOutputStream( Files.newOutputStream(cachefile.toPath()))) { cache.store(bos, null); diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index e7e7fa041..92b695378 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -666,7 +666,7 @@ public class FileUtils { filename = filename.replace('/', sep).replace('\\', sep); char c = filename.charAt(0); if (!ON_DOS && !ON_NETWARE) { - return (c == sep); + return c == sep; } if (c == sep) { // CheckStyle:MagicNumber OFF diff --git a/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java b/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java index 073a89f1e..d62386a81 100644 --- a/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java +++ b/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java @@ -53,7 +53,7 @@ public abstract class LineOrientedOutputStream extends OutputStream { @Override public final void write(int cc) throws IOException { final byte c = (byte) cc; - if ((c == LF) || (c == CR)) { + if (c == LF || c == CR) { if (!skip) { processBuffer(); } diff --git a/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java b/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java index 45be038a0..b5cc5e17f 100644 --- a/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java +++ b/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java @@ -110,7 +110,7 @@ public class DependencyVisitor extends EmptyVisitor { } // Check to see if it's an inner class 'com.company.Class$Inner' // CheckStyle:MagicNumber OFF - if ((start > 0x40) && (start < 0x5B)) { + if (start > 0x40 && start < 0x5B) { // first letter of the previous segment of the class name 'Class' // is upper case ascii. so according to the spec it's an inner class classname = classname.substring(0, index) + "$" diff --git a/src/main/org/apache/tools/bzip2/CBZip2InputStream.java b/src/main/org/apache/tools/bzip2/CBZip2InputStream.java index e4d49804f..2f982deaa 100644 --- a/src/main/org/apache/tools/bzip2/CBZip2InputStream.java +++ b/src/main/org/apache/tools/bzip2/CBZip2InputStream.java @@ -288,7 +288,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { } int blockSize = this.in.read(); - if ((blockSize < '1') || (blockSize > '9')) { + if (blockSize < '1' || blockSize > '9') { throw new IOException("Stream is not BZip2 formatted: illegal " + "blocksize " + (char) blockSize); } @@ -662,7 +662,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { int minLens_zt = minLens[zt]; while (nextSym != eob) { - if ((nextSym == RUNA) || (nextSym == RUNB)) { + if (nextSym == RUNA || nextSym == RUNB) { int s = -1; for (int n = 1; true; n <<= 1) { @@ -855,7 +855,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { tt[cftab[ll8[i] & 0xff]++] = i; } - if ((this.origPtr < 0) || (this.origPtr >= tt.length)) { + if (this.origPtr < 0 || this.origPtr >= tt.length) { throw new IOException("stream corrupted"); } @@ -1039,7 +1039,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { // it can happen, if the compressor mixed small and large // blocks. Normally only the last block will be smaller // than others. - if ((ttShadow == null) || (ttShadow.length < length)) { + if (ttShadow == null || ttShadow.length < length) { this.tt = ttShadow = new int[length]; } diff --git a/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java b/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java index ea4699567..ec438be66 100644 --- a/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java +++ b/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java @@ -1008,18 +1008,17 @@ public class CBZip2OutputStream extends OutputStream int ge = gs - 1; int aFreq = 0; - for (final int a = alphaSize - 1; (aFreq < tFreq) && (ge < a);) { + while (aFreq < tFreq && ge < alphaSize - 1) { aFreq += mtfFreq[++ge]; } - if ((ge > gs) && (nPart != nGroups) && (nPart != 1) - && (((nGroups - nPart) & 1) != 0)) { + if (ge > gs && nPart != nGroups && nPart != 1 && (nGroups - nPart & 1) != 0) { aFreq -= mtfFreq[ge--]; } final byte[] len_np = len[nPart - 1]; for (int v = alphaSize; --v >= 0;) { - if ((v >= gs) && (v <= ge)) { + if (v >= gs && v <= ge) { len_np[v] = LESSER_ICOST; } else { len_np[v] = GREATER_ICOST; diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java index 72e18a714..28ca2bd37 100644 --- a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java @@ -402,7 +402,7 @@ public abstract class BuildFileTest extends TestCase { executeTarget(target); } catch (BuildException ex) { buildException = ex; - if ((null != msg) && (!ex.getMessage().equals(msg))) { + if (null != msg && !ex.getMessage().equals(msg)) { fail("Should throw BuildException because '" + cause + "' with message '" + msg + "' (actual message '" + ex.getMessage() + "' instead)"); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java index 0da59783d..545e5a429 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java @@ -100,7 +100,7 @@ public class ParallelTest { int firstPipe = s.indexOf('|', start); int beginSlash = s.indexOf('/', firstPipe); int lastPipe = s.indexOf('|', beginSlash); - if ((firstPipe == -1) || (beginSlash == -1) || (lastPipe == -1)) { + if (firstPipe == -1 || beginSlash == -1 || lastPipe == -1) { return -1; }