ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaiki...@apache.org
Subject [5/7] ant-ivy git commit: Add generics and Java 7 syntax to core
Date Tue, 18 Jul 2017 05:02:22 GMT
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
index 85b9c74..2d2b97b 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
@@ -67,30 +67,30 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(
                 ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName() + "-caller",
                     "working"), "integration", null, true);
-        for (int i = 0; i < confs.length; i++) {
-            moduleDescriptor.addConfiguration(new Configuration(confs[i]));
+        for (String conf : confs) {
+            moduleDescriptor.addConfiguration(new Configuration(conf));
         }
         moduleDescriptor.setLastModified(System.currentTimeMillis());
         DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(moduleDescriptor, mrid,
                 true, changing, transitive);
-        for (int j = 0; j < confs.length; j++) {
-            dd.addDependencyConfiguration(confs[j], confs[j]);
+        for (String conf : confs) {
+            dd.addDependencyConfiguration(conf, conf);
         }
         moduleDescriptor.addDependency(dd);
 
         return moduleDescriptor;
     }
 
-    public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid,
+    public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrids,
             boolean transitive, boolean changing) {
         DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(
                 ModuleRevisionId.newInstance("caller", "all-caller", "working"), "integration",
                 null, true);
         moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
         moduleDescriptor.setLastModified(System.currentTimeMillis());
-        for (int i = 0; i < mrid.length; i++) {
+        for (ModuleRevisionId mrid : mrids) {
             DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(moduleDescriptor,
-                    mrid[i], true, changing, transitive);
+                    mrid, true, changing, transitive);
             dd.addDependencyConfiguration(DEFAULT_CONFIGURATION, "*");
             moduleDescriptor.addDependency(dd);
         }
@@ -104,15 +104,14 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
                 null, true);
         moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
         if (artifacts != null && artifacts.length > 0) {
-            for (int i = 0; i < artifacts.length; i++) {
+            for (DependencyArtifactDescriptor artifact : artifacts) {
                 moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION,
-                    new MDArtifact(moduleDescriptor, artifacts[i].getName(),
-                            artifacts[i].getType(), artifacts[i].getExt(), artifacts[i].getUrl(),
-                            artifacts[i].getExtraAttributes()));
+                    new MDArtifact(moduleDescriptor, artifact.getName(), artifact.getType(),
+                            artifact.getExt(), artifact.getUrl(), artifact.getExtraAttributes()));
             }
         } else {
-            moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor,
-                    mrid.getName(), "jar", "jar"));
+            moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION,
+                new MDArtifact(moduleDescriptor, mrid.getName(), "jar", "jar"));
         }
         moduleDescriptor.setLastModified(System.currentTimeMillis());
         return moduleDescriptor;
@@ -131,7 +130,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     /**
      * Transforms the given module descriptor of the given namespace and return a new module
      * descriptor in the system namespace. <i>Note that dependency exclude rules are not converted
-     * in system namespace, because they aren't transformable (the name space hasn't the ability to
+     * in system namespace, because they aren't transformable (the namespace lacks the ability to
      * convert regular expressions)</i>
      *
      * @param md ModuleDescriptor
@@ -150,9 +149,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         nmd.publicationDate = md.getPublicationDate();
         nmd.resolvedPublicationDate = md.getResolvedPublicationDate();
 
-        ExtendsDescriptor[] ed = md.getInheritedDescriptors();
-        for (int i = 0; i < ed.length; ++i) {
-            ModuleDescriptor parentMd = ed[i].getParentMd();
+        for (ExtendsDescriptor ed : md.getInheritedDescriptors()) {
+            ModuleDescriptor parentMd = ed.getParentMd();
             DefaultModuleDescriptor parentNmd = new DefaultModuleDescriptor(parentMd.getParser(),
                     parentMd.getResource());
             parentNmd.revId = t.transform(parentMd.getModuleRevisionId());
@@ -161,28 +159,26 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             parentNmd.publicationDate = parentMd.getPublicationDate();
             parentNmd.resolvedPublicationDate = parentMd.getResolvedPublicationDate();
 
-            nmd.inheritedDescriptors.add(new DefaultExtendsDescriptor(parentNmd, ed[i]
-                    .getLocation(), ed[i].getExtendsTypes()));
+            nmd.inheritedDescriptors.add(new DefaultExtendsDescriptor(parentNmd, ed.getLocation(),
+                    ed.getExtendsTypes()));
         }
 
-        DependencyDescriptor[] dd = md.getDependencies();
-        for (int i = 0; i < dd.length; i++) {
-            nmd.dependencies.add(NameSpaceHelper.toSystem(dd[i], ns));
+        for (DependencyDescriptor dd : md.getDependencies()) {
+            nmd.dependencies.add(NameSpaceHelper.toSystem(dd, ns));
         }
-        Configuration[] confs = md.getConfigurations();
-        for (int i = 0; i < confs.length; i++) {
-            nmd.configurations.put(confs[i].getName(), confs[i]);
-            Artifact[] arts = md.getArtifacts(confs[i].getName());
-            for (int j = 0; j < arts.length; j++) {
-                nmd.addArtifact(confs[i].getName(), NameSpaceHelper.transform(arts[j], t));
+
+        for (Configuration conf : md.getConfigurations()) {
+            final String confName = conf.getName();
+            nmd.configurations.put(confName, conf);
+            for (Artifact art : md.getArtifacts(confName)) {
+                nmd.addArtifact(confName, NameSpaceHelper.transform(art, t));
             }
         }
         nmd.setDefault(md.isDefault());
         if (md instanceof DefaultModuleDescriptor) {
             DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
-            nmd.conflictManagers = (ModuleRules) dmd.conflictManagers.clone();
-            nmd.dependencyDescriptorMediators = (ModuleRules) dmd.dependencyDescriptorMediators
-                    .clone();
+            nmd.conflictManagers = dmd.conflictManagers.clone();
+            nmd.dependencyDescriptorMediators = dmd.dependencyDescriptorMediators.clone();
         } else {
             Message.warn("transformed module descriptor is not a default module descriptor: "
                     + "impossible to copy conflict manager and version mediation configuration: "
@@ -209,24 +205,24 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
 
     private Date resolvedPublicationDate;
 
-    private List<DependencyDescriptor> dependencies = new ArrayList<DependencyDescriptor>();
+    private List<DependencyDescriptor> dependencies = new ArrayList<>();
 
-    private Map<String, Configuration> configurations = new LinkedHashMap<String, Configuration>();
+    private Map<String, Configuration> configurations = new LinkedHashMap<>();
 
-    private Map<String, Collection<Artifact>> artifactsByConf = new HashMap<String, Collection<Artifact>>();
+    private Map<String, Collection<Artifact>> artifactsByConf = new HashMap<>();
 
-    private Collection<Artifact> artifacts = new LinkedHashSet<Artifact>();
+    private Collection<Artifact> artifacts = new LinkedHashSet<>();
 
     // all artifacts could also be found in the artifactsByConf map, but here we can
     // preserve the order
 
     private boolean isDefault = false;
 
-    private ModuleRules conflictManagers = new ModuleRules();
+    private ModuleRules<ConflictManager> conflictManagers = new ModuleRules<>();
 
-    private ModuleRules dependencyDescriptorMediators = new ModuleRules();
+    private ModuleRules<DependencyDescriptorMediator> dependencyDescriptorMediators = new ModuleRules<>();
 
-    private List<License> licenses = new ArrayList<License>();
+    private List<License> licenses = new ArrayList<>();
 
     private String homePage;
 
@@ -246,15 +242,15 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
 
     private Resource resource;
 
-    private List<ExcludeRule> excludeRules = new ArrayList<ExcludeRule>();
+    private List<ExcludeRule> excludeRules = new ArrayList<>();
 
     private Artifact metadataArtifact;
 
-    private List<ExtendsDescriptor> inheritedDescriptors = new ArrayList<ExtendsDescriptor>();
+    private List<ExtendsDescriptor> inheritedDescriptors = new ArrayList<>();
 
-    private Map<String, String> extraAttributesNamespaces = new LinkedHashMap<String, String>();
+    private Map<String, String> extraAttributesNamespaces = new LinkedHashMap<>();
 
-    private List<ExtraInfoHolder> extraInfos = new ArrayList<ExtraInfoHolder>();
+    private List<ExtraInfoHolder> extraInfos = new ArrayList<>();
 
     public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
         this(id, status, pubDate, false);
@@ -378,14 +374,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         }
         if (c instanceof ConfigurationGroup) {
             ConfigurationGroup group = (ConfigurationGroup) c;
-            String[] members = group.getMembersConfigurationNames();
-            for (int i = 0; i < members.length; i++) {
-                addArtifact(members[i], artifact);
+            for (String member : group.getMembersConfigurationNames()) {
+                addArtifact(member, artifact);
             }
         } else {
             Collection<Artifact> artifacts = artifactsByConf.get(conf);
             if (artifacts == null) {
-                artifacts = new ArrayList<Artifact>();
+                artifacts = new ArrayList<>();
                 artifactsByConf.put(conf, artifacts);
             }
             artifacts.add(artifact);
@@ -418,7 +413,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public String[] getPublicConfigurationsNames() {
-        List<String> ret = new ArrayList<String>();
+        List<String> ret = new ArrayList<>();
         for (Configuration conf : configurations.values()) {
             if (conf.getVisibility() == Configuration.Visibility.PUBLIC) {
                 ret.add(conf.getName());
@@ -442,7 +437,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
                 String attValue = m.group(2);
 
                 // this is a conf group, let's search for its members
-                Map<String, Configuration> members = new LinkedHashMap<String, Configuration>();
+                Map<String, Configuration> members = new LinkedHashMap<>();
                 for (Configuration conf : configurations.values()) {
                     if (attValue.equals(conf.getAttribute(attName))) {
                         members.put(conf.getName(), conf);
@@ -456,15 +451,15 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             if (confs.length <= 1) {
                 return null;
             }
-            Map<String, Configuration> intersectedConfs = new LinkedHashMap<String, Configuration>();
-            for (int i = 0; i < confs.length; i++) {
-                Configuration c = configurations.get(confs[i]);
+            Map<String, Configuration> intersectedConfs = new LinkedHashMap<>();
+            for (String conf : confs) {
+                Configuration c = configurations.get(conf);
                 if (c == null) {
-                    Message.verbose("missing configuration '" + confs[i] + "' from intersection "
+                    Message.verbose("missing configuration '" + conf + "' from intersection "
                             + confName + " in " + this);
                     return null;
                 }
-                intersectedConfs.put(confs[i], c);
+                intersectedConfs.put(conf, c);
             }
             return new ConfigurationIntersection(confName, intersectedConfs);
         }
@@ -479,10 +474,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         Collection<Artifact> artifacts = artifactsByConf.get(conf);
         if (c instanceof ConfigurationIntersection) {
             ConfigurationIntersection intersection = (ConfigurationIntersection) c;
-            String[] intersected = intersection.getIntersectedConfigurationNames();
-            Set<Artifact> intersectedArtifacts = new LinkedHashSet<Artifact>();
-            for (int j = 0; j < intersected.length; j++) {
-                Collection<Artifact> arts = getArtifactsIncludingExtending(intersected[j]);
+            Set<Artifact> intersectedArtifacts = new LinkedHashSet<>();
+            for (String intersect : intersection.getIntersectedConfigurationNames()) {
+                Collection<Artifact> arts = getArtifactsIncludingExtending(intersect);
                 if (intersectedArtifacts.isEmpty()) {
                     intersectedArtifacts.addAll(arts);
                 } else {
@@ -495,10 +489,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             return intersectedArtifacts.toArray(new Artifact[intersectedArtifacts.size()]);
         } else if (c instanceof ConfigurationGroup) {
             ConfigurationGroup group = (ConfigurationGroup) c;
-            String[] members = group.getMembersConfigurationNames();
-            Set<Artifact> groupArtifacts = new LinkedHashSet<Artifact>();
-            for (int i = 0; i < members.length; i++) {
-                groupArtifacts.addAll(getArtifactsIncludingExtending(members[i]));
+            Set<Artifact> groupArtifacts = new LinkedHashSet<>();
+            for (String member : group.getMembersConfigurationNames()) {
+                groupArtifacts.addAll(getArtifactsIncludingExtending(member));
             }
             if (artifacts != null) {
                 groupArtifacts.addAll(artifacts);
@@ -516,7 +509,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     private Collection<Artifact> getArtifactsIncludingExtending(String conf) {
         Collection<Configuration> extendingConfs = Configuration.findConfigurationExtending(conf,
             getConfigurations());
-        Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+        Set<Artifact> artifacts = new LinkedHashSet<>();
         Collection<Artifact> arts = artifactsByConf.get(conf);
         if (arts != null) {
             artifacts.addAll(arts);
@@ -572,10 +565,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof DefaultModuleDescriptor)) {
             return false;
         }
         DefaultModuleDescriptor other = (DefaultModuleDescriptor) obj;
@@ -614,7 +604,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public ConflictManager getConflictManager(ModuleId moduleId) {
-        return (ConflictManager) conflictManagers.getRule(moduleId);
+        return conflictManagers.getRule(moduleId);
     }
 
     public void addDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher,
@@ -624,15 +614,14 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public DependencyDescriptor mediate(DependencyDescriptor dd) {
-        Object[] mediators = dependencyDescriptorMediators.getRules(dd.getDependencyId());
-        for (int i = 0; i < mediators.length; i++) {
-            dd = ((DependencyDescriptorMediator) mediators[i]).mediate(dd);
+        for (DependencyDescriptorMediator mediator : dependencyDescriptorMediators.getRules(dd.getDependencyId())) {
+            dd = mediator.mediate(dd);
         }
         return dd;
     }
 
-    public ModuleRules getAllDependencyDescriptorMediators() {
-        return (ModuleRules) dependencyDescriptorMediators.clone();
+    public ModuleRules<DependencyDescriptorMediator> getAllDependencyDescriptorMediators() {
+        return dependencyDescriptorMediators.clone();
     }
 
     public void addLicense(License license) {
@@ -689,12 +678,11 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
      * configurations existence and cycles are checked
      */
     public void check() {
-        Stack<String> confs = new Stack<String>();
+        Stack<String> confs = new Stack<>();
         for (Configuration conf : configurations.values()) {
-            String[] ext = conf.getExtends();
-            for (int i = 0; i < ext.length; i++) {
+            for (String ext : conf.getExtends()) {
                 confs.push(conf.getName());
-                checkConf(confs, ext[i].trim());
+                checkConf(confs, ext.trim());
                 confs.pop();
             }
         }
@@ -703,7 +691,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     private void checkConf(Stack<String> confs, String confName) {
         int index = confs.indexOf(confName);
         if (index != -1) {
-            StringBuffer cycle = new StringBuffer();
+            StringBuilder cycle = new StringBuilder();
             for (; index < confs.size(); index++) {
                 cycle.append(confs.get(index)).append(" => ");
             }
@@ -716,10 +704,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             throw new IllegalStateException("unknown configuration '" + confName
                     + "'. It is extended by " + confs.get(confs.size() - 1));
         }
-        String[] ext = conf.getExtends();
-        for (int i = 0; i < ext.length; i++) {
+        for (String ext : conf.getExtends()) {
             confs.push(conf.getName());
-            checkConf(confs, ext[i].trim());
+            checkConf(confs, ext.trim());
             confs.pop();
         }
     }
@@ -797,9 +784,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             artifactId = NameSpaceHelper
                     .transform(artifactId, namespace.getFromSystemTransformer());
         }
-        ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
-        for (int i = 0; i < rules.length; i++) {
-            if (MatcherHelper.matches(rules[i].getMatcher(), rules[i].getId(), artifactId)) {
+        for (ExcludeRule rule : getExcludeRules(moduleConfigurations)) {
+            if (MatcherHelper.matches(rule.getMatcher(), rule.getId(), artifactId)) {
                 return true;
             }
         }
@@ -811,7 +797,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
-        Set<ExcludeRule> rules = new LinkedHashSet<ExcludeRule>();
+        Set<ExcludeRule> rules = new LinkedHashSet<>();
         for (ExcludeRule rule : excludeRules) {
             String[] ruleConfs = rule.getConfigurations();
             if (containsAny(ruleConfs, moduleConfigurations)) {
@@ -822,7 +808,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     private boolean containsAny(String[] arr1, String[] arr2) {
-        return new ArrayList<String>(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
+        return new ArrayList<>(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
     }
 
     public Map<String, String> getExtraAttributesNamespaces() {
@@ -840,7 +826,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
 
     @Deprecated
     public Map<String, String> getExtraInfo() {
-        Map<String, String> map = new HashMap<String, String>();
+        Map<String, String> map = new HashMap<>();
         for (ExtraInfoHolder extraInfo : extraInfos) {
             populateExtraInfoMap(map, extraInfo);
         }
@@ -877,6 +863,5 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             }
         }
         return null;
-
     }
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/descriptor/ExtraInfoHolder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/ExtraInfoHolder.java b/src/java/org/apache/ivy/core/module/descriptor/ExtraInfoHolder.java
index 1422378..7a7cfe4 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/ExtraInfoHolder.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/ExtraInfoHolder.java
@@ -26,11 +26,11 @@ public class ExtraInfoHolder {
 
     private String name;
 
-    private Map<String, String> attributes = new LinkedHashMap<String, String>();
+    private Map<String, String> attributes = new LinkedHashMap<>();
 
     private String content;
 
-    private List<ExtraInfoHolder> nestedExtraInfoHolder = new ArrayList<ExtraInfoHolder>();
+    private List<ExtraInfoHolder> nestedExtraInfoHolder = new ArrayList<>();
 
     public ExtraInfoHolder() {
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java b/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java
index 0efabbd..ecd511b 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java
@@ -43,9 +43,9 @@ public class MDArtifact extends AbstractArtifact {
 
     private String ext;
 
-    private List/* <String> */confs = new ArrayList();
+    private final List<String> confs = new ArrayList<>();
 
-    private Map extraAttributes = null;
+    private Map<String, String> extraAttributes = null;
 
     private URL url;
 
@@ -61,7 +61,7 @@ public class MDArtifact extends AbstractArtifact {
     }
 
     public MDArtifact(ModuleDescriptor md, String name, String type, String ext, URL url,
-            Map extraAttributes) {
+            Map<String, String> extraAttributes) {
         if (md == null) {
             throw new NullPointerException("null module descriptor not allowed");
         }
@@ -109,7 +109,7 @@ public class MDArtifact extends AbstractArtifact {
     }
 
     public String[] getConfigurations() {
-        return (String[]) confs.toArray(new String[confs.size()]);
+        return confs.toArray(new String[confs.size()]);
     }
 
     public void addConfiguration(String conf) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
index 03694aa..da92131 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
@@ -212,7 +212,7 @@ public interface ModuleDescriptor extends ExtendableItem, ArtifactInfo,
      * @return all the {@link DependencyDescriptorMediator}s used by this
      * {@link ModuleDescriptor}, as an instance of {@link ModuleRules}.
      */
-    public ModuleRules/* <DependencyDescriptorMediator> */getAllDependencyDescriptorMediators();
+    public ModuleRules<DependencyDescriptorMediator> getAllDependencyDescriptorMediators();
 
     /**
      * @return the list of xml namespaces used by extra attributes, as Map from prefix to namespace

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java b/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
index 3c10cc4..c55b0f0 100644
--- a/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
+++ b/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
@@ -34,7 +34,7 @@ public class ArtifactRevisionId extends UnmodifiableExtendableItem {
     }
 
     public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type,
-            String ext, Map extraAttributes) {
+            String ext, Map<String, String> extraAttributes) {
         return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid,
                 extraAttributes);
     }
@@ -47,7 +47,8 @@ public class ArtifactRevisionId extends UnmodifiableExtendableItem {
         this(artifactId, mrid, null);
     }
 
-    public ArtifactRevisionId(ArtifactId artfId, ModuleRevisionId mdlRevId, Map extraAttributes) {
+    public ArtifactRevisionId(ArtifactId artfId, ModuleRevisionId mdlRevId,
+                              Map<String, String> extraAttributes) {
         super(null, extraAttributes);
         artifactId = artfId;
         mrid = mdlRevId;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/id/MatcherLookup.java b/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
index 56c0ca7..5d223ae 100644
--- a/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
+++ b/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
@@ -57,9 +57,9 @@ public class MatcherLookup {
 
     private static final String DEFAULT = "{org:" + "default" + ", module:" + "default" + "}";
 
-    private Map<String, List<MapMatcher>> lookup = new HashMap<String, List<MapMatcher>>();
+    private Map<String, List<MapMatcher>> lookup = new HashMap<>();
 
-    private List<MapMatcher> non_exact_matchers = new ArrayList<MapMatcher>();
+    private List<MapMatcher> nonExactMatchers = new ArrayList<>();
 
     /**
      * Add matcher.
@@ -73,16 +73,16 @@ public class MatcherLookup {
      */
     public void add(MapMatcher matcher) {
         if (!(matcher.getPatternMatcher() instanceof ExactPatternMatcher)) {
-            non_exact_matchers.add(matcher);
+            nonExactMatchers.add(matcher);
             return;
         }
         String key = key(matcher.getAttributes());
-        List<MapMatcher> exact_matchers = lookup.get(key);
-        if (exact_matchers == null) {
-            exact_matchers = new ArrayList<MapMatcher>();
-            lookup.put(key, exact_matchers);
+        List<MapMatcher> exactMatchers = lookup.get(key);
+        if (exactMatchers == null) {
+            exactMatchers = new ArrayList<>();
+            lookup.put(key, exactMatchers);
         }
-        exact_matchers.add(matcher);
+        exactMatchers.add(matcher);
     }
 
     /**
@@ -92,30 +92,30 @@ public class MatcherLookup {
      * @return a list of matchers that can apply to module withs specified attributes
      */
     public List<MapMatcher> get(Map<String, String> attrs) {
-        List<MapMatcher> matchers = new ArrayList<MapMatcher>();
-        // Step 1: find matchers from non_exact_matchers list
-        if (!non_exact_matchers.isEmpty()) {
-            for (MapMatcher matcher : non_exact_matchers) {
+        List<MapMatcher> matchers = new ArrayList<>();
+        // Step 1: find matchers from nonExactMatchers list
+        if (!nonExactMatchers.isEmpty()) {
+            for (MapMatcher matcher : nonExactMatchers) {
                 if (matcher.matches(attrs)) {
                     matchers.add(matcher);
                 }
             }
         }
-        // Step 2: find matchers from exact_matchers list of key
+        // Step 2: find matchers from exactMatchers list of key
         String key = key(attrs);
-        List<MapMatcher> exact_matchers = lookup.get(key);
-        if (exact_matchers != null) {
-            for (MapMatcher matcher : exact_matchers) {
+        List<MapMatcher> exactMatchers = lookup.get(key);
+        if (exactMatchers != null) {
+            for (MapMatcher matcher : exactMatchers) {
                 if (matcher.matches(attrs)) {
                     matchers.add(matcher);
                 }
             }
         }
-        // Step 3: (iff key != DEFAULT) find matchers from exact_matchers of DEFAULT
+        // Step 3: (iff key != DEFAULT) find matchers from exactMatchers of DEFAULT
         if (!DEFAULT.equals(key)) {
-            List<MapMatcher> default_exact_matchers = lookup.get(DEFAULT);
-            if (default_exact_matchers != null) {
-                for (MapMatcher matcher : default_exact_matchers) {
+            List<MapMatcher> defaultExactMatchers = lookup.get(DEFAULT);
+            if (defaultExactMatchers != null) {
+                for (MapMatcher matcher : defaultExactMatchers) {
                     if (matcher.matches(attrs)) {
                         matchers.add(matcher);
                     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/id/ModuleId.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/id/ModuleId.java b/src/java/org/apache/ivy/core/module/id/ModuleId.java
index b2866b6..1c605f1 100644
--- a/src/java/org/apache/ivy/core/module/id/ModuleId.java
+++ b/src/java/org/apache/ivy/core/module/id/ModuleId.java
@@ -35,7 +35,7 @@ public class ModuleId implements Comparable<ModuleId> {
 
     static final String ENCODE_SEPARATOR = ":#@#:";
 
-    private static final Map<ModuleId, WeakReference<ModuleId>> CACHE = new WeakHashMap<ModuleId, WeakReference<ModuleId>>();
+    private static final Map<ModuleId, WeakReference<ModuleId>> CACHE = new WeakHashMap<>();
 
     /**
      * Returns a ModuleId for the given organization and module name.
@@ -72,7 +72,7 @@ public class ModuleId implements Comparable<ModuleId> {
             }
             if (r == null) {
                 r = moduleId;
-                CACHE.put(r, new WeakReference<ModuleId>(r));
+                CACHE.put(r, new WeakReference<>(r));
             }
         }
 
@@ -85,7 +85,7 @@ public class ModuleId implements Comparable<ModuleId> {
 
     private int hash;
 
-    private Map<String, String> attributes = new HashMap<String, String>();
+    private Map<String, String> attributes = new HashMap<>();
 
     /**
      * Constructor.
@@ -129,11 +129,9 @@ public class ModuleId implements Comparable<ModuleId> {
             return false;
         }
         ModuleId other = (ModuleId) obj;
-        if (other.organisation == null) {
-            return organisation == null && other.name.equals(name);
-        } else {
-            return other.organisation.equals(organisation) && other.name.equals(name);
-        }
+        return (other.organisation == null)
+                ? organisation == null && other.name.equals(name)
+                : other.organisation.equals(organisation) && other.name.equals(name);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java b/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
index a31d50a..9579159 100644
--- a/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
+++ b/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
@@ -47,7 +47,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
 
     private static final String REV_STRICT_CHARS_PATTERN = "[a-zA-Z0-9\\-/\\._+=,\\[\\]\\{\\}\\(\\):@]";
 
-    private static final Map<ModuleRevisionId, WeakReference<ModuleRevisionId>> CACHE = new WeakHashMap<ModuleRevisionId, WeakReference<ModuleRevisionId>>();
+    private static final Map<ModuleRevisionId, WeakReference<ModuleRevisionId>> CACHE = new WeakHashMap<>();
 
     /**
      * Pattern to use to matched mrid text representation.
@@ -157,7 +157,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
             }
             if (r == null) {
                 r = moduleRevisionId;
-                CACHE.put(r, new WeakReference<ModuleRevisionId>(r));
+                CACHE.put(r, new WeakReference<>(r));
             }
         }
 
@@ -259,8 +259,8 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
     }
 
     public String encodeToString() {
-        StringBuffer buf = new StringBuffer();
-        Map<String, String> attributes = new HashMap<String, String>(getAttributes());
+        StringBuilder buf = new StringBuilder();
+        Map<String, String> attributes = new HashMap<>(getAttributes());
         attributes.keySet().removeAll(getExtraAttributes().keySet());
         attributes.putAll(getQualifiedExtraAttributes());
 
@@ -280,7 +280,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
             throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
                     + "'");
         }
-        Map<String, String> attributes = new HashMap<String, String>();
+        Map<String, String> attributes = new HashMap<>();
         for (int i = 0; i < parts.length; i += 2) {
             String attName = parts[i];
             if (!attName.startsWith(ENCODE_PREFIX)) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/id/ModuleRules.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/id/ModuleRules.java b/src/java/org/apache/ivy/core/module/id/ModuleRules.java
index 128dff4..19b3d67 100644
--- a/src/java/org/apache/ivy/core/module/id/ModuleRules.java
+++ b/src/java/org/apache/ivy/core/module/id/ModuleRules.java
@@ -53,9 +53,9 @@ import org.apache.ivy.util.filter.NoFilter;
  */
 public class ModuleRules<T> {
 
-    private Map<MapMatcher, T> rules = new LinkedHashMap<MapMatcher, T>();
+    private Map<MapMatcher, T> rules = new LinkedHashMap<>();
 
-    private MatcherLookup matcher_lookup = new MatcherLookup();
+    private MatcherLookup matcherLookup = new MatcherLookup();
 
     /**
      * Constructs an empty ModuleRules.
@@ -64,9 +64,9 @@ public class ModuleRules<T> {
     }
 
     private ModuleRules(Map<MapMatcher, T> rules) {
-        this.rules = new LinkedHashMap<MapMatcher, T>(rules);
+        this.rules = new LinkedHashMap<>(rules);
         for (MapMatcher matcher : rules.keySet()) {
-            matcher_lookup.add(matcher);
+            matcherLookup.add(matcher);
         }
     }
 
@@ -83,7 +83,7 @@ public class ModuleRules<T> {
         Checks.checkNotNull(rule, "rule");
 
         rules.put(condition, rule);
-        matcher_lookup.add(condition);
+        matcherLookup.add(condition);
     }
 
     /**
@@ -108,7 +108,7 @@ public class ModuleRules<T> {
      *            the {@link ModuleId} to search the rule for. Must not be <code>null</code>.
      * @return an array of rule objects matching the given {@link ModuleId}.
      */
-    public T[] getRules(ModuleId mid) {
+    public List<T> getRules(ModuleId mid) {
         return getRules(mid.getAttributes(), NoFilter.<T> instance());
     }
 
@@ -172,7 +172,7 @@ public class ModuleRules<T> {
     }
 
     private T getRule(Map<String, String> moduleAttributes, Filter<T> filter) {
-        List<MapMatcher> matchers = matcher_lookup.get(moduleAttributes);
+        List<MapMatcher> matchers = matcherLookup.get(moduleAttributes);
         for (MapMatcher midm : matchers) {
             T rule = rules.get(midm);
             if (filter.accept(rule)) {
@@ -195,23 +195,23 @@ public class ModuleRules<T> {
      *            {@link ModuleRevisionId}. Must not be <code>null</code>.
      * @return an array of rule objects matching the given {@link ModuleRevisionId}.
      */
-    public T[] getRules(ModuleRevisionId mrid, Filter<T> filter) {
+    public List<T> getRules(ModuleRevisionId mrid, Filter<T> filter) {
         Checks.checkNotNull(mrid, "mrid");
         Checks.checkNotNull(filter, "filter");
         Map<String, String> moduleAttributes = mrid.getAttributes();
         return getRules(moduleAttributes, filter);
     }
 
-    private T[] getRules(Map<String, String> moduleAttributes, Filter<T> filter) {
-        List<MapMatcher> matchers = matcher_lookup.get(moduleAttributes);
-        List<T> matchingRules = new ArrayList<T>();
+    private List<T> getRules(Map<String, String> moduleAttributes, Filter<T> filter) {
+        List<MapMatcher> matchers = matcherLookup.get(moduleAttributes);
+        List<T> matchingRules = new ArrayList<>();
         for (MapMatcher midm : matchers) {
             T rule = rules.get(midm);
             if (filter.accept(rule)) {
                 matchingRules.add(rule);
             }
         }
-        return matchingRules.toArray((T[]) new Object[0]);
+        return matchingRules;
     }
 
     /**
@@ -245,8 +245,7 @@ public class ModuleRules<T> {
         return Collections.unmodifiableMap(rules);
     }
 
-    @Override
-    public Object clone() {
-        return new ModuleRules<T>(rules);
+    public ModuleRules<T> clone() {
+        return new ModuleRules<>(rules);
     }
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/module/status/StatusManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/status/StatusManager.java b/src/java/org/apache/ivy/core/module/status/StatusManager.java
index 0e355d7..ba57a0e 100644
--- a/src/java/org/apache/ivy/core/module/status/StatusManager.java
+++ b/src/java/org/apache/ivy/core/module/status/StatusManager.java
@@ -20,9 +20,7 @@ package org.apache.ivy.core.module.status;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
 
 import org.apache.ivy.core.IvyContext;
@@ -42,7 +40,7 @@ public class StatusManager {
         return IvyContext.getContext().getSettings().getStatusManager();
     }
 
-    private List<Status> status = new ArrayList<Status>();
+    private final List<Status> statuses = new ArrayList<>();
 
     private String defaultStatus;
 
@@ -54,7 +52,7 @@ public class StatusManager {
     private String deliveryStatusListString;
 
     public StatusManager(Status[] status, String defaultStatus) {
-        this.status.addAll(Arrays.asList(status));
+        this.statuses.addAll(Arrays.asList(status));
         this.defaultStatus = defaultStatus;
 
         computeMaps();
@@ -64,7 +62,7 @@ public class StatusManager {
     }
 
     public void addStatus(Status status) {
-        this.status.add(status);
+        this.statuses.add(status);
     }
 
     public void setDefaultStatus(String defaultStatus) {
@@ -72,22 +70,20 @@ public class StatusManager {
     }
 
     public List<Status> getStatuses() {
-        return status;
+        return statuses;
     }
 
     private void computeMaps() {
-        if (status.isEmpty()) {
-            throw new IllegalStateException("badly configured statuses: no status found");
+        if (statuses.isEmpty()) {
+            throw new IllegalStateException("badly configured statuses: none found");
         }
-        statusPriorityMap = new HashMap<String, Integer>();
-        for (ListIterator<Status> iter = status.listIterator(); iter.hasNext();) {
-            Status status = iter.next();
-            statusPriorityMap.put(status.getName(), new Integer(iter.previousIndex()));
+        statusPriorityMap = new HashMap<>();
+        for (Status status : statuses) {
+            statusPriorityMap.put(status.getName(), statuses.indexOf(status));
         }
-        statusIntegrationMap = new HashMap<String, Boolean>();
-        for (Iterator<Status> iter = status.iterator(); iter.hasNext();) {
-            Status status = iter.next();
-            statusIntegrationMap.put(status.getName(), Boolean.valueOf(status.isIntegration()));
+        statusIntegrationMap = new HashMap<>();
+        for (Status status : statuses) {
+            statusIntegrationMap.put(status.getName(), status.isIntegration());
         }
     }
 
@@ -102,19 +98,19 @@ public class StatusManager {
         if (statusPriorityMap == null) {
             computeMaps();
         }
-        Integer priority = (Integer) statusPriorityMap.get(status);
+        Integer priority = statusPriorityMap.get(status);
         if (priority == null) {
             Message.debug("unknown status " + status + ": assuming lowest priority");
             return Integer.MAX_VALUE;
         }
-        return priority.intValue();
+        return priority;
     }
 
     public boolean isIntegration(String status) {
         if (statusIntegrationMap == null) {
             computeMaps();
         }
-        Boolean isIntegration = (Boolean) statusIntegrationMap.get(status);
+        Boolean isIntegration = statusIntegrationMap.get(status);
         if (isIntegration == null) {
             Message.debug("unknown status " + status + ": assuming integration");
             return true;
@@ -124,8 +120,8 @@ public class StatusManager {
 
     public String getDeliveryStatusListString() {
         if (deliveryStatusListString == null) {
-            StringBuffer ret = new StringBuffer();
-            for (Status status : this.status) {
+            StringBuilder ret = new StringBuilder();
+            for (Status status : statuses) {
                 if (!status.isIntegration()) {
                     ret.append(status.getName()).append(",");
                 }
@@ -140,10 +136,10 @@ public class StatusManager {
 
     public String getDefaultStatus() {
         if (defaultStatus == null) {
-            if (status.isEmpty()) {
-                throw new IllegalStateException("badly configured statuses: no status found");
+            if (statuses.isEmpty()) {
+                throw new IllegalStateException("badly configured statuses: none found");
             }
-            defaultStatus = ((Status) status.get(status.size() - 1)).getName();
+            defaultStatus = statuses.get(statuses.size() - 1).getName();
         }
         return defaultStatus;
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/pack/PackagingManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/pack/PackagingManager.java b/src/java/org/apache/ivy/core/pack/PackagingManager.java
index 0271f87..6d9a03e 100644
--- a/src/java/org/apache/ivy/core/pack/PackagingManager.java
+++ b/src/java/org/apache/ivy/core/pack/PackagingManager.java
@@ -55,7 +55,7 @@ public class PackagingManager implements IvySettingsAware {
                 throw new IllegalStateException("Unsupported archive only packing type '"
                         + packings[i] + "' in the streamed chain: " + packaging);
             }
-            ext = ((StreamPacking) packing).getUnpackedExtension(ext);
+            ext = packing.getUnpackedExtension(ext);
         }
         ArchivePacking packing = settings.getPackingRegistry().get(packings[0]);
         if (packing == null) {
@@ -110,12 +110,11 @@ public class PackagingManager implements IvySettingsAware {
                 }
             }
         }
-        final DefaultArtifact unpacked = new DefaultArtifact(artifact.getModuleRevisionId(),
+
+        return new DefaultArtifact(artifact.getModuleRevisionId(),
                 artifact.getPublicationDate(), artifact.getName(),
                 artifact.getType() + "_unpacked", ext);
 
-        return unpacked;
-
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/pack/PackingRegistry.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/pack/PackingRegistry.java b/src/java/org/apache/ivy/core/pack/PackingRegistry.java
index 6688677f..77684dc 100644
--- a/src/java/org/apache/ivy/core/pack/PackingRegistry.java
+++ b/src/java/org/apache/ivy/core/pack/PackingRegistry.java
@@ -22,7 +22,7 @@ import java.util.Map;
 
 public class PackingRegistry {
 
-    private Map<String, ArchivePacking> packings = new HashMap<String, ArchivePacking>();
+    private Map<String, ArchivePacking> packings = new HashMap<>();
 
     public PackingRegistry() {
         // register defaults

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/pack/ZipPacking.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/pack/ZipPacking.java b/src/java/org/apache/ivy/core/pack/ZipPacking.java
index 35da694..76d06ad 100644
--- a/src/java/org/apache/ivy/core/pack/ZipPacking.java
+++ b/src/java/org/apache/ivy/core/pack/ZipPacking.java
@@ -49,9 +49,7 @@ public class ZipPacking extends ArchivePacking {
 
     @Override
     public void unpack(InputStream packed, File dest) throws IOException {
-        ZipInputStream zip = null;
-        try {
-            zip = new ZipInputStream(packed);
+        try (ZipInputStream zip = new ZipInputStream(packed)) {
             ZipEntry entry = null;
             while (((entry = zip.getNextEntry()) != null)) {
                 File f = new File(dest, entry.getName());
@@ -71,14 +69,6 @@ public class ZipPacking extends ArchivePacking {
 
                 f.setLastModified(entry.getTime());
             }
-        } finally {
-            if (zip != null) {
-                try {
-                    zip.close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/publish/PublishEngine.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/publish/PublishEngine.java b/src/java/org/apache/ivy/core/publish/PublishEngine.java
index a43240c..9730957 100644
--- a/src/java/org/apache/ivy/core/publish/PublishEngine.java
+++ b/src/java/org/apache/ivy/core/publish/PublishEngine.java
@@ -118,7 +118,7 @@ public class PublishEngine {
                     tmp.deleteOnExit();
 
                     String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
-                    Set<String> confsToRemove = new HashSet<String>(Arrays.asList(md
+                    Set<String> confsToRemove = new HashSet<>(Arrays.asList(md
                             .getConfigurationsNames()));
                     confsToRemove.removeAll(Arrays.asList(confs));
 
@@ -183,24 +183,24 @@ public class PublishEngine {
 
     public Collection<Artifact> publish(ModuleDescriptor md, Collection<String> srcArtifactPattern,
             DependencyResolver resolver, PublishOptions options) throws IOException {
-        Collection<Artifact> missing = new ArrayList<Artifact>();
-        Set<Artifact> artifactsSet = new LinkedHashSet<Artifact>();
+        Collection<Artifact> missing = new ArrayList<>();
+        Set<Artifact> artifactsSet = new LinkedHashSet<>();
         String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
 
-        for (int i = 0; i < confs.length; i++) {
-            Artifact[] artifacts = md.getArtifacts(confs[i]);
+        for (String conf : confs) {
+            Artifact[] artifacts = md.getArtifacts(conf);
             artifactsSet.addAll(Arrays.asList(artifacts));
         }
         Artifact[] extraArtifacts = options.getExtraArtifacts();
         if (extraArtifacts != null) {
-            for (int i = 0; i < extraArtifacts.length; i++) {
-                artifactsSet.add(new MDArtifact(md, extraArtifacts[i].getName(), extraArtifacts[i]
-                        .getType(), extraArtifacts[i].getExt(), extraArtifacts[i].getUrl(),
-                        extraArtifacts[i].getQualifiedExtraAttributes()));
+            for (Artifact extraArtifact : extraArtifacts) {
+                artifactsSet.add(new MDArtifact(md, extraArtifact.getName(), extraArtifact
+                        .getType(), extraArtifact.getExt(), extraArtifact.getUrl(),
+                        extraArtifact.getQualifiedExtraAttributes()));
             }
         }
         // now collects artifacts files
-        Map<Artifact, File> artifactsFiles = new LinkedHashMap<Artifact, File>();
+        Map<Artifact, File> artifactsFiles = new LinkedHashMap<>();
         for (Artifact artifact : artifactsSet) {
             for (String pattern : srcArtifactPattern) {
                 File artifactFile = settings.resolveFile(IvyPatternHelper.substitute(
@@ -211,7 +211,7 @@ public class PublishEngine {
                 }
             }
             if (!artifactsFiles.containsKey(artifact)) {
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 sb.append("missing artifact ").append(artifact).append(":\n");
                 for (String pattern : srcArtifactPattern) {
                     sb.append("\t").append(settings.resolveFile(IvyPatternHelper.substitute(pattern, artifact))).append(" file does not exist\n");

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java b/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
index 03c2441..6ca13ca 100644
--- a/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
+++ b/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
@@ -182,14 +182,11 @@ public class ArtifactDownloadReport {
     }
 
     public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
+        if (!(obj instanceof ArtifactDownloadReport)) {
             return false;
         }
-        if (getClass() != obj.getClass()) {
-            return false;
+        if (this == obj) {
+            return true;
         }
         ArtifactDownloadReport other = (ArtifactDownloadReport) obj;
         if (artifact == null) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java b/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
index 47fa680..c8e2854 100644
--- a/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
+++ b/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
@@ -56,13 +56,13 @@ public class ConfigurationResolveReport {
 
     private final ResolveOptions options;
 
-    private Map<IvyNode, List<ArtifactDownloadReport>> dependencyReports = new LinkedHashMap<IvyNode, List<ArtifactDownloadReport>>();
+    private Map<IvyNode, List<ArtifactDownloadReport>> dependencyReports = new LinkedHashMap<>();
 
-    private Map<ModuleRevisionId, IvyNode> dependencies = new LinkedHashMap<ModuleRevisionId, IvyNode>();
+    private Map<ModuleRevisionId, IvyNode> dependencies = new LinkedHashMap<>();
 
     private final ResolveEngine resolveEngine;
 
-    private Map<ModuleId, Collection<IvyNode>> modulesIdsMap = new LinkedHashMap<ModuleId, Collection<IvyNode>>();
+    private Map<ModuleId, Collection<IvyNode>> modulesIdsMap = new LinkedHashMap<>();
 
     private List<ModuleId> modulesIds;
 
@@ -98,7 +98,7 @@ public class ConfigurationResolveReport {
                 parser.parse(previousReportFile);
                 List<ModuleRevisionId> previousDeps = Arrays.asList(parser
                         .getDependencyRevisionIds());
-                HashSet<ModuleRevisionId> previousDepSet = new HashSet<ModuleRevisionId>(
+                HashSet<ModuleRevisionId> previousDepSet = new HashSet<>(
                         previousDeps);
                 hasChanged = !previousDepSet.equals(getModuleRevisionIds());
             } catch (Exception e) {
@@ -126,7 +126,7 @@ public class ConfigurationResolveReport {
      * @return all non evicted and non error dependency mrids
      */
     public Set<ModuleRevisionId> getModuleRevisionIds() {
-        Set<ModuleRevisionId> mrids = new LinkedHashSet<ModuleRevisionId>();
+        Set<ModuleRevisionId> mrids = new LinkedHashSet<>();
         for (IvyNode node : getDependencies()) {
             if (!node.isEvicted(getConfiguration()) && !node.hasProblem()) {
                 mrids.add(node.getResolvedId());
@@ -148,7 +148,7 @@ public class ConfigurationResolveReport {
     public void addDependency(IvyNode node, DownloadReport report) {
         dependencies.put(node.getId(), node);
         dependencies.put(node.getResolvedId(), node);
-        List<ArtifactDownloadReport> adrs = new ArrayList<ArtifactDownloadReport>();
+        List<ArtifactDownloadReport> adrs = new ArrayList<>();
         Artifact[] artifacts = node.getArtifacts(conf);
         for (Artifact artifact : artifacts) {
             ArtifactDownloadReport artifactReport = report.getArtifactReport(artifact);
@@ -174,7 +174,7 @@ public class ConfigurationResolveReport {
     }
 
     public IvyNode[] getUnresolvedDependencies() {
-        List<IvyNode> unresolved = new ArrayList<IvyNode>();
+        List<IvyNode> unresolved = new ArrayList<>();
         for (IvyNode node : getDependencies()) {
             if (node.hasProblem()) {
                 unresolved.add(node);
@@ -184,11 +184,11 @@ public class ConfigurationResolveReport {
     }
 
     private Collection<IvyNode> getDependencies() {
-        return new LinkedHashSet<IvyNode>(dependencies.values());
+        return new LinkedHashSet<>(dependencies.values());
     }
 
     public IvyNode[] getEvictedNodes() {
-        List<IvyNode> evicted = new ArrayList<IvyNode>();
+        List<IvyNode> evicted = new ArrayList<>();
         for (IvyNode node : getDependencies()) {
             if (node.isEvicted(conf)) {
                 evicted.add(node);
@@ -198,7 +198,7 @@ public class ConfigurationResolveReport {
     }
 
     private Set<ModuleRevisionId> getEvictedMrids() {
-        Set<ModuleRevisionId> evicted = new LinkedHashSet<ModuleRevisionId>();
+        Set<ModuleRevisionId> evicted = new LinkedHashSet<>();
         IvyNode[] evictedNodes = getEvictedNodes();
         for (IvyNode node : evictedNodes) {
             evicted.add(node.getId());
@@ -207,7 +207,7 @@ public class ConfigurationResolveReport {
     }
 
     public IvyNode[] getDownloadedNodes() {
-        List<IvyNode> downloaded = new ArrayList<IvyNode>();
+        List<IvyNode> downloaded = new ArrayList<>();
         for (IvyNode node : getDependencies()) {
             if (node.isDownloaded() && node.getRealNode() == node) {
                 downloaded.add(node);
@@ -217,7 +217,7 @@ public class ConfigurationResolveReport {
     }
 
     public IvyNode[] getSearchedNodes() {
-        List<IvyNode> downloaded = new ArrayList<IvyNode>();
+        List<IvyNode> downloaded = new ArrayList<>();
         for (IvyNode node : getDependencies()) {
             if (node.isSearched() && node.getRealNode() == node) {
                 downloaded.add(node);
@@ -252,12 +252,12 @@ public class ConfigurationResolveReport {
                 ModuleId mid = dependency.getResolvedId().getModuleId();
                 Collection<IvyNode> deps = modulesIdsMap.get(mid);
                 if (deps == null) {
-                    deps = new LinkedHashSet<IvyNode>();
+                    deps = new LinkedHashSet<>();
                     modulesIdsMap.put(mid, deps);
                 }
                 deps.add(dependency);
             }
-            modulesIds = new ArrayList<ModuleId>(modulesIdsMap.keySet());
+            modulesIds = new ArrayList<>(modulesIdsMap.keySet());
         }
         return Collections.unmodifiableList(modulesIds);
     }
@@ -305,7 +305,7 @@ public class ConfigurationResolveReport {
      */
     public ArtifactDownloadReport[] getArtifactsReports(DownloadStatus downloadStatus,
             boolean withEvicted) {
-        Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
+        Collection<ArtifactDownloadReport> all = new LinkedHashSet<>();
         Collection<ModuleRevisionId> evictedMrids = null;
         if (!withEvicted) {
             evictedMrids = getEvictedMrids();
@@ -353,9 +353,10 @@ public class ConfigurationResolveReport {
 
     public static ArtifactDownloadReport[] filterOutMergedArtifacts(
             ArtifactDownloadReport[] allFailedReports) {
-        Collection<ArtifactDownloadReport> adrs = new ArrayList<ArtifactDownloadReport>(
+        Collection<ArtifactDownloadReport> adrs = new ArrayList<>(
                 Arrays.asList(allFailedReports));
-        for (Iterator<ArtifactDownloadReport> iterator = adrs.iterator(); iterator.hasNext();) {
+        Iterator<ArtifactDownloadReport> iterator = adrs.iterator();
+        while (iterator.hasNext()) {
             ArtifactDownloadReport adr = iterator.next();
 
             if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/report/DownloadReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/report/DownloadReport.java b/src/java/org/apache/ivy/core/report/DownloadReport.java
index f2dfcb6..267c7b1 100644
--- a/src/java/org/apache/ivy/core/report/DownloadReport.java
+++ b/src/java/org/apache/ivy/core/report/DownloadReport.java
@@ -19,7 +19,6 @@ package org.apache.ivy.core.report;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -29,29 +28,27 @@ import org.apache.ivy.core.module.descriptor.Artifact;
  *
  */
 public class DownloadReport {
-    private Map artifacts = new HashMap();
+    private final Map<Artifact, ArtifactDownloadReport> artifacts = new HashMap<>();
 
     public void addArtifactReport(ArtifactDownloadReport adr) {
         artifacts.put(adr.getArtifact(), adr);
     }
 
     public ArtifactDownloadReport[] getArtifactsReports() {
-        return (ArtifactDownloadReport[]) artifacts.values().toArray(
-            new ArtifactDownloadReport[artifacts.size()]);
+        return artifacts.values().toArray(new ArtifactDownloadReport[artifacts.size()]);
     }
 
     public ArtifactDownloadReport[] getArtifactsReports(DownloadStatus status) {
-        List ret = new ArrayList(artifacts.size());
-        for (Iterator iter = artifacts.values().iterator(); iter.hasNext();) {
-            ArtifactDownloadReport adr = (ArtifactDownloadReport) iter.next();
+        List<ArtifactDownloadReport> ret = new ArrayList<>(artifacts.size());
+        for (ArtifactDownloadReport adr : artifacts.values()) {
             if (adr.getDownloadStatus() == status) {
                 ret.add(adr);
             }
         }
-        return (ArtifactDownloadReport[]) ret.toArray(new ArtifactDownloadReport[ret.size()]);
+        return ret.toArray(new ArtifactDownloadReport[ret.size()]);
     }
 
     public ArtifactDownloadReport getArtifactReport(Artifact artifact) {
-        return (ArtifactDownloadReport) artifacts.get(artifact);
+        return artifacts.get(artifact);
     }
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/report/ResolveReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/report/ResolveReport.java b/src/java/org/apache/ivy/core/report/ResolveReport.java
index 01be748..5bc7e56 100644
--- a/src/java/org/apache/ivy/core/report/ResolveReport.java
+++ b/src/java/org/apache/ivy/core/report/ResolveReport.java
@@ -50,16 +50,16 @@ import org.apache.ivy.util.filter.Filter;
 public class ResolveReport {
     private ModuleDescriptor md;
 
-    private Map<String, ConfigurationResolveReport> confReports = new LinkedHashMap<String, ConfigurationResolveReport>();
+    private Map<String, ConfigurationResolveReport> confReports = new LinkedHashMap<>();
 
-    private List<String> problemMessages = new ArrayList<String>();
+    private List<String> problemMessages = new ArrayList<>();
 
     /**
      * the list of all dependencies resolved, ordered from the more dependent to the less dependent
      */
-    private List<IvyNode> dependencies = new ArrayList<IvyNode>();
+    private List<IvyNode> dependencies = new ArrayList<>();
 
-    private List<Artifact> artifacts = new ArrayList<Artifact>();
+    private List<Artifact> artifacts = new ArrayList<>();
 
     private long resolveTime;
 
@@ -101,8 +101,8 @@ public class ResolveReport {
 
     public void output(ReportOutputter[] outputters, ResolutionCacheManager cacheMgr,
             ResolveOptions options) throws IOException {
-        for (int i = 0; i < outputters.length; i++) {
-            outputters[i].output(this, cacheMgr, options);
+        for (ReportOutputter outputter : outputters) {
+            outputter.output(this, cacheMgr, options);
         }
     }
 
@@ -111,7 +111,7 @@ public class ResolveReport {
     }
 
     public IvyNode[] getEvictedNodes() {
-        Collection<IvyNode> all = new LinkedHashSet<IvyNode>();
+        Collection<IvyNode> all = new LinkedHashSet<>();
         for (ConfigurationResolveReport report : confReports.values()) {
             all.addAll(Arrays.asList(report.getEvictedNodes()));
         }
@@ -119,7 +119,7 @@ public class ResolveReport {
     }
 
     public IvyNode[] getUnresolvedDependencies() {
-        Collection<IvyNode> all = new LinkedHashSet<IvyNode>();
+        Collection<IvyNode> all = new LinkedHashSet<>();
         for (ConfigurationResolveReport report : confReports.values()) {
             all.addAll(Arrays.asList(report.getUnresolvedDependencies()));
         }
@@ -161,7 +161,7 @@ public class ResolveReport {
      */
     public ArtifactDownloadReport[] getArtifactsReports(DownloadStatus downloadStatus,
             boolean withEvicted) {
-        Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
+        Collection<ArtifactDownloadReport> all = new LinkedHashSet<>();
         for (ConfigurationResolveReport report : confReports.values()) {
             ArtifactDownloadReport[] reports = report.getArtifactsReports(downloadStatus,
                 withEvicted);
@@ -171,7 +171,7 @@ public class ResolveReport {
     }
 
     public ArtifactDownloadReport[] getArtifactsReports(ModuleRevisionId mrid) {
-        Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
+        Collection<ArtifactDownloadReport> all = new LinkedHashSet<>();
         for (ConfigurationResolveReport report : confReports.values()) {
             all.addAll(Arrays.asList(report.getDownloadReports(mrid)));
         }
@@ -207,20 +207,18 @@ public class ResolveReport {
     }
 
     public List<String> getAllProblemMessages() {
-        List<String> ret = new ArrayList<String>(problemMessages);
+        List<String> ret = new ArrayList<>(problemMessages);
         for (ConfigurationResolveReport r : confReports.values()) {
-            IvyNode[] unresolved = r.getUnresolvedDependencies();
-            for (int i = 0; i < unresolved.length; i++) {
-                String errMsg = unresolved[i].getProblemMessage();
+            for (IvyNode unresolved : r.getUnresolvedDependencies()) {
+                String errMsg = unresolved.getProblemMessage();
                 if (errMsg.length() > 0) {
-                    ret.add("unresolved dependency: " + unresolved[i].getId() + ": " + errMsg);
+                    ret.add("unresolved dependency: " + unresolved.getId() + ": " + errMsg);
                 } else {
-                    ret.add("unresolved dependency: " + unresolved[i].getId());
+                    ret.add("unresolved dependency: " + unresolved.getId());
                 }
             }
-            ArtifactDownloadReport[] adrs = r.getFailedArtifactsReports();
-            for (int i = 0; i < adrs.length; i++) {
-                ret.add("download failed: " + adrs[i].getArtifact());
+            for (ArtifactDownloadReport adr : r.getFailedArtifactsReports()) {
+                ret.add("download failed: " + adr.getArtifact());
             }
         }
         return ret;
@@ -229,16 +227,15 @@ public class ResolveReport {
     public void setDependencies(List<IvyNode> dependencies, Filter<Artifact> artifactFilter) {
         this.dependencies = dependencies;
         // collect list of artifacts
-        artifacts = new ArrayList<Artifact>();
+        artifacts = new ArrayList<>();
         for (IvyNode dependency : dependencies) {
             if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()) {
                 artifacts.addAll(Arrays.asList(dependency.getSelectedArtifacts(artifactFilter)));
             }
             // update the configurations reports with the dependencies
             // these reports will be completed later with download information, if any
-            String[] dconfs = dependency.getRootModuleConfigurations();
-            for (int j = 0; j < dconfs.length; j++) {
-                ConfigurationResolveReport configurationReport = getConfigurationReport(dconfs[j]);
+            for (String dconf : dependency.getRootModuleConfigurations()) {
+                ConfigurationResolveReport configurationReport = getConfigurationReport(dconf);
                 if (configurationReport != null) {
                     configurationReport.addDependency(dependency);
                 }
@@ -272,8 +269,8 @@ public class ResolveReport {
      * @return a list of ModuleId
      */
     public List<ModuleId> getModuleIds() {
-        List<ModuleId> ret = new ArrayList<ModuleId>();
-        List<IvyNode> sortedDependencies = new ArrayList<IvyNode>(dependencies);
+        List<ModuleId> ret = new ArrayList<>();
+        List<IvyNode> sortedDependencies = new ArrayList<>(dependencies);
         for (IvyNode dependency : sortedDependencies) {
             ModuleId mid = dependency.getResolvedId().getModuleId();
             if (!ret.contains(mid)) {
@@ -329,11 +326,10 @@ public class ResolveReport {
      */
     @SuppressWarnings("unused")
     private String[] getExtendingConfs(String extended) {
-        String[] allConfs = md.getConfigurationsNames();
-        Set<String> extendingConfs = new HashSet<String>();
+        Set<String> extendingConfs = new HashSet<>();
         extendingConfs.add(extended);
-        for (int i = 0; i < allConfs.length; i++) {
-            gatherExtendingConfs(extendingConfs, allConfs[i], extended);
+        for (String conf : md.getConfigurationsNames()) {
+            gatherExtendingConfs(extendingConfs, conf, extended);
         }
         return extendingConfs.toArray(new String[extendingConfs.size()]);
     }
@@ -342,20 +338,20 @@ public class ResolveReport {
         if (extendingConfs.contains(conf)) {
             return true;
         }
-        String[] ext = md.getConfiguration(conf).getExtends();
-        if (ext == null || ext.length == 0) {
+        String[] exts = md.getConfiguration(conf).getExtends();
+        if (exts == null || exts.length == 0) {
             return false;
         }
-        for (int i = 0; i < ext.length; i++) {
-            if (extendingConfs.contains(ext[i])) {
+        for (String ext : exts) {
+            if (extendingConfs.contains(ext)) {
                 extendingConfs.add(conf);
                 return true;
             }
-            if (ext[i].equals(extended)) {
+            if (ext.equals(extended)) {
                 extendingConfs.add(conf);
                 return true;
             }
-            if (gatherExtendingConfs(extendingConfs, ext[i], extended)) {
+            if (gatherExtendingConfs(extendingConfs, ext, extended)) {
                 extendingConfs.add(conf);
                 return true;
             }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java b/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
index ae769cc..c700b02 100644
--- a/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
+++ b/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
@@ -22,13 +22,14 @@ import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.TreeSet;
 
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolveEngine;
@@ -85,17 +86,17 @@ public class RepositoryManagementEngine {
     /**
      * ModuleDescriptors stored by ModuleRevisionId
      */
-    private Map/* <ModuleRevisionId,ModuleDescriptor> */revisions = new HashMap();
+    private Map<ModuleRevisionId, ModuleDescriptor> revisions = new HashMap<>();
 
     /**
      * ModuleRevisionId for which loading was not possible, with corresponding error message.
      */
-    private Map/* <ModuleRevisionId,String> */errors = new HashMap();
+    private Map<ModuleRevisionId, String> errors = new HashMap<>();
 
     /**
-     * List of ModuleRevisionId per ModuleId.
+     * List of ModuleDescriptor per ModuleId.
      */
-    private Map/* <ModuleId,Collection<ModuleRevisionId>> */modules = new HashMap();
+    private Map<ModuleId, Collection<ModuleDescriptor>> modules = new HashMap<>();
 
     // /////////////////////////////////////////
     // state loaded on #analyze()
@@ -109,12 +110,12 @@ public class RepositoryManagementEngine {
     /**
      * Cache from requested module revision id to actual module revision id.
      */
-    private Map/* <ModuleRevisionId,ModuleRevisionId> */cache = new HashMap();
+    private Map<ModuleRevisionId, ModuleRevisionId> cache = new HashMap<>();
 
     /**
      * list of dependers per ModuleRevisionId.
      */
-    private Map/* <ModuleRevisionId,List<ModuleRevisionId>> */dependers = new HashMap();
+    private Map<ModuleRevisionId, List<ModuleRevisionId>> dependers = new HashMap<>();
 
     // /////////////////////////////////////////
     // dependencies
@@ -148,22 +149,19 @@ public class RepositoryManagementEngine {
         Message.rawinfo("searching modules... ");
         ModuleRevisionId[] mrids = searchModules();
         Message.info("loading repository metadata...");
-        for (int i = 0; i < mrids.length; i++) {
+        for (ModuleRevisionId mrid : mrids) {
             try {
-                loadModuleRevision(mrids[i]);
+                loadModuleRevision(mrid);
             } catch (Exception e) {
                 Message.debug(e);
-                errors.put(mrids[i], e.getMessage());
+                errors.put(mrid, e.getMessage());
             }
         }
         long endTime = System.currentTimeMillis();
-        Message.info("\nrepository loaded: "
-                + modules.size()
-                + " modules; "
-                + revisions.size()
-                + " revisions; "
-                + (settings.dumpMemoryUsage() ? (MemoryUtil.getUsedMemory() - startingMemoryUse)
-                        / KILO + "kB; " : "") + (endTime - startTime) / THOUSAND + "s");
+        Message.info(String.format("\nrepository loaded: %d modules; %d revisions; %s%ss",
+                modules.size(), revisions.size(), settings.dumpMemoryUsage()
+                        ? (MemoryUtil.getUsedMemory() - startingMemoryUse) / KILO + "kB; " : "",
+                (endTime - startTime) / THOUSAND));
         loaded = true;
     }
 
@@ -181,14 +179,11 @@ public class RepositoryManagementEngine {
     public void analyze() {
         ensureLoaded();
         Message.info("\nanalyzing dependencies...");
-        for (Iterator iterator = revisions.values().iterator(); iterator.hasNext();) {
-            ModuleDescriptor md = (ModuleDescriptor) iterator.next();
-            DependencyDescriptor[] dds = md.getDependencies();
-            for (int i = 0; i < dds.length; i++) {
-                ModuleRevisionId dep = getDependency(dds[i]);
+        for (ModuleDescriptor md : revisions.values()) {
+            for (DependencyDescriptor dd : md.getDependencies()) {
+                ModuleRevisionId dep = getDependency(dd);
                 if (dep == null) {
-                    Message.warn("inconsistent repository: declared dependency not found: "
-                            + dds[i]);
+                    Message.warn("inconsistent repository: declared dependency not found: " + dd);
                 } else {
                     getDependers(dep).add(md.getModuleRevisionId());
                 }
@@ -233,30 +228,27 @@ public class RepositoryManagementEngine {
      *             if the repository has not been analyzed yet
      * @see #analyze()
      */
-    public Collection getOrphans() {
+    public Collection<ModuleRevisionId> getOrphans() {
         ensureAnalyzed();
-        Collection orphans = new HashSet(revisions.keySet());
+        Collection<ModuleRevisionId> orphans = new HashSet<>(revisions.keySet());
         orphans.removeAll(dependers.keySet());
         return orphans;
     }
 
     private ModuleRevisionId[] searchModules() {
-        ModuleRevisionId[] mrids = searchEngine.listModules(ModuleRevisionId.newInstance(
+        return searchEngine.listModules(ModuleRevisionId.newInstance(
             PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION,
             PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
             RegexpPatternMatcher.INSTANCE);
-        return mrids;
     }
 
     private ModuleRevisionId getDependency(DependencyDescriptor dd) {
         ModuleRevisionId askedMrid = dd.getDependencyRevisionId();
         VersionMatcher vmatcher = settings.getVersionMatcher();
         if (vmatcher.isDynamic(askedMrid)) {
-            ModuleRevisionId mrid = (ModuleRevisionId) cache.get(askedMrid);
+            ModuleRevisionId mrid = cache.get(askedMrid);
             if (mrid == null) {
-                Collection revs = getAllRevisions(askedMrid);
-                for (Iterator iterator = revs.iterator(); iterator.hasNext();) {
-                    ModuleDescriptor md = (ModuleDescriptor) iterator.next();
+                for (ModuleDescriptor md : getAllRevisions(askedMrid)) {
                     if (vmatcher.needModuleDescriptor(askedMrid, md.getResolvedModuleRevisionId())) {
                         if (vmatcher.accept(askedMrid, md)) {
                             mrid = md.getResolvedModuleRevisionId();
@@ -281,10 +273,10 @@ public class RepositoryManagementEngine {
         }
     }
 
-    private Collection getDependers(ModuleRevisionId id) {
-        Collection depders = (Collection) dependers.get(id);
+    private Collection<ModuleRevisionId> getDependers(ModuleRevisionId id) {
+        List<ModuleRevisionId> depders = dependers.get(id);
         if (depders == null) {
-            depders = new ArrayList();
+            depders = new ArrayList<>();
             dependers.put(id, depders);
         }
         return depders;
@@ -302,13 +294,11 @@ public class RepositoryManagementEngine {
         Message.progress();
     }
 
-    private Collection getAllRevisions(ModuleRevisionId id) {
-        Collection revisions = (Collection) modules.get(id.getModuleId());
+    private Collection<ModuleDescriptor> getAllRevisions(ModuleRevisionId id) {
+        Collection<ModuleDescriptor> revisions = modules.get(id.getModuleId());
         if (revisions == null) {
-            revisions = new TreeSet(new Comparator() {
-                public int compare(Object o1, Object o2) {
-                    ModuleDescriptor md1 = (ModuleDescriptor) o1;
-                    ModuleDescriptor md2 = (ModuleDescriptor) o2;
+            revisions = new TreeSet<>(new Comparator<ModuleDescriptor>() {
+                public int compare(ModuleDescriptor md1, ModuleDescriptor md2) {
                     // we use reverse order compared to latest revision, to have latest revision
                     // first
                     return settings.getDefaultLatestStrategy().sort(new ArtifactInfo[] {md1, md2})


Mime
View raw message