ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject [6/6] ant-ivy git commit: use java 5 constructs
Date Sun, 04 Jan 2015 18:00:42 GMT
use java 5 constructs


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

Branch: refs/heads/master
Commit: e1276e0ac2407111d7bebd16e32a944660166ff6
Parents: a42d2dc
Author: Nicolas Lalevée <nicolas.lalevee@hibnet.org>
Authored: Tue Dec 30 17:55:53 2014 +0100
Committer: Nicolas Lalevée <nicolas.lalevee@hibnet.org>
Committed: Sun Jan 4 19:00:21 2015 +0100

----------------------------------------------------------------------
 src/java/org/apache/ivy/Ivy.java                |  17 +-
 src/java/org/apache/ivy/ant/FixDepsTask.java    |  10 +-
 src/java/org/apache/ivy/ant/IvyBuildList.java   | 123 +++++------
 src/java/org/apache/ivy/ant/IvyDependency.java  |  25 +--
 src/java/org/apache/ivy/ant/IvyResolve.java     |  27 +--
 .../cache/DefaultRepositoryCacheManager.java    |  19 +-
 .../core/module/descriptor/Configuration.java   |  20 +-
 .../descriptor/DefaultModuleDescriptor.java     | 119 +++++------
 .../ivy/core/module/id/MatcherLookup.java       |  38 ++--
 .../org/apache/ivy/core/module/id/ModuleId.java |  25 ++-
 .../ivy/core/module/id/ModuleRevisionId.java    |  46 +++--
 .../apache/ivy/core/module/id/ModuleRules.java  |  72 +++----
 .../apache/ivy/core/report/ResolveReport.java   |  92 ++++-----
 .../apache/ivy/core/resolve/ResolveData.java    |  48 +++--
 .../apache/ivy/core/resolve/ResolveEngine.java  | 107 +++++-----
 .../apache/ivy/core/resolve/ResolveOptions.java |   7 +-
 .../org/apache/ivy/core/resolve/VisitData.java  |  10 +-
 .../org/apache/ivy/core/resolve/VisitNode.java  |  43 ++--
 .../apache/ivy/core/search/SearchEngine.java    | 196 ++++++++----------
 .../apache/ivy/core/settings/IvySettings.java   | 177 ++++++++--------
 .../org/apache/ivy/osgi/filter/AndFilter.java   |   1 +
 .../apache/ivy/osgi/filter/CompareFilter.java   |  20 +-
 .../ivy/osgi/filter/MultiOperatorFilter.java    |   3 +
 .../org/apache/ivy/osgi/filter/NotFilter.java   |   1 +
 .../org/apache/ivy/osgi/filter/OSGiFilter.java  |   1 +
 .../ivy/osgi/filter/OSGiFilterParser.java       |  36 +++-
 .../org/apache/ivy/osgi/filter/OrFilter.java    |   1 +
 .../ivy/osgi/filter/UniOperatorFilter.java      |   3 +
 .../org/apache/ivy/osgi/obr/OBRResolver.java    |   6 +-
 .../apache/ivy/osgi/obr/xml/OBRXMLParser.java   |  20 +-
 .../apache/ivy/osgi/p2/P2ArtifactParser.java    |   8 +
 .../apache/ivy/osgi/p2/P2CompositeParser.java   |   4 +
 .../apache/ivy/osgi/p2/P2MetadataParser.java    |  30 +++
 .../apache/ivy/osgi/p2/PropertiesParser.java    |   3 +
 .../ivy/osgi/repo/AbstractOSGiResolver.java     |  75 ++++---
 .../updatesite/xml/EclipseUpdateSiteParser.java |   7 +-
 .../ivy/osgi/updatesite/xml/FeatureParser.java  |  15 +-
 .../updatesite/xml/UpdateSiteDigestParser.java  |   6 +-
 .../apache/ivy/osgi/util/DelegatingHandler.java |  19 +-
 .../conflict/AbstractConflictManager.java       |   5 +-
 .../ivy/plugins/conflict/ConflictManager.java   |   5 +-
 .../plugins/conflict/FixedConflictManager.java  |  13 +-
 .../LatestCompatibleConflictManager.java        |  67 +++---
 .../plugins/conflict/LatestConflictManager.java |  24 +--
 .../ivy/plugins/conflict/NoConflictManager.java |   2 +-
 .../plugins/conflict/RegexpConflictManager.java |   6 +-
 .../plugins/conflict/StrictConflictManager.java |   7 +-
 .../plugins/latest/AbstractLatestStrategy.java  |   7 +-
 .../latest/ComparatorLatestStrategy.java        |  12 +-
 .../latest/LatestLexicographicStrategy.java     |   8 +-
 .../plugins/latest/LatestRevisionStrategy.java  |  36 ++--
 .../ivy/plugins/latest/LatestStrategy.java      |   2 +-
 .../ivy/plugins/latest/LatestTimeStrategy.java  |   8 +-
 .../plugins/matcher/AbstractPatternMatcher.java |   1 +
 .../matcher/ExactOrRegexpPatternMatcher.java    |   1 +
 .../plugins/matcher/ExactPatternMatcher.java    |   1 +
 .../ivy/plugins/matcher/GlobPatternMatcher.java |   1 +
 .../apache/ivy/plugins/matcher/MapMatcher.java  |  25 +--
 .../plugins/matcher/RegexpPatternMatcher.java   |   1 +
 .../parser/AbstractModuleDescriptorParser.java  |   9 +-
 .../parser/ModuleDescriptorParserRegistry.java  |   9 +-
 .../ivy/plugins/parser/ParserSettings.java      |   2 +-
 .../ivy/plugins/parser/m2/PomDependencyMgt.java |   4 +-
 .../parser/m2/PomModuleDescriptorBuilder.java   |  95 ++++-----
 .../apache/ivy/plugins/parser/m2/PomReader.java |  46 ++---
 .../parser/xml/XmlModuleDescriptorParser.java   |  44 ++--
 .../plugins/repository/AbstractRepository.java  |   1 +
 .../ivy/plugins/repository/Repository.java      |   4 +-
 .../resolver/AbstractPatternsBasedResolver.java | 137 +++++++------
 .../ivy/plugins/resolver/AbstractResolver.java  |   5 +-
 .../resolver/AbstractSshBasedResolver.java      |   1 +
 .../ivy/plugins/resolver/BasicResolver.java     | 100 ++++-----
 .../ivy/plugins/resolver/BintrayResolver.java   |   2 -
 .../ivy/plugins/resolver/CacheResolver.java     |  14 +-
 .../ivy/plugins/resolver/ChainResolver.java     |  74 +++----
 .../plugins/resolver/DependencyResolver.java    |   6 +-
 .../ivy/plugins/resolver/DualResolver.java      |   7 +
 .../plugins/resolver/FileSystemResolver.java    |  28 ++-
 .../ivy/plugins/resolver/IBiblioResolver.java   |  55 +++--
 .../ivy/plugins/resolver/IvyRepResolver.java    |  29 ++-
 .../ivy/plugins/resolver/JarResolver.java       |   2 +
 .../plugins/resolver/MirroredURLResolver.java   |  16 +-
 .../plugins/resolver/RepositoryResolver.java    |  24 ++-
 .../ivy/plugins/resolver/ResolverSettings.java  |   2 +-
 .../ivy/plugins/resolver/SFTPResolver.java      |   1 +
 .../ivy/plugins/resolver/SshResolver.java       |   1 +
 .../ivy/plugins/resolver/URLResolver.java       |   1 +
 .../ivy/plugins/resolver/VfsResolver.java       |   2 +
 .../ivy/plugins/resolver/VsftpResolver.java     |   1 +
 .../resolver/util/ApacheHttpURLLister.java      |   3 +-
 .../plugins/resolver/util/FileURLLister.java    |   7 +-
 .../plugins/resolver/util/ResolvedResource.java |   1 +
 .../plugins/resolver/util/ResolverHelper.java   |  34 ++-
 .../ivy/plugins/resolver/util/URLLister.java    |   2 +-
 .../apache/ivy/util/AbstractMessageLogger.java  |  82 +-------
 .../apache/ivy/util/ContextualSAXHandler.java   |   9 +-
 .../apache/ivy/util/MessageLoggerEngine.java    |  29 ++-
 .../apache/ivy/util/cli/CommandLineParser.java  |  29 ++-
 .../ivy/util/extendable/ExtendableItem.java     |   6 +-
 .../util/extendable/ExtendableItemHelper.java   |  22 +-
 .../extendable/UnmodifiableExtendableItem.java  |  34 +--
 .../apache/ivy/util/url/ApacheURLLister.java    |  10 +-
 .../apache/ivy/core/module/id/ModuleIdTest.java |  13 --
 .../apache/ivy/core/resolve/ResolveTest.java    | 205 +++++++++----------
 104 files changed, 1483 insertions(+), 1437 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/Ivy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/Ivy.java b/src/java/org/apache/ivy/Ivy.java
index c3799e9..6cbd02c 100644
--- a/src/java/org/apache/ivy/Ivy.java
+++ b/src/java/org/apache/ivy/Ivy.java
@@ -24,7 +24,6 @@ import java.net.URL;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -45,6 +44,7 @@ import org.apache.ivy.core.publish.PublishEngine;
 import org.apache.ivy.core.publish.PublishOptions;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.repository.RepositoryManagementEngine;
+import org.apache.ivy.core.resolve.IvyNode;
 import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolveEngine;
 import org.apache.ivy.core.resolve.ResolveOptions;
@@ -631,7 +631,7 @@ public class Ivy {
     /**
      * Sorts the collection of IvyNode from the less dependent to the more dependent
      */
-    public List sortNodes(Collection nodes, SortOptions options) {
+    public List<IvyNode> sortNodes(Collection<IvyNode> nodes, SortOptions options) {
         pushContext();
         try {
             return getSortEngine().sortNodes(nodes, options);
@@ -654,7 +654,8 @@ public class Ivy {
      *             if a circular dependency exists and circular dependency strategy decide to throw
      *             an exception
      */
-    public List sortModuleDescriptors(Collection moduleDescriptors, SortOptions options) {
+    public List<ModuleDescriptor> sortModuleDescriptors(
+            Collection<ModuleDescriptor> moduleDescriptors, SortOptions options) {
         pushContext();
         try {
             return getSortEngine().sortModuleDescriptors(moduleDescriptors, options);
@@ -750,7 +751,7 @@ public class Ivy {
         }
     }
 
-    public String[] listTokenValues(String token, Map otherTokenValues) {
+    public String[] listTokenValues(String token, Map<String, Object> otherTokenValues) {
         pushContext();
         try {
             return searchEngine.listTokenValues(token, otherTokenValues);
@@ -833,14 +834,12 @@ public class Ivy {
     }
 
     private void postConfigure() {
-        Collection triggers = settings.getTriggers();
-        for (Iterator iter = triggers.iterator(); iter.hasNext();) {
-            Trigger trigger = (Trigger) iter.next();
+        List<Trigger> triggers = settings.getTriggers();
+        for (Trigger trigger : triggers) {
             eventManager.addIvyListener(trigger, trigger.getEventFilter());
         }
 
-        for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
-            DependencyResolver resolver = (DependencyResolver) iter.next();
+        for (DependencyResolver resolver : settings.getResolvers()) {
             if (resolver instanceof BasicResolver) {
                 ((BasicResolver) resolver).setEventManager(eventManager);
             }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/ant/FixDepsTask.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/ant/FixDepsTask.java b/src/java/org/apache/ivy/ant/FixDepsTask.java
index 1be9222..8695cb8 100644
--- a/src/java/org/apache/ivy/ant/FixDepsTask.java
+++ b/src/java/org/apache/ivy/ant/FixDepsTask.java
@@ -32,7 +32,7 @@ public class FixDepsTask extends IvyPostResolveTask {
 
     private File dest;
 
-    private List/* <Keep> */keeps = new ArrayList();
+    private List<Keep> keeps = new ArrayList<Keep>();
 
     public void setToFile(File dest) {
         this.dest = dest;
@@ -59,6 +59,7 @@ public class FixDepsTask extends IvyPostResolveTask {
         return k;
     }
 
+    @Override
     public void doExecute() throws BuildException {
         prepareAndCheck();
 
@@ -72,10 +73,9 @@ public class FixDepsTask extends IvyPostResolveTask {
 
         ResolveReport report = getResolvedReport();
 
-        List/* <ModuleId> */midToKeep = new ArrayList();
-        for (int i = 0; i < keeps.size(); i++) {
-            midToKeep.add(ModuleId.newInstance(((Keep) keeps.get(i)).org,
-                ((Keep) keeps.get(i)).module));
+        List<ModuleId> midToKeep = new ArrayList<ModuleId>();
+        for (Keep keep : keeps) {
+            midToKeep.add(ModuleId.newInstance(keep.org, keep.module));
         }
 
         ModuleDescriptor md = report.toFixedModuleDescriptor(getSettings(), midToKeep);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/ant/IvyBuildList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/ant/IvyBuildList.java b/src/java/org/apache/ivy/ant/IvyBuildList.java
index 0620b49..ba4b1a3 100644
--- a/src/java/org/apache/ivy/ant/IvyBuildList.java
+++ b/src/java/org/apache/ivy/ant/IvyBuildList.java
@@ -23,7 +23,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.ListIterator;
@@ -66,7 +65,7 @@ public class IvyBuildList extends IvyTask {
 
     public static final String DESCRIPTOR_REQUIRED = "required";
 
-    private List buildFileSets = new ArrayList(); // List (FileSet)
+    private List<FileSet> buildFileSets = new ArrayList<FileSet>();
 
     private String reference;
 
@@ -152,6 +151,7 @@ public class IvyBuildList extends IvyTask {
         this.onlydirectdep = onlydirectdep;
     }
 
+    @Override
     public void doExecute() throws BuildException {
         if (reference == null) {
             throw new BuildException("reference should be provided in ivy build list");
@@ -168,12 +168,12 @@ public class IvyBuildList extends IvyTask {
 
         Path path = new Path(getProject());
 
-        Map buildFiles = new HashMap(); // Map (ModuleDescriptor -> File buildFile)
-        List independent = new ArrayList();
-        List noDescriptor = new ArrayList();
-        Collection mds = new ArrayList();
+        Map<ModuleDescriptor, File> buildFiles = new HashMap<ModuleDescriptor, File>();
+        List<File> independent = new ArrayList<File>();
+        List<File> noDescriptor = new ArrayList<File>();
+        Collection<ModuleDescriptor> mds = new ArrayList<ModuleDescriptor>();
 
-        Set rootModuleNames = new LinkedHashSet();
+        Set<String> rootModuleNames = new LinkedHashSet<String>();
         if (!"*".equals(root)) {
             StringTokenizer st = new StringTokenizer(root, delimiter);
             while (st.hasMoreTokens()) {
@@ -181,7 +181,7 @@ public class IvyBuildList extends IvyTask {
             }
         }
 
-        Set leafModuleNames = new LinkedHashSet();
+        Set<String> leafModuleNames = new LinkedHashSet<String>();
         if (!"*".equals(leaf)) {
             StringTokenizer st = new StringTokenizer(leaf, delimiter);
             while (st.hasMoreTokens()) {
@@ -189,15 +189,14 @@ public class IvyBuildList extends IvyTask {
             }
         }
 
-        Set restartFromModuleNames = new LinkedHashSet();
+        Set<String> restartFromModuleNames = new LinkedHashSet<String>();
         if (!"*".equals(restartFrom)) {
             StringTokenizer st = new StringTokenizer(restartFrom, delimiter);
             // Only accept one (first) module
             restartFromModuleNames.add(st.nextToken());
         }
 
-        for (ListIterator iter = buildFileSets.listIterator(); iter.hasNext();) {
-            FileSet fs = (FileSet) iter.next();
+        for (FileSet fs : buildFileSets) {
             DirectoryScanner ds = fs.getDirectoryScanner(getProject());
             String[] builds = ds.getIncludedFiles();
             for (int i = 0; i < builds.length; i++) {
@@ -228,12 +227,12 @@ public class IvyBuildList extends IvyTask {
             }
         }
 
-        List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, leafModuleNames,
-            "leaf");
-        List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, rootModuleNames,
-            "root");
-        List restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
-            restartFromModuleNames, "restartFrom");
+        List<ModuleDescriptor> leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
+            leafModuleNames, "leaf");
+        List<ModuleDescriptor> rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
+            rootModuleNames, "root");
+        List<ModuleDescriptor> restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(
+            mds, restartFromModuleNames, "restartFrom");
 
         if (!rootModuleDescriptors.isEmpty()) {
             Message.info("Filtering modules based on roots " + rootModuleNames);
@@ -244,16 +243,14 @@ public class IvyBuildList extends IvyTask {
             mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
         }
 
-        List sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
+        List<ModuleDescriptor> sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
 
         if (!OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
-            for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
-                File buildFile = (File) iter.next();
+            for (File buildFile : noDescriptor) {
                 addBuildFile(path, buildFile);
             }
         }
-        for (ListIterator iter = independent.listIterator(); iter.hasNext();) {
-            File buildFile = (File) iter.next();
+        for (File buildFile : independent) {
             addBuildFile(path, buildFile);
         }
         if (isReverse()) {
@@ -264,11 +261,9 @@ public class IvyBuildList extends IvyTask {
         // so they are not removed from build path.
         if (!restartFromModuleDescriptors.isEmpty()) {
             boolean foundRestartFrom = false;
-            List keptModules = new ArrayList();
-            ModuleDescriptor restartFromModuleDescriptor = (ModuleDescriptor) restartFromModuleDescriptors
-                    .get(0);
-            for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
-                ModuleDescriptor md = (ModuleDescriptor) iter.next();
+            List<ModuleDescriptor> keptModules = new ArrayList<ModuleDescriptor>();
+            ModuleDescriptor restartFromModuleDescriptor = restartFromModuleDescriptors.get(0);
+            for (ModuleDescriptor md : sortedModules) {
                 if (md.equals(restartFromModuleDescriptor)) {
                     foundRestartFrom = true;
                 }
@@ -279,18 +274,17 @@ public class IvyBuildList extends IvyTask {
             sortedModules = keptModules;
         }
         StringBuffer order = new StringBuffer();
-        for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
-            ModuleDescriptor md = (ModuleDescriptor) iter.next();
+        for (ListIterator<ModuleDescriptor> iter = sortedModules.listIterator(); iter.hasNext();) {
+            ModuleDescriptor md = iter.next();
             order.append(md.getModuleRevisionId().getModuleId());
             if (iter.hasNext()) {
                 order.append(", ");
             }
-            File buildFile = (File) buildFiles.get(md);
+            File buildFile = buildFiles.get(md);
             addBuildFile(path, buildFile);
         }
         if (OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
-            for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
-                File buildFile = (File) iter.next();
+            for (File buildFile : noDescriptor) {
                 addBuildFile(path, buildFile);
             }
         }
@@ -299,7 +293,7 @@ public class IvyBuildList extends IvyTask {
         getProject().setProperty("ivy.sorted.modules", order.toString());
     }
 
-    private void onMissingDescriptor(File buildFile, File ivyFile, List noDescriptor) {
+    private void onMissingDescriptor(File buildFile, File ivyFile, List<File> noDescriptor) {
         if (OnMissingDescriptor.SKIP.equals(onMissingDescriptor)) {
             Message.debug("skipping " + buildFile + ": descriptor " + ivyFile + " doesn't exist");
         } else if (OnMissingDescriptor.FAIL.equals(onMissingDescriptor)) {
@@ -323,12 +317,12 @@ public class IvyBuildList extends IvyTask {
         }
     }
 
-    private List convertModuleNamesToModuleDescriptors(Collection mds, Set moduleNames, String kind) {
-        List result = new ArrayList();
-        Set foundModuleNames = new HashSet();
+    private List<ModuleDescriptor> convertModuleNamesToModuleDescriptors(
+            Collection<ModuleDescriptor> mds, Set<String> moduleNames, String kind) {
+        List<ModuleDescriptor> result = new ArrayList<ModuleDescriptor>();
+        Set<String> foundModuleNames = new HashSet<String>();
 
-        for (Iterator it = mds.iterator(); it.hasNext();) {
-            ModuleDescriptor md = (ModuleDescriptor) it.next();
+        for (ModuleDescriptor md : mds) {
             String name = md.getModuleRevisionId().getModuleId().getName();
             if (moduleNames.contains(name)) {
                 foundModuleNames.add(name);
@@ -337,14 +331,14 @@ public class IvyBuildList extends IvyTask {
         }
 
         if (foundModuleNames.size() < moduleNames.size()) {
-            Set missingModules = new HashSet(moduleNames);
+            Set<String> missingModules = new HashSet<String>(moduleNames);
             missingModules.removeAll(foundModuleNames);
 
             StringBuffer missingNames = new StringBuffer();
             String sep = "";
-            for (Iterator it = missingModules.iterator(); it.hasNext();) {
+            for (String name : missingModules) {
                 missingNames.append(sep);
-                missingNames.append(it.next());
+                missingNames.append(name);
                 sep = ", ";
             }
 
@@ -365,20 +359,17 @@ public class IvyBuildList extends IvyTask {
      *            root module
      * @return filtered list of modules
      */
-    private Collection filterModulesFromRoot(Collection mds, List rootmds) {
-        // Make a map of ModuleId objects -> ModuleDescriptors
-        Map moduleIdMap = new HashMap();
-        for (Iterator iter = mds.iterator(); iter.hasNext();) {
-            ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+    private Collection<ModuleDescriptor> filterModulesFromRoot(Collection<ModuleDescriptor> mds,
+            List<ModuleDescriptor> rootmds) {
+        Map<ModuleId, ModuleDescriptor> moduleIdMap = new HashMap<ModuleId, ModuleDescriptor>();
+        for (ModuleDescriptor md : mds) {
             moduleIdMap.put(md.getModuleRevisionId().getModuleId(), md);
         }
 
         // recursively process the nodes
-        Set toKeep = new LinkedHashSet();
+        Set<ModuleDescriptor> toKeep = new LinkedHashSet<ModuleDescriptor>();
 
-        Iterator it = rootmds.iterator();
-        while (it.hasNext()) {
-            ModuleDescriptor rootmd = (ModuleDescriptor) it.next();
+        for (ModuleDescriptor rootmd : rootmds) {
             processFilterNodeFromRoot(rootmd, toKeep, moduleIdMap);
             // With the excluderoot attribute set to true, take the rootmd out of the toKeep set.
             if (excludeRoot) {
@@ -391,8 +382,7 @@ public class IvyBuildList extends IvyTask {
         }
 
         // just for logging
-        for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
-            ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+        for (ModuleDescriptor md : toKeep) {
             Message.verbose("Kept module " + md.getModuleRevisionId().getModuleId().getName());
         }
 
@@ -411,13 +401,14 @@ public class IvyBuildList extends IvyTask {
      * @param moduleIdMap
      *            reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
      */
-    private void processFilterNodeFromRoot(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
+    private void processFilterNodeFromRoot(ModuleDescriptor node, Set<ModuleDescriptor> toKeep,
+            Map<ModuleId, ModuleDescriptor> moduleIdMap) {
         // toKeep.add(node);
 
         DependencyDescriptor[] deps = node.getDependencies();
         for (int i = 0; i < deps.length; i++) {
             ModuleId id = deps[i].getDependencyId();
-            ModuleDescriptor md = (ModuleDescriptor) moduleIdMap.get(id);
+            ModuleDescriptor md = moduleIdMap.get(id);
             // we test if this module id has a module descriptor, and if it isn't already in the
             // toKeep Set, in which there's probably a circular dependency
             if (md != null && !toKeep.contains(md)) {
@@ -439,19 +430,16 @@ public class IvyBuildList extends IvyTask {
      *            leaf module
      * @return filtered list of modules
      */
-    private Collection filterModulesFromLeaf(Collection mds, List leafmds) {
-        // Make a map of ModuleId objects -> ModuleDescriptors
-        Map moduleIdMap = new HashMap();
-        for (Iterator iter = mds.iterator(); iter.hasNext();) {
-            ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+    private Collection<ModuleDescriptor> filterModulesFromLeaf(Collection<ModuleDescriptor> mds,
+            List<ModuleDescriptor> leafmds) {
+        Map<ModuleId, ModuleDescriptor> moduleIdMap = new HashMap<ModuleId, ModuleDescriptor>();
+        for (ModuleDescriptor md : mds) {
             moduleIdMap.put(md.getModuleRevisionId().getModuleId(), md);
         }
 
         // recursively process the nodes
-        Set toKeep = new LinkedHashSet();
-        Iterator it = leafmds.iterator();
-        while (it.hasNext()) {
-            ModuleDescriptor leafmd = (ModuleDescriptor) it.next();
+        Set<ModuleDescriptor> toKeep = new LinkedHashSet<ModuleDescriptor>();
+        for (ModuleDescriptor leafmd : leafmds) {
             // With the excludeleaf attribute set to true, take the rootmd out of the toKeep set.
             if (excludeLeaf) {
                 Message.verbose("Excluded module "
@@ -463,8 +451,7 @@ public class IvyBuildList extends IvyTask {
         }
 
         // just for logging
-        for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
-            ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+        for (ModuleDescriptor md : toKeep) {
             Message.verbose("Kept module " + md.getModuleRevisionId().getModuleId().getName());
         }
 
@@ -482,9 +469,9 @@ public class IvyBuildList extends IvyTask {
      * @param moduleIdMap
      *            reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
      */
-    private void processFilterNodeFromLeaf(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
-        for (Iterator iter = moduleIdMap.values().iterator(); iter.hasNext();) {
-            ModuleDescriptor md = (ModuleDescriptor) iter.next();
+    private void processFilterNodeFromLeaf(ModuleDescriptor node, Set<ModuleDescriptor> toKeep,
+            Map<ModuleId, ModuleDescriptor> moduleIdMap) {
+        for (ModuleDescriptor md : moduleIdMap.values()) {
             DependencyDescriptor[] deps = md.getDependencies();
             for (int i = 0; i < deps.length; i++) {
                 ModuleId id = deps[i].getDependencyId();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/ant/IvyDependency.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/ant/IvyDependency.java b/src/java/org/apache/ivy/ant/IvyDependency.java
index dbc8f21..051a55a 100644
--- a/src/java/org/apache/ivy/ant/IvyDependency.java
+++ b/src/java/org/apache/ivy/ant/IvyDependency.java
@@ -18,7 +18,6 @@
 package org.apache.ivy.ant;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
@@ -32,13 +31,13 @@ import org.apache.tools.ant.BuildException;
 
 public class IvyDependency {
 
-    private List/* <IvyDependencyConf> */confs = new ArrayList();
+    private List<IvyDependencyConf> confs = new ArrayList<IvyDependencyConf>();
 
-    private List/* <IvyDependencyArtifact> */artifacts = new ArrayList();
+    private List<IvyDependencyArtifact> artifacts = new ArrayList<IvyDependencyArtifact>();
 
-    private List/* <IvyDependencyExclude> */excludes = new ArrayList();
+    private List<IvyDependencyExclude> excludes = new ArrayList<IvyDependencyExclude>();
 
-    private List/* <IvyDependencyIncludes> */includes = new ArrayList();
+    private List<IvyDependencyInclude> includes = new ArrayList<IvyDependencyInclude>();
 
     private String org;
 
@@ -161,28 +160,20 @@ public class IvyDependency {
             dd.addDependencyConfiguration(masterConf, "*");
         }
 
-        Iterator itConfs = confs.iterator();
-        while (itConfs.hasNext()) {
-            IvyDependencyConf c = (IvyDependencyConf) itConfs.next();
+        for (IvyDependencyConf c : confs) {
             c.addConf(dd, masterConf);
         }
 
-        Iterator itArtifacts = artifacts.iterator();
-        while (itArtifacts.hasNext()) {
-            IvyDependencyArtifact artifact = (IvyDependencyArtifact) itArtifacts.next();
+        for (IvyDependencyArtifact artifact : artifacts) {
             artifact.addArtifact(dd, masterConf);
         }
 
-        Iterator itExcludes = excludes.iterator();
-        while (itExcludes.hasNext()) {
-            IvyDependencyExclude exclude = (IvyDependencyExclude) itExcludes.next();
+        for (IvyDependencyExclude exclude : excludes) {
             DefaultExcludeRule rule = exclude.asRule(settings);
             dd.addExcludeRule(masterConf, rule);
         }
 
-        Iterator itIncludes = includes.iterator();
-        while (itIncludes.hasNext()) {
-            IvyDependencyInclude include = (IvyDependencyInclude) itIncludes.next();
+        for (IvyDependencyInclude include : includes) {
             DefaultIncludeRule rule = include.asRule(settings);
             dd.addIncludeRule(masterConf, rule);
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/ant/IvyResolve.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/ant/IvyResolve.java b/src/java/org/apache/ivy/ant/IvyResolve.java
index 5dd7757..c700421 100644
--- a/src/java/org/apache/ivy/ant/IvyResolve.java
+++ b/src/java/org/apache/ivy/ant/IvyResolve.java
@@ -23,7 +23,6 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivy.Ivy;
@@ -91,11 +90,11 @@ public class IvyResolve extends IvyTask {
 
     private boolean checkIfChanged = true; // for backward compatibility
 
-    private List/* <IvyDependency> */dependencies = new ArrayList();
+    private List<IvyDependency> dependencies = new ArrayList<IvyDependency>();
 
-    private List/* <IvyExclude> */excludes = new ArrayList();
+    private List<IvyExclude> excludes = new ArrayList<IvyExclude>();
 
-    private List/* <IvyConflict> */conflicts = new ArrayList();
+    private List<IvyConflict> conflicts = new ArrayList<IvyConflict>();
 
     public boolean isUseOrigin() {
         return useOrigin;
@@ -229,11 +228,13 @@ public class IvyResolve extends IvyTask {
         return c;
     }
 
+    @Override
     protected void prepareTask() {
         super.prepareTask();
         Message.setShowProgress(showProgress);
     }
 
+    @Override
     public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
@@ -267,24 +268,18 @@ public class IvyResolve extends IvyTask {
                     Ivy.getWorkingRevision());
                 DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(mrid, null);
 
-                Iterator itDeps = dependencies.iterator();
-                while (itDeps.hasNext()) {
-                    IvyDependency dep = (IvyDependency) itDeps.next();
+                for (IvyDependency dep : dependencies) {
                     DependencyDescriptor dd = dep.asDependencyDescriptor(md, "default", settings);
                     md.addDependency(dd);
                 }
 
-                Iterator itExcludes = excludes.iterator();
-                while (itExcludes.hasNext()) {
-                    IvyExclude exclude = (IvyExclude) itExcludes.next();
+                for (IvyExclude exclude : excludes) {
                     DefaultExcludeRule rule = exclude.asRule(settings);
                     rule.addConfiguration("default");
                     md.addExcludeRule(rule);
                 }
 
-                Iterator itConflicts = conflicts.iterator();
-                while (itConflicts.hasNext()) {
-                    IvyConflict conflict = (IvyConflict) itConflicts.next();
+                for (IvyConflict conflict : conflicts) {
                     conflict.addConflict(md, settings);
                 }
 
@@ -426,9 +421,9 @@ public class IvyResolve extends IvyTask {
         }
     }
 
-    protected Collection/* <String> */getAllowedLogOptions() {
-        return Arrays.asList(new String[] {LogOptions.LOG_DEFAULT, LogOptions.LOG_DOWNLOAD_ONLY,
-                LogOptions.LOG_QUIET});
+    protected Collection<String> getAllowedLogOptions() {
+        return Arrays.asList(LogOptions.LOG_DEFAULT, LogOptions.LOG_DOWNLOAD_ONLY,
+            LogOptions.LOG_QUIET);
     }
 
     private ResolveOptions getResolveOptions(Ivy ivy, String[] confs, IvySettings settings) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
index 55f498d..a950c0b 100644
--- a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
+++ b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
@@ -26,8 +26,8 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.text.ParseException;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.regex.Pattern;
 
 import org.apache.ivy.Ivy;
@@ -114,7 +114,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
 
     private Boolean useOrigin;
 
-    private ModuleRules/* <Long> */ttlRules = new ModuleRules();
+    private ModuleRules<Long> ttlRules = new ModuleRules<Long>();
 
     private Long defaultTTL = null;
 
@@ -239,16 +239,16 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
         this.changingPattern = changingPattern;
     }
 
-    public void addTTL(Map attributes, PatternMatcher matcher, long duration) {
+    public void addTTL(Map<String, String> attributes, PatternMatcher matcher, long duration) {
         ttlRules.defineRule(new MapMatcher(attributes, matcher), new Long(duration));
     }
 
-    public void addConfiguredTtl(Map/* <String,String> */attributes) {
-        String duration = (String) attributes.remove("duration");
+    public void addConfiguredTtl(Map<String, String> attributes) {
+        String duration = attributes.remove("duration");
         if (duration == null) {
             throw new IllegalArgumentException("'duration' attribute is mandatory for ttl");
         }
-        String matcher = (String) attributes.remove("matcher");
+        String matcher = attributes.remove("matcher");
         addTTL(attributes,
             matcher == null ? ExactPatternMatcher.INSTANCE : settings.getMatcher(matcher),
             parseDuration(duration));
@@ -531,10 +531,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
                     // try to find other cached artifact info with same location. This must be the
                     // origin. We must parse the key as we do not know for sure what the original
                     // artifact is named.
-                    Iterator it = cdf.entrySet().iterator();
                     String ownLocationKey = getLocationKey(artifact);
-                    while (it.hasNext()) {
-                        Map.Entry entry = (Map.Entry) it.next();
+                    for (Entry<Object, Object> entry : cdf.entrySet()) {
                         if (entry.getValue().equals(location)
                                 && !ownLocationKey.equals(entry.getKey())) {
                             // found a match, key is
@@ -891,10 +889,11 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
     }
 
     public long getTTL(ModuleRevisionId mrid) {
-        Long ttl = (Long) ttlRules.getRule(mrid);
+        Long ttl = ttlRules.getRule(mrid);
         return ttl == null ? getDefaultTTL() : ttl.longValue();
     }
 
+    @Override
     public String toString() {
         return name;
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java b/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
index 30d111b..de43912 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
@@ -52,14 +52,15 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
             this.name = name;
         }
 
+        @Override
         public String toString() {
             return name;
         }
     }
 
-    public static Collection/* <Configuration> */findConfigurationExtending(String conf,
+    public static Collection<Configuration> findConfigurationExtending(String conf,
             Configuration[] confs) {
-        Collection extendingConfs = new ArrayList();
+        Collection<Configuration> extendingConfs = new ArrayList<Configuration>();
         for (int i = 0; i < confs.length; i++) {
             if (confs[i] != null && Arrays.asList(confs[i].getExtends()).contains(conf)) {
                 extendingConfs.add(confs[i]);
@@ -120,9 +121,9 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
         this(null, null, name, visibility, description, ext, transitive, deprecated, null);
     }
 
-    private Configuration(Map attributes, Map extraAttributes, String name, Visibility visibility,
-            String description, String[] ext, boolean transitive, String deprecated,
-            ModuleRevisionId sourceModule) {
+    private Configuration(Map<String, String> attributes, Map<String, String> extraAttributes,
+            String name, Visibility visibility, String description, String[] ext,
+            boolean transitive, String deprecated, ModuleRevisionId sourceModule) {
         super(attributes, extraAttributes);
 
         if (name == null) {
@@ -195,10 +196,12 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
         return sourceModule;
     }
 
+    @Override
     public String toString() {
         return name;
     }
 
+    @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof Configuration)) {
             return false;
@@ -206,6 +209,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
         return ((Configuration) obj).getName().equals(getName());
     }
 
+    @Override
     public int hashCode() {
         return getName().hashCode();
     }
@@ -218,7 +222,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
 
         Configuration[] configs = md.getConfigurations();
 
-        Set newExtends = new LinkedHashSet();
+        Set<String> newExtends = new LinkedHashSet<String>();
         for (int j = 0; j < extendsFrom.length; j++) {
             if ("*".equals(extendsFrom[j])) {
                 addOther(configs, null, newExtends);
@@ -231,10 +235,10 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
             }
         }
 
-        this.extendsFrom = (String[]) newExtends.toArray(new String[newExtends.size()]);
+        this.extendsFrom = newExtends.toArray(new String[newExtends.size()]);
     }
 
-    private void addOther(Configuration[] allConfigs, Visibility visibility, Set configs) {
+    private void addOther(Configuration[] allConfigs, Visibility visibility, Set<String> configs) {
         for (int i = 0; i < allConfigs.length; i++) {
             String currentName = allConfigs[i].getName();
             if (!name.equals(currentName)

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/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 2c544c5..39256d2 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
@@ -25,7 +25,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -210,13 +209,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
 
     private Date resolvedPublicationDate;
 
-    private List dependencies = new ArrayList(); // List (DependencyDescriptor)
+    private List<DependencyDescriptor> dependencies = new ArrayList<DependencyDescriptor>();
 
-    private Map configurations = new LinkedHashMap(); // Map(String conf -> Configuration)
+    private Map<String, Configuration> configurations = new LinkedHashMap<String, Configuration>();
 
-    private Map artifactsByConf = new HashMap(); // Map (String conf -> Collection(Artifact))
+    private Map<String, Collection<Artifact>> artifactsByConf = new HashMap<String, Collection<Artifact>>();
 
-    private Collection artifacts = new LinkedHashSet(); // Collection(Artifact)
+    private Collection<Artifact> artifacts = new LinkedHashSet<Artifact>();
 
     // all artifacts could also be found in the artifactsByConf map, but here we can
     // preserve the order
@@ -227,7 +226,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
 
     private ModuleRules dependencyDescriptorMediators = new ModuleRules();
 
-    private List licenses = new ArrayList(); // List(License)
+    private List<License> licenses = new ArrayList<License>();
 
     private String homePage;
 
@@ -247,13 +246,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
 
     private Resource resource;
 
-    private List excludeRules = new ArrayList(); // List(ExcludeRule)
+    private List<ExcludeRule> excludeRules = new ArrayList<ExcludeRule>();
 
     private Artifact metadataArtifact;
 
-    private List inheritedDescriptors = new ArrayList(); // List(ExtendsDescriptor)
+    private List<ExtendsDescriptor> inheritedDescriptors = new ArrayList<ExtendsDescriptor>();
 
-    private Map/* <String,String> */extraAttributesNamespaces = new LinkedHashMap();
+    private Map<String, String> extraAttributesNamespaces = new LinkedHashMap<String, String>();
 
     private List<ExtraInfoHolder> extraInfos = new ArrayList<ExtraInfoHolder>();
 
@@ -381,9 +380,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
                 addArtifact(members[i], artifact);
             }
         } else {
-            Collection artifacts = (Collection) artifactsByConf.get(conf);
+            Collection<Artifact> artifacts = artifactsByConf.get(conf);
             if (artifacts == null) {
-                artifacts = new ArrayList();
+                artifacts = new ArrayList<Artifact>();
                 artifactsByConf.put(conf, artifacts);
             }
             artifacts.add(artifact);
@@ -404,28 +403,25 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public ExtendsDescriptor[] getInheritedDescriptors() {
-        return (ExtendsDescriptor[]) inheritedDescriptors
-                .toArray(new ExtendsDescriptor[inheritedDescriptors.size()]);
+        return inheritedDescriptors.toArray(new ExtendsDescriptor[inheritedDescriptors.size()]);
     }
 
     public Configuration[] getConfigurations() {
-        return (Configuration[]) configurations.values().toArray(
-            new Configuration[configurations.size()]);
+        return configurations.values().toArray(new Configuration[configurations.size()]);
     }
 
     public String[] getConfigurationsNames() {
-        return (String[]) configurations.keySet().toArray(new String[configurations.size()]);
+        return configurations.keySet().toArray(new String[configurations.size()]);
     }
 
     public String[] getPublicConfigurationsNames() {
-        List ret = new ArrayList();
-        for (Iterator iter = configurations.values().iterator(); iter.hasNext();) {
-            Configuration conf = (Configuration) iter.next();
+        List<String> ret = new ArrayList<String>();
+        for (Configuration conf : configurations.values()) {
             if (conf.getVisibility() == Configuration.Visibility.PUBLIC) {
                 ret.add(conf.getName());
             }
         }
-        return (String[]) ret.toArray(new String[ret.size()]);
+        return ret.toArray(new String[ret.size()]);
     }
 
     /**
@@ -433,7 +429,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
      * if not found.
      */
     public Configuration getConfiguration(String confName) {
-        Configuration configuration = (Configuration) configurations.get(confName);
+        Configuration configuration = configurations.get(confName);
         if (configuration == null && confName != null) {
             // let's first check if the configuration is a conf group
             Matcher m = Pattern.compile("\\*\\[([^=]+)\\=([^\\]]+)\\]").matcher(confName);
@@ -442,9 +438,8 @@ 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();
-                for (Iterator it = configurations.values().iterator(); it.hasNext();) {
-                    Configuration conf = (Configuration) it.next();
+                Map<String, Configuration> members = new LinkedHashMap<String, Configuration>();
+                for (Configuration conf : configurations.values()) {
                     if (attValue.equals(conf.getAttribute(attName))) {
                         members.put(conf.getName(), conf);
                     }
@@ -457,9 +452,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             if (confs.length <= 1) {
                 return null;
             }
-            Map /* <String,Configuration> */intersectedConfs = new LinkedHashMap();
+            Map<String, Configuration> intersectedConfs = new LinkedHashMap<String, Configuration>();
             for (int i = 0; i < confs.length; i++) {
-                Configuration c = (Configuration) configurations.get(confs[i]);
+                Configuration c = configurations.get(confs[i]);
                 if (c == null) {
                     Message.verbose("missing configuration '" + confs[i] + "' from intersection "
                             + confName + " in " + this);
@@ -477,13 +472,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         if (c == null) {
             return new Artifact[0];
         }
-        Collection artifacts = (Collection) artifactsByConf.get(conf);
+        Collection<Artifact> artifacts = artifactsByConf.get(conf);
         if (c instanceof ConfigurationIntersection) {
             ConfigurationIntersection intersection = (ConfigurationIntersection) c;
             String[] intersected = intersection.getIntersectedConfigurationNames();
-            Set/* <Artifact> */intersectedArtifacts = new LinkedHashSet();
+            Set<Artifact> intersectedArtifacts = new LinkedHashSet<Artifact>();
             for (int j = 0; j < intersected.length; j++) {
-                Collection arts = getArtifactsIncludingExtending(intersected[j]);
+                Collection<Artifact> arts = getArtifactsIncludingExtending(intersected[j]);
                 if (intersectedArtifacts.isEmpty()) {
                     intersectedArtifacts.addAll(arts);
                 } else {
@@ -493,39 +488,37 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
             if (artifacts != null) {
                 intersectedArtifacts.addAll(artifacts);
             }
-            return (Artifact[]) intersectedArtifacts.toArray(new Artifact[intersectedArtifacts
-                    .size()]);
+            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();
+            Set<Artifact> groupArtifacts = new LinkedHashSet<Artifact>();
             for (int i = 0; i < members.length; i++) {
                 groupArtifacts.addAll(getArtifactsIncludingExtending(members[i]));
             }
             if (artifacts != null) {
                 groupArtifacts.addAll(artifacts);
             }
-            return (Artifact[]) groupArtifacts.toArray(new Artifact[groupArtifacts.size()]);
+            return groupArtifacts.toArray(new Artifact[groupArtifacts.size()]);
         } else {
             if (artifacts == null) {
                 return new Artifact[0];
             } else {
-                return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
+                return artifacts.toArray(new Artifact[artifacts.size()]);
             }
         }
     }
 
-    private Collection/* <Artifact> */getArtifactsIncludingExtending(String conf) {
-        Collection extendingConfs = Configuration.findConfigurationExtending(conf,
+    private Collection<Artifact> getArtifactsIncludingExtending(String conf) {
+        Collection<Configuration> extendingConfs = Configuration.findConfigurationExtending(conf,
             getConfigurations());
-        Set/* <Artifact> */artifacts = new LinkedHashSet();
-        Collection arts = (Collection) artifactsByConf.get(conf);
+        Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+        Collection<Artifact> arts = artifactsByConf.get(conf);
         if (arts != null) {
             artifacts.addAll(arts);
         }
-        for (Iterator it = extendingConfs.iterator(); it.hasNext();) {
-            Configuration extendingConf = (Configuration) it.next();
-            arts = (Collection) artifactsByConf.get(extendingConf.getName());
+        for (Configuration extendingConf : extendingConfs) {
+            arts = artifactsByConf.get(extendingConf.getName());
             if (arts != null) {
                 artifacts.addAll(arts);
             }
@@ -534,17 +527,15 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public Artifact[] getAllArtifacts() {
-        return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
+        return artifacts.toArray(new Artifact[artifacts.size()]);
     }
 
     public DependencyDescriptor[] getDependencies() {
-        return (DependencyDescriptor[]) dependencies.toArray(new DependencyDescriptor[dependencies
-                .size()]);
+        return dependencies.toArray(new DependencyDescriptor[dependencies.size()]);
     }
 
     public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md) {
-        for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
-            DependencyDescriptor dd = (DependencyDescriptor) iter.next();
+        for (DependencyDescriptor dd : dependencies) {
             if (dd.getDependencyId().equals(md.getModuleRevisionId().getModuleId())) {
                 if (md.getResolvedModuleRevisionId().getRevision() == null) {
                     return true;
@@ -564,6 +555,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         }
     }
 
+    @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
@@ -571,6 +563,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         return result;
     }
 
+    @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
@@ -592,6 +585,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         return true;
     }
 
+    @Override
     public String toString() {
         return "module: " + revId + " status=" + status + " publication=" + publicationDate
                 + " configurations=" + configurations + " artifacts=" + artifactsByConf
@@ -633,7 +627,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         return dd;
     }
 
-    public ModuleRules/* <DependencyDescriptorMediator> */getAllDependencyDescriptorMediators() {
+    public ModuleRules getAllDependencyDescriptorMediators() {
         return (ModuleRules) dependencyDescriptorMediators.clone();
     }
 
@@ -642,7 +636,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public License[] getLicenses() {
-        return (License[]) licenses.toArray(new License[licenses.size()]);
+        return licenses.toArray(new License[licenses.size()]);
     }
 
     public String getHomePage() {
@@ -674,8 +668,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public boolean isNamespaceUseful() {
-        for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
-            DependencyDescriptor dd = (DependencyDescriptor) iter.next();
+        for (DependencyDescriptor dd : dependencies) {
             if (dd.getAllExcludeRules().length > 0) {
                 return true;
             }
@@ -692,9 +685,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
      * configurations existence and cycles are checked
      */
     public void check() {
-        Stack confs = new Stack();
-        for (Iterator iter = configurations.values().iterator(); iter.hasNext();) {
-            Configuration conf = (Configuration) iter.next();
+        Stack<String> confs = new Stack<String>();
+        for (Configuration conf : configurations.values()) {
             String[] ext = conf.getExtends();
             for (int i = 0; i < ext.length; i++) {
                 confs.push(conf.getName());
@@ -704,7 +696,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         }
     }
 
-    private void checkConf(Stack confs, String confName) {
+    private void checkConf(Stack<String> confs, String confName) {
         int index = confs.indexOf(confName);
         if (index != -1) {
             StringBuffer cycle = new StringBuffer();
@@ -756,7 +748,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         return resolvedRevId.getAttribute(attName);
     }
 
-    public Map getAttributes() {
+    public Map<String, String> getAttributes() {
         return resolvedRevId.getAttributes();
     }
 
@@ -764,11 +756,11 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
         return resolvedRevId.getExtraAttribute(attName);
     }
 
-    public Map getExtraAttributes() {
+    public Map<String, String> getExtraAttributes() {
         return resolvedRevId.getExtraAttributes();
     }
 
-    public Map getQualifiedExtraAttributes() {
+    public Map<String, String> getQualifiedExtraAttributes() {
         return resolvedRevId.getQualifiedExtraAttributes();
     }
 
@@ -807,26 +799,25 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
     }
 
     public ExcludeRule[] getAllExcludeRules() {
-        return (ExcludeRule[]) excludeRules.toArray(new ExcludeRule[excludeRules.size()]);
+        return excludeRules.toArray(new ExcludeRule[excludeRules.size()]);
     }
 
     public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
-        Set rules = new LinkedHashSet();
-        for (Iterator iter = excludeRules.iterator(); iter.hasNext();) {
-            ExcludeRule rule = (ExcludeRule) iter.next();
+        Set<ExcludeRule> rules = new LinkedHashSet<ExcludeRule>();
+        for (ExcludeRule rule : excludeRules) {
             String[] ruleConfs = rule.getConfigurations();
             if (containsAny(ruleConfs, moduleConfigurations)) {
                 rules.add(rule);
             }
         }
-        return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
+        return rules.toArray(new ExcludeRule[rules.size()]);
     }
 
     private boolean containsAny(String[] arr1, String[] arr2) {
-        return new ArrayList(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
+        return new ArrayList<String>(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
     }
 
-    public Map getExtraAttributesNamespaces() {
+    public Map<String, String> getExtraAttributesNamespaces() {
         return extraAttributesNamespaces;
     }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/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 76a44fc..e4650de 100644
--- a/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
+++ b/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
@@ -19,7 +19,6 @@ package org.apache.ivy.core.module.id;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -56,13 +55,13 @@ import org.apache.ivy.plugins.matcher.PatternMatcher;
  */
 public class MatcherLookup {
 
-    //private static final String FORMAT = "{org:%s, module:%s}";
+    // private static final String FORMAT = "{org:%s, module:%s}";
 
     private static final String DEFAULT = "{org:" + "default" + ", module:" + "default" + "}";
 
-    private Map/* <String, List<MapMatcher>> */lookup = new HashMap();
+    private Map<String, List<MapMatcher>> lookup = new HashMap<String, List<MapMatcher>>();
 
-    private List/* <MapMatcher> */non_exact_matchers = new ArrayList();
+    private List<MapMatcher> non_exact_matchers = new ArrayList<MapMatcher>();
 
     /**
      * Add matcher.
@@ -79,10 +78,10 @@ public class MatcherLookup {
             non_exact_matchers.add(matcher);
             return;
         }
-        Object key = key(matcher.getAttributes());
-        List exact_matchers = (List) lookup.get(key);
+        String key = key(matcher.getAttributes());
+        List<MapMatcher> exact_matchers = lookup.get(key);
         if (exact_matchers == null) {
-            exact_matchers = new ArrayList();
+            exact_matchers = new ArrayList<MapMatcher>();
             lookup.put(key, exact_matchers);
         }
         exact_matchers.add(matcher);
@@ -96,23 +95,21 @@ public class MatcherLookup {
      * 
      * @return list A list of candidate matchers that matches specified attributes
      */
-    public List get(Map attrs) {
-        List matchers = new ArrayList();
+    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 (Iterator iter = non_exact_matchers.iterator(); iter.hasNext();) {
-                MapMatcher matcher = (MapMatcher) iter.next();
+            for (MapMatcher matcher : non_exact_matchers) {
                 if (matcher.matches(attrs)) {
                     matchers.add(matcher);
                 }
             }
         }
         // Step 2: find matchers from exact_matchers list of key
-        Object key = key(attrs);
-        List exact_matchers = (List) lookup.get(key);
+        String key = key(attrs);
+        List<MapMatcher> exact_matchers = lookup.get(key);
         if (exact_matchers != null) {
-            for (Iterator iter = exact_matchers.iterator(); iter.hasNext();) {
-                MapMatcher matcher = (MapMatcher) iter.next();
+            for (MapMatcher matcher : exact_matchers) {
                 if (matcher.matches(attrs)) {
                     matchers.add(matcher);
                 }
@@ -120,10 +117,9 @@ public class MatcherLookup {
         }
         // Step 3: (iff key != DEFAULT) find matchers from exact_matchers of DEFAULT
         if (key != DEFAULT) {
-            List default_exact_matchers = (List) lookup.get(DEFAULT);
+            List<MapMatcher> default_exact_matchers = lookup.get(DEFAULT);
             if (default_exact_matchers != null) {
-                for (Iterator iter = default_exact_matchers.iterator(); iter.hasNext();) {
-                    MapMatcher matcher = (MapMatcher) iter.next();
+                for (MapMatcher matcher : default_exact_matchers) {
                     if (matcher.matches(attrs)) {
                         matchers.add(matcher);
                     }
@@ -140,9 +136,9 @@ public class MatcherLookup {
      *            A map of attributes
      * @return key object
      */
-    private Object key(Map attrs) {
-        Object org = attrs.get(IvyPatternHelper.ORGANISATION_KEY);
-        Object module = attrs.get(IvyPatternHelper.MODULE_KEY);
+    private String key(Map<String, String> attrs) {
+        String org = attrs.get(IvyPatternHelper.ORGANISATION_KEY);
+        String module = attrs.get(IvyPatternHelper.MODULE_KEY);
         if (org == null || PatternMatcher.ANY_EXPRESSION.equals(org) || module == null
                 || PatternMatcher.ANY_EXPRESSION.equals(module)) {
             return DEFAULT;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/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 4492827..8d2a85d 100644
--- a/src/java/org/apache/ivy/core/module/id/ModuleId.java
+++ b/src/java/org/apache/ivy/core/module/id/ModuleId.java
@@ -31,10 +31,11 @@ import org.apache.ivy.core.IvyPatternHelper;
  * 
  * @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
  */
-public class ModuleId implements Comparable {
+public class ModuleId implements Comparable<ModuleId> {
+
     static final String ENCODE_SEPARATOR = ":#@#:";
 
-    private static final Map/* <ModuleId, WeakReference<ModuleId>> */CACHE = new WeakHashMap();
+    private static final Map<ModuleId, WeakReference<ModuleId>> CACHE = new WeakHashMap<ModuleId, WeakReference<ModuleId>>();
 
     /**
      * Returns a ModuleId for the given organization and module name.
@@ -65,13 +66,13 @@ public class ModuleId implements Comparable {
         ModuleId r = null;
 
         synchronized (CACHE) {
-            WeakReference ref = (WeakReference) CACHE.get(moduleId);
+            WeakReference<ModuleId> ref = CACHE.get(moduleId);
             if (ref != null) {
-                r = (ModuleId) ref.get();
+                r = ref.get();
             }
             if (r == null) {
                 r = moduleId;
-                CACHE.put(r, new WeakReference(r));
+                CACHE.put(r, new WeakReference<ModuleId>(r));
             }
         }
 
@@ -84,7 +85,7 @@ public class ModuleId implements Comparable {
 
     private int hash;
 
-    private Map/* <String, String> */attributes = new HashMap();
+    private Map<String, String> attributes = new HashMap<String, String>();
 
     /**
      * Constructor.
@@ -122,7 +123,7 @@ public class ModuleId implements Comparable {
         return organisation;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof ModuleId)) {
             return false;
@@ -135,7 +136,7 @@ public class ModuleId implements Comparable {
         }
     }
 
-    /** {@inheritDoc} */
+    @Override
     public int hashCode() {
         if (hash == 0) {
             // CheckStyle:MagicNumber| OFF
@@ -147,14 +148,12 @@ public class ModuleId implements Comparable {
         return hash;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public String toString() {
         return organisation + "#" + name;
     }
 
-    /** {@inheritDoc} */
-    public int compareTo(Object obj) {
-        ModuleId that = (ModuleId) obj;
+    public int compareTo(ModuleId that) {
         int result = organisation.compareTo(that.organisation);
         if (result == 0) {
             result = name.compareTo(that.name);
@@ -177,7 +176,7 @@ public class ModuleId implements Comparable {
      * 
      * @return A Map instance containing all the attributes and their values.
      */
-    public Map getAttributes() {
+    public Map<String, String> getAttributes() {
         return attributes;
     }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/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 6c36f5c..38de003 100644
--- a/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
+++ b/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
@@ -19,8 +19,8 @@ package org.apache.ivy.core.module.id;
 
 import java.lang.ref.WeakReference;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.WeakHashMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -36,6 +36,7 @@ import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
  * @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
  */
 public class ModuleRevisionId extends UnmodifiableExtendableItem {
+
     private static final String ENCODE_SEPARATOR = ModuleId.ENCODE_SEPARATOR;
 
     private static final String ENCODE_PREFIX = "+";
@@ -46,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, ModuleRevisionId> */CACHE = new WeakHashMap();
+    private static final Map<ModuleRevisionId, WeakReference<ModuleRevisionId>> CACHE = new WeakHashMap<ModuleRevisionId, WeakReference<ModuleRevisionId>>();
 
     /**
      * Pattern to use to matched mrid text representation.
@@ -97,7 +98,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
     }
 
     public static ModuleRevisionId newInstance(String organisation, String name, String revision,
-            Map extraAttributes) {
+            Map<String, String> extraAttributes) {
         return intern(new ModuleRevisionId(ModuleId.newInstance(organisation, name), revision,
                 extraAttributes));
     }
@@ -109,13 +110,14 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
     }
 
     public static ModuleRevisionId newInstance(String organisation, String name, String branch,
-            String revision, Map extraAttributes) {
+            String revision, Map<String, String> extraAttributes) {
         return intern(new ModuleRevisionId(ModuleId.newInstance(organisation, name), branch,
                 revision, extraAttributes));
     }
 
     public static ModuleRevisionId newInstance(String organisation, String name, String branch,
-            String revision, Map extraAttributes, boolean replaceNullBranchWithDefault) {
+            String revision, Map<String, String> extraAttributes,
+            boolean replaceNullBranchWithDefault) {
         return intern(new ModuleRevisionId(ModuleId.newInstance(organisation, name), branch,
                 revision, extraAttributes, replaceNullBranchWithDefault));
     }
@@ -149,13 +151,13 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
         ModuleRevisionId r = null;
 
         synchronized (CACHE) {
-            WeakReference ref = (WeakReference) CACHE.get(moduleRevisionId);
+            WeakReference<ModuleRevisionId> ref = CACHE.get(moduleRevisionId);
             if (ref != null) {
-                r = (ModuleRevisionId) ref.get();
+                r = ref.get();
             }
             if (r == null) {
                 r = moduleRevisionId;
-                CACHE.put(r, new WeakReference(r));
+                CACHE.put(r, new WeakReference<ModuleRevisionId>(r));
             }
         }
 
@@ -180,16 +182,17 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
         this(moduleId, branch, revision, null);
     }
 
-    private ModuleRevisionId(ModuleId moduleId, String revision, Map extraAttributes) {
+    private ModuleRevisionId(ModuleId moduleId, String revision, Map<String, String> extraAttributes) {
         this(moduleId, null, revision, extraAttributes);
     }
 
-    private ModuleRevisionId(ModuleId moduleId, String branch, String revision, Map extraAttributes) {
+    private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
+            Map<String, String> extraAttributes) {
         this(moduleId, branch, revision, extraAttributes, true);
     }
 
     private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
-            Map extraAttributes, boolean replaceNullBranchWithDefault) {
+            Map<String, String> extraAttributes, boolean replaceNullBranchWithDefault) {
         super(null, extraAttributes);
         this.moduleId = moduleId;
         IvyContext context = IvyContext.getContext();
@@ -221,6 +224,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
         return revision;
     }
 
+    @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof ModuleRevisionId)) {
             return false;
@@ -240,6 +244,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
         }
     }
 
+    @Override
     public int hashCode() {
         if (hash == 0) {
             // CheckStyle:MagicNumber| OFF
@@ -253,6 +258,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
         return hash;
     }
 
+    @Override
     public String toString() {
         return moduleId + (branch == null || branch.length() == 0 ? "" : "#" + branch) + ";"
                 + (revision == null ? "NONE" : revision);
@@ -260,13 +266,13 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
 
     public String encodeToString() {
         StringBuffer buf = new StringBuffer();
-        Map attributes = new HashMap(getAttributes());
+        Map<String, String> attributes = new HashMap<String, String>(getAttributes());
         attributes.keySet().removeAll(getExtraAttributes().keySet());
         attributes.putAll(getQualifiedExtraAttributes());
 
-        for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
-            String attName = (String) iter.next();
-            String value = (String) attributes.get(attName);
+        for (Entry<String, String> att : attributes.entrySet()) {
+            String attName = att.getKey();
+            String value = att.getValue();
             value = value == null ? NULL_ENCODE : value;
             buf.append(ENCODE_PREFIX).append(attName).append(ENCODE_SEPARATOR)
                     .append(ENCODE_PREFIX).append(value).append(ENCODE_SEPARATOR);
@@ -280,7 +286,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
             throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
                     + "'");
         }
-        Map attributes = new HashMap();
+        Map<String, String> attributes = new HashMap<String, String>();
         for (int i = 0; i < parts.length; i += 2) {
             String attName = parts[i];
             if (!attName.startsWith(ENCODE_PREFIX)) {
@@ -301,10 +307,10 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
             }
             attributes.put(attName, attValue);
         }
-        String org = (String) attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
-        String mod = (String) attributes.remove(IvyPatternHelper.MODULE_KEY);
-        String rev = (String) attributes.remove(IvyPatternHelper.REVISION_KEY);
-        String branch = (String) attributes.remove(IvyPatternHelper.BRANCH_KEY);
+        String org = attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
+        String mod = attributes.remove(IvyPatternHelper.MODULE_KEY);
+        String rev = attributes.remove(IvyPatternHelper.REVISION_KEY);
+        String branch = attributes.remove(IvyPatternHelper.BRANCH_KEY);
         if (org == null) {
             throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
                     + "': no organisation");

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e1276e0a/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 f16981d..5c4948c 100644
--- a/src/java/org/apache/ivy/core/module/id/ModuleRules.java
+++ b/src/java/org/apache/ivy/core/module/id/ModuleRules.java
@@ -19,10 +19,10 @@ package org.apache.ivy.core.module.id;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.ivy.plugins.matcher.MapMatcher;
 import org.apache.ivy.util.Checks;
@@ -49,8 +49,9 @@ import org.apache.ivy.util.filter.NoFilter;
  * which resolver to use, which TTL in cache, ...)
  * </p>
  */
-public class ModuleRules {
-    private Map/* <MapMatcher,Object> */rules = new LinkedHashMap();
+public class ModuleRules<T> {
+
+    private Map<MapMatcher, T> rules = new LinkedHashMap<MapMatcher, T>();
 
     private MatcherLookup matcher_lookup = new MatcherLookup();
 
@@ -60,10 +61,10 @@ public class ModuleRules {
     public ModuleRules() {
     }
 
-    private ModuleRules(Map/* <MapMatcher,Object> */rules) {
-        this.rules = new LinkedHashMap(rules);
-        for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
-            matcher_lookup.add((MapMatcher) iter.next());
+    private ModuleRules(Map<MapMatcher, T> rules) {
+        this.rules = new LinkedHashMap<MapMatcher, T>(rules);
+        for (MapMatcher matcher : rules.keySet()) {
+            matcher_lookup.add(matcher);
         }
     }
 
@@ -75,7 +76,7 @@ public class ModuleRules {
      * @param rule
      *            the rule to apply. Must not be <code>null</code>.
      */
-    public void defineRule(MapMatcher condition, Object rule) {
+    public void defineRule(MapMatcher condition, T rule) {
         Checks.checkNotNull(condition, "condition");
         Checks.checkNotNull(rule, "rule");
 
@@ -93,8 +94,8 @@ public class ModuleRules {
      *         applies.
      * @see #getRule(ModuleId, Filter)
      */
-    public Object getRule(ModuleId mid) {
-        return getRule(mid, NoFilter.INSTANCE);
+    public T getRule(ModuleId mid) {
+        return getRule(mid, NoFilter.<T> instance());
     }
 
     /**
@@ -105,8 +106,8 @@ public class ModuleRules {
      *            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 Object[] getRules(ModuleId mid) {
-        return getRules(mid.getAttributes(), NoFilter.INSTANCE);
+    public T[] getRules(ModuleId mid) {
+        return getRules(mid.getAttributes(), NoFilter.<T> instance());
     }
 
     /**
@@ -120,8 +121,8 @@ public class ModuleRules {
      *         no rule applies.
      * @see #getRule(ModuleRevisionId, Filter)
      */
-    public Object getRule(ModuleRevisionId mrid) {
-        return getRule(mrid, NoFilter.INSTANCE);
+    public T getRule(ModuleRevisionId mrid) {
+        return getRule(mrid, NoFilter.<T> instance());
     }
 
     /**
@@ -140,7 +141,7 @@ public class ModuleRules {
      *         applies.
      * @see #getRule(ModuleRevisionId, Filter)
      */
-    public Object getRule(ModuleId mid, Filter filter) {
+    public T getRule(ModuleId mid, Filter<T> filter) {
         Checks.checkNotNull(mid, "mid");
         return getRule(mid.getAttributes(), filter);
     }
@@ -161,18 +162,17 @@ public class ModuleRules {
      *         no rule applies.
      * @see #getRule(ModuleRevisionId)
      */
-    public Object getRule(ModuleRevisionId mrid, Filter filter) {
+    public T getRule(ModuleRevisionId mrid, Filter<T> filter) {
         Checks.checkNotNull(mrid, "mrid");
         Checks.checkNotNull(filter, "filter");
-        Map moduleAttributes = mrid.getAttributes();
+        Map<String, String> moduleAttributes = mrid.getAttributes();
         return getRule(moduleAttributes, filter);
     }
 
-    private Object getRule(Map moduleAttributes, Filter filter) {
-        List matchers = matcher_lookup.get(moduleAttributes);
-        for (Iterator iter = matchers.iterator(); iter.hasNext();) {
-            MapMatcher midm = (MapMatcher) iter.next();
-            Object rule = rules.get(midm);
+    private T getRule(Map<String, String> moduleAttributes, Filter<T> filter) {
+        List<MapMatcher> matchers = matcher_lookup.get(moduleAttributes);
+        for (MapMatcher midm : matchers) {
+            T rule = rules.get(midm);
             if (filter.accept(rule)) {
                 return rule;
             }
@@ -193,24 +193,23 @@ public class ModuleRules {
      *            {@link ModuleRevisionId}. Must not be <code>null</code>.
      * @return an array of rule objects matching the given {@link ModuleRevisionId}.
      */
-    public Object[] getRules(ModuleRevisionId mrid, Filter filter) {
+    public T[] getRules(ModuleRevisionId mrid, Filter<T> filter) {
         Checks.checkNotNull(mrid, "mrid");
         Checks.checkNotNull(filter, "filter");
-        Map moduleAttributes = mrid.getAttributes();
+        Map<String, String> moduleAttributes = mrid.getAttributes();
         return getRules(moduleAttributes, filter);
     }
 
-    private Object[] getRules(Map moduleAttributes, Filter filter) {
-        List matchers = matcher_lookup.get(moduleAttributes);
-        List matchingRules = new ArrayList();
-        for (Iterator iter = matchers.iterator(); iter.hasNext();) {
-            MapMatcher midm = (MapMatcher) iter.next();
-            Object rule = rules.get(midm);
+    private T[] getRules(Map<String, String> moduleAttributes, Filter<T> filter) {
+        List<MapMatcher> matchers = matcher_lookup.get(moduleAttributes);
+        List<T> matchingRules = new ArrayList<T>();
+        for (MapMatcher midm : matchers) {
+            T rule = rules.get(midm);
             if (filter.accept(rule)) {
                 matchingRules.add(rule);
             }
         }
-        return matchingRules.toArray();
+        return matchingRules.toArray((T[]) new Object[0]);
     }
 
     /**
@@ -223,9 +222,9 @@ public class ModuleRules {
         if (rules.isEmpty()) {
             Message.debug(prefix + "NONE");
         } else {
-            for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
-                MapMatcher midm = (MapMatcher) iter.next();
-                Object rule = rules.get(midm);
+            for (Entry<MapMatcher, T> entry : rules.entrySet()) {
+                MapMatcher midm = entry.getKey();
+                T rule = entry.getValue();
                 Message.debug(prefix + midm + " -> " + rule);
             }
         }
@@ -240,11 +239,12 @@ public class ModuleRules {
      * 
      * @return an unmodifiable view of all the rules defined on this ModuleRules.
      */
-    public Map/* <MapMatcher,Object> */getAllRules() {
+    public Map<MapMatcher, T> getAllRules() {
         return Collections.unmodifiableMap(rules);
     }
 
+    @Override
     public Object clone() {
-        return new ModuleRules(rules);
+        return new ModuleRules<T>(rules);
     }
 }


Mime
View raw message