You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2009/08/16 00:36:52 UTC

svn commit: r804537 - in /maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings: DefaultMavenSettingsBuilder.java SettingsUtils.java

Author: hboutemy
Date: Sat Aug 15 22:36:52 2009
New Revision: 804537

URL: http://svn.apache.org/viewvc?rev=804537&view=rev
Log:
use Java 5 generics

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/SettingsUtils.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java?rev=804537&r1=804536&r2=804537&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java Sat Aug 15 22:36:52 2009
@@ -114,12 +114,12 @@
 
         return userSettings;
     }
-    
+
 
     private Settings interpolate( Settings settings, MavenExecutionRequest request )
         throws IOException, XmlPullParserException
     {
-        List activeProfiles = settings.getActiveProfiles();
+        List<String> activeProfiles = settings.getActiveProfiles();
 
         StringWriter writer = new StringWriter();
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/SettingsUtils.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/SettingsUtils.java?rev=804537&r1=804536&r2=804537&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/SettingsUtils.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/SettingsUtils.java Sat Aug 15 22:36:52 2009
@@ -21,7 +21,6 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -54,21 +53,19 @@
 
         recessive.setSourceLevel( recessiveSourceLevel );
 
-        List dominantActiveProfiles = dominant.getActiveProfiles();
-        List recessiveActiveProfiles = recessive.getActiveProfiles();
+        List<String> dominantActiveProfiles = dominant.getActiveProfiles();
+        List<String> recessiveActiveProfiles = recessive.getActiveProfiles();
 
         if ( recessiveActiveProfiles != null )
         {
             if ( dominantActiveProfiles == null )
             {
-                dominantActiveProfiles = new ArrayList();
+                dominantActiveProfiles = new ArrayList<String>();
                 dominant.setActiveProfiles( dominantActiveProfiles );
             }
 
-            for ( Iterator it = recessiveActiveProfiles.iterator(); it.hasNext(); )
+            for ( String profileId : recessiveActiveProfiles )
             {
-                String profileId = (String) it.next();
-
                 if ( !dominantActiveProfiles.contains( profileId ) )
                 {
                     dominantActiveProfiles.add( profileId );
@@ -76,22 +73,20 @@
             }
         }
 
-        List dominantPluginGroupIds = dominant.getPluginGroups();
+        List<String> dominantPluginGroupIds = dominant.getPluginGroups();
 
-        List recessivePluginGroupIds = recessive.getPluginGroups();
+        List<String> recessivePluginGroupIds = recessive.getPluginGroups();
 
         if ( recessivePluginGroupIds != null )
         {
             if ( dominantPluginGroupIds == null )
             {
-                dominantPluginGroupIds = new ArrayList();
+                dominantPluginGroupIds = new ArrayList<String>();
                 dominant.setPluginGroups( dominantPluginGroupIds );
             }
 
-            for ( Iterator it = recessivePluginGroupIds.iterator(); it.hasNext(); )
+            for ( String pluginGroupId : recessivePluginGroupIds )
             {
-                String pluginGroupId = (String) it.next();
-
                 if ( !dominantPluginGroupIds.contains( pluginGroupId ) )
                 {
                     dominantPluginGroupIds.add( pluginGroupId );
@@ -116,14 +111,13 @@
      * @param recessive
      * @param recessiveSourceLevel
      */
-    private static void shallowMergeById( List dominant, List recessive, String recessiveSourceLevel )
+    private static <T extends IdentifiableBase> void shallowMergeById( List<T> dominant, List<T> recessive,
+                                                                       String recessiveSourceLevel )
     {
-        Map dominantById = mapById( dominant );
+        Map<String, T> dominantById = mapById( dominant );
 
-        for ( Iterator it = recessive.iterator(); it.hasNext(); )
+        for ( T identifiable : recessive )
         {
-            IdentifiableBase identifiable = (IdentifiableBase) it.next();
-
             if ( !dominantById.containsKey( identifiable.getId() ) )
             {
                 identifiable.setSourceLevel( recessiveSourceLevel );
@@ -137,14 +131,12 @@
      * @param identifiables
      * @return a map
      */
-    private static Map mapById( List identifiables )
+    private static <T extends IdentifiableBase> Map<String, T> mapById( List<T> identifiables )
     {
-        Map byId = new HashMap();
+        Map<String, T> byId = new HashMap<String, T>();
 
-        for ( Iterator it = identifiables.iterator(); it.hasNext(); )
+        for ( T identifiable : identifiables )
         {
-            IdentifiableBase identifiable = (IdentifiableBase) it.next();
-
             byId.put( identifiable.getId(), identifiable );
         }
 
@@ -216,21 +208,21 @@
 
         profile.setProperties( settingsProfile.getProperties() );
 
-        List repos = settingsProfile.getRepositories();
+        List<Repository> repos = settingsProfile.getRepositories();
         if ( repos != null )
         {
-            for ( Iterator it = repos.iterator(); it.hasNext(); )
+            for ( Repository repo : repos )
             {
-                profile.addRepository( convertFromSettingsRepository( (Repository) it.next() ) );
+                profile.addRepository( convertFromSettingsRepository( repo ) );
             }
         }
 
-        List pluginRepos = settingsProfile.getPluginRepositories();
+        List<Repository> pluginRepos = settingsProfile.getPluginRepositories();
         if ( pluginRepos != null )
         {
-            for ( Iterator it = pluginRepos.iterator(); it.hasNext(); )
+            for ( Repository pluginRepo : pluginRepos )
             {
-                profile.addPluginRepository( convertFromSettingsRepository( (Repository) it.next() ) );
+                profile.addPluginRepository( convertFromSettingsRepository( pluginRepo ) );
             }
         }