added more generics

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-2/branches/maven-2.2.x@1096343 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
index e0c7a3e..b622773 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
@@ -23,7 +23,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -86,16 +85,14 @@
             + baseVersion;
     }
 
-    public static Map artifactMapByVersionlessId( Collection artifacts )
+    public static Map<String, Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts )
     {
-        Map artifactMap = new LinkedHashMap();
+        Map<String, Artifact> artifactMap = new LinkedHashMap<String, Artifact>();
 
         if ( artifacts != null )
         {
-            for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+            for ( Artifact artifact : artifacts )
             {
-                Artifact artifact = (Artifact) it.next();
-
                 artifactMap.put( versionlessKey( artifact ), artifact );
             }
         }
@@ -103,16 +100,14 @@
         return artifactMap;
     }
 
-    public static Map artifactMapByArtifactId( Collection artifacts )
+    public static Map<String, Artifact> artifactMapByArtifactId( Collection<Artifact> artifacts )
     {
-        Map artifactMap = new LinkedHashMap();
+        Map<String, Artifact> artifactMap = new LinkedHashMap<String, Artifact>();
 
         if ( artifacts != null )
         {
-            for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+            for ( Artifact artifact : artifacts )
             {
-                Artifact artifact = (Artifact) it.next();
-
                 artifactMap.put( artifact.getId(), artifact );
             }
         }
@@ -141,13 +136,13 @@
         return clone;
     }
 
-    private static List copyList( List original )
+    private static <T> List<T> copyList( List<T> original )
     {
-        List copy = null;
+        List<T> copy = null;
 
         if ( original != null )
         {
-            copy = new ArrayList();
+            copy = new ArrayList<T>();
 
             if ( !original.isEmpty() )
             {
diff --git a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
index dc93db2..b565486 100644
--- a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
+++ b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
@@ -25,7 +25,6 @@
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -57,9 +56,9 @@
 
     private static final String DEFAULT_LANGUAGE = "java";
 
-    private List parameters;
+    private List<Parameter> parameters;
 
-    private Map parameterMap;
+    private Map<String, Parameter> parameterMap;
 
     /** By default, the execution strategy is "once-per-session" */
     private String executionStrategy = SINGLE_PASS_EXEC_STRATEGY;
@@ -107,7 +106,7 @@
     /**  Plugin descriptor */
     private PluginDescriptor pluginDescriptor;
 
-    /**  By default, the Mojo is herited */
+    /**  By default, the Mojo is inherited */
     private boolean inheritedByDefault = true;
 
     /**  By default, the Mojo could not be invoke directly */
@@ -164,7 +163,7 @@
     /**
      * @return the list of parameters
      */
-    public List getParameters()
+    public List<Parameter> getParameters()
     {
         return parameters;
     }
@@ -173,12 +172,11 @@
      * @param parameters the new list of parameters
      * @throws DuplicateParameterException if any
      */
-    public void setParameters( List parameters )
+    public void setParameters( List<Parameter> parameters )
         throws DuplicateParameterException
     {
-        for ( Iterator it = parameters.iterator(); it.hasNext(); )
+        for ( Parameter parameter : parameters )
         {
-            Parameter parameter = (Parameter) it.next();
             addParameter( parameter );
         }
     }
@@ -199,7 +197,7 @@
 
         if ( parameters == null )
         {
-            parameters = new LinkedList();
+            parameters = new LinkedList<Parameter>();
         }
 
         parameters.add( parameter );
@@ -210,18 +208,16 @@
     /**
      * @return the list parameters as a Map
      */
-    public Map getParameterMap()
+    public Map<String, Parameter> getParameterMap()
     {
         if ( parameterMap == null )
         {
-            parameterMap = new HashMap();
+            parameterMap = new HashMap<String, Parameter>();
 
             if ( parameters != null )
             {
-                for ( Iterator iterator = parameters.iterator(); iterator.hasNext(); )
+                for ( Parameter pd : parameters )
                 {
-                    Parameter pd = (Parameter) iterator.next();
-
                     parameterMap.put( pd.getName(), pd );
                 }
             }
diff --git a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
index 5726146..6c7cbf5 100644
--- a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
+++ b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
@@ -27,15 +27,15 @@
 import org.codehaus.classworlds.ClassRealm;
 import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.Reader;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -47,6 +47,9 @@
 public class PluginDescriptor
     extends ComponentSetDescriptor
 {
+
+    private static final String LIFECYCLE_DESCRIPTOR = "META-INF/maven/lifecycle.xml";
+
     private String groupId;
 
     private String artifactId;
@@ -61,16 +64,16 @@
     
     private Artifact pluginArtifact;
 
-    private List artifacts;
+    private List<Artifact> artifacts;
 
-    private Map lifecycleMappings;
+    private Map<String, Lifecycle> lifecycleMappings;
 
     private ClassRealm classRealm;
 
     // calculated on-demand.
-    private Map artifactMap;
+    private Map<String, Artifact> artifactMap;
 
-    private Set introducedDependencyArtifacts;
+    private Set<Artifact> introducedDependencyArtifacts;
 
     private String name;
 
@@ -80,7 +83,8 @@
     //
     // ----------------------------------------------------------------------
 
-    public List getMojos()
+    @SuppressWarnings( { "unchecked", "rawtypes" } )
+    public List<MojoDescriptor> getMojos()
     {
         return getComponents();
     }
@@ -92,7 +96,7 @@
         // this relies heavily on the equals() and hashCode() for ComponentDescriptor,
         // which uses role:roleHint for identity...and roleHint == goalPrefix:goal.
         // role does not vary for Mojos.
-        List mojos = getComponents();
+        List<MojoDescriptor> mojos = getMojos();
 
         if ( mojos != null && mojos.contains( mojoDescriptor ) )
         {
@@ -232,12 +236,12 @@
         this.inheritedByDefault = inheritedByDefault;
     }
 
-    public List getArtifacts()
+    public List<Artifact> getArtifacts()
     {
         return artifacts;
     }
 
-    public void setArtifacts( List artifacts )
+    public void setArtifacts( List<Artifact> artifacts )
     {
         this.artifacts = artifacts;
 
@@ -245,7 +249,7 @@
         artifactMap = null;
     }
 
-    public Map getArtifactMap()
+    public Map<String, Artifact> getArtifactMap()
     {
         if ( artifactMap == null )
         {
@@ -278,18 +282,15 @@
         }
 
         // TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to
-        // changes above not being propogated to the map
-
-        MojoDescriptor mojoDescriptor = null;
-        for ( Iterator i = getMojos().iterator(); i.hasNext() && mojoDescriptor == null; )
+        // changes above not being propagated to the map
+        for ( MojoDescriptor desc : getMojos() )
         {
-            MojoDescriptor desc = (MojoDescriptor) i.next();
             if ( goal.equals( desc.getGoal() ) )
             {
-                mojoDescriptor = desc;
+                return desc;
             }
         }
-        return mojoDescriptor;
+        return null;
     }
 
     public Lifecycle getLifecycleMapping( String lifecycle )
@@ -297,36 +298,32 @@
     {
         if ( lifecycleMappings == null )
         {
-            LifecycleMappingsXpp3Reader reader = new LifecycleMappingsXpp3Reader();
-            InputStreamReader r = null;
             LifecycleConfiguration config;
 
+            Reader reader = null;
             try
             {
-                InputStream resourceAsStream = classRealm.getResourceAsStream( "/META-INF/maven/lifecycle.xml" );
+                InputStream resourceAsStream = classRealm.getResourceAsStream( LIFECYCLE_DESCRIPTOR );
                 if ( resourceAsStream == null )
                 {
-                    throw new FileNotFoundException( "Unable to find /META-INF/maven/lifecycle.xml in the plugin" );
+                    throw new FileNotFoundException( "Unable to find " + LIFECYCLE_DESCRIPTOR + " in the plugin" );
                 }
-                r = new InputStreamReader( resourceAsStream );
-                config = reader.read( r, true );
+                reader = ReaderFactory.newXmlReader( resourceAsStream );
+                config = new LifecycleMappingsXpp3Reader().read( reader, true );
             }
             finally
             {
-                IOUtil.close( r );
+                IOUtil.close( reader );
             }
 
-            Map map = new HashMap();
+            lifecycleMappings = new HashMap<String, Lifecycle>();
 
-            for ( Iterator i = config.getLifecycles().iterator(); i.hasNext(); )
+            for ( Lifecycle l : config.getLifecycles() )
             {
-                Lifecycle l = (Lifecycle) i.next();
-                map.put( l.getId(), l );
+                lifecycleMappings.put( l.getId(), l );
             }
-
-            lifecycleMappings = map;
         }
-        return (Lifecycle) lifecycleMappings.get( lifecycle );
+        return lifecycleMappings.get( lifecycle );
     }
 
     public void setClassRealm( ClassRealm classRealm )
@@ -339,14 +336,15 @@
         return classRealm;
     }
 
-    public void setIntroducedDependencyArtifacts( Set introducedDependencyArtifacts )
+    public void setIntroducedDependencyArtifacts( Set<Artifact> introducedDependencyArtifacts )
     {
         this.introducedDependencyArtifacts = introducedDependencyArtifacts;
     }
 
-    public Set getIntroducedDependencyArtifacts()
+    public Set<Artifact> getIntroducedDependencyArtifacts()
     {
-        return introducedDependencyArtifacts != null ? introducedDependencyArtifacts : Collections.EMPTY_SET;
+        return ( introducedDependencyArtifacts != null ) ? introducedDependencyArtifacts
+                        : Collections.<Artifact> emptySet();
     }
 
     public void setName( String name )