maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steph...@apache.org
Subject [01/21] git commit: Use for each
Date Mon, 06 Jan 2014 11:25:14 GMT
Updated Branches:
  refs/heads/master 3480789f1 -> 3929f55c3


Use for each


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/71f73b29
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/71f73b29
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/71f73b29

Branch: refs/heads/master
Commit: 71f73b29fa90b78f12a7742fbf713d8a83400316
Parents: 3480789
Author: Stephen Connolly <stephen.alan.connolly@gmail.com>
Authored: Mon Jan 6 10:30:42 2014 +0000
Committer: Stephen Connolly <stephen.alan.connolly@gmail.com>
Committed: Mon Jan 6 10:30:42 2014 +0000

----------------------------------------------------------------------
 .../DefaultModelInheritanceAssembler.java       | 49 +++++++++-----------
 .../resolver/DefaultArtifactResolverTest.java   |  6 +--
 .../inheritance/t02/ProjectInheritanceTest.java | 16 +++----
 3 files changed, 31 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/71f73b29/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
index ec04f34..4b08eb9 100644
--- a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
+++ b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
@@ -20,6 +20,7 @@ package org.apache.maven.project.inheritance;
  */
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
@@ -372,18 +373,16 @@ public class DefaultModelInheritanceAssembler
             return;
         }
 
-        List parentPlugins = parent.getPlugins();
+        List<ReportPlugin> parentPlugins = parent.getPlugins();
 
         if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
         {
-            Map assembledPlugins = new TreeMap();
+            Map<String, ReportPlugin> assembledPlugins = new TreeMap<String, ReportPlugin>();
 
-            Map childPlugins = child.getReportPluginsAsMap();
+            Map<String, ReportPlugin> childPlugins = child.getReportPluginsAsMap();
 
-            for ( Object parentPlugin1 : parentPlugins )
+            for ( ReportPlugin parentPlugin : parentPlugins )
             {
-                ReportPlugin parentPlugin = (ReportPlugin) parentPlugin1;
-
                 String parentInherited = parentPlugin.getInherited();
 
                 if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf(
parentInherited ) )
@@ -391,7 +390,7 @@ public class DefaultModelInheritanceAssembler
 
                     ReportPlugin assembledPlugin = parentPlugin;
 
-                    ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey()
);
+                    ReportPlugin childPlugin = childPlugins.get( parentPlugin.getKey() );
 
                     if ( childPlugin != null )
                     {
@@ -409,17 +408,15 @@ public class DefaultModelInheritanceAssembler
                 }
             }
 
-            for ( Iterator it = childPlugins.values().iterator(); it.hasNext(); )
+            for ( ReportPlugin childPlugin : childPlugins.values() )
             {
-                ReportPlugin childPlugin = (ReportPlugin) it.next();
-
                 if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
                 {
                     assembledPlugins.put( childPlugin.getKey(), childPlugin );
                 }
             }
 
-            child.setPlugins( new ArrayList( assembledPlugins.values() ) );
+            child.setPlugins( new ArrayList<ReportPlugin>( assembledPlugins.values()
) );
 
             child.flushReportPluginMap();
         }
@@ -427,10 +424,10 @@ public class DefaultModelInheritanceAssembler
 
     private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
     {
-        List parentReports = parent.getReports();
-        List childReports = child.getReports();
+        List<String> parentReports = parent.getReports();
+        List<String> childReports = child.getReports();
 
-        List reports = new ArrayList();
+        List<String> reports = new ArrayList<String>();
 
         if ( ( childReports != null ) && !childReports.isEmpty() )
         {
@@ -439,10 +436,8 @@ public class DefaultModelInheritanceAssembler
 
         if ( parentReports != null )
         {
-            for ( Iterator i = parentReports.iterator(); i.hasNext(); )
+            for ( String report : parentReports )
             {
-                String report = (String) i.next();
-
                 if ( !reports.contains( report ) )
                 {
                     reports.add( report );
@@ -480,23 +475,23 @@ public class DefaultModelInheritanceAssembler
 
         boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited
);
 
-        List parentReportSets = parent.getReportSets();
+        List<ReportSet> parentReportSets = parent.getReportSets();
 
         if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
         {
-            Map assembledReportSets = new TreeMap();
+            Map<String, ReportSet> assembledReportSets = new TreeMap<String, ReportSet>();
 
-            Map childReportSets = child.getReportSetsAsMap();
+            Map<String, ReportSet> childReportSets = child.getReportSetsAsMap();
 
-            for ( Iterator it = parentReportSets.iterator(); it.hasNext(); )
+            for ( Object parentReportSet1 : parentReportSets )
             {
-                ReportSet parentReportSet = (ReportSet) it.next();
+                ReportSet parentReportSet = (ReportSet) parentReportSet1;
 
                 if ( !handleAsInheritance || parentIsInherited )
                 {
                     ReportSet assembledReportSet = parentReportSet;
 
-                    ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId()
);
+                    ReportSet childReportSet = childReportSets.get( parentReportSet.getId()
);
 
                     if ( childReportSet != null )
                     {
@@ -513,11 +508,9 @@ public class DefaultModelInheritanceAssembler
                 }
             }
 
-            for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); )
+            for ( Map.Entry<String, ReportSet> entry : childReportSets.entrySet() )
             {
-                Map.Entry entry = (Map.Entry) it.next();
-
-                String id = (String) entry.getKey();
+                String id = entry.getKey();
 
                 if ( !assembledReportSets.containsKey( id ) )
                 {
@@ -525,7 +518,7 @@ public class DefaultModelInheritanceAssembler
                 }
             }
 
-            child.setReportSets( new ArrayList( assembledReportSets.values() ) );
+            child.setReportSets( new ArrayList<ReportSet>( assembledReportSets.values()
) );
 
             child.flushReportSetMap();
         }

http://git-wip-us.apache.org/repos/asf/maven/blob/71f73b29/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
index 40d94c2..914d9d1 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
@@ -78,16 +78,16 @@ public class DefaultArtifactResolverTest
 
         boolean seen = false;
 
-        for ( int i = 0; i < tgList.length; i++ )
+        for ( ThreadGroup aTgList : tgList )
         {
-            if ( !tgList[i].getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) )
+            if ( !aTgList.getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) )
             {
                 continue;
             }
 
             seen = true;
 
-            tg = tgList[i];
+            tg = aTgList;
             Thread[] ts = new Thread[tg.activeCount()];
             tg.enumerate( ts );
 

http://git-wip-us.apache.org/repos/asf/maven/blob/71f73b29/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
index 2bcf7b5..808f8f0 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
@@ -116,7 +116,7 @@ public class ProjectInheritanceTest
         assertEquals( "4.0.0", project4.getModelVersion() );
         
         Build build = project4.getBuild();
-        List plugins = build.getPlugins();
+        List<Plugin> plugins = build.getPlugins();
         
         Map validPluginCounts = new HashMap();
         
@@ -131,13 +131,11 @@ public class ProjectInheritanceTest
         validPluginCounts.put( "maven-source-plugin", 0 );
         
         Plugin testPlugin = null;
-        
-        for ( Iterator it = plugins.iterator(); it.hasNext(); )
+
+        for ( Plugin plugin : plugins )
         {
-            Plugin plugin = (Plugin) it.next();
-            
             String pluginArtifactId = plugin.getArtifactId();
-            
+
             if ( !validPluginCounts.containsKey( pluginArtifactId ) )
             {
                 fail( "Illegal plugin found: " + pluginArtifactId );
@@ -148,9 +146,9 @@ public class ProjectInheritanceTest
                 {
                     testPlugin = plugin;
                 }
-                
+
                 Integer count = (Integer) validPluginCounts.get( pluginArtifactId );
-                
+
                 if ( count.intValue() > 0 )
                 {
                     fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM."
);
@@ -158,7 +156,7 @@ public class ProjectInheritanceTest
                 else
                 {
                     count = count.intValue() + 1;
-                    
+
                     validPluginCounts.put( pluginArtifactId, count );
                 }
             }


Mime
View raw message