ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaiki...@apache.org
Subject [4/7] ant-ivy git commit: Add generics and Java 7 syntax to core
Date Tue, 18 Jul 2017 05:02:21 GMT
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/IvyNode.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/IvyNode.java b/src/java/org/apache/ivy/core/resolve/IvyNode.java
index a26146f..47bc3e1 100644
--- a/src/java/org/apache/ivy/core/resolve/IvyNode.java
+++ b/src/java/org/apache/ivy/core/resolve/IvyNode.java
@@ -82,7 +82,7 @@ public class IvyNode implements Comparable<IvyNode> {
     private ModuleRevisionId id;
 
     // set only when node has been built or updated from a DependencyDescriptor
-    private Map<IvyNode, DependencyDescriptor> dds = new HashMap<IvyNode, DependencyDescriptor>();
+    private Map<IvyNode, DependencyDescriptor> dds = new HashMap<>();
 
     // Set when data has been loaded only, or when constructed from a module descriptor
     private ModuleDescriptor md;
@@ -96,18 +96,18 @@ public class IvyNode implements Comparable<IvyNode> {
 
     private boolean searched = false;
 
-    private Collection<String> confsToFetch = new HashSet<String>();
+    private Collection<String> confsToFetch = new HashSet<>();
 
-    private Collection<String> fetchedConfigurations = new HashSet<String>();
+    private Collection<String> fetchedConfigurations = new HashSet<>();
 
-    private Collection<String> loadedRootModuleConfs = new HashSet<String>();
+    private Collection<String> loadedRootModuleConfs = new HashSet<>();
 
     // //////// USAGE DATA
 
     private IvyNodeUsage usage = new IvyNodeUsage(this);
 
     // usage information merged from evicted nodes this node is "replacing"
-    private Map<ModuleRevisionId, IvyNodeUsage> mergedUsages = new LinkedHashMap<ModuleRevisionId, IvyNodeUsage>();
+    private Map<ModuleRevisionId, IvyNodeUsage> mergedUsages = new LinkedHashMap<>();
 
     public IvyNode(ResolveData data, IvyNode parent, DependencyDescriptor dd) {
         id = dd.getDependencyRevisionId();
@@ -310,9 +310,9 @@ public class IvyNode implements Comparable<IvyNode> {
                 confs = md.getPublicConfigurationsNames();
             }
         }
-        Collection<IvyNode> deps = new HashSet<IvyNode>();
-        for (int i = 0; i < confs.length; i++) {
-            deps.addAll(getDependencies(rootModuleConf, confs[i], requestedConf));
+        Collection<IvyNode> deps = new HashSet<>();
+        for (String conf : confs) {
+            deps.addAll(getDependencies(rootModuleConf, conf, requestedConf));
         }
         return deps;
     }
@@ -336,10 +336,9 @@ public class IvyNode implements Comparable<IvyNode> {
             throw new IllegalStateException(
                     "impossible to get dependencies when data has not been loaded");
         }
-        DependencyDescriptor[] dds = md.getDependencies();
         // it's important to respect order => LinkedHashMap
-        Map<ModuleRevisionId, IvyNode> dependencies = new LinkedHashMap<ModuleRevisionId, IvyNode>();
-        for (DependencyDescriptor dependencyDescriptor : dds) {
+        Map<ModuleRevisionId, IvyNode> dependencies = new LinkedHashMap<>();
+        for (DependencyDescriptor dependencyDescriptor : md.getDependencies()) {
             DependencyDescriptor dd = data.mediate(dependencyDescriptor);
             String[] dependencyConfigurations = dd.getDependencyConfigurations(conf, requestedConf);
             if (dependencyConfigurations.length == 0) {
@@ -423,7 +422,7 @@ public class IvyNode implements Comparable<IvyNode> {
                 // a circular dependency, we cannot be conclusive here
                 return null;
             }
-            return Boolean.valueOf(c.doesCallersExclude(rootModuleConf, artifact, callersStack));
+            return c.doesCallersExclude(rootModuleConf, artifact, callersStack);
         }
         return Boolean.FALSE;
     }
@@ -513,7 +512,7 @@ public class IvyNode implements Comparable<IvyNode> {
             // there are exclusions in the configuration
             List<String> exclusions = Arrays.asList(conf.substring(2).split("\\!"));
 
-            List<String> ret = new ArrayList<String>(Arrays.asList(getDescriptor()
+            List<String> ret = new ArrayList<>(Arrays.asList(getDescriptor()
                     .getPublicConfigurationsNames()));
             ret.removeAll(exclusions);
 
@@ -530,7 +529,7 @@ public class IvyNode implements Comparable<IvyNode> {
      * @return array of configuration names
      */
     public String[] getRequiredConfigurations(IvyNode in, String inConf) {
-        Collection<String> req = new LinkedHashSet<String>();
+        Collection<String> req = new LinkedHashSet<>();
         addAllIfNotNull(req, usage.getRequiredConfigurations(in, inConf));
         for (IvyNodeUsage usage : mergedUsages.values()) {
             addAllIfNotNull(req, usage.getRequiredConfigurations(in, inConf));
@@ -550,7 +549,7 @@ public class IvyNode implements Comparable<IvyNode> {
      * @return array of configuration names
      */
     public String[] getRequiredConfigurations() {
-        Collection<String> required = new ArrayList<String>(confsToFetch.size()
+        Collection<String> required = new ArrayList<>(confsToFetch.size()
                 + fetchedConfigurations.size());
         required.addAll(fetchedConfigurations);
         required.addAll(confsToFetch);
@@ -578,7 +577,7 @@ public class IvyNode implements Comparable<IvyNode> {
      * @return array of configuration names
      */
     public String[] getConfigurations(String rootModuleConf) {
-        Set<String> depConfs = new LinkedHashSet<String>();
+        Set<String> depConfs = new LinkedHashSet<>();
         addAllIfNotNull(depConfs, usage.getConfigurations(rootModuleConf));
         for (IvyNodeUsage usage : mergedUsages.values()) {
             addAllIfNotNull(depConfs, usage.getConfigurations(rootModuleConf));
@@ -598,10 +597,9 @@ public class IvyNode implements Comparable<IvyNode> {
             // remove all given dependency configurations to the set + extended ones
             Configuration c = md.getConfiguration(conf);
             if (conf != null) {
-                String[] exts = c.getExtends();
-                for (int i = 0; i < exts.length; i++) {
-                    discardConf(rootModuleConf, exts[i]); // recursive remove of extended
-                    // configurations
+                // recursive remove of extended configurations
+                for (String ext : c.getExtends()) {
+                    discardConf(rootModuleConf, ext);
                 }
                 depConfs.remove(c.getName());
             } else {
@@ -643,7 +641,7 @@ public class IvyNode implements Comparable<IvyNode> {
      * @return {@link Set} of configuration names
      */
     public Set<String> getRootModuleConfigurationsSet() {
-        Set<String> confs = new LinkedHashSet<String>();
+        Set<String> confs = new LinkedHashSet<>();
         addAllIfNotNull(confs, usage.getRootModuleConfigurations());
         for (IvyNodeUsage usage : mergedUsages.values()) {
             addAllIfNotNull(confs, usage.getRootModuleConfigurations());
@@ -672,7 +670,7 @@ public class IvyNode implements Comparable<IvyNode> {
         if (conf.charAt(0) == '*') {
             return resolveSpecialConfigurations(new String[] {conf});
         }
-        if (conf.indexOf(',') != -1) {
+        if (conf.contains(",")) {
             String[] confs = conf.split(",");
             for (int i = 0; i < confs.length; i++) {
                 confs[i] = confs[i].trim();
@@ -749,7 +747,7 @@ public class IvyNode implements Comparable<IvyNode> {
     }
 
     private Collection<IvyNodeUsage> getAllUsages() {
-        Collection<IvyNodeUsage> usages = new ArrayList<IvyNodeUsage>();
+        Collection<IvyNodeUsage> usages = new ArrayList<>();
         usages.add(usage);
         usages.addAll(mergedUsages.values());
         return usages;
@@ -761,7 +759,7 @@ public class IvyNode implements Comparable<IvyNode> {
      * @return array of {@link Artifact}s
      */
     public Artifact[] getAllArtifacts() {
-        Set<Artifact> ret = new HashSet<Artifact>();
+        Set<Artifact> ret = new HashSet<>();
         for (String rootModuleConf : getRootModuleConfigurationsSet()) {
             ret.addAll(Arrays.asList(getArtifacts(rootModuleConf)));
         }
@@ -776,7 +774,7 @@ public class IvyNode implements Comparable<IvyNode> {
      * @return array of {@link Artifact}s
      */
     public Artifact[] getSelectedArtifacts(Filter<Artifact> artifactFilter) {
-        Collection<Artifact> ret = new HashSet<Artifact>();
+        Collection<Artifact> ret = new HashSet<>();
         for (String rootModuleConf : getRootModuleConfigurationsSet()) {
             if (!isEvicted(rootModuleConf) && !isBlacklisted(rootModuleConf)) {
                 ret.addAll(Arrays.asList(getArtifacts(rootModuleConf)));
@@ -807,7 +805,7 @@ public class IvyNode implements Comparable<IvyNode> {
                             + this);
         }
 
-        Set<Artifact> artifacts = new HashSet<Artifact>(); // the set we fill before returning
+        Set<Artifact> artifacts = new HashSet<>(); // the set we fill before returning
 
         // we check if we have dependencyArtifacts includes description for this rootModuleConf
         Set<DependencyArtifactDescriptor> dependencyArtifacts = usage
@@ -817,7 +815,7 @@ public class IvyNode implements Comparable<IvyNode> {
             addArtifactsFromOwnUsage(artifacts, dependencyArtifacts);
             addArtifactsFromMergedUsage(rootModuleConf, artifacts);
         } else {
-            Set<IncludeRule> includes = new LinkedHashSet<IncludeRule>();
+            Set<IncludeRule> includes = new LinkedHashSet<>();
             addAllIfNotNull(includes, usage.getDependencyIncludesSet(rootModuleConf));
             for (IvyNodeUsage usage : mergedUsages.values()) {
                 addAllIfNotNull(includes, usage.getDependencyIncludesSet(rootModuleConf));
@@ -826,19 +824,17 @@ public class IvyNode implements Comparable<IvyNode> {
             if ((dependencyArtifacts == null || dependencyArtifacts.isEmpty())
                     && (includes.isEmpty())) {
                 // no artifacts / includes: we get all artifacts as defined by the descriptor
-                for (int i = 0; i < confs.length; i++) {
-                    artifacts.addAll(Arrays.asList(md.getArtifacts(confs[i])));
+                for (String conf : confs) {
+                    artifacts.addAll(Arrays.asList(md.getArtifacts(conf)));
                 }
             } else {
-                // we have to get only artifacts listed as "includes"
-
+                // we have to get only artifacts listed as "includes";
                 // first we get all artifacts as defined by the module descriptor
                 // and classify them by artifact id
-                Map<ArtifactId, Artifact> allArtifacts = new HashMap<ArtifactId, Artifact>();
-                for (int i = 0; i < confs.length; i++) {
-                    Artifact[] arts = md.getArtifacts(confs[i]);
-                    for (int j = 0; j < arts.length; j++) {
-                        allArtifacts.put(arts[j].getId().getArtifactId(), arts[j]);
+                Map<ArtifactId, Artifact> allArtifacts = new HashMap<>();
+                for (String conf : confs) {
+                    for (Artifact art : md.getArtifacts(conf)) {
+                        allArtifacts.put(art.getId().getArtifactId(), art);
                     }
                 }
 
@@ -849,7 +845,8 @@ public class IvyNode implements Comparable<IvyNode> {
                 addArtifactsFromMergedUsage(rootModuleConf, artifacts);
 
                 // and now we filter according to include rules
-                for (Iterator<IncludeRule> it = includes.iterator(); it.hasNext();) {
+                Iterator<IncludeRule> it = includes.iterator();
+                while (it.hasNext()) {
                     IncludeRule dad = it.next();
                     Collection<Artifact> arts = findArtifactsMatching(dad, allArtifacts);
                     if (arts.isEmpty()) {
@@ -866,8 +863,9 @@ public class IvyNode implements Comparable<IvyNode> {
             }
         }
 
-        // now excludes artifacts that aren't accepted by any caller
-        for (Iterator<Artifact> iter = artifacts.iterator(); iter.hasNext();) {
+        // now exclude artifacts that aren't accepted by any caller
+        Iterator<Artifact> iter = artifacts.iterator();
+        while (iter.hasNext()) {
             Artifact artifact = iter.next();
             boolean excluded = callers.doesCallersExclude(rootModuleConf, artifact);
             if (excluded) {
@@ -892,7 +890,7 @@ public class IvyNode implements Comparable<IvyNode> {
                     .getDependencyArtifactsSet(rootModuleConf);
             if (mergedDependencyArtifacts != null) {
                 for (DependencyArtifactDescriptor dad : mergedDependencyArtifacts) {
-                    Map<String, String> extraAttributes = new HashMap<String, String>(
+                    Map<String, String> extraAttributes = new HashMap<>(
                             dad.getQualifiedExtraAttributes());
                     MDArtifact artifact = new MDArtifact(md, dad.getName(), dad.getType(),
                             dad.getExt(), dad.getUrl(), extraAttributes);
@@ -910,7 +908,7 @@ public class IvyNode implements Comparable<IvyNode> {
 
     private static Collection<Artifact> findArtifactsMatching(IncludeRule rule,
             Map<ArtifactId, Artifact> allArtifacts) {
-        Collection<Artifact> ret = new ArrayList<Artifact>();
+        Collection<Artifact> ret = new ArrayList<>();
         for (Entry<ArtifactId, Artifact> entry : allArtifacts.entrySet()) {
             if (MatcherHelper.matches(rule.getMatcher(), rule.getId(), entry.getKey())) {
                 ret.add(entry.getValue());
@@ -1243,7 +1241,7 @@ public class IvyNode implements Comparable<IvyNode> {
             Message.verbose("BLACKLISTING " + bdata);
         }
 
-        Stack<IvyNode> callerStack = new Stack<IvyNode>();
+        Stack<IvyNode> callerStack = new Stack<>();
         callerStack.push(this);
         clearEvictionDataInAllCallers(bdata.getRootModuleConf(), callerStack);
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java b/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
index f9c6d57..558565b 100644
--- a/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
+++ b/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
@@ -39,7 +39,7 @@ public class IvyNodeCallers {
         private ModuleRevisionId mrid;
 
         // callerConf -> dependencyConfs
-        private Map<String, String[]> confs = new HashMap<String, String[]>();
+        private Map<String, String[]> confs = new HashMap<>();
 
         private DependencyDescriptor dd;
 
@@ -61,8 +61,8 @@ public class IvyNodeCallers {
             if (conf != null) {
                 String[] confExtends = conf.getExtends();
                 if (confExtends != null) {
-                    for (int i = 0; i < confExtends.length; i++) {
-                        addConfiguration(confExtends[i], dependencyConfs);
+                    for (String confExtend : confExtends) {
+                        addConfiguration(confExtend, dependencyConfs);
                     }
                 }
             }
@@ -71,7 +71,7 @@ public class IvyNodeCallers {
         private void updateConfs(String callerConf, String[] dependencyConfs) {
             String[] prevDepConfs = confs.get(callerConf);
             if (prevDepConfs != null) {
-                Set<String> newDepConfs = new HashSet<String>(Arrays.asList(prevDepConfs));
+                Set<String> newDepConfs = new HashSet<>(Arrays.asList(prevDepConfs));
                 newDepConfs.addAll(Arrays.asList(dependencyConfs));
                 confs.put(callerConf, newDepConfs.toArray(new String[newDepConfs.size()]));
             } else {
@@ -137,12 +137,12 @@ public class IvyNodeCallers {
     }
 
     // key in second map is used to easily get a caller by its mrid
-    private Map<String, Map<ModuleRevisionId, Caller>> callersByRootConf = new HashMap<String, Map<ModuleRevisionId, Caller>>();
+    private Map<String, Map<ModuleRevisionId, Caller>> callersByRootConf = new HashMap<>();
 
     // this map contains all the module ids calling this one (including transitively) as keys.
     // the mapped nodes (values) correspond to a direct caller from which the transitive caller
     // comes
-    private Map<ModuleId, IvyNode> allCallers = new HashMap<ModuleId, IvyNode>();
+    private Map<ModuleId, IvyNode> allCallers = new HashMap<>();
 
     private IvyNode node;
 
@@ -170,7 +170,7 @@ public class IvyNodeCallers {
         }
         Map<ModuleRevisionId, Caller> callers = callersByRootConf.get(rootModuleConf);
         if (callers == null) {
-            callers = new HashMap<ModuleRevisionId, Caller>();
+            callers = new HashMap<>();
             callersByRootConf.put(rootModuleConf, callers);
         }
         Caller caller = callers.get(mrid);
@@ -204,7 +204,7 @@ public class IvyNodeCallers {
     }
 
     public Caller[] getAllCallers() {
-        Set<Caller> all = new HashSet<Caller>();
+        Set<Caller> all = new HashSet<>();
         for (Map<ModuleRevisionId, Caller> callers : callersByRootConf.values()) {
             all.addAll(callers.values());
         }
@@ -212,7 +212,7 @@ public class IvyNodeCallers {
     }
 
     public Caller[] getAllRealCallers() {
-        Set<Caller> all = new HashSet<Caller>();
+        Set<Caller> all = new HashSet<>();
         for (Map<ModuleRevisionId, Caller> callers : callersByRootConf.values()) {
             for (Caller c : callers.values()) {
                 if (c.isRealCaller()) {
@@ -232,7 +232,7 @@ public class IvyNodeCallers {
         if (nodecallers != null) {
             Map<ModuleRevisionId, Caller> thiscallers = callersByRootConf.get(rootModuleConf);
             if (thiscallers == null) {
-                thiscallers = new HashMap<ModuleRevisionId, Caller>();
+                thiscallers = new HashMap<>();
                 callersByRootConf.put(rootModuleConf, thiscallers);
             }
             for (Caller caller : nodecallers.values()) {
@@ -270,14 +270,14 @@ public class IvyNodeCallers {
                 return false;
             }
             boolean allInconclusive = true;
-            for (int i = 0; i < callers.length; i++) {
-                if (!callers[i].canExclude()) {
+            for (Caller caller : callers) {
+                if (!caller.canExclude()) {
                     return false;
                 }
-                ModuleDescriptor md = callers[i].getModuleDescriptor();
+                ModuleDescriptor md = caller.getModuleDescriptor();
                 Boolean doesExclude = node.doesExclude(md, rootModuleConf,
-                    callers[i].getCallerConfigurations(), callers[i].getDependencyDescriptor(),
-                    artifact, callersStack);
+                        caller.getCallerConfigurations(), caller.getDependencyDescriptor(),
+                        artifact, callersStack);
                 if (doesExclude != null) {
                     if (!doesExclude) {
                         return false;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java b/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
index 3524f21..abd135c 100644
--- a/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
+++ b/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
@@ -157,7 +157,9 @@ public class IvyNodeEviction {
 
         @Override
         public boolean equals(Object obj) {
-            return obj instanceof ModuleIdConf && getModuleId().equals(((ModuleIdConf) obj).getModuleId()) && getConf().equals(((ModuleIdConf) obj).getConf());
+            return obj instanceof ModuleIdConf
+                    && getModuleId().equals(((ModuleIdConf) obj).getModuleId())
+                    && getConf().equals(((ModuleIdConf) obj).getConf());
         }
 
         @Override
@@ -174,20 +176,20 @@ public class IvyNodeEviction {
     private IvyNode node;
 
     // map indicating for each dependency which node has been selected
-    private Map<ModuleIdConf, Set<IvyNode>> selectedDeps = new HashMap<ModuleIdConf, Set<IvyNode>>();
+    private Map<ModuleIdConf, Set<IvyNode>> selectedDeps = new HashMap<>();
 
     // map indicating for each dependency which nodes are in pending conflict (conflict detected but
     // not yet resolved)
-    private Map<ModuleIdConf, Set<IvyNode>> pendingConflicts = new HashMap<ModuleIdConf, Set<IvyNode>>();
+    private Map<ModuleIdConf, Set<IvyNode>> pendingConflicts = new HashMap<>();
 
     // map indicating for each dependency which node has been evicted
-    private Map<ModuleIdConf, Set<IvyNode>> evictedDeps = new HashMap<ModuleIdConf, Set<IvyNode>>();
+    private Map<ModuleIdConf, Set<IvyNode>> evictedDeps = new HashMap<>();
 
     // map indicating for each dependency which revision has been evicted
-    private Map<ModuleIdConf, Collection<ModuleRevisionId>> evictedRevs = new HashMap<ModuleIdConf, Collection<ModuleRevisionId>>();
+    private Map<ModuleIdConf, Collection<ModuleRevisionId>> evictedRevs = new HashMap<>();
 
     // indicates if the node is evicted in each root module conf
-    private Map<String, EvictionData> evicted = new HashMap<String, EvictionData>();
+    private Map<String, EvictionData> evicted = new HashMap<>();
 
     public IvyNodeEviction(IvyNode node) {
         if (node == null) {
@@ -203,7 +205,7 @@ public class IvyNodeEviction {
      */
     public Set<IvyNode> getResolvedNodes(ModuleId mid, String rootModuleConf) {
         Collection<IvyNode> resolved = selectedDeps.get(new ModuleIdConf(mid, rootModuleConf));
-        Set<IvyNode> ret = new HashSet<IvyNode>();
+        Set<IvyNode> ret = new HashSet<>();
         if (resolved != null) {
             for (IvyNode node : resolved) {
                 ret.add(node.getRealNode());
@@ -215,9 +217,9 @@ public class IvyNodeEviction {
     public Collection<ModuleRevisionId> getResolvedRevisions(ModuleId mid, String rootModuleConf) {
         Collection<IvyNode> resolved = selectedDeps.get(new ModuleIdConf(mid, rootModuleConf));
         if (resolved == null) {
-            return new HashSet<ModuleRevisionId>();
+            return new HashSet<>();
         } else {
-            Collection<ModuleRevisionId> resolvedRevs = new HashSet<ModuleRevisionId>();
+            Collection<ModuleRevisionId> resolvedRevs = new HashSet<>();
             for (IvyNode node : resolved) {
                 ModuleRevisionId resolvedId = node.getResolvedId();
                 resolvedRevs.add(node.getId());
@@ -237,12 +239,12 @@ public class IvyNodeEviction {
     public void setResolvedNodes(ModuleId moduleId, String rootModuleConf,
             Collection<IvyNode> resolved) {
         ModuleIdConf moduleIdConf = new ModuleIdConf(moduleId, rootModuleConf);
-        selectedDeps.put(moduleIdConf, new HashSet<IvyNode>(resolved));
+        selectedDeps.put(moduleIdConf, new HashSet<>(resolved));
     }
 
     public Collection<IvyNode> getEvictedNodes(ModuleId mid, String rootModuleConf) {
         Collection<IvyNode> resolved = evictedDeps.get(new ModuleIdConf(mid, rootModuleConf));
-        Set<IvyNode> ret = new HashSet<IvyNode>();
+        Set<IvyNode> ret = new HashSet<>();
         if (resolved != null) {
             for (IvyNode node : resolved) {
                 ret.add(node.getRealNode());
@@ -255,17 +257,17 @@ public class IvyNodeEviction {
         Collection<ModuleRevisionId> evicted = evictedRevs
                 .get(new ModuleIdConf(mid, rootModuleConf));
         if (evicted == null) {
-            return new HashSet<ModuleRevisionId>();
+            return new HashSet<>();
         } else {
-            return new HashSet<ModuleRevisionId>(evicted);
+            return new HashSet<>(evicted);
         }
     }
 
     public void setEvictedNodes(ModuleId moduleId, String rootModuleConf,
             Collection<IvyNode> evicted) {
         ModuleIdConf moduleIdConf = new ModuleIdConf(moduleId, rootModuleConf);
-        evictedDeps.put(moduleIdConf, new HashSet<IvyNode>(evicted));
-        Collection<ModuleRevisionId> evictedRevs = new HashSet<ModuleRevisionId>();
+        evictedDeps.put(moduleIdConf, new HashSet<>(evicted));
+        Collection<ModuleRevisionId> evictedRevs = new HashSet<>();
         for (IvyNode node : evicted) {
             evictedRevs.add(node.getId());
             evictedRevs.add(node.getResolvedId());
@@ -295,9 +297,8 @@ public class IvyNodeEviction {
         if (node.isRoot()) {
             return false;
         }
-        String[] rootModuleConfigurations = node.getRootModuleConfigurations();
-        for (int i = 0; i < rootModuleConfigurations.length; i++) {
-            if (!isEvicted(rootModuleConfigurations[i])) {
+        for (String rootModuleConfiguration : node.getRootModuleConfigurations()) {
+            if (!isEvicted(rootModuleConfiguration)) {
                 return false;
             }
         }
@@ -306,7 +307,8 @@ public class IvyNodeEviction {
 
     private void cleanEvicted() {
         // check if it was evicted by a node that we are now the real node for
-        for (Iterator<String> iter = evicted.keySet().iterator(); iter.hasNext();) {
+        Iterator<String> iter = evicted.keySet().iterator();
+        while (iter.hasNext()) {
             String rootModuleConf = iter.next();
             EvictionData ed = evicted.get(rootModuleConf);
             Collection<IvyNode> sel = ed.getSelected();
@@ -348,7 +350,7 @@ public class IvyNodeEviction {
             Collection<IvyNode> selected = ed.getSelected();
             if (selected != null) {
                 if (allEvictingNodes == null) {
-                    allEvictingNodes = new HashSet<IvyNode>();
+                    allEvictingNodes = new HashSet<>();
                 }
                 allEvictingNodes.addAll(selected);
             }
@@ -362,7 +364,7 @@ public class IvyNodeEviction {
             Collection<IvyNode> selected = ed.getSelected();
             if (selected != null) {
                 if (ret == null) {
-                    ret = new HashSet<String>();
+                    ret = new HashSet<>();
                 }
                 if (selected.size() == 1) {
                     ret.add(selected.iterator().next()
@@ -376,7 +378,7 @@ public class IvyNodeEviction {
     }
 
     public Collection<ConflictManager> getAllEvictingConflictManagers() {
-        Collection<ConflictManager> ret = new HashSet<ConflictManager>();
+        Collection<ConflictManager> ret = new HashSet<>();
         for (EvictionData ed : evicted.values()) {
             ret.add(ed.getConflictManager());
         }
@@ -409,7 +411,7 @@ public class IvyNodeEviction {
 
     public Collection<IvyNode> getPendingConflicts(String rootModuleConf, ModuleId mid) {
         Collection<IvyNode> resolved = pendingConflicts.get(new ModuleIdConf(mid, rootModuleConf));
-        Set<IvyNode> ret = new HashSet<IvyNode>();
+        Set<IvyNode> ret = new HashSet<>();
         if (resolved != null) {
             for (IvyNode node : resolved) {
                 ret.add(node.getRealNode());
@@ -421,7 +423,7 @@ public class IvyNodeEviction {
     public void setPendingConflicts(ModuleId moduleId, String rootModuleConf,
             Collection<IvyNode> conflicts) {
         ModuleIdConf moduleIdConf = new ModuleIdConf(moduleId, rootModuleConf);
-        pendingConflicts.put(moduleIdConf, new HashSet<IvyNode>(conflicts));
+        pendingConflicts.put(moduleIdConf, new HashSet<>(conflicts));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java b/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
index 0399f52..99bdf74 100644
--- a/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
+++ b/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
@@ -123,14 +123,14 @@ public class IvyNodeUsage {
     // used to know which configurations of the dependency are required
     // for each root module configuration
     // rootConfName -> confNames
-    private Map<String, Set<String>> rootModuleConfs = new HashMap<String, Set<String>>();
+    private Map<String, Set<String>> rootModuleConfs = new HashMap<>();
 
-    private Map<NodeConf, Set<String>> requiredConfs = new HashMap<NodeConf, Set<String>>();
+    private Map<NodeConf, Set<String>> requiredConfs = new HashMap<>();
 
-    private Map<String, Set<Depender>> dependers = new HashMap<String, Set<Depender>>();
+    private Map<String, Set<Depender>> dependers = new HashMap<>();
 
     // rootModuleConf -> black list
-    private Map<String, IvyNodeBlacklist> blacklisted = new HashMap<String, IvyNodeBlacklist>();
+    private Map<String, IvyNodeBlacklist> blacklisted = new HashMap<>();
 
     public IvyNodeUsage(IvyNode node) {
         this.node = node;
@@ -141,12 +141,12 @@ public class IvyNodeUsage {
     }
 
     protected void setRequiredConfs(IvyNode parent, String parentConf, Collection<String> confs) {
-        requiredConfs.put(new NodeConf(parent, parentConf), new HashSet<String>(confs));
+        requiredConfs.put(new NodeConf(parent, parentConf), new HashSet<>(confs));
     }
 
     /**
      * Returns the configurations of the dependency required in a given root module configuration.
-     * 
+     *
      * @param rootModuleConf ditto
      * @return Set&lt;String&gt;
      */
@@ -157,7 +157,7 @@ public class IvyNodeUsage {
     protected Set<String> addAndGetConfigurations(String rootModuleConf) {
         Set<String> depConfs = rootModuleConfs.get(rootModuleConf);
         if (depConfs == null) {
-            depConfs = new HashSet<String>();
+            depConfs = new HashSet<>();
             rootModuleConfs.put(rootModuleConf, depConfs);
         }
         return depConfs;
@@ -197,7 +197,7 @@ public class IvyNodeUsage {
             if (toupdate != null) {
                 toupdate.addAll(set);
             } else {
-                to.put(key, new HashSet<V>(set));
+                to.put(key, new HashSet<>(set));
             }
         }
     }
@@ -205,7 +205,7 @@ public class IvyNodeUsage {
     private <K, V> void addObjectsForConf(K rootModuleConf, V objectToAdd, Map<K, Set<V>> map) {
         Set<V> set = map.get(rootModuleConf);
         if (set == null) {
-            set = new HashSet<V>();
+            set = new HashSet<>();
             map.put(rootModuleConf, set);
         }
         set.add(objectToAdd);
@@ -224,7 +224,7 @@ public class IvyNodeUsage {
         if (dependersInConf == null) {
             return null;
         }
-        Set<DependencyArtifactDescriptor> dependencyArtifacts = new HashSet<DependencyArtifactDescriptor>();
+        Set<DependencyArtifactDescriptor> dependencyArtifacts = new HashSet<>();
         for (Depender depender : dependersInConf) {
             DependencyArtifactDescriptor[] dads = depender.dd
                     .getDependencyArtifacts(depender.dependerConf);
@@ -238,7 +238,7 @@ public class IvyNodeUsage {
         if (dependersInConf == null) {
             return null;
         }
-        Set<IncludeRule> dependencyIncludes = new HashSet<IncludeRule>();
+        Set<IncludeRule> dependencyIncludes = new HashSet<>();
         for (Depender depender : dependersInConf) {
             IncludeRule[] rules = depender.dd.getIncludeRules(depender.dependerConf);
             if (rules == null || rules.length == 0) {
@@ -264,10 +264,10 @@ public class IvyNodeUsage {
      * <p>
      * A blacklisted node should be considered as if it doesn't even exist on the repository.
      * </p>
-     * 
+     *
      * @param rootModuleConf
      *            the root module conf for which we'd like to know if the node is blacklisted
-     * 
+     *
      * @return true if this node is blacklisted int he given root module conf, false otherwise
      * @see #blacklist(IvyNodeBlacklist)
      */
@@ -278,7 +278,7 @@ public class IvyNodeUsage {
     /**
      * Returns the blacklist data of this node in the given root module conf, or <code>null</code>
      * if this node is not blacklisted in this root module conf.
-     * 
+     *
      * @param rootModuleConf
      *            the root module configuration to consider
      * @return the blacklist data if any
@@ -294,7 +294,7 @@ public class IvyNodeUsage {
     /**
      * Indicates if at least one depender has a transitive dependency descriptor for the given root
      * module conf.
-     * 
+     *
      * @param rootModuleConf
      *            the root module conf to consider
      * @return <code>true</code> if at least one depender has a transitive dependency descriptor for

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/ResolveData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/ResolveData.java b/src/java/org/apache/ivy/core/resolve/ResolveData.java
index 74221f0..920e97d 100644
--- a/src/java/org/apache/ivy/core/resolve/ResolveData.java
+++ b/src/java/org/apache/ivy/core/resolve/ResolveData.java
@@ -82,7 +82,7 @@ public class ResolveData {
     }
 
     public Collection<IvyNode> getNodes() {
-        Collection<IvyNode> nodes = new ArrayList<IvyNode>();
+        Collection<IvyNode> nodes = new ArrayList<>();
         for (VisitData vdata : visitData.values()) {
             nodes.add(vdata.getNode());
         }
@@ -142,19 +142,7 @@ public class ResolveData {
     }
 
     private static boolean isEqual(Object obj1, Object obj2) {
-        if (obj1 == obj2) {
-            return true;
-        }
-
-        if (obj1 == null) {
-            return obj2 == null;
-        }
-
-        if (obj2 == null) {
-            return obj1 == null;
-        }
-
-        return obj1.equals(obj2);
+        return obj1 == obj2 || obj1 != null && obj2 != null && obj1.equals(obj2);
     }
 
     /**
@@ -256,11 +244,10 @@ public class ResolveData {
     }
 
     void blacklist(IvyNode node) {
-        for (Iterator<Entry<ModuleRevisionId, VisitData>> iter = visitData.entrySet().iterator(); iter
-                .hasNext();) {
+        Iterator<Entry<ModuleRevisionId, VisitData>> iter = visitData.entrySet().iterator();
+        while (iter.hasNext()) {
             Entry<ModuleRevisionId, VisitData> entry = iter.next();
-            VisitData vdata = entry.getValue();
-            if (vdata.getNode() == node && !node.getResolvedId().equals(entry.getKey())) {
+            if (entry.getValue().getNode() == node && !node.getResolvedId().equals(entry.getKey())) {
                 // this visit data was associated with the blacklisted node,
                 // we discard this association
                 iter.remove();
@@ -271,22 +258,22 @@ public class ResolveData {
     public boolean isBlacklisted(String rootModuleConf, ModuleRevisionId mrid) {
         IvyNode node = getNode(mrid);
 
-        // if (node == null) {
-        // // search again, now ignore the extra attributes
-        // // TODO: maybe we should search the node that has at least the
-        // // same attributes as mrid
-        // for (Iterator it = visitData.entrySet().iterator(); it.hasNext();) {
-        // Map.Entry entry = (Entry) it.next();
-        // ModuleRevisionId current = (ModuleRevisionId) entry.getKey();
-        // if (current.getModuleId().equals(mrid.getModuleId())
-        // && current.getRevision().equals(mrid.getRevision())) {
-        // VisitData data = (VisitData) entry.getValue();
-        // node = data.getNode();
-        // break;
-        // }
-        // }
-        // }
-        //
+        /*
+        if (node == null) {
+            // search again, now ignore the extra attributes
+            // TODO: maybe we should search the node that has at least the same attributes as mrid
+            for (Entry<ModuleRevisionId, VisitData> entry : visitData.entrySet()) {
+                ModuleRevisionId current = entry.getKey();
+                if (current.getModuleId().equals(mrid.getModuleId())
+                        && current.getRevision().equals(mrid.getRevision())) {
+                    VisitData data = entry.getValue();
+                    node = data.getNode();
+                    break;
+                }
+            }
+        }
+        */
+
         return node != null && node.isBlacklisted(rootModuleConf);
     }
 
@@ -297,7 +284,7 @@ public class ResolveData {
         VisitNode current = getCurrentVisitNode();
         if (current != null) {
             // mediating dd through dependers stack
-            List<VisitNode> dependers = new ArrayList<VisitNode>(current.getPath());
+            List<VisitNode> dependers = new ArrayList<>(current.getPath());
             // the returned path contains the currently visited node, we are only interested in
             // the dependers, so we remove the currently visited node from the end
             dependers.remove(dependers.size() - 1);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/ResolveEngine.java b/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
index 4258424..3d538ae 100644
--- a/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
+++ b/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
@@ -86,7 +86,7 @@ public class ResolveEngine {
 
     private SortEngine sortEngine;
 
-    private Set<String> fetchedSet = new HashSet<String>();
+    private Set<String> fetchedSet = new HashSet<>();
 
     private DependencyResolver dictatorResolver;
 
@@ -267,47 +267,47 @@ public class ResolveEngine {
                     .getResolvedModuleRevisionId());
             Properties props = new Properties();
             if (dependencies.length > 0) {
-                Map<ModuleId, ModuleRevisionId> forcedRevisions = new HashMap<ModuleId, ModuleRevisionId>();
-                for (int i = 0; i < dependencies.length; i++) {
-                    if (dependencies[i].getModuleRevision() != null
-                            && dependencies[i].getModuleRevision().isForce()) {
-                        forcedRevisions.put(dependencies[i].getModuleId(),
-                            dependencies[i].getResolvedId());
+                Map<ModuleId, ModuleRevisionId> forcedRevisions = new HashMap<>();
+                for (IvyNode dependency : dependencies) {
+                    if (dependency.getModuleRevision() != null
+                            && dependency.getModuleRevision().isForce()) {
+                        forcedRevisions.put(dependency.getModuleId(),
+                                dependency.getResolvedId());
                     }
                 }
 
                 IvyNode root = dependencies[0].getRoot();
 
-                Map<ModuleId, IvyNode> topLevelDeps = new HashMap<ModuleId, IvyNode>();
-                for (int i = 0; i < dependencies.length; i++) {
-                    if (!dependencies[i].hasProblem()) {
-                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
+                Map<ModuleId, IvyNode> topLevelDeps = new HashMap<>();
+                for (IvyNode dependency : dependencies) {
+                    if (!dependency.hasProblem()) {
+                        DependencyDescriptor dd = dependency.getDependencyDescriptor(root);
                         if (dd != null) {
-                            ModuleId orgMod = dependencies[i].getModuleId();
-                            topLevelDeps.put(orgMod, dependencies[i]);
+                            ModuleId orgMod = dependency.getModuleId();
+                            topLevelDeps.put(orgMod, dependency);
                         }
                     }
                 }
 
-                for (int i = 0; i < dependencies.length; i++) {
-                    if (!dependencies[i].hasProblem() && !dependencies[i].isCompletelyEvicted()) {
-                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
+                for (IvyNode dependency : dependencies) {
+                    if (!dependency.hasProblem() && !dependency.isCompletelyEvicted()) {
+                        DependencyDescriptor dd = dependency.getDependencyDescriptor(root);
                         if (dd == null) {
-                            ModuleId mid = dependencies[i].getModuleId();
+                            ModuleId mid = dependency.getModuleId();
                             IvyNode tlDep = topLevelDeps.get(mid);
                             if (tlDep != null) {
                                 dd = tlDep.getDependencyDescriptor(root);
                             }
                         }
                         if (dd != null) {
-                            ModuleRevisionId depResolvedId = dependencies[i].getResolvedId();
-                            ModuleDescriptor depDescriptor = dependencies[i].getDescriptor();
+                            ModuleRevisionId depResolvedId = dependency.getResolvedId();
+                            ModuleDescriptor depDescriptor = dependency.getDescriptor();
                             ModuleRevisionId depRevisionId = dd.getDependencyRevisionId();
-                            ModuleRevisionId forcedRevisionId = forcedRevisions.get(dependencies[i]
+                            ModuleRevisionId forcedRevisionId = forcedRevisions.get(dependency
                                     .getModuleId());
 
-                            if (dependencies[i].getModuleRevision() != null
-                                    && dependencies[i].getModuleRevision().isForce()
+                            if (dependency.getModuleRevision() != null
+                                    && dependency.getModuleRevision().isForce()
                                     && !depResolvedId.equals(depRevisionId)
                                     && !settings.getVersionMatcher().isDynamic(depRevisionId)) {
                                 // if we were forced to this revision and we
@@ -319,7 +319,7 @@ public class ResolveEngine {
 
                             if (depResolvedId == null) {
                                 throw new NullPointerException("getResolvedId() is null for "
-                                        + dependencies[i].toString());
+                                        + dependency.toString());
                             }
                             if (depRevisionId == null) {
                                 throw new NullPointerException("getDependencyRevisionId() "
@@ -391,49 +391,45 @@ public class ResolveEngine {
     public void downloadArtifacts(ResolveReport report, Filter<Artifact> artifactFilter,
             DownloadOptions options) {
         long start = System.currentTimeMillis();
-        IvyNode[] dependencies = report.getDependencies().toArray(
-            new IvyNode[report.getDependencies().size()]);
 
         eventManager.fireIvyEvent(new PrepareDownloadEvent(report.getArtifacts().toArray(
             new Artifact[report.getArtifacts().size()])));
 
         long totalSize = 0;
-        for (int i = 0; i < dependencies.length; i++) {
+        for (IvyNode dependency : report.getDependencies()) {
             checkInterrupted();
             // download artifacts required in all asked configurations
-            if (!dependencies[i].isCompletelyEvicted() && !dependencies[i].hasProblem()
-                    && dependencies[i].getModuleRevision() != null) {
-                DependencyResolver resolver = dependencies[i].getModuleRevision()
+            if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()
+                    && dependency.getModuleRevision() != null) {
+                DependencyResolver resolver = dependency.getModuleRevision()
                         .getArtifactResolver();
-                Artifact[] selectedArtifacts = dependencies[i].getSelectedArtifacts(artifactFilter);
+                Artifact[] selectedArtifacts = dependency.getSelectedArtifacts(artifactFilter);
                 DownloadReport dReport = resolver.download(selectedArtifacts, options);
-                ArtifactDownloadReport[] adrs = dReport.getArtifactsReports();
-                for (int j = 0; j < adrs.length; j++) {
-                    if (adrs[j].getDownloadStatus() == DownloadStatus.FAILED) {
-                        if (adrs[j].getArtifact().getExtraAttribute("ivy:merged") != null) {
-                            Message.warn("\tmerged artifact not found: " + adrs[j].getArtifact()
+                for (ArtifactDownloadReport adr : dReport.getArtifactsReports()) {
+                    if (adr.getDownloadStatus() == DownloadStatus.FAILED) {
+                        if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) {
+                            Message.warn("\tmerged artifact not found: " + adr.getArtifact()
                                     + ". It was required in "
-                                    + adrs[j].getArtifact().getExtraAttribute("ivy:merged"));
+                                    + adr.getArtifact().getExtraAttribute("ivy:merged"));
                         } else {
-                            Message.warn("\t" + adrs[j]);
-                            resolver.reportFailure(adrs[j].getArtifact());
+                            Message.warn("\t" + adr);
+                            resolver.reportFailure(adr.getArtifact());
                         }
-                    } else if (adrs[j].getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
-                        totalSize += adrs[j].getSize();
+                    } else if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
+                        totalSize += adr.getSize();
                     }
                 }
                 // update concerned reports
-                String[] dconfs = dependencies[i].getRootModuleConfigurations();
-                for (int j = 0; j < dconfs.length; j++) {
+                for (String dconf : dependency.getRootModuleConfigurations()) {
                     // the report itself is responsible to take into account only
                     // artifacts required in its corresponding configuration
                     // (as described by the Dependency object)
-                    if (dependencies[i].isEvicted(dconfs[j])
-                            || dependencies[i].isBlacklisted(dconfs[j])) {
-                        report.getConfigurationReport(dconfs[j]).addDependency(dependencies[i]);
+                    if (dependency.isEvicted(dconf)
+                            || dependency.isBlacklisted(dconf)) {
+                        report.getConfigurationReport(dconf).addDependency(dependency);
                     } else {
-                        report.getConfigurationReport(dconfs[j]).addDependency(dependencies[i],
-                            dReport);
+                        report.getConfigurationReport(dconf).addDependency(dependency,
+                                dReport);
                     }
                 }
             }
@@ -554,15 +550,15 @@ public class ResolveEngine {
             throw new NullPointerException("module descriptor must not be null");
         }
         String[] confs = options.getConfs(md);
-        Collection<String> missingConfs = new ArrayList<String>();
-        for (int i = 0; i < confs.length; i++) {
-            if (confs[i] == null) {
+        Collection<String> missingConfs = new ArrayList<>();
+        for (String conf : confs) {
+            if (conf == null) {
                 throw new NullPointerException("null conf not allowed: confs where: "
                         + Arrays.asList(confs));
             }
 
-            if (md.getConfiguration(confs[i]) == null) {
-                missingConfs.add(" '" + confs[i] + "' ");
+            if (md.getConfiguration(conf) == null) {
+                missingConfs.add(" '" + conf + "' ");
             }
         }
         if (!missingConfs.isEmpty()) {
@@ -583,33 +579,33 @@ public class ResolveEngine {
             }
             IvyNode rootNode = new IvyNode(data, md);
 
-            for (int i = 0; i < confs.length; i++) {
-                Message.verbose("resolving dependencies for configuration '" + confs[i] + "'");
+            for (String conf : confs) {
+                Message.verbose("resolving dependencies for configuration '" + conf + "'");
                 // for each configuration we clear the cache of what's been fetched
                 fetchedSet.clear();
 
                 ConfigurationResolveReport confReport = null;
                 if (report != null) {
-                    confReport = report.getConfigurationReport(confs[i]);
+                    confReport = report.getConfigurationReport(conf);
                     if (confReport == null) {
-                        confReport = new ConfigurationResolveReport(this, md, confs[i], reportDate,
+                        confReport = new ConfigurationResolveReport(this, md, conf, reportDate,
                                 options);
-                        report.addReport(confs[i], confReport);
+                        report.addReport(conf, confReport);
                     }
                 }
                 // we reuse the same resolve data with a new report for each conf
                 data.setReport(confReport);
 
                 // update the root module conf we are about to fetch
-                VisitNode root = new VisitNode(data, rootNode, null, confs[i], null);
-                root.setRequestedConf(confs[i]);
-                rootNode.updateConfsToFetch(Collections.singleton(confs[i]));
+                VisitNode root = new VisitNode(data, rootNode, null, conf, null);
+                root.setRequestedConf(conf);
+                rootNode.updateConfsToFetch(Collections.singleton(conf));
 
                 // go fetch !
                 boolean fetched = false;
                 while (!fetched) {
                     try {
-                        fetchDependencies(root, confs[i], false);
+                        fetchDependencies(root, conf, false);
                         fetched = true;
                     } catch (RestartResolveProcess restart) {
                         Message.verbose("====================================================");
@@ -629,7 +625,7 @@ public class ResolveEngine {
             // prune and reverse sort fetched dependencies
             Collection<IvyNode> nodes = data.getNodes();
             // use a Set to avoid duplicates, linked to preserve order
-            Collection<IvyNode> dependencies = new LinkedHashSet<IvyNode>(nodes.size());
+            Collection<IvyNode> dependencies = new LinkedHashSet<>(nodes.size());
             for (IvyNode node : nodes) {
                 if (node != null && !node.isRoot() && !node.isCompletelyBlacklisted()) {
                     dependencies.add(node);
@@ -655,26 +651,26 @@ public class ResolveEngine {
         // can traverse the list and check only the direct parent and not all the ancestors
         for (IvyNode node : sortedDependencies) {
             if (!node.isCompletelyEvicted()) {
-                for (int i = 0; i < confs.length; i++) {
-                    IvyNodeCallers.Caller[] callers = node.getCallers(confs[i]);
+                for (String conf : confs) {
+                    IvyNodeCallers.Caller[] callers = node.getCallers(conf);
                     if (settings.debugConflictResolution()) {
                         Message.debug("checking if " + node.getId()
-                                + " is transitively evicted in " + confs[i]);
+                                + " is transitively evicted in " + conf);
                     }
                     boolean allEvicted = callers.length > 0;
-                    for (int j = 0; j < callers.length; j++) {
-                        if (callers[j].getModuleRevisionId().equals(md.getModuleRevisionId())) {
+                    for (IvyNodeCallers.Caller caller : callers) {
+                        if (caller.getModuleRevisionId().equals(md.getModuleRevisionId())) {
                             // the caller is the root module itself, it can't be evicted
                             allEvicted = false;
                             break;
                         } else {
-                            IvyNode callerNode = data.getNode(callers[j].getModuleRevisionId());
+                            IvyNode callerNode = data.getNode(caller.getModuleRevisionId());
                             if (callerNode == null) {
                                 Message.warn("ivy internal error: no node found for "
-                                        + callers[j].getModuleRevisionId() + ": looked in "
+                                        + caller.getModuleRevisionId() + ": looked in "
                                         + data.getNodeIds() + " and root module id was "
                                         + md.getModuleRevisionId());
-                            } else if (!callerNode.isEvicted(confs[i])) {
+                            } else if (!callerNode.isEvicted(conf)) {
                                 allEvicted = false;
                                 break;
                             } else {
@@ -687,7 +683,7 @@ public class ResolveEngine {
                     }
                     if (allEvicted) {
                         Message.verbose("all callers are evicted for " + node + ": evicting too");
-                        node.markEvicted(confs[i], null, null, null);
+                        node.markEvicted(conf, null, null, null);
                     } else {
                         if (settings.debugConflictResolution()) {
                             Message.debug(node.getId()
@@ -715,9 +711,8 @@ public class ResolveEngine {
         data.setCurrentVisitNode(node);
         DependencyDescriptor dd = node.getDependencyDescriptor();
         VersionMatcher versionMatcher = node.getNode().getData().getSettings().getVersionMatcher();
-        if (dd != null
-                && !(node.getRoot() == node.getParent() && versionMatcher.isDynamic(dd
-                        .getDependencyRevisionId()))) {
+        if (dd != null && !(node.getRoot() == node.getParent()
+                && versionMatcher.isDynamic(dd.getDependencyRevisionId()))) {
             /*
              * we don't resolve conflicts before loading data for direct dependencies on dynamic
              * revisions, so that direct dynamic revisions are always resolved, which is mandatory
@@ -732,18 +727,16 @@ public class ResolveEngine {
             // dependency to take the decision
             resolveConflict(node, conf);
             if (!node.isEvicted() && !node.isCircular()) {
-                String[] confs = node.getRealConfs(conf);
-                for (int i = 0; i < confs.length; i++) {
-                    doFetchDependencies(node, confs[i]);
+                for (String rconf : node.getRealConfs(conf)) {
+                    doFetchDependencies(node, rconf);
                 }
             }
         } else if (!node.hasProblem()) {
             // the node has not been loaded but hasn't problem: it was already loaded
             // => we just have to update its dependencies data
             if (!node.isEvicted() && !node.isCircular()) {
-                String[] confs = node.getRealConfs(conf);
-                for (int i = 0; i < confs.length; i++) {
-                    doFetchDependencies(node, confs[i]);
+                for (String rconf : node.getRealConfs(conf)) {
+                    doFetchDependencies(node, rconf);
                 }
             }
         }
@@ -797,31 +790,28 @@ public class ResolveEngine {
         if (extendedConfs.length > 0) {
             node.updateConfsToFetch(Arrays.asList(extendedConfs));
         }
-        for (int i = 0; i < extendedConfs.length; i++) {
-            fetchDependencies(node, extendedConfs[i], false);
+        for (String extendedConf : extendedConfs) {
+            fetchDependencies(node, extendedConf, false);
         }
 
         // now we can actually resolve this configuration dependencies
         if (!isDependenciesFetched(node.getNode(), conf) && node.isTransitive()) {
-            Collection<VisitNode> dependencies = node.getDependencies(conf);
-            for (VisitNode dep : dependencies) {
+            for (VisitNode dep : node.getDependencies(conf)) {
                 dep.useRealNode(); // the node may have been resolved to another real one while
                 // resolving other deps
-                String[] confs = dep.getRequiredConfigurations(node, conf);
-                for (int i = 0; i < confs.length; i++) {
-                    fetchDependencies(dep, confs[i], true);
+                for (String rconf : dep.getRequiredConfigurations(node, conf)) {
+                    fetchDependencies(dep, rconf, true);
                 }
                 if (!dep.isEvicted() && !dep.hasProblem()) {
                     // if there are still confs to fetch (usually because they have
                     // been updated when evicting another module), we fetch them now
-                    confs = dep.getConfsToFetch();
-                    for (int i = 0; i < confs.length; i++) {
+                    for (String fconf : dep.getConfsToFetch()) {
                         // shouldBeFixed=false to because some of those dependencies might
                         // be private when they were actually extending public conf.
                         // Should we keep two list of confs to fetch (private&public)?
                         // I don't think, visibility is already checked, and a change in the
                         // configuration between version might anyway have worse problems.
-                        fetchDependencies(dep, confs[i], false);
+                        fetchDependencies(dep, fconf, false);
                     }
                 }
             }
@@ -982,8 +972,8 @@ public class ResolveEngine {
             ancestor.getNode().setResolvedNodes(node.getModuleId(), node.getRootModuleConf(),
                 resolved);
 
-            Collection<IvyNode> evicted = new HashSet<IvyNode>(ancestor.getNode().getEvictedNodes(
-                node.getModuleId(), node.getRootModuleConf()));
+            Collection<IvyNode> evicted = new HashSet<>(ancestor.getNode().getEvictedNodes(
+                    node.getModuleId(), node.getRootModuleConf()));
             evicted.removeAll(resolved);
             evicted.addAll(toevict);
             ancestor.getNode().setEvictedNodes(node.getModuleId(), node.getRootModuleConf(),
@@ -1003,8 +993,8 @@ public class ResolveEngine {
 
             // it's time to update parent resolved and evicted with what was found
 
-            Collection<IvyNode> evicted = new HashSet<IvyNode>(ancestor.getNode().getEvictedNodes(
-                node.getModuleId(), node.getRootModuleConf()));
+            Collection<IvyNode> evicted = new HashSet<>(ancestor.getNode().getEvictedNodes(
+                    node.getModuleId(), node.getRootModuleConf()));
             toevict.removeAll(resolved);
             evicted.removeAll(resolved);
             evicted.addAll(toevict);
@@ -1091,7 +1081,7 @@ public class ResolveEngine {
      */
     private Collection<IvyNode> computeConflicts(VisitNode node, VisitNode ancestor, String conf,
             Collection<IvyNode> toevict, Collection<IvyNode> selectedNodes) {
-        Collection<IvyNode> conflicts = new LinkedHashSet<IvyNode>();
+        Collection<IvyNode> conflicts = new LinkedHashSet<>();
         conflicts.add(node.getNode());
         /*
          * We first try to remove all evicted nodes from the collection of selected nodes to update

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/ResolveOptions.java b/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
index b434c05..77c5ee1 100644
--- a/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
+++ b/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
@@ -175,12 +175,7 @@ public class ResolveOptions extends LogOptions {
      * @see #getConfs(ModuleDescriptor)
      */
     public boolean useSpecialConfs() {
-        for (int i = 0; confs != null && i < confs.length; i++) {
-            if (confs[0].startsWith("*")) {
-                return true;
-            }
-        }
-        return false;
+        return confs != null && confs[0].startsWith("*");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/VisitData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/VisitData.java b/src/java/org/apache/ivy/core/resolve/VisitData.java
index 3beb877..fa66858 100644
--- a/src/java/org/apache/ivy/core/resolve/VisitData.java
+++ b/src/java/org/apache/ivy/core/resolve/VisitData.java
@@ -38,7 +38,7 @@ public class VisitData {
      * The associated visit nodes, per rootModuleConf Note that the value is a List, because a node
      * can be visited from several parents during the resolution process
      */
-    private Map<String, List<VisitNode>> visitNodes = new HashMap<String, List<VisitNode>>();
+    private Map<String, List<VisitNode>> visitNodes = new HashMap<>();
 
     public VisitData(IvyNode node) {
         this.node = node;
@@ -52,7 +52,7 @@ public class VisitData {
     public List<VisitNode> getVisitNodes(String rootModuleConf) {
         List<VisitNode> visits = visitNodes.get(rootModuleConf);
         if (visits == null) {
-            visits = new ArrayList<VisitNode>();
+            visits = new ArrayList<>();
             visitNodes.put(rootModuleConf, visits);
         }
         return visits;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/resolve/VisitNode.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/resolve/VisitNode.java b/src/java/org/apache/ivy/core/resolve/VisitNode.java
index b5171b9..39497f1 100644
--- a/src/java/org/apache/ivy/core/resolve/VisitNode.java
+++ b/src/java/org/apache/ivy/core/resolve/VisitNode.java
@@ -164,7 +164,7 @@ public class VisitNode {
 
     private Collection<VisitNode> computePath() {
         if (parent != null) {
-            Collection<VisitNode> p = new LinkedHashSet<VisitNode>(parent.getPath());
+            Collection<VisitNode> p = new LinkedHashSet<>(parent.getPath());
             p.add(this);
             return p;
         } else {
@@ -196,7 +196,7 @@ public class VisitNode {
 
     public static VisitNode getRoot(VisitNode parent) {
         VisitNode root = parent;
-        Collection<VisitNode> path = new HashSet<VisitNode>();
+        Collection<VisitNode> path = new HashSet<>();
         path.add(root);
         while (root.getParent() != null && !root.getNode().isRoot()) {
             if (path.contains(root.getParent())) {
@@ -303,7 +303,7 @@ public class VisitNode {
 
     public Collection<VisitNode> getDependencies(String conf) {
         Collection<IvyNode> deps = node.getDependencies(rootModuleConf, conf, requestedConf);
-        Collection<VisitNode> ret = new ArrayList<VisitNode>(deps.size());
+        Collection<VisitNode> ret = new ArrayList<>(deps.size());
         for (IvyNode depNode : deps) {
             ret.add(traverseChild(conf, depNode));
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java b/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
index 4822e89..9fcf80a 100644
--- a/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
+++ b/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
@@ -128,15 +128,15 @@ public class RetrieveEngine {
             report.setRetrieveRoot(fileRetrieveRoot);
             File ivyRetrieveRoot = destIvyPattern == null ? null : settings
                     .resolveFile(IvyPatternHelper.getTokenRoot(destIvyPattern));
-            Collection<File> targetArtifactsStructure = new HashSet<File>();
+            Collection<File> targetArtifactsStructure = new HashSet<>();
             // Set(File) set of all paths which should be present at then end of retrieve (useful
             // for sync)
-            Collection<File> targetIvysStructure = new HashSet<File>(); // same for ivy files
+            Collection<File> targetIvysStructure = new HashSet<>(); // same for ivy files
 
             if (options.isMakeSymlinksInMass()) {
                 // The HashMap is of "destToSrc" because src could go two places, but dest can only
                 // come from one
-                destToSrcMap = new HashMap<File, File>();
+                destToSrcMap = new HashMap<>();
             }
 
             // do retrieve
@@ -217,15 +217,13 @@ public class RetrieveEngine {
                 Collection<String> ignoreList = Arrays.asList(ignorableFilenames);
 
                 Collection<File> existingArtifacts = FileUtil.listAll(fileRetrieveRoot, ignoreList);
-                Collection<File> existingIvys = ivyRetrieveRoot == null ? null : FileUtil.listAll(
+                Collection<File> existingIvys = (ivyRetrieveRoot == null) ? null : FileUtil.listAll(
                     ivyRetrieveRoot, ignoreList);
 
                 if (fileRetrieveRoot.equals(ivyRetrieveRoot)) {
-                    Collection<File> target = targetArtifactsStructure;
-                    target.addAll(targetIvysStructure);
-                    Collection<File> existing = existingArtifacts;
-                    existing.addAll(existingIvys);
-                    sync(target, existing);
+                    targetArtifactsStructure.addAll(targetIvysStructure);
+                    existingArtifacts.addAll(existingIvys);
+                    sync(targetArtifactsStructure, existingArtifacts);
                 } else {
                     sync(targetArtifactsStructure, existingArtifacts);
                     if (existingIvys != null) {
@@ -269,9 +267,7 @@ public class RetrieveEngine {
             } catch (IOException e) {
                 throw e;
             } catch (Exception e) {
-                IOException ioex = new IOException(e.getMessage());
-                ioex.initCause(e);
-                throw ioex;
+                throw new IOException(e.getMessage(), e);
             }
         }
         return confs;
@@ -282,7 +278,7 @@ public class RetrieveEngine {
     }
 
     private void sync(Collection<File> target, Collection<File> existing) {
-        Collection<File> toRemove = new HashSet<File>();
+        Collection<File> toRemove = new HashSet<>();
         for (File file : existing) {
             toRemove.add(file.getAbsoluteFile());
         }
@@ -313,28 +309,25 @@ public class RetrieveEngine {
         // find what we must retrieve where
 
         // ArtifactDownloadReport source -> Set (String copyDestAbsolutePath)
-        final Map<ArtifactDownloadReport, Set<String>> artifactsToCopy = new HashMap<ArtifactDownloadReport, Set<String>>();
+        final Map<ArtifactDownloadReport, Set<String>> artifactsToCopy = new HashMap<>();
         // String copyDestAbsolutePath -> Set (ArtifactRevisionId source)
-        final Map<String, Set<ArtifactRevisionId>> conflictsMap = new HashMap<String, Set<ArtifactRevisionId>>();
+        final Map<String, Set<ArtifactRevisionId>> conflictsMap = new HashMap<>();
         // String copyDestAbsolutePath -> Set (ArtifactDownloadReport source)
-        final Map<String, Set<ArtifactDownloadReport>> conflictsReportsMap = new HashMap<String, Set<ArtifactDownloadReport>>();
+        final Map<String, Set<ArtifactDownloadReport>> conflictsReportsMap = new HashMap<>();
         // String copyDestAbsolutePath -> Set (String conf)
-        final Map<String, Set<String>> conflictsConfMap = new HashMap<String, Set<String>>();
+        final Map<String, Set<String>> conflictsConfMap = new HashMap<>();
 
         XmlReportParser parser = new XmlReportParser();
-        for (int i = 0; i < confs.length; i++) {
-            final String conf = confs[i];
-
+        for (final String conf : confs) {
             File report = cacheManager.getConfigurationResolveReportInCache(options.getResolveId(),
                 conf);
             parser.parse(report);
 
-            Collection<ArtifactDownloadReport> artifacts = new ArrayList<ArtifactDownloadReport>(
+            Collection<ArtifactDownloadReport> artifacts = new ArrayList<>(
                     Arrays.asList(parser.getArtifactReports()));
             if (destIvyPattern != null) {
-                ModuleRevisionId[] mrids = parser.getRealDependencyRevisionIds();
-                for (int j = 0; j < mrids.length; j++) {
-                    artifacts.add(parser.getMetadataArtifactReport(mrids[j]));
+                for (ModuleRevisionId rmrid : parser.getRealDependencyRevisionIds()) {
+                    artifacts.add(parser.getMetadataArtifactReport(rmrid));
                 }
             }
             final PackagingManager packagingManager = new PackagingManager();
@@ -356,8 +349,8 @@ public class RetrieveEngine {
                         unpackedArtifact = packagingManager.getUnpackedArtifact(artifact);
                     }
                     if (unpackedArtifact == null) {
-                        throw new RuntimeException("Could not determine unpacked artifact for " + artifact +
-                                " while determining artifacts to copy for module " + mrid);
+                        throw new RuntimeException("Could not determine unpacked artifact for " + artifact
+                                + " while determining artifacts to copy for module " + mrid);
                     }
                     ext = unpackedArtifact.getExt();
                 }
@@ -377,7 +370,7 @@ public class RetrieveEngine {
                     artifact.getQualifiedExtraAttributes());
                 Set<String> dest = artifactsToCopy.get(adr);
                 if (dest == null) {
-                    dest = new HashSet<String>();
+                    dest = new HashSet<>();
                     artifactsToCopy.put(adr, dest);
                 }
                 String copyDest = settings.resolveFile(destFileName).getAbsolutePath();
@@ -387,24 +380,24 @@ public class RetrieveEngine {
                     destinations = options.getMapper().mapFileName(copyDest);
                 }
 
-                for (int j = 0; j < destinations.length; j++) {
-                    dest.add(destinations[j]);
+                for (String destination : destinations) {
+                    dest.add(destination);
 
-                    Set<ArtifactRevisionId> conflicts = conflictsMap.get(destinations[j]);
+                    Set<ArtifactRevisionId> conflicts = conflictsMap.get(destination);
                     Set<ArtifactDownloadReport> conflictsReports = conflictsReportsMap
-                            .get(destinations[j]);
-                    Set<String> conflictsConf = conflictsConfMap.get(destinations[j]);
+                            .get(destination);
+                    Set<String> conflictsConf = conflictsConfMap.get(destination);
                     if (conflicts == null) {
-                        conflicts = new HashSet<ArtifactRevisionId>();
-                        conflictsMap.put(destinations[j], conflicts);
+                        conflicts = new HashSet<>();
+                        conflictsMap.put(destination, conflicts);
                     }
                     if (conflictsReports == null) {
-                        conflictsReports = new HashSet<ArtifactDownloadReport>();
-                        conflictsReportsMap.put(destinations[j], conflictsReports);
+                        conflictsReports = new HashSet<>();
+                        conflictsReportsMap.put(destination, conflictsReports);
                     }
                     if (conflictsConf == null) {
-                        conflictsConf = new HashSet<String>();
-                        conflictsConfMap.put(destinations[j], conflictsConf);
+                        conflictsConf = new HashSet<>();
+                        conflictsConfMap.put(destination, conflictsConf);
                     }
                     if (conflicts.add(artifact.getId())) {
                         conflictsReports.add(adr);
@@ -420,7 +413,7 @@ public class RetrieveEngine {
             Set<ArtifactRevisionId> artifacts = entry.getValue();
             Set<String> conflictsConfs = conflictsConfMap.get(copyDest);
             if (artifacts.size() > 1) {
-                List<ArtifactDownloadReport> artifactsList = new ArrayList<ArtifactDownloadReport>(
+                List<ArtifactDownloadReport> artifactsList = new ArrayList<>(
                         conflictsReportsMap.get(copyDest));
                 // conflicts battle is resolved by a sort using a conflict resolving policy
                 // comparator which consider as greater a winning artifact

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java b/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
index 7f27d56..6fa2399 100644
--- a/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
+++ b/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
@@ -18,6 +18,7 @@
 package org.apache.ivy.core.retrieve;
 
 import org.apache.ivy.core.LogOptions;
+import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.util.filter.Filter;
 import org.apache.ivy.util.filter.FilterHelper;
 
@@ -55,7 +56,7 @@ public class RetrieveOptions extends LogOptions {
     /**
      * The filter to apply before retrieving artifacts.
      */
-    private Filter artifactFilter = FilterHelper.NO_FILTER;
+    private Filter<Artifact> artifactFilter = FilterHelper.NO_FILTER;
 
     /**
      * True if a synchronisation of the destination directory should be done, false if a simple copy
@@ -117,11 +118,11 @@ public class RetrieveOptions extends LogOptions {
         return this;
     }
 
-    public Filter getArtifactFilter() {
+    public Filter<Artifact> getArtifactFilter() {
         return artifactFilter;
     }
 
-    public RetrieveOptions setArtifactFilter(Filter artifactFilter) {
+    public RetrieveOptions setArtifactFilter(Filter<Artifact> artifactFilter) {
         this.artifactFilter = artifactFilter;
         return this;
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/retrieve/RetrieveReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/retrieve/RetrieveReport.java b/src/java/org/apache/ivy/core/retrieve/RetrieveReport.java
index 6dcb9fd..256678c 100644
--- a/src/java/org/apache/ivy/core/retrieve/RetrieveReport.java
+++ b/src/java/org/apache/ivy/core/retrieve/RetrieveReport.java
@@ -28,11 +28,11 @@ import org.apache.ivy.core.report.ArtifactDownloadReport;
 
 public class RetrieveReport {
 
-    private Collection<File> upToDateFiles = new HashSet<File>();
+    private Collection<File> upToDateFiles = new HashSet<>();
 
-    private Collection<File> copiedFiles = new HashSet<File>();
+    private Collection<File> copiedFiles = new HashSet<>();
 
-    private Map<File, ArtifactDownloadReport> downloadReport = new HashMap<File, ArtifactDownloadReport>();
+    private Map<File, ArtifactDownloadReport> downloadReport = new HashMap<>();
 
     private File retrieveRoot;
 
@@ -74,7 +74,7 @@ public class RetrieveReport {
      * @return Collection&lt;File&gt;
      */
     public Collection<File> getCopiedFiles() {
-        return new ArrayList<File>(copiedFiles);
+        return new ArrayList<>(copiedFiles);
     }
 
     /**
@@ -84,7 +84,7 @@ public class RetrieveReport {
      * @return Collection&lt;File&gt;
      */
     public Collection<File> getUpToDateFiles() {
-        return new ArrayList<File>(upToDateFiles);
+        return new ArrayList<>(upToDateFiles);
     }
 
     /**
@@ -94,7 +94,7 @@ public class RetrieveReport {
      * @return Collection&lt;File&gt;
      */
     public Collection<File> getRetrievedFiles() {
-        Collection<File> result = new ArrayList<File>(upToDateFiles.size() + copiedFiles.size());
+        Collection<File> result = new ArrayList<>(upToDateFiles.size() + copiedFiles.size());
         result.addAll(upToDateFiles);
         result.addAll(copiedFiles);
         return result;


Mime
View raw message