ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [05/34] ant git commit: java 5-8
Date Thu, 13 Apr 2017 15:16:05 GMT
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java b/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
index aa2f55a..dbe13d4 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java
@@ -17,7 +17,7 @@
  */
 package org.apache.tools.ant.types.resources.comparators;
 
-import java.util.Iterator;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Stack;
 import java.util.Vector;
@@ -47,7 +47,7 @@ public class DelegatedResourceComparator extends ResourceComparator {
         if (c == null) {
             return;
         }
-        resourceComparators = (resourceComparators == null) ? new Vector<ResourceComparator>() : resourceComparators;
+        resourceComparators = (resourceComparators == null) ? new Vector<>() : resourceComparators;
         resourceComparators.add(c);
         setChecked(false);
     }
@@ -58,6 +58,7 @@ public class DelegatedResourceComparator extends ResourceComparator {
      * @param o the object to check against.
      * @return true if there is equality.
      */
+    @Override
     public synchronized boolean equals(Object o) {
         if (o == this) {
             return true;
@@ -76,6 +77,7 @@ public class DelegatedResourceComparator extends ResourceComparator {
      * Hashcode based on the rules for equality.
      * @return a hashcode.
      */
+    @Override
     public synchronized int hashCode() {
         if (isReference()) {
             return getCheckedRef().hashCode();
@@ -84,16 +86,9 @@ public class DelegatedResourceComparator extends ResourceComparator {
     }
 
     /** {@inheritDoc} */
+    @Override
     protected synchronized int resourceCompare(Resource foo, Resource bar) {
-        //if no nested, natural order:
-        if (resourceComparators == null || resourceComparators.isEmpty()) {
-            return foo.compareTo(bar);
-        }
-        int result = 0;
-        for (Iterator<ResourceComparator> i = resourceComparators.iterator(); result == 0 && i.hasNext();) {
-            result = i.next().resourceCompare(foo, bar);
-        }
-        return result;
+        return composite(resourceComparators).compare(foo, bar);
     }
 
     /**
@@ -103,6 +98,7 @@ s.
      * @param p   the Project to resolve against.
      * @throws BuildException on error.
      */
+    @Override
     protected void dieOnCircularReference(Stack<Object> stk, Project p)
         throws BuildException {
         if (isChecked()) {
@@ -122,4 +118,18 @@ s.
             setChecked(true);
         }
     }
+    
+    private static Comparator<Resource> composite(List<? extends Comparator<Resource>> foo) {
+        Comparator<Resource> result = null;
+        if (foo != null) {
+            for (Comparator<Resource> comparator : foo) {
+                if (result == null) {
+                    result = comparator;
+                    continue;
+                }
+                result = result.thenComparing(comparator);
+            }
+        }
+        return result == null ? Comparator.naturalOrder() : result;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java b/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java
index 5832150..c66d6fb 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java
@@ -17,6 +17,8 @@
  */
 package org.apache.tools.ant.types.resources.comparators;
 
+import java.util.Comparator;
+
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -33,11 +35,7 @@ public class Exists extends ResourceComparator {
      *         argument is less than, equal to, or greater than the second.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        boolean f = foo.isExists();
-        if (f == bar.isExists()) {
-            return 0;
-        }
-        return f ? 1 : -1;
+        return Comparator.comparing(Resource::isExists).compare(foo, bar);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java b/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
index 7eafeb9..1d6d3c3 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
@@ -18,6 +18,9 @@
 package org.apache.tools.ant.types.resources.comparators;
 
 import java.io.File;
+import java.util.Comparator;
+import java.util.Objects;
+import java.util.function.Function;
 
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.FileProvider;
@@ -36,25 +39,33 @@ public class FileSystem extends ResourceComparator {
      * @param bar the second Resource.
      * @return a negative integer, zero, or a positive integer as the first
      *         argument is less than, equal to, or greater than the second.
-     * @throws ClassCastException if either resource is not an instance of FileResource.
+     * @throws ClassCastException if either resource is not capable of
+     *         exposing a {@link FileProvider}
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        FileProvider fooFP = foo.as(FileProvider.class);
-        if (fooFP == null) {
-            throw new ClassCastException(foo.getClass()
-                                         + " doesn't provide files");
+        return compare(file(foo), file(bar));
+    }
+    
+    private File file(Resource r) {
+        return r.asOptional(FileProvider.class)
+            .orElseThrow(() -> new ClassCastException(
+                r.getClass() + " doesn't provide files"))
+            .getFile();
+    }
+
+    private int compare(File f1, File f2) {
+        if (Objects.equals(f1, f2)) {
+            return 0;
         }
-        File foofile = fooFP.getFile();
-        FileProvider barFP = bar.as(FileProvider.class);
-        if (barFP == null) {
-            throw new ClassCastException(bar.getClass()
-                                         + " doesn't provide files");
+        if (FILE_UTILS.isLeadingPath(f1, f2)) {
+            return -1;
         }
-        File barfile = barFP.getFile();
-        return foofile.equals(barfile) ? 0
-            : FILE_UTILS.isLeadingPath(foofile, barfile) ? -1
-            : FILE_UTILS.normalize(foofile.getAbsolutePath()).compareTo(
-                FILE_UTILS.normalize(barfile.getAbsolutePath()));
+        if (FILE_UTILS.isLeadingPath(f2, f1)) {
+            return 1;
+        }
+        return Comparator
+            .comparing(((Function<File, String>) File::getAbsolutePath)
+                .andThen(FILE_UTILS::normalize))
+            .compare(f1, f2);
     }
-
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java b/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
index 3bfc9c7..ee9c556 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
@@ -36,10 +36,10 @@ public abstract class ResourceComparator extends DataType implements Comparator<
      *         argument is less than, equal to, or greater than the second.
      * @throws ClassCastException if either argument is null.
      */
+    @Override
     public final int compare(Resource foo, Resource bar) {
         dieOnCircularReference();
-        ResourceComparator c =
-            isReference() ? (ResourceComparator) getCheckedRef() : this;
+        ResourceComparator c = isReference() ? getCheckedRef() : this;
         return c.resourceCompare(foo, bar);
     }
 
@@ -48,6 +48,7 @@ public abstract class ResourceComparator extends DataType implements Comparator<
      * @param o the Object to compare against.
      * @return true if the specified Object equals this one.
      */
+    @Override
     public boolean equals(Object o) {
         if (isReference()) {
             return getCheckedRef().equals(o);
@@ -62,6 +63,7 @@ public abstract class ResourceComparator extends DataType implements Comparator<
      * Hashcode based on the rules for equality.
      * @return a hashcode.
      */
+    @Override
     public synchronized int hashCode() {
         if (isReference()) {
             return getCheckedRef().hashCode();
@@ -78,4 +80,8 @@ public abstract class ResourceComparator extends DataType implements Comparator<
      */
     protected abstract int resourceCompare(Resource foo, Resource bar);
 
+    @Override
+    protected ResourceComparator getCheckedRef() {
+        return (ResourceComparator) super.getCheckedRef();
+    }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java b/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java
index c787a76..664261d 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java
@@ -17,6 +17,8 @@
  */
 package org.apache.tools.ant.types.resources.comparators;
 
+import java.util.Comparator;
+import java.util.Optional;
 import java.util.Stack;
 
 import org.apache.tools.ant.BuildException;
@@ -69,8 +71,8 @@ public class Reverse extends ResourceComparator {
      *         argument is greater than, equal to, or less than the second.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        return -1 * (nested == null
-            ? foo.compareTo(bar) : nested.compare(foo, bar));
+        return Optional.<Comparator<Resource>> ofNullable(nested)
+            .orElseGet(Comparator::naturalOrder).reversed().compare(foo, bar);
     }
 
     protected void dieOnCircularReference(Stack<Object> stk, Project p)
@@ -88,4 +90,5 @@ public class Reverse extends ResourceComparator {
             setChecked(true);
         }
     }
+
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/Size.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/Size.java b/src/main/org/apache/tools/ant/types/resources/comparators/Size.java
index b94f250..bf0fe35 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/Size.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/Size.java
@@ -17,6 +17,8 @@
  */
 package org.apache.tools.ant.types.resources.comparators;
 
+import java.util.Comparator;
+
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -32,8 +34,7 @@ public class Size extends ResourceComparator {
      *         argument is less than, equal to, or greater than the second.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        long diff = foo.getSize() - bar.getSize();
-        return diff > 0 ? 1 : (diff == 0 ? 0 : -1);
+        return Comparator.comparingLong(Resource::getSize).compare(foo, bar);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/comparators/Type.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/comparators/Type.java b/src/main/org/apache/tools/ant/types/resources/comparators/Type.java
index 6c082ef..2039735 100644
--- a/src/main/org/apache/tools/ant/types/resources/comparators/Type.java
+++ b/src/main/org/apache/tools/ant/types/resources/comparators/Type.java
@@ -17,6 +17,8 @@
  */
 package org.apache.tools.ant.types.resources.comparators;
 
+import java.util.Comparator;
+
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -34,11 +36,7 @@ public class Type extends ResourceComparator {
      *         argument is less than, equal to, or greater than the second.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        boolean f = foo.isDirectory();
-        if (f == bar.isDirectory()) {
-            return 0;
-        }
-        return f ? 1 : -1;
+        return Comparator.comparing(Resource::isDirectory).compare(foo, bar);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/And.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/And.java b/src/main/org/apache/tools/ant/types/resources/selectors/And.java
index 409ed66..6925360 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/And.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/And.java
@@ -17,8 +17,6 @@
  */
 package org.apache.tools.ant.types.resources.selectors;
 
-import java.util.Iterator;
-
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -37,7 +35,7 @@ public class And extends ResourceSelectorContainer implements ResourceSelector {
      * Convenience constructor.
      * @param r the ResourceSelector[] to add.
      */
-    public And(ResourceSelector[] r) {
+    public And(ResourceSelector... r) {
         super(r);
     }
 
@@ -47,12 +45,7 @@ public class And extends ResourceSelectorContainer implements ResourceSelector {
      * @return whether the Resource was selected.
      */
     public boolean isSelected(Resource r) {
-        for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) {
-            if (!i.next().isSelected(r)) {
-                return false;
-            }
-        }
-        return true;
+        return getResourceSelectors().stream().allMatch(s -> s.isSelected(r));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/Date.java b/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
index 0719a18..23698af 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
@@ -144,15 +144,15 @@ public class Date implements ResourceSelector {
             try {
                 long m = df.parse(dateTime).getTime();
                 if (m < 0) {
-                    throw new BuildException("Date of " + dateTime
-                        + " results in negative milliseconds value"
-                        + " relative to epoch (January 1, 1970, 00:00:00 GMT).");
+                    throw new BuildException(
+                        "Date of %s results in negative milliseconds value relative to epoch (January 1, 1970, 00:00:00 GMT).",
+                        dateTime);
                 }
                 setMillis(m);
             } catch (ParseException pe) {
-                throw new BuildException("Date of " + dateTime
-                        + " Cannot be parsed correctly. It should be in '"
-                        + p + "' format.");
+                throw new BuildException(
+                    "Date of %s Cannot be parsed correctly. It should be in '%s' format.",
+                    dateTime, p);
             }
         }
         return when.evaluate(r.getLastModified(), millis.longValue(), granularity);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java b/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java
index 39b3108..2b50514 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java
@@ -110,13 +110,12 @@ public class InstanceOf implements ResourceSelector {
         if (type != null) {
             if (project == null) {
                 throw new BuildException(
-                    "No project set for InstanceOf ResourceSelector; "
-                    + "the type attribute is invalid.");
+                    "No project set for InstanceOf ResourceSelector; the type attribute is invalid.");
             }
             AntTypeDefinition d = ComponentHelper.getComponentHelper(
                 project).getDefinition(ProjectHelper.genComponentName(uri, type));
             if (d == null) {
-                throw new BuildException("type " + type + " not found.");
+                throw new BuildException("type %s not found.",type);
             }
             try {
                 c = d.innerGetTypeClass();

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java b/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java
index 5a7a95c..e87e232 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java
@@ -25,8 +25,8 @@ import org.apache.tools.ant.types.Resource;
  * Majority ResourceSelector.
  * @since Ant 1.7
  */
-public class Majority
-    extends ResourceSelectorContainer implements ResourceSelector {
+public class Majority extends ResourceSelectorContainer
+    implements ResourceSelector {
 
     private boolean tie = true;
 
@@ -40,7 +40,7 @@ public class Majority
      * Convenience constructor.
      * @param r the ResourceSelector[] to add.
      */
-    public Majority(ResourceSelector[] r) {
+    public Majority(ResourceSelector... r) {
         super(r);
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/Name.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/Name.java b/src/main/org/apache/tools/ant/types/resources/selectors/Name.java
index 50c242a..f5adeb4 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/Name.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/Name.java
@@ -132,18 +132,17 @@ public class Name implements ResourceSelector {
     private boolean matches(String name) {
         if (pattern != null) {
             return SelectorUtils.match(modify(pattern), modify(name), cs);
-        } else {
-            if (reg == null) {
-                reg = new RegularExpression();
-                reg.setPattern(regex);
-                expression = reg.getRegexp(project);
-            }
-            return expression.matches(modify(name), RegexpUtil.asOptions(cs));
+        } 
+        if (reg == null) {
+            reg = new RegularExpression();
+            reg.setPattern(regex);
+            expression = reg.getRegexp(project);
         }
+        return expression.matches(modify(name), RegexpUtil.asOptions(cs));
     }
 
     private String modify(String s) {
-        if (s == null || !handleDirSep || s.indexOf("\\") == -1) {
+        if (s == null || !handleDirSep || s.indexOf('\\') < 0) {
             return s;
         }
         return s.replace('\\', '/');

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/None.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/None.java b/src/main/org/apache/tools/ant/types/resources/selectors/None.java
index 0de8623..204d9c2 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/None.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/None.java
@@ -17,8 +17,6 @@
  */
 package org.apache.tools.ant.types.resources.selectors;
 
-import java.util.Iterator;
-
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -38,7 +36,7 @@ public class None
      * Convenience constructor.
      * @param r the ResourceSelector[] to add.
      */
-    public None(ResourceSelector[] r) {
+    public None(ResourceSelector... r) {
         super(r);
     }
 
@@ -48,12 +46,7 @@ public class None
      * @return whether the Resource was selected.
      */
     public boolean isSelected(Resource r) {
-        for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) {
-            if (i.next().isSelected(r)) {
-                return false;
-            }
-        }
-        return true;
+        return getResourceSelectors().stream().noneMatch(s -> s.isSelected(r));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/Or.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/Or.java b/src/main/org/apache/tools/ant/types/resources/selectors/Or.java
index b22303a..9a39b86 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/Or.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/Or.java
@@ -17,8 +17,6 @@
  */
 package org.apache.tools.ant.types.resources.selectors;
 
-import java.util.Iterator;
-
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -37,7 +35,7 @@ public class Or extends ResourceSelectorContainer implements ResourceSelector {
      * Convenience constructor.
      * @param r the ResourceSelector[] to add.
      */
-    public Or(ResourceSelector[] r) {
+    public Or(ResourceSelector... r) {
         super(r);
     }
 
@@ -47,12 +45,7 @@ public class Or extends ResourceSelectorContainer implements ResourceSelector {
      * @return whether the Resource was selected.
      */
     public boolean isSelected(Resource r) {
-        for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) {
-            if (i.next().isSelected(r)) {
-                return true;
-            }
-        }
-        return false;
+        return getResourceSelectors().stream().anyMatch(s -> s.isSelected(r));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java b/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
index 6b1c800..795d453 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java
@@ -33,7 +33,7 @@ import org.apache.tools.ant.types.DataType;
  */
 public class ResourceSelectorContainer extends DataType {
 
-    private final List<ResourceSelector> resourceSelectors = new ArrayList<ResourceSelector>();
+    private final List<ResourceSelector> resourceSelectors = new ArrayList<>();
 
     /**
      * Default constructor.
@@ -45,9 +45,9 @@ public class ResourceSelectorContainer extends DataType {
      * Construct a new ResourceSelectorContainer with the specified array of selectors.
      * @param r the ResourceSelector[] to add.
      */
-    public ResourceSelectorContainer(ResourceSelector[] r) {
-        for (int i = 0; i < r.length; i++) {
-            add(r[i]);
+    public ResourceSelectorContainer(ResourceSelector... resourceSelectors) {
+        for (ResourceSelector rsel : resourceSelectors) {
+            add(rsel);
         }
     }
 
@@ -72,7 +72,7 @@ public class ResourceSelectorContainer extends DataType {
      */
     public boolean hasSelectors() {
         if (isReference()) {
-            return ((ResourceSelectorContainer) getCheckedRef()).hasSelectors();
+            return getCheckedRef().hasSelectors();
         }
         dieOnCircularReference();
         return !resourceSelectors.isEmpty();
@@ -84,7 +84,7 @@ public class ResourceSelectorContainer extends DataType {
      */
     public int selectorCount() {
         if (isReference()) {
-            return ((ResourceSelectorContainer) getCheckedRef()).selectorCount();
+            return getCheckedRef().selectorCount();
         }
         dieOnCircularReference();
         return resourceSelectors.size();
@@ -96,10 +96,21 @@ public class ResourceSelectorContainer extends DataType {
      */
     public Iterator<ResourceSelector> getSelectors() {
         if (isReference()) {
-            return ((ResourceSelectorContainer) getCheckedRef()).getSelectors();
+            return getCheckedRef().getSelectors();
+        }
+        return getResourceSelectors().iterator();
+    }
+
+    /**
+     * Get the configured {@link ResourceSelector}s as a {@link List}.
+     * @return {@link List} of {@link ResourceSelector}
+     */
+    public List<ResourceSelector> getResourceSelectors() {
+        if (isReference()) {
+            return getCheckedRef().getResourceSelectors();
         }
         dieOnCircularReference();
-        return Collections.unmodifiableList(resourceSelectors).iterator();
+        return Collections.unmodifiableList(resourceSelectors);
     }
 
     /**
@@ -125,4 +136,8 @@ public class ResourceSelectorContainer extends DataType {
         }
     }
 
+    @Override
+    protected ResourceSelectorContainer getCheckedRef() {
+        return (ResourceSelectorContainer) super.getCheckedRef();
+    }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java b/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
index 3039d48..61f02b6 100644
--- a/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
+++ b/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
@@ -18,9 +18,13 @@
 
 package org.apache.tools.ant.types.selectors;
 
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Stack;
 import java.util.Vector;
+import java.util.stream.Collectors;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -36,18 +40,20 @@ import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector;
 public abstract class AbstractSelectorContainer extends DataType
     implements Cloneable, SelectorContainer {
 
-    private Vector<FileSelector> selectorsList = new Vector<FileSelector>();
+    private List<FileSelector> selectorsList =
+        Collections.synchronizedList(new ArrayList<>());
 
     /**
      * Indicates whether there are any selectors here.
      * @return true if there are selectors
      */
+    @Override
     public boolean hasSelectors() {
         if (isReference()) {
-            return ((AbstractSelectorContainer) getCheckedRef()).hasSelectors();
+            return getCheckedRef().hasSelectors();
         }
         dieOnCircularReference();
-        return !(selectorsList.isEmpty());
+        return !selectorsList.isEmpty();
     }
 
     /**
@@ -56,7 +62,7 @@ public abstract class AbstractSelectorContainer extends DataType
      */
     public int selectorCount() {
         if (isReference()) {
-            return ((AbstractSelectorContainer) getCheckedRef()).selectorCount();
+            return getCheckedRef().selectorCount();
         }
         dieOnCircularReference();
         return selectorsList.size();
@@ -69,13 +75,11 @@ public abstract class AbstractSelectorContainer extends DataType
      */
     public FileSelector[] getSelectors(Project p) {
         if (isReference()) {
-            return ((AbstractSelectorContainer) getCheckedRef(p))
-                .getSelectors(p);
+            return getCheckedRef(AbstractSelectorContainer.class,
+                getDataTypeName(), p).getSelectors(p);
         }
         dieOnCircularReference(p);
-        FileSelector[] result = new FileSelector[selectorsList.size()];
-        selectorsList.copyInto(result);
-        return result;
+        return selectorsList.toArray(new FileSelector[selectorsList.size()]);
     }
 
     /**
@@ -84,11 +88,10 @@ public abstract class AbstractSelectorContainer extends DataType
      */
     public Enumeration<FileSelector> selectorElements() {
         if (isReference()) {
-            return ((AbstractSelectorContainer) getCheckedRef())
-                .selectorElements();
+            return getCheckedRef().selectorElements();
         }
         dieOnCircularReference();
-        return selectorsList.elements();
+        return Collections.enumeration(selectorsList);
     }
 
     /**
@@ -99,18 +102,8 @@ public abstract class AbstractSelectorContainer extends DataType
      * @return comma separated list of Selectors contained in this one
      */
     public String toString() {
-        StringBuilder buf = new StringBuilder();
-        Enumeration<FileSelector> e = selectorElements();
-        if (e.hasMoreElements()) {
-            while (e.hasMoreElements()) {
-                buf.append(e.nextElement().toString());
-                if (e.hasMoreElements()) {
-                    buf.append(", ");
-                }
-            }
-        }
-
-        return buf.toString();
+        return selectorsList.stream().map(Object::toString)
+            .collect(Collectors.joining(", "));
     }
 
     /**
@@ -122,7 +115,7 @@ public abstract class AbstractSelectorContainer extends DataType
         if (isReference()) {
             throw noChildrenAllowed();
         }
-        selectorsList.addElement(selector);
+        selectorsList.add(selector);
         setChecked(false);
     }
 
@@ -144,16 +137,11 @@ public abstract class AbstractSelectorContainer extends DataType
      */
     public void validate() {
         if (isReference()) {
-            ((AbstractSelectorContainer) getCheckedRef()).validate();
+            getCheckedRef().validate();
         }
         dieOnCircularReference();
-        Enumeration<FileSelector> e = selectorElements();
-        while (e.hasMoreElements()) {
-            Object o = e.nextElement();
-            if (o instanceof BaseSelector) {
-                ((BaseSelector) o).validate();
-            }
-        }
+        selectorsList.stream().filter(BaseSelector.class::isInstance)
+            .map(BaseSelector.class::cast).forEach(BaseSelector::validate);
     }
 
 
@@ -358,17 +346,23 @@ public abstract class AbstractSelectorContainer extends DataType
         }
     }
 
-    public synchronized Object clone() {
+    public synchronized AbstractSelectorContainer clone() {
         if (isReference()) {
-            return ((AbstractSelectorContainer) getCheckedRef()).clone();
+            return getCheckedRef().clone();
         }
         try {
             AbstractSelectorContainer sc =
                 (AbstractSelectorContainer) super.clone();
-            sc.selectorsList = new Vector<FileSelector>(selectorsList);
+            sc.selectorsList = new Vector<>(selectorsList);
             return sc;
         } catch (CloneNotSupportedException e) {
             throw new BuildException(e);
         }
     }
+    
+    @Override
+    protected AbstractSelectorContainer getCheckedRef() {
+        return (AbstractSelectorContainer) super.getCheckedRef();
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/AndSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/AndSelector.java b/src/main/org/apache/tools/ant/types/selectors/AndSelector.java
index c8e96a0..5487d41 100644
--- a/src/main/org/apache/tools/ant/types/selectors/AndSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/AndSelector.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
-import java.util.Enumeration;
+import java.util.stream.Stream;
 
 /**
  * This selector has a collection of other selectors, all of which have to
@@ -30,12 +30,6 @@ import java.util.Enumeration;
 public class AndSelector extends BaseSelectorContainer {
 
     /**
-     * Default constructor.
-     */
-    public AndSelector() {
-    }
-
-    /**
      * @return a string representation of the selector
      */
     public String toString() {
@@ -60,14 +54,8 @@ public class AndSelector extends BaseSelectorContainer {
      */
     public boolean isSelected(File basedir, String filename, File file) {
         validate();
-        Enumeration<FileSelector> e = selectorElements();
-
-        while (e.hasMoreElements()) {
-            if (!e.nextElement().isSelected(basedir, filename, file)) {
-                return false;
-            }
-        }
-        return true;
+        return Stream.of(getSelectors(getProject()))
+            .allMatch(s -> s.isSelected(basedir, filename, file));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java b/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java
index f17ca02..f65eb3f 100644
--- a/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java
@@ -30,9 +30,8 @@ import org.apache.tools.ant.types.Parameter;
  *
  * @since 1.5
  */
-public abstract class BaseExtendSelector
-        extends BaseSelector
-        implements ExtendFileSelector {
+public abstract class BaseExtendSelector extends BaseSelector
+    implements ExtendFileSelector {
 
     // CheckStyle:VisibilityModifier OFF - bc
 
@@ -42,18 +41,13 @@ public abstract class BaseExtendSelector
     // CheckStyle:VisibilityModifier ON
 
     /**
-     * Default constructor.
-     */
-    public BaseExtendSelector() {
-    }
-
-    /**
      * Set all the Parameters for this custom selector, collected by
      * the ExtendSelector class.
      *
      * @param parameters the complete set of parameters for this selector
      */
-    public void setParameters(Parameter[] parameters) {
+    @Override
+    public void setParameters(Parameter... parameters) {
         this.parameters = parameters;
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java b/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
index 414390e..6307ced 100644
--- a/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
@@ -37,12 +37,6 @@ public abstract class BaseSelector extends DataType implements FileSelector {
     private Throwable cause;
 
     /**
-     * Do nothing constructor.
-     */
-    public BaseSelector() {
-    }
-
-    /**
      * Allows all selectors to indicate a setup error. Note that only
      * the first error message is recorded.
      *
@@ -76,7 +70,6 @@ public abstract class BaseSelector extends DataType implements FileSelector {
         return errmsg;
     }
 
-
     /**
      * <p>Subclasses can override this method to provide checking of their
      * state. So long as they call validate() from isSelected(), this will
@@ -86,11 +79,10 @@ public abstract class BaseSelector extends DataType implements FileSelector {
      */
     public void verifySettings() {
         if (isReference()) {
-            ((BaseSelector) getCheckedRef()).verifySettings();
+            getCheckedRef().verifySettings();
         }
     }
 
-
     /**
      * Subclasses can use this to throw the requisite exception
      * in isSelected() in the case of an error condition.
@@ -121,6 +113,10 @@ public abstract class BaseSelector extends DataType implements FileSelector {
     public abstract boolean isSelected(File basedir, String filename,
                                        File file);
 
+    @Override
+    protected BaseSelector getCheckedRef() {
+        return (BaseSelector) super.getCheckedRef();
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java b/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
index 3fcccd7..baf14da 100644
--- a/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
+++ b/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
@@ -19,9 +19,12 @@
 package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Stack;
-import java.util.Vector;
+import java.util.stream.Collectors;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -36,13 +39,7 @@ import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector;
 public abstract class BaseSelectorContainer extends BaseSelector
         implements SelectorContainer {
 
-    private Vector<FileSelector> selectorsList = new Vector<FileSelector>();
-
-    /**
-     * Default constructor.
-     */
-    public BaseSelectorContainer() {
-    }
+    private List<FileSelector> selectorsList = Collections.synchronizedList(new ArrayList<>());
 
     /**
      * Indicates whether there are any selectors here.
@@ -50,7 +47,7 @@ public abstract class BaseSelectorContainer extends BaseSelector
      */
     public boolean hasSelectors() {
         dieOnCircularReference();
-        return !(selectorsList.isEmpty());
+        return !selectorsList.isEmpty();
     }
 
     /**
@@ -69,9 +66,7 @@ public abstract class BaseSelectorContainer extends BaseSelector
      */
     public FileSelector[] getSelectors(Project p) {
         dieOnCircularReference();
-        FileSelector[] result = new FileSelector[selectorsList.size()];
-        selectorsList.copyInto(result);
-        return result;
+        return selectorsList.toArray(new FileSelector[selectorsList.size()]);
     }
 
     /**
@@ -80,7 +75,7 @@ public abstract class BaseSelectorContainer extends BaseSelector
      */
     public Enumeration<FileSelector> selectorElements() {
         dieOnCircularReference();
-        return selectorsList.elements();
+        return Collections.enumeration(selectorsList);
     }
 
     /**
@@ -92,15 +87,8 @@ public abstract class BaseSelectorContainer extends BaseSelector
      */
     public String toString() {
         dieOnCircularReference();
-        StringBuilder buf = new StringBuilder();
-        Enumeration<FileSelector> e = selectorElements();
-        while (e.hasMoreElements()) {
-            buf.append(e.nextElement().toString());
-            if (e.hasMoreElements()) {
-                buf.append(", ");
-            }
-        }
-        return buf.toString();
+        return selectorsList.stream().map(Object::toString)
+            .collect(Collectors.joining(", "));
     }
 
     /**
@@ -109,7 +97,7 @@ public abstract class BaseSelectorContainer extends BaseSelector
      * @param selector the new selector to add
      */
     public void appendSelector(FileSelector selector) {
-        selectorsList.addElement(selector);
+        selectorsList.add(selector);
         setChecked(false);
     }
 
@@ -136,16 +124,10 @@ public abstract class BaseSelectorContainer extends BaseSelector
         if (errmsg != null) {
             throw new BuildException(errmsg);
         }
-        Enumeration<FileSelector> e = selectorElements();
-        while (e.hasMoreElements()) {
-            Object o = e.nextElement();
-            if (o instanceof BaseSelector) {
-                ((BaseSelector) o).validate();
-            }
-        }
+        selectorsList.stream().filter(BaseSelector.class::isInstance)
+            .map(BaseSelector.class::cast).forEach(BaseSelector::validate);
     }
 
-
     /**
      * Method that each selector will implement to create their selection
      * behaviour. This is what makes SelectorContainer abstract.
@@ -157,8 +139,7 @@ public abstract class BaseSelectorContainer extends BaseSelector
      * @return whether the file should be selected or not
      */
     public abstract boolean isSelected(File basedir, String filename,
-                                       File file);
-
+        File file);
 
     /* Methods below all add specific selectors */
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java b/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
index 7140b97..b139b62 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
@@ -41,12 +41,6 @@ import org.apache.tools.ant.util.regexp.RegexpUtil;
 public class ContainsRegexpSelector extends BaseExtendSelector
         implements ResourceSelector {
 
-    private String userProvidedExpression = null;
-    private RegularExpression myRegExp = null;
-    private Regexp myExpression = null;
-    private boolean caseSensitive = true;
-    private boolean multiLine = false;
-    private boolean singleLine = false;
     /** Key to used for parameterized custom selector */
     public static final String EXPRESSION_KEY = "expression";
     /** Parameter name for the casesensitive attribute. */
@@ -56,21 +50,19 @@ public class ContainsRegexpSelector extends BaseExtendSelector
     /** Parameter name for the singleline attribute. */
     private static final String SL_KEY = "singleline";
 
-    /**
-     * Creates a new <code>ContainsRegexpSelector</code> instance.
-     */
-    public ContainsRegexpSelector() {
-    }
+    private String userProvidedExpression = null;
+    private RegularExpression myRegExp = null;
+    private Regexp myExpression = null;
+    private boolean caseSensitive = true;
+    private boolean multiLine = false;
+    private boolean singleLine = false;
 
     /**
      * @return a string describing this object
      */
     public String toString() {
-        StringBuilder buf = new StringBuilder(
-                "{containsregexpselector expression: ");
-        buf.append(userProvidedExpression);
-        buf.append("}");
-        return buf.toString();
+        return String.format("{containsregexpselector expression: %s}",
+            userProvidedExpression);
     }
 
     /**
@@ -116,7 +108,7 @@ public class ContainsRegexpSelector extends BaseExtendSelector
      *
      * @param parameters the complete set of parameters for this selector
      */
-    public void setParameters(Parameter[] parameters) {
+    public void setParameters(Parameter... parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
             for (int i = 0; i < parameters.length; i++) {
@@ -166,11 +158,7 @@ public class ContainsRegexpSelector extends BaseExtendSelector
      * @return whether the Resource is selected or not
      */
     public boolean isSelected(Resource r) {
-        String teststr = null;
-        BufferedReader in = null;
-
         // throw BuildException on error
-
         validate();
 
         if (r.isDirectory()) {
@@ -183,40 +171,25 @@ public class ContainsRegexpSelector extends BaseExtendSelector
             myExpression = myRegExp.getRegexp(getProject());
         }
 
-        try {
-            in = new BufferedReader(new InputStreamReader(r.getInputStream())); //NOSONAR
-        } catch (Exception e) {
-            throw new BuildException("Could not get InputStream from "
-                    + r.toLongString(), e);
-        }
-        boolean success = false;
-        try {
-            teststr = in.readLine();
-
-            while (teststr != null) {
-
-                if (myExpression.matches(teststr,
-                                         RegexpUtil.asOptions(caseSensitive,
-                                                              multiLine,
-                                                              singleLine))) {
-                    return true;
-                }
-                teststr = in.readLine();
-            }
-            success = true;
-            return false;
-        } catch (IOException ioe) {
-            throw new BuildException("Could not read " + r.toLongString());
-        } finally {
+        try (BufferedReader in =
+            new BufferedReader(new InputStreamReader(r.getInputStream()))) {
             try {
-                in.close();
-            } catch (Exception e) {
-                if (success) {
-                    throw new BuildException("Could not close " //NOSONAR
-                                             + r.toLongString());
+                String teststr = in.readLine();
+
+                while (teststr != null) {
+                    if (myExpression.matches(teststr, RegexpUtil
+                        .asOptions(caseSensitive, multiLine, singleLine))) {
+                        return true;
+                    }
+                    teststr = in.readLine();
                 }
+                return false;
+            } catch (IOException ioe) {
+                throw new BuildException("Could not read " + r.toLongString());
             }
+        } catch (IOException e) {
+            throw new BuildException(
+                "Could not get InputStream from " + r.toLongString(), e);
         }
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java b/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
index a1004a8..f75367e 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.charset.Charset;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -29,7 +30,6 @@ import org.apache.tools.ant.types.Parameter;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
-import org.apache.tools.ant.util.FileUtils;
 
 /**
  * Selector that filters files/resources based on whether they contain a
@@ -39,10 +39,6 @@ import org.apache.tools.ant.util.FileUtils;
  */
 public class ContainsSelector extends BaseExtendSelector implements ResourceSelector {
 
-    private String contains = null;
-    private boolean casesensitive = true;
-    private boolean ignorewhitespace = false;
-    private String encoding = null;
     /** Key to used for parameterized custom selector */
     public static final String EXPRESSION_KEY = "expression";
     /** Used for parameterized custom selector */
@@ -52,13 +48,10 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
     /** Used for parameterized custom selector */
     public static final String WHITESPACE_KEY = "ignorewhitespace";
 
-
-    /**
-     * Creates a new <code>ContainsSelector</code> instance.
-     *
-     */
-    public ContainsSelector() {
-    }
+    private String contains = null;
+    private boolean casesensitive = true;
+    private boolean ignorewhitespace = false;
+    private String encoding = null;
 
     /**
      * @return a string describing this object
@@ -66,10 +59,8 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
     public String toString() {
         StringBuilder buf = new StringBuilder("{containsselector text: ");
         buf.append('"').append(contains).append('"');
-        buf.append(" casesensitive: ");
-        buf.append(casesensitive ? "true" : "false");
-        buf.append(" ignorewhitespace: ");
-        buf.append(ignorewhitespace ? "true" : "false");
+        buf.append(" casesensitive: ").append(casesensitive);
+        buf.append(" ignorewhitespace: ").append(ignorewhitespace);
         buf.append("}");
         return buf.toString();
     }
@@ -117,7 +108,7 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
      *
      * @param parameters the complete set of parameters for this selector
      */
-    public void setParameters(Parameter[] parameters) {
+    public void setParameters(Parameter... parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
             for (int i = 0; i < parameters.length; i++) {
@@ -169,11 +160,10 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
      * @return whether the Resource is selected.
      */
     public boolean isSelected(Resource r) {
-
         // throw BuildException on error
         validate();
 
-        if (r.isDirectory() || contains.length() == 0) {
+        if (r.isDirectory() || contains.isEmpty()) {
             return true;
         }
 
@@ -184,38 +174,30 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
         if (ignorewhitespace) {
             userstr = SelectorUtils.removeWhitespace(userstr);
         }
-        BufferedReader in = null;
-        try {
-            if (encoding != null) {
-                in = new BufferedReader(new InputStreamReader(r.getInputStream(), encoding)); //NOSONAR
-            }   else {
-                in = new BufferedReader(new InputStreamReader(r.getInputStream())); //NOSONAR
-            }
-        } catch (Exception e) {
-            throw new BuildException("Could not get InputStream from "
-                    + r.toLongString(), e);
-        }
-        try {
-            String teststr = in.readLine();
-            while (teststr != null) {
-                if (!casesensitive) {
-                    teststr = teststr.toLowerCase();
-                }
-                if (ignorewhitespace) {
-                    teststr = SelectorUtils.removeWhitespace(teststr);
-                }
-                if (teststr.indexOf(userstr) > -1) {
-                    return true;
+        try (BufferedReader in = new BufferedReader(
+            new InputStreamReader(r.getInputStream(), encoding == null
+                ? Charset.defaultCharset() : Charset.forName(encoding)))) {
+            try {
+                String teststr = in.readLine();
+                while (teststr != null) {
+                    if (!casesensitive) {
+                        teststr = teststr.toLowerCase();
+                    }
+                    if (ignorewhitespace) {
+                        teststr = SelectorUtils.removeWhitespace(teststr);
+                    }
+                    if (teststr.indexOf(userstr) > -1) {
+                        return true;
+                    }
+                    teststr = in.readLine();
                 }
-                teststr = in.readLine();
+                return false;
+            } catch (IOException ioe) {
+                throw new BuildException("Could not read " + r.toLongString());
             }
-            return false;
-        } catch (IOException ioe) {
-            throw new BuildException("Could not read " + r.toLongString());
-        } finally {
-            FileUtils.close(in);
+        } catch (IOException e) {
+            throw new BuildException(
+                "Could not get InputStream from " + r.toLongString(), e);
         }
     }
-
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DateSelector.java b/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
index 8232e45..e79061c 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
@@ -36,16 +36,6 @@ import org.apache.tools.ant.util.FileUtils;
  */
 public class DateSelector extends BaseExtendSelector {
 
-    /** Utilities used for file operations */
-    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
-
-    private long millis = -1;
-    private String dateTime = null;
-    private boolean includeDirs = false;
-    private long granularity = 0;
-    private String pattern;
-    private TimeComparison when = TimeComparison.EQUAL;
-
     /** Key to used for parameterized custom selector */
     public static final String MILLIS_KEY = "millis";
     /** Key to used for parameterized custom selector */
@@ -59,13 +49,15 @@ public class DateSelector extends BaseExtendSelector {
     /** Key to used for parameterized custom selector */
     public static final String PATTERN_KEY = "pattern";
 
-    /**
-     * Creates a new <code>DateSelector</code> instance.
-     *
-     */
-    public DateSelector() {
-        granularity = FILE_UTILS.getFileTimestampGranularity();
-    }
+    /** Utilities used for file operations */
+    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+
+    private long millis = -1;
+    private String dateTime = null;
+    private boolean includeDirs = false;
+    private long granularity = FILE_UTILS.getFileTimestampGranularity();
+    private String pattern;
+    private TimeComparison when = TimeComparison.EQUAL;
 
     /**
      * @return a string describing this object
@@ -74,8 +66,7 @@ public class DateSelector extends BaseExtendSelector {
         StringBuilder buf = new StringBuilder("{dateselector date: ");
         buf.append(dateTime);
         buf.append(" compare: ").append(when.getValue());
-        buf.append(" granularity: ");
-        buf.append(granularity);
+        buf.append(" granularity: ").append(granularity);
         if (pattern != null) {
             buf.append(" pattern: ").append(pattern);
         }
@@ -166,7 +157,7 @@ public class DateSelector extends BaseExtendSelector {
      *
      * @param parameters the complete set of parameters for this selector.
      */
-    public void setParameters(Parameter[] parameters) {
+    public void setParameters(Parameter... parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
             for (int i = 0; i < parameters.length; i++) {
@@ -239,9 +230,7 @@ public class DateSelector extends BaseExtendSelector {
      * @return whether the file is selected.
      */
     public boolean isSelected(File basedir, String filename, File file) {
-
         validate();
-
         return (file.isDirectory() && !includeDirs)
             || when.evaluate(file.lastModified(), millis, granularity);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/DependSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DependSelector.java b/src/main/org/apache/tools/ant/types/selectors/DependSelector.java
index 01ac237..24d4eab 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DependSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DependSelector.java
@@ -31,14 +31,6 @@ import java.io.File;
 public class DependSelector extends MappingSelector {
 
     /**
-     * Creates a new <code>DependSelector</code> instance.
-     *
-     */
-    public DependSelector() {
-
-    }
-
-    /**
      * @return a string describing this object
      */
     public String toString() {
@@ -48,8 +40,7 @@ public class DependSelector extends MappingSelector {
         } else {
             buf.append(targetdir.getName());
         }
-        buf.append(" granularity: ");
-        buf.append(granularity);
+        buf.append(" granularity: ").append(granularity);
         if (map != null) {
             buf.append(" mapper: ");
             buf.append(map.toString());
@@ -61,7 +52,6 @@ public class DependSelector extends MappingSelector {
         return buf.toString();
     }
 
-
     /**
      * this test is our selection test that compared the file with the destfile
      * @param srcfile the source file
@@ -69,9 +59,7 @@ public class DependSelector extends MappingSelector {
      * @return true if destination is out of date
      */
     public boolean selectionTest(File srcfile, File destfile) {
-        boolean selected = SelectorUtils.isOutOfDate(srcfile, destfile,
-                granularity);
-        return selected;
+        return SelectorUtils.isOutOfDate(srcfile, destfile, granularity);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java b/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
index a80f9aa..e313983 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
@@ -32,6 +32,11 @@ import org.apache.tools.ant.types.Parameter;
  */
 public class DepthSelector extends BaseExtendSelector {
 
+    /** Used for parameterized custom selector */
+    public static final String MIN_KEY = "min";
+    /** Used for parameterized custom selector */
+    public static final String MAX_KEY = "max";
+
     // CheckStyle:VisibilityModifier OFF - bc
 
     /** min attribute */
@@ -41,26 +46,13 @@ public class DepthSelector extends BaseExtendSelector {
 
     // CheckStyle:VisibilityModifier ON
 
-    /** Used for parameterized custom selector */
-    public static final String MIN_KEY = "min";
-    /** Used for parameterized custom selector */
-    public static final String MAX_KEY = "max";
-
-    /**
-     * Creates a new <code>DepthSelector</code> instance.
-     *
-     */
-    public DepthSelector() {
-    }
-
     /**
      * @return a string describing this object
      */
     public String toString() {
-        StringBuilder buf = new StringBuilder("{depthselector min: ");
-        buf.append(min);
-        buf.append(" max: ");
-        buf.append(max);
+        StringBuilder buf = new StringBuilder("{depthselector");
+        buf.append(" min: ").append(min);
+        buf.append(" max: ").append(max);
         buf.append("}");
         return buf.toString();
     }
@@ -89,7 +81,7 @@ public class DepthSelector extends BaseExtendSelector {
      *
      * @param parameters the complete set of parameters for this selector
      */
-    public void setParameters(Parameter[] parameters) {
+    public void setParameters(Parameter... parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
             for (int i = 0; i < parameters.length; i++) {
@@ -121,8 +113,7 @@ public class DepthSelector extends BaseExtendSelector {
      */
     public void verifySettings() {
         if (min < 0 && max < 0) {
-            setError("You must set at least one of the min or the "
-                    + "max levels.");
+            setError("You must set at least one of the min or the max levels.");
         }
         if (max < min && max > -1) {
             setError("The maximum depth is lower than the minimum.");
@@ -150,19 +141,17 @@ public class DepthSelector extends BaseExtendSelector {
         // If you felt daring, you could cache the basedir absolute path
         String absBase = basedir.getAbsolutePath();
         String absFile = file.getAbsolutePath();
-        StringTokenizer tokBase = new StringTokenizer(absBase,
-                File.separator);
-        StringTokenizer tokFile = new StringTokenizer(absFile,
-                File.separator);
+        StringTokenizer tokBase = new StringTokenizer(absBase, File.separator);
+        StringTokenizer tokFile = new StringTokenizer(absFile, File.separator);
         while (tokFile.hasMoreTokens()) {
             String filetoken = tokFile.nextToken();
             if (tokBase.hasMoreTokens()) {
                 String basetoken = tokBase.nextToken();
                 // Sanity check. Ditch it if you want faster performance
                 if (!basetoken.equals(filetoken)) {
-                    throw new BuildException("File " + filename
-                            + " does not appear within " + absBase
-                            + "directory");
+                    throw new BuildException(
+                        "File %s does not appear within %s directory", filename,
+                        absBase);
                 }
             } else {
                 depth += 1;
@@ -172,14 +161,12 @@ public class DepthSelector extends BaseExtendSelector {
             }
         }
         if (tokBase.hasMoreTokens()) {
-            throw new BuildException("File " + filename
-                + " is outside of " + absBase + "directory tree");
+            throw new BuildException("File %s is outside of %s directory tree",
+                filename, absBase);
         }
         if (min > -1 && depth < min) {
             return false;
         }
         return true;
     }
-
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java b/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java
index c701fb8..90fa9e0 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java
@@ -54,7 +54,6 @@ public class DifferentSelector extends MappingSelector {
     private boolean ignoreFileTimes = true;
     private boolean ignoreContents = false;
 
-
     /**
      * This flag tells the selector to ignore file times in the comparison
      * @param ignoreFileTimes if true ignore file times
@@ -62,6 +61,7 @@ public class DifferentSelector extends MappingSelector {
     public void setIgnoreFileTimes(boolean ignoreFileTimes) {
         this.ignoreFileTimes = ignoreFileTimes;
     }
+
     /**
      * This flag tells the selector to ignore contents
      * @param ignoreContents if true ignore contents
@@ -70,6 +70,7 @@ public class DifferentSelector extends MappingSelector {
     public void setIgnoreContents(boolean ignoreContents) {
         this.ignoreContents = ignoreContents;
     }
+
     /**
      * this test is our selection test that compared the file with the destfile
      * @param srcfile the source file
@@ -99,16 +100,15 @@ public class DifferentSelector extends MappingSelector {
                 return true;
             }
         }
-        if (!ignoreContents) {
-            //here do a bulk comparison
-            try {
-                return !FILE_UTILS.contentEquals(srcfile, destfile);
-            } catch (IOException e) {
-                throw new BuildException("while comparing " + srcfile + " and "
-                        + destfile, e);
-            }
-        } else {
+        if (ignoreContents) {
             return false;
         }
+        //here do a bulk comparison
+        try {
+            return !FILE_UTILS.contentEquals(srcfile, destfile);
+        } catch (IOException e) {
+            throw new BuildException(
+                "while comparing " + srcfile + " and " + destfile, e);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java b/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java
index 891b795..214b98f 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java
@@ -18,12 +18,8 @@
 
 package org.apache.tools.ant.types.selectors;
 
-import java.nio.file.Files;
 import java.io.File;
-
-import org.apache.tools.ant.types.Resource;
-import org.apache.tools.ant.types.resources.FileProvider;
-import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
+import java.nio.file.Files;
 
 /**
  * A selector that selects executable files.
@@ -35,17 +31,10 @@ import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
  *
  * @since Ant 1.10.0
  */
-public class ExecutableSelector implements FileSelector, ResourceSelector {
+public class ExecutableSelector implements FileSelector {
 
     public boolean isSelected(File basedir, String filename, File file) {
         return file != null && Files.isExecutable(file.toPath());
     }
 
-    public boolean isSelected(Resource r) {
-        FileProvider fp = r.as(FileProvider.class);
-        if (fp != null) {
-            return isSelected(null, null, fp.getFile());
-        }
-        return false;
-    }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java b/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
index af8c920..c9ee75d 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
@@ -19,7 +19,9 @@
 package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.BuildException;
@@ -37,16 +39,11 @@ public class ExtendSelector extends BaseSelector {
 
     private String classname = null;
     private FileSelector dynselector = null;
-    private Vector<Parameter> paramVec = new Vector<Parameter>();
+    private List<Parameter> parameters =
+        Collections.synchronizedList(new ArrayList<>());
     private Path classpath = null;
 
     /**
-     * Default constructor.
-     */
-    public ExtendSelector() {
-    }
-
-    /**
      * Sets the classname of the custom selector.
      *
      * @param classname is the class which implements this selector
@@ -61,7 +58,7 @@ public class ExtendSelector extends BaseSelector {
     public void selectorCreate() {
         if (classname != null && classname.length() > 0) {
             try {
-                Class<?> c = null;
+                Class<?> c;
                 if (classpath == null) {
                     c = Class.forName(classname);
                 } else {
@@ -96,10 +93,9 @@ public class ExtendSelector extends BaseSelector {
      * @param p The new Parameter object
      */
     public void addParam(Parameter p) {
-        paramVec.addElement(p);
+        parameters.add(p);
     }
 
-
     /**
      * Set the classpath to load the classname specified using an attribute.
      * @param classpath the classpath to use
@@ -166,13 +162,12 @@ public class ExtendSelector extends BaseSelector {
         } else if (dynselector == null) {
             setError("Internal Error: The custom selector was not created");
         } else if (!(dynselector instanceof ExtendFileSelector)
-                    && (paramVec.size() > 0)) {
-            setError("Cannot set parameters on custom selector that does not "
-                    + "implement ExtendFileSelector");
+                    && !parameters.isEmpty()) {
+            setError(
+                "Cannot set parameters on custom selector that does not implement ExtendFileSelector");
         }
     }
 
-
     /**
      * Allows the custom selector to choose whether to select a file. This
      * is also where the Parameters are passed to the custom selector,
@@ -188,14 +183,12 @@ public class ExtendSelector extends BaseSelector {
     public boolean isSelected(File basedir, String filename, File file)
             throws BuildException {
         validate();
-        if (paramVec.size() > 0 && dynselector instanceof ExtendFileSelector) {
-            Parameter[] paramArray = new Parameter[paramVec.size()];
-            paramVec.copyInto(paramArray);
+        if (!parameters.isEmpty() && dynselector instanceof ExtendFileSelector) {
             // We know that dynselector must be non-null if no error message
-            ((ExtendFileSelector) dynselector).setParameters(paramArray);
+            ((ExtendFileSelector) dynselector).setParameters(
+                parameters.toArray(new Parameter[parameters.size()]));
         }
         return dynselector.isSelected(basedir, filename, file);
     }
 
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/FileSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/FileSelector.java b/src/main/org/apache/tools/ant/types/selectors/FileSelector.java
index 614a970..984db23 100644
--- a/src/main/org/apache/tools/ant/types/selectors/FileSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/FileSelector.java
@@ -21,13 +21,16 @@ package org.apache.tools.ant.types.selectors;
 import java.io.File;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileProvider;
+import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
 
 /**
  * This is the interface to be used by all selectors.
  *
  * @since 1.5
  */
-public interface FileSelector {
+public interface FileSelector extends ResourceSelector {
 
     /**
      * Method that each selector will implement to create their
@@ -44,5 +47,15 @@ public interface FileSelector {
     boolean isSelected(File basedir, String filename, File file)
             throws BuildException;
 
+    /**
+     * Implement a basic {@link Resource} selection that delegates to this
+     * {@link FileSelector}.
+     * @param r
+     * @return whether the resource is selected
+     */
+    default boolean isSelected(Resource r) {
+        return r.asOptional(FileProvider.class).map(FileProvider::getFile)
+                .map(f -> isSelected(null, null, f)).orElse(false);
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java b/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
index 1b998f9..21cc901 100644
--- a/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
@@ -32,12 +32,6 @@ import org.apache.tools.ant.util.regexp.RegexpUtil;
  * @since 1.5
  */
 public class FilenameSelector extends BaseExtendSelector {
-
-    private String pattern = null;
-    private String regex = null;
-    private boolean casesensitive = true;
-
-    private boolean negated = false;
     /** Used for parameterized custom selector */
     public static final String NAME_KEY = "name";
     /** Used for parameterized custom selector */
@@ -47,18 +41,17 @@ public class FilenameSelector extends BaseExtendSelector {
     /** Used for parameterized custom selector */
     public static final String REGEX_KEY = "regex";
 
+    private String pattern = null;
+    private String regex = null;
+    private boolean casesensitive = true;
+
+    private boolean negated = false;
+
     // caches for performance reasons
     private RegularExpression reg;
     private Regexp expression;
 
     /**
-     * Creates a new <code>FilenameSelector</code> instance.
-     *
-     */
-    public FilenameSelector() {
-    }
-
-    /**
      * @return a string describing this object
      */
     public String toString() {
@@ -129,7 +122,7 @@ public class FilenameSelector extends BaseExtendSelector {
      *
      * @param parameters the complete set of parameters for this selector
      */
-    public void setParameters(Parameter[] parameters) {
+    public void setParameters(Parameter... parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
             for (int i = 0; i < parameters.length; i++) {
@@ -178,18 +171,16 @@ public class FilenameSelector extends BaseExtendSelector {
     public boolean isSelected(File basedir, String filename, File file) {
         validate();
         if (pattern != null) {
-            return (SelectorUtils.matchPath(pattern, filename,
-                                            casesensitive) == !(negated));
-        } else {
-            if (reg == null) {
-                reg = new RegularExpression();
-                reg.setPattern(regex);
-                expression = reg.getRegexp(getProject());
-            }
-            int options = RegexpUtil.asOptions(casesensitive);
-            return expression.matches(filename, options) == !negated;
+            return SelectorUtils.matchPath(pattern, filename,
+                casesensitive) == !(negated);
         }
+        if (reg == null) {
+            reg = new RegularExpression();
+            reg.setPattern(regex);
+            expression = reg.getRegexp(getProject());
+        }
+        int options = RegexpUtil.asOptions(casesensitive);
+        return expression.matches(filename, options) == !negated;
     }
 
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java b/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
index 842258f..444d1c1 100644
--- a/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
@@ -37,12 +37,6 @@ public class MajoritySelector extends BaseSelectorContainer {
     private boolean allowtie = true;
 
     /**
-     * Default constructor.
-     */
-    public MajoritySelector() {
-    }
-
-    /**
      * @return a string describing this object
      */
     public String toString() {
@@ -93,7 +87,8 @@ public class MajoritySelector extends BaseSelectorContainer {
         }
         if (yesvotes > novotes) {
             return true;
-        } else if (novotes > yesvotes) {
+        }
+        if (novotes > yesvotes) {
             return false;
         }
         // At this point, we know we have a tie.

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java b/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java
index 1a27494..3d94937 100644
--- a/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java
@@ -40,20 +40,11 @@ public abstract class MappingSelector extends BaseSelector {
     protected File targetdir = null;
     protected Mapper mapperElement = null;
     protected FileNameMapper map = null;
-    protected int granularity = 0;
+    protected int granularity = (int) FILE_UTILS.getFileTimestampGranularity();
 
     // CheckStyle:VisibilityModifier ON
 
     /**
-     * Creates a new <code>MappingSelector</code> instance.
-     *
-     */
-    public MappingSelector() {
-        granularity = (int) FILE_UTILS.getFileTimestampGranularity();
-    }
-
-
-    /**
      * The name of the file or directory which is checked for out-of-date
      * files.
      *
@@ -140,8 +131,7 @@ public abstract class MappingSelector extends BaseSelector {
         String destname = destfiles[0];
         File destfile = FILE_UTILS.resolveFile(targetdir, destname);
 
-        boolean selected = selectionTest(file, destfile);
-        return selected;
+        return selectionTest(file, destfile);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java b/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java
index 536b5b5..5691514 100644
--- a/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
-import java.util.Enumeration;
+import java.util.stream.Stream;
 
 /**
  * This selector has a collection of other selectors. All of those selectors
@@ -31,12 +31,6 @@ import java.util.Enumeration;
 public class NoneSelector extends BaseSelectorContainer {
 
     /**
-     * Default constructor.
-     */
-    public NoneSelector() {
-    }
-
-    /**
      * @return a string representation of the selector
      */
     public String toString() {
@@ -61,15 +55,8 @@ public class NoneSelector extends BaseSelectorContainer {
      */
     public boolean isSelected(File basedir, String filename, File file) {
         validate();
-        Enumeration<FileSelector> e = selectorElements();
-
-        while (e.hasMoreElements()) {
-            if (e.nextElement().isSelected(basedir, filename, file)) {
-                return false;
-            }
-        }
-        return true;
+        return Stream.of(getSelectors(getProject()))
+            .noneMatch(s -> s.isSelected(basedir, filename, file));
     }
 
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/NotSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/NotSelector.java b/src/main/org/apache/tools/ant/types/selectors/NotSelector.java
index 71c3940..5ce4079 100644
--- a/src/main/org/apache/tools/ant/types/selectors/NotSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/NotSelector.java
@@ -64,8 +64,8 @@ public class NotSelector extends NoneSelector {
      */
     public void verifySettings() {
         if (selectorCount() != 1) {
-            setError("One and only one selector is allowed within the "
-                + "<not> tag");
+            setError(
+                "One and only one selector is allowed within the <not> tag");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/OrSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/OrSelector.java b/src/main/org/apache/tools/ant/types/selectors/OrSelector.java
index b077744..f98a327 100644
--- a/src/main/org/apache/tools/ant/types/selectors/OrSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/OrSelector.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
-import java.util.Enumeration;
+import java.util.stream.Stream;
 
 /**
  * This selector has a collection of other selectors, any of which have to
@@ -30,12 +30,6 @@ import java.util.Enumeration;
 public class OrSelector extends BaseSelectorContainer {
 
     /**
-     * Default constructor.
-     */
-    public OrSelector() {
-    }
-
-    /**
      * @return a string representation of the selector
      */
     public String toString() {
@@ -60,15 +54,8 @@ public class OrSelector extends BaseSelectorContainer {
      */
     public boolean isSelected(File basedir, String filename, File file) {
         validate();
-        Enumeration<FileSelector> e = selectorElements();
-
-        // First, check that all elements are correctly configured
-        while (e.hasMoreElements()) {
-            if (e.nextElement().isSelected(basedir, filename, file)) {
-                return true;
-            }
-        }
-        return false;
+        return Stream.of(getSelectors(getProject()))
+            .anyMatch(s -> s.isSelected(basedir, filename, file));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java b/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
index 32aaa8d..88f3b08 100644
--- a/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
@@ -18,15 +18,12 @@
 
 package org.apache.tools.ant.types.selectors;
 
-import java.nio.file.Files;
-import java.nio.file.attribute.UserPrincipal;
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.attribute.UserPrincipal;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Resource;
-import org.apache.tools.ant.types.resources.FileProvider;
-import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
 
 /**
  * A selector that selects files based on their owner.
@@ -39,7 +36,7 @@ import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
  *
  * @since Ant 1.10.0
  */
-public class OwnedBySelector implements FileSelector, ResourceSelector {
+public class OwnedBySelector implements FileSelector {
 
     private String owner;
 
@@ -67,12 +64,4 @@ public class OwnedBySelector implements FileSelector, ResourceSelector {
         return false;
     }
 
-    @Override
-    public boolean isSelected(Resource r) {
-        FileProvider fp = r.as(FileProvider.class);
-        if (fp != null) {
-            return isSelected(null, null, fp.getFile());
-        }
-        return false;
-    }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java b/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
index 1c0c000..1b39d22 100644
--- a/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
@@ -42,13 +42,6 @@ public class PresentSelector extends BaseSelector {
     private boolean destmustexist = true;
 
     /**
-     * Creates a new <code>PresentSelector</code> instance.
-     *
-     */
-    public PresentSelector() {
-    }
-
-    /**
      * @return a string describing this object
      */
     @Override

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java b/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java
index b0c527c..cd03ebf 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java
@@ -20,10 +20,6 @@ package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
 
-import org.apache.tools.ant.types.Resource;
-import org.apache.tools.ant.types.resources.FileProvider;
-import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
-
 /**
  * A selector that selects readable files.
  *
@@ -33,17 +29,11 @@ import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
  *
  * @since Ant 1.8.0
  */
-public class ReadableSelector implements FileSelector, ResourceSelector {
+public class ReadableSelector implements FileSelector {
 
+    @Override
     public boolean isSelected(File basedir, String filename, File file) {
         return file != null && file.canRead();
     }
 
-    public boolean isSelected(Resource r) {
-        FileProvider fp = r.as(FileProvider.class);
-        if (fp != null) {
-            return isSelected(null, null, fp.getFile());
-        }
-        return false;
-    }
 }
\ No newline at end of file


Mime
View raw message