maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1388769 - in /maven/plugins/trunk/maven-changelog-plugin/src: main/java/org/apache/maven/plugin/changelog/ test/java/org/apache/maven/plugin/changelog/ test/java/org/apache/maven/plugin/changelog/stubs/
Date Sat, 22 Sep 2012 11:02:23 GMT
Author: hboutemy
Date: Sat Sep 22 11:02:22 2012
New Revision: 1388769

URL: http://svn.apache.org/viewvc?rev=1388769&view=rev
Log:
added generics

Modified:
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLog.java
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogHandler.java
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityComparator.java
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
    maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/ChangeLogTest.java
    maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/FileActivityComparatorTest.java
    maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ChangeLogScmResultStub.java
    maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/DevelopersStub.java
    maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmManagerStub.java
    maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmProviderStub.java

Modified: maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLog.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLog.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLog.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLog.java
Sat Sep 22 11:02:22 2012
@@ -29,6 +29,7 @@ import javax.xml.parsers.ParserConfigura
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.maven.scm.command.changelog.ChangeLogSet;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -56,24 +57,24 @@ public class ChangeLog
      * @throws SAXException                 when an error occurred while parsing the xml
document
      * @throws IOException                  when an error occurred while accessing the xml
document
      */
-    public static List loadChangedSets( InputStream stream )
+    public static List<ChangeLogSet> loadChangedSets( InputStream stream )
         throws ParserConfigurationException, SAXException, IOException
     {
         SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
 
-        List changeLogSets = new ArrayList();
+        List<ChangeLogSet> changeLogSets = new ArrayList<ChangeLogSet>();
 
         parser.parse( stream, new ChangeLogHandler( changeLogSets ) );
 
         return changeLogSets;
     }
 
-    public static List loadChangedSets( Reader reader )
+    public static List<ChangeLogSet> loadChangedSets( Reader reader )
         throws ParserConfigurationException, SAXException, IOException
     {
         SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
 
-        List changeLogSets = new ArrayList();
+        List<ChangeLogSet> changeLogSets = new ArrayList<ChangeLogSet>();
 
         parser.parse( new InputSource( reader ), new ChangeLogHandler( changeLogSets ) );
 

Modified: maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogHandler.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogHandler.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogHandler.java
Sat Sep 22 11:02:22 2012
@@ -32,6 +32,7 @@ import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.TimeZone;
 
 /**
@@ -43,7 +44,7 @@ import java.util.TimeZone;
 public class ChangeLogHandler
     extends DefaultHandler
 {
-    private Collection changeSets;
+    private Collection<ChangeLogSet> changeSets;
 
     private String bufData = "";
 
@@ -51,7 +52,7 @@ public class ChangeLogHandler
 
     private ChangeSet bufEntry;
 
-    private LinkedList bufEntries;
+    private List<ChangeSet> bufEntries;
 
     private ChangeLogSet bufSet;
 
@@ -62,7 +63,7 @@ public class ChangeLogHandler
      *
      * @param changeSets collection object to store all change sets found within the xml
document
      */
-    public ChangeLogHandler( Collection changeSets )
+    public ChangeLogHandler( Collection<ChangeLogSet> changeSets )
     {
         this.changeSets = changeSets;
     }
@@ -176,7 +177,7 @@ public class ChangeLogHandler
         }
         else if ( "changeset".equals( qName ) )
         {
-            bufEntries = new LinkedList();
+            bufEntries = new LinkedList<ChangeSet>();
 
             currentPattern = attributes.getValue( "datePattern" );
             if ( currentPattern == null )

Modified: maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
Sat Sep 22 11:02:22 2012
@@ -138,13 +138,13 @@ public class ChangeLogReport
      * Used to specify the absolute date (or list of dates) to start log entries from.
      */
     @Parameter
-    private List dates;
+    private List<String> dates;
 
     /**
      * Used to specify the tag (or list of tags) to start log entries from.
      */
     @Parameter
-    private List tags;
+    private List<String> tags;
 
     /**
      * Used to specify the date format of the log entries that are retrieved from your SCM
system.
@@ -368,13 +368,13 @@ public class ChangeLogReport
      * @since 2.2
      */
     @Parameter( property = "project.developers" )
-    protected List developers;
+    protected List<Developer> developers;
 
     /**
      * List of provider implementations.
      */
     @Parameter
-    private Map providerImplementations;
+    private Map<String, String> providerImplementations;
 
     // temporary field holder while generating the report
     private String rptRepository, rptOneRepoParam, rptMultiRepoParam;
@@ -383,10 +383,10 @@ public class ChangeLogReport
     private String connection;
 
     // field used to hold a map of the developers by Id
-    private HashMap developersById;
+    private HashMap<String, Developer> developersById;
 
     // field used to hold a map of the developers by Name
-    private HashMap developersByName;
+    private HashMap<String, Developer> developersByName;
 
     /**
      * The system properties to use (needed by the perforce scm provider).
@@ -408,12 +408,12 @@ public class ChangeLogReport
 
         if ( providerImplementations != null )
         {
-            for ( Iterator i = providerImplementations.keySet().iterator(); i.hasNext();
)
+            for ( Map.Entry<String, String> entry : providerImplementations.entrySet()
)
             {
-                String providerType = (String) i.next();
-                String providerImplementation = (String) providerImplementations.get( providerType
);
+                String providerType = entry.getKey();
+                String providerImplementation = entry.getValue();
                 getLog().info( "Change the default '" + providerType + "' provider implementation
to '"
-                    + providerImplementation + "'." );
+                                   + providerImplementation + "'." );
                 manager.setScmProviderImplementation( providerType, providerImplementation
);
             }
         }
@@ -427,7 +427,7 @@ public class ChangeLogReport
         if ( systemProperties != null )
         {
             // Add all system properties configured by the user
-            Iterator iter = systemProperties.keySet().iterator();
+            Iterator<?> iter = systemProperties.keySet().iterator();
 
             while ( iter.hasNext() )
             {
@@ -462,15 +462,13 @@ public class ChangeLogReport
      */
     private void initializeDeveloperMaps()
     {
-        developersById = new HashMap();
-        developersByName = new HashMap();
+        developersById = new HashMap<String, Developer>();
+        developersByName = new HashMap<String, Developer>();
 
         if ( developers != null )
         {
-            for ( Iterator i = developers.iterator(); i.hasNext(); )
+            for ( Developer developer : developers )
             {
-                Developer developer = (Developer) i.next();
-
                 developersById.put( developer.getId(), developer );
                 developersByName.put( developer.getName(), developer );
             }
@@ -483,10 +481,10 @@ public class ChangeLogReport
      *
      * @throws MavenReportException
      */
-    protected List getChangedSets()
+    protected List<ChangeLogSet> getChangedSets()
         throws MavenReportException
     {
-        List changelogList = null;
+        List<ChangeLogSet> changelogList = null;
 
         if ( !outputXML.isAbsolute() )
         {
@@ -551,7 +549,7 @@ public class ChangeLogReport
         return changelogList;
     }
 
-    private void writeChangelogXml( List changelogList )
+    private void writeChangelogXml( List<ChangeLogSet> changelogList )
         throws FileNotFoundException, UnsupportedEncodingException, IOException
     {
         StringBuilder changelogXml = new StringBuilder();
@@ -559,11 +557,10 @@ public class ChangeLogReport
         changelogXml.append( "<?xml version=\"1.0\" encoding=\"" ).append( getOutputEncoding()
).append( "\"?>\n" );
         changelogXml.append( "<changelog>" );
 
-        for ( Iterator sets = changelogList.iterator(); sets.hasNext(); )
+        for ( ChangeLogSet changelogSet : changelogList )
         {
             changelogXml.append( "\n  " );
 
-            ChangeLogSet changelogSet = (ChangeLogSet) sets.next();
             String changeset = changelogSet.toXML( getOutputEncoding() );
 
             //remove xml header
@@ -597,12 +594,12 @@ public class ChangeLogReport
      * @return changedlogsets generated from the SCM
      * @throws MavenReportException
      */
-    protected List generateChangeSetsFromSCM()
+    protected List<ChangeLogSet> generateChangeSetsFromSCM()
         throws MavenReportException
     {
         try
         {
-            List changeSets = new ArrayList();
+            List<ChangeLogSet> changeSets = new ArrayList<ChangeLogSet>();
 
             ScmRepository repository = getScmRepository();
 
@@ -626,16 +623,16 @@ public class ChangeLogReport
                     throw new MavenReportException( "The type '" + type + "' isn't supported
for svn." );
                 }
 
-                Iterator tagsIter = tags.iterator();
+                Iterator<String> tagsIter = tags.iterator();
 
-                String startTag = (String) tagsIter.next();
+                String startTag = tagsIter.next();
                 String endTag = null;
 
                 if ( tagsIter.hasNext() )
                 {
                     while ( tagsIter.hasNext() )
                     {
-                        endTag = (String) tagsIter.next();
+                        endTag = tagsIter.next();
 
                         result = provider.changeLog( repository, new ScmFileSet( basedir
), new ScmRevision( startTag ),
                                                      new ScmRevision( endTag ) );
@@ -659,16 +656,16 @@ public class ChangeLogReport
             }
             else if ( "date".equals( type ) )
             {
-                Iterator dateIter = dates.iterator();
+                Iterator<String> dateIter = dates.iterator();
 
-                String startDate = (String) dateIter.next();
+                String startDate = dateIter.next();
                 String endDate = null;
 
                 if ( dateIter.hasNext() )
                 {
                     while ( dateIter.hasNext() )
                     {
-                        endDate = (String) dateIter.next();
+                        endDate = dateIter.next();
 
                         result = provider.changeLog( repository, new ScmFileSet( basedir
), parseDate( startDate ),
                                                      parseDate( endDate ), 0, (ScmBranch)
null );
@@ -973,7 +970,7 @@ public class ChangeLogReport
      * @param bundle        the resource bundle to retrieve report phrases from
      * @param sink          the report formatting tool
      */
-    protected void doGenerateReport( List changeLogSets, ResourceBundle bundle, Sink sink
)
+    protected void doGenerateReport( List<ChangeLogSet> changeLogSets, ResourceBundle
bundle, Sink sink )
     {
         sink.head();
         sink.title();
@@ -991,10 +988,8 @@ public class ChangeLogReport
         // Summary section
         doSummarySection( changeLogSets, bundle, sink );
 
-        for ( Iterator sets = changeLogSets.iterator(); sets.hasNext(); )
+        for ( ChangeLogSet changeLogSet : changeLogSets )
         {
-            ChangeLogSet changeLogSet = (ChangeLogSet) sets.next();
-
             doChangedSet( changeLogSet, bundle, sink );
         }
 
@@ -1012,7 +1007,7 @@ public class ChangeLogReport
      * @param bundle        the resource bundle to retrieve report phrases from
      * @param sink          the report formatting tool
      */
-    private void doSummarySection( List changeLogSets, ResourceBundle bundle, Sink sink )
+    private void doSummarySection( List<ChangeLogSet> changeLogSets, ResourceBundle
bundle, Sink sink )
     {
         sink.paragraph();
 
@@ -1120,7 +1115,7 @@ public class ChangeLogReport
      * @param entries a collection of SCM changes
      * @return number of files changed for the changedsets
      */
-    protected long countFilesChanged( Collection entries )
+    protected long countFilesChanged( Collection<ChangeSet> entries )
     {
         if ( entries == null )
         {
@@ -1132,29 +1127,22 @@ public class ChangeLogReport
             return 0;
         }
 
-        HashMap fileList = new HashMap();
+        HashMap<String, List<ChangeFile>> fileList = new HashMap<String, List<ChangeFile>>();
 
-        for ( Iterator i = entries.iterator(); i.hasNext(); )
+        for ( ChangeSet entry : entries )
         {
-            ChangeSet entry = (ChangeSet) i.next();
-
-            List files = entry.getFiles();
-
-            for ( Iterator fileIterator = files.iterator(); fileIterator.hasNext(); )
+            for ( ChangeFile file : entry.getFiles() )
             {
-                ChangeFile file = (ChangeFile) fileIterator.next();
-
                 String name = file.getName();
+                List<ChangeFile> list = fileList.get( name );
 
-                if ( fileList.containsKey( name ) )
+                if ( list != null )
                 {
-                    LinkedList list = (LinkedList) fileList.get( name );
-
                     list.add( file );
                 }
                 else
                 {
-                    LinkedList list = new LinkedList();
+                    list = new LinkedList<ChangeFile>();
 
                     list.add( file );
 
@@ -1173,7 +1161,7 @@ public class ChangeLogReport
      * @param bundle  the resource bundle to retrieve report phrases from
      * @param sink    the report formatting tool
      */
-    private void doChangedSetTable( Collection entries, ResourceBundle bundle, Sink sink
)
+    private void doChangedSetTable( Collection<ChangeSet> entries, ResourceBundle bundle,
Sink sink )
     {
         sink.table();
 
@@ -1191,21 +1179,17 @@ public class ChangeLogReport
 
         initReportUrls();
 
-        List sortedEntries = new ArrayList( entries );
-        Collections.sort( sortedEntries, new Comparator()
+        List<ChangeSet> sortedEntries = new ArrayList<ChangeSet>( entries );
+        Collections.sort( sortedEntries, new Comparator<ChangeSet>()
         {
-            public int compare( Object arg0, Object arg1 )
+            public int compare( ChangeSet changeSet0, ChangeSet changeSet1 )
             {
-                ChangeSet changeSet0 = (ChangeSet) arg0;
-                ChangeSet changeSet1 = (ChangeSet) arg1;
                 return changeSet1.getDate().compareTo( changeSet0.getDate() );
             }
         } );
 
-        for ( Iterator i = sortedEntries.iterator(); i.hasNext(); )
+        for ( ChangeSet entry : sortedEntries )
         {
-            ChangeSet entry = (ChangeSet) i.next();
-
             doChangedSetDetail( entry, bundle, sink );
         }
 
@@ -1418,11 +1402,10 @@ public class ChangeLogReport
      * @param files list of files to generate the reports from
      * @param sink  the report formatting tool
      */
-    private void doChangedFiles( List files, Sink sink )
+    private void doChangedFiles( List<ChangeFile> files, Sink sink )
     {
-        for ( Iterator i = files.iterator(); i.hasNext(); )
+        for ( ChangeFile file : files )
         {
-            ChangeFile file = (ChangeFile) i.next();
             sinkLogFile( sink, file.getName(), file.getRevision() );
         }
     }

Modified: maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
Sat Sep 22 11:02:22 2012
@@ -27,10 +27,10 @@ import org.apache.maven.scm.command.chan
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.ResourceBundle;
 
 /**
@@ -45,9 +45,9 @@ public class DeveloperActivityReport
     /**
      * Used to hold data while creating the report
      */
-    private HashMap commits;
+    private Map<String, List<ChangeSet>> commits;
 
-    private HashMap files;
+    private Map<String, Map<String, ChangeFile>> files;
 
     /** {@inheritDoc} */
     public String getDescription( Locale locale )
@@ -95,7 +95,7 @@ public class DeveloperActivityReport
     }
 
     /** {@inheritDoc} */
-    protected void doGenerateReport( List changeLogSets, ResourceBundle bundle, Sink sink
)
+    protected void doGenerateReport( List<ChangeLogSet> changeLogSets, ResourceBundle
bundle, Sink sink )
     {
         sink.head();
         sink.title();
@@ -117,9 +117,8 @@ public class DeveloperActivityReport
         }
         else
         {
-            for ( Iterator sets = changeLogSets.iterator(); sets.hasNext(); )
+            for ( ChangeLogSet set : changeLogSets )
             {
-                ChangeLogSet set = (ChangeLogSet) sets.next();
                 doChangedSets( set, bundle, sink );
             }
         }
@@ -176,12 +175,12 @@ public class DeveloperActivityReport
     {
         initDeveloperDetails( set );
 
-        for( Iterator i = commits.keySet().iterator(); i.hasNext(); )
+        for( Map.Entry<String, List<ChangeSet>> commit : commits.entrySet() )
         {
-            String author = (String) i.next();
+            String author = commit.getKey();
 
-            LinkedList devCommits = (LinkedList) commits.get( author );
-            HashMap devFiles = (HashMap) files.get( author );
+            List<ChangeSet> devCommits = commit.getValue();
+            Map<String, ChangeFile> devFiles = files.get( author );
 
             sink.tableRow();
             sink.tableCell();
@@ -191,11 +190,11 @@ public class DeveloperActivityReport
             sink.tableCell_();
 
             sink.tableCell();
-            sink.text( "" + devCommits.size() );
+            sink.text( String.valueOf( devCommits.size() ) );
             sink.tableCell_();
 
             sink.tableCell();
-            sink.text( "" + devFiles.size() );
+            sink.text( String.valueOf( devFiles.size() ) );
             sink.tableCell_();
 
             sink.tableRow_();
@@ -209,9 +208,9 @@ public class DeveloperActivityReport
      */
     private void initDeveloperDetails( ChangeLogSet set )
     {
-        commits = new HashMap();
+        commits = new HashMap<String, List<ChangeSet>>();
 
-        files = new HashMap();
+        files = new HashMap<String, Map<String, ChangeFile>>();
 
         countDevCommits( set.getChangeSets() );
 
@@ -223,28 +222,21 @@ public class DeveloperActivityReport
      *
      * @param entries the change log entries used to search and count developer commits
      */
-    private void countDevCommits( Collection entries )
+    private void countDevCommits( Collection<ChangeSet> entries )
     {
-        for ( Iterator i = entries.iterator(); i.hasNext(); )
+        for ( ChangeSet entry : entries )
         {
-            ChangeSet entry = (ChangeSet) i.next();
-
             String developer = entry.getAuthor();
 
-            LinkedList list;
+            List<ChangeSet> list = commits.get( developer );
 
-            if ( commits.containsKey( developer ) )
-            {
-                list = (LinkedList) commits.get( developer );
-            }
-            else
+            if ( list == null )
             {
-                list = new LinkedList();
+                list = new LinkedList<ChangeSet>();
+                commits.put( developer, list );
             }
 
             list.add( entry );
-
-            commits.put( developer, list );
         }
     }
 
@@ -253,33 +245,27 @@ public class DeveloperActivityReport
      *
      * @param entries the change log entries used to search and count file changes
      */
-    private void countDevFiles( Collection entries )
+    private void countDevFiles( Collection<ChangeSet> entries )
     {
-        for ( Iterator i2 = entries.iterator(); i2.hasNext(); )
+        for ( ChangeSet entry : entries )
         {
-            ChangeSet entry = (ChangeSet) i2.next();
-
             String developer = entry.getAuthor();
 
-            HashMap filesMap;
+            Map<String, ChangeFile> filesMap;
 
-            if ( files.containsKey( developer ) )
-            {
-                filesMap = (HashMap) files.get( developer );
-            }
-            else
+            filesMap = files.get( developer );
+
+            if ( files == null )
             {
-                filesMap = new HashMap();
+                filesMap = new HashMap<String, ChangeFile>();
+                files.put( developer, filesMap );
             }
 
-            for ( Iterator i3 = entry.getFiles().iterator(); i3.hasNext(); )
+            for ( ChangeFile file : entry.getFiles() )
             {
-                ChangeFile file = (ChangeFile) i3.next();
-
                 filesMap.put( file.getName(), file );
             }
 
-            files.put( developer, filesMap );
         }
     }
 }

Modified: maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityComparator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityComparator.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityComparator.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityComparator.java
Sat Sep 22 11:02:22 2012
@@ -23,31 +23,23 @@ import org.apache.commons.lang.StringUti
 import org.apache.maven.scm.ChangeFile;
 
 import java.util.Comparator;
-import java.util.Iterator;
 import java.util.List;
 
-
 /**
  * Object used to sort the file-activity report into descending order.
  *
  * @version $Id$
  */
 public class FileActivityComparator
-    implements Comparator
+    implements Comparator<List<ChangeFile>>
 {
     /**
      * {@inheritDoc}
      */
-    public int compare( Object o1, Object o2 )
+    public int compare( List<ChangeFile> list1, List<ChangeFile> list2 )
         throws ClassCastException
     {
-        int returnValue;
-
-        List list1 = (List) o1;
-
-        List list2 = (List) o2;
-
-        returnValue = sortByCommits( list1, list2 );
+        int returnValue = sortByCommits( list1, list2 );
 
         if ( returnValue != 0 )
         {
@@ -61,9 +53,7 @@ public class FileActivityComparator
             return returnValue;
         }
 
-        returnValue = sortByName( list1, list2 );
-
-        return returnValue;
+        return sortByName( list1, list2 );
     }
 
     /**
@@ -73,7 +63,7 @@ public class FileActivityComparator
      * @param list2 the object to compare list1 against
      * @return an integer describing the order comparison of list1 and list2
      */
-    private int sortByCommits( List list1, List list2 )
+    private int sortByCommits( List<ChangeFile> list1, List<ChangeFile> list2
)
     {
         if ( list1.size() > list2.size() )
         {
@@ -95,7 +85,7 @@ public class FileActivityComparator
      * @param list2 the object to compare list1 against
      * @return an integer describing the order comparison of list1 and list2
      */
-    private int sortByRevision( List list1, List list2 )
+    private int sortByRevision( List<ChangeFile> list1, List<ChangeFile> list2
)
     {
         String revision1 = getLatestRevision( list1 );
 
@@ -120,14 +110,12 @@ public class FileActivityComparator
      * @param list The list of revisions from the file
      * @return the latest revision code
      */
-    private String getLatestRevision( List list )
+    private String getLatestRevision( List<ChangeFile> list )
     {
         String latest = "";
 
-        for ( Iterator i = list.iterator(); i.hasNext(); )
+        for ( ChangeFile file : list )
         {
-            ChangeFile file = (ChangeFile) i.next();
-
             if ( StringUtils.isNotBlank( latest) )
             {
                 latest = file.getRevision();
@@ -149,11 +137,11 @@ public class FileActivityComparator
      * @param list2 the object to compare list1 against
      * @return an integer describing the order comparison of list1 and list2
      */
-    private int sortByName( List list1, List list2 )
+    private int sortByName( List<ChangeFile> list1, List<ChangeFile> list2 )
     {
-        ChangeFile file1 = (ChangeFile) list1.get( 0 );
+        ChangeFile file1 = list1.get( 0 );
 
-        ChangeFile file2 = (ChangeFile) list2.get( 0 );
+        ChangeFile file2 = list2.get( 0 );
 
         return file1.getName().compareTo( file2.getName() );
     }

Modified: maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
Sat Sep 22 11:02:22 2012
@@ -28,7 +28,6 @@ import org.apache.maven.scm.command.chan
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -90,7 +89,7 @@ public class FileActivityReport
     }
 
     /** {@inheritDoc} */
-    protected void doGenerateReport( List changeLogSets, ResourceBundle bundle, Sink sink
)
+    protected void doGenerateReport( List<ChangeLogSet> changeLogSets, ResourceBundle
bundle, Sink sink )
     {
         sink.head();
         sink.title();
@@ -104,9 +103,8 @@ public class FileActivityReport
         sink.text( bundle.getString( "report.file-activity.mainTitle" ) );
         sink.sectionTitle1_();
 
-        for ( Iterator sets = changeLogSets.iterator(); sets.hasNext(); )
+        for ( ChangeLogSet set : changeLogSets )
         {
-            ChangeLogSet set = (ChangeLogSet) sets.next();
             doChangedSets( set, bundle, sink );
         }
 
@@ -158,14 +156,13 @@ public class FileActivityReport
      */
     private void doRows( ChangeLogSet set, Sink sink )
     {
-        List list = getOrderedFileList( set.getChangeSets() );
+        List<List<ChangeFile>> list = getOrderedFileList( set.getChangeSets()
);
 
         initReportUrls();
 
-        for ( Iterator i = list.iterator(); i.hasNext(); )
+        for ( List<ChangeFile> revision : list )
         {
-            List revision = (List) i.next();
-            ChangeFile file = (ChangeFile) revision.get( 0 );
+            ChangeFile file = revision.get( 0 );
 
             sink.tableRow();
             sink.tableCell();
@@ -204,34 +201,25 @@ public class FileActivityReport
      * @param entries the changelog entries to generate the report
      * @return list of changed files within the SCM with the number of times changed in descending
order
      */
-    private List getOrderedFileList( Collection entries )
+    private List<List<ChangeFile>> getOrderedFileList( Collection<ChangeSet>
entries )
     {
-        List list = new LinkedList();
+        List<List<ChangeFile>> list = new LinkedList<List<ChangeFile>>();
 
-        Map map = new HashMap();
+        Map<String, List<ChangeFile>> map = new HashMap<String, List<ChangeFile>>();
 
-        for ( Iterator i = entries.iterator(); i.hasNext(); )
+        for ( ChangeSet entry : entries )
         {
-            ChangeSet entry = (ChangeSet) i.next();
-
-            for ( Iterator j = entry.getFiles().iterator(); j.hasNext(); )
+            for ( ChangeFile file : entry.getFiles() )
             {
-                ChangeFile file = (ChangeFile) j.next();
-
-                List revisions;
+                List<ChangeFile> revisions = map.get( file.getName() );
 
-                if ( map.containsKey( file.getName() ) )
-                {
-                    revisions = (List) map.get( file.getName() );
-                }
-                else
+                if ( revisions == null )
                 {
-                    revisions = new LinkedList();
+                    revisions = new LinkedList<ChangeFile>();
+                    map.put( file.getName(), revisions );
                 }
 
                 revisions.add( file );
-
-                map.put( file.getName(), revisions );
             }
         }
 

Modified: maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/ChangeLogTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/ChangeLogTest.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/ChangeLogTest.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/ChangeLogTest.java
Sat Sep 22 11:02:22 2012
@@ -40,17 +40,17 @@ public class ChangeLogTest
     public void testReadFile()
         throws Exception
     {
-        List changedLogs = readChangeLogXml( "min-changelog.xml" );
+        List<ChangeLogSet> changedLogs = readChangeLogXml( "min-changelog.xml" );
 
         assertNotNull( "Test changedSets were parsed", changedLogs );
 
         assertEquals( "Test number of changelog entries", 2, changedLogs.size() );
 
-        ChangeLogSet changelogSets = (ChangeLogSet) changedLogs.get( 0 );
+        ChangeLogSet changelogSets = changedLogs.get( 0 );
 
         assertEquals( "Test number of revisions on changelog 1", 2, changelogSets.getChangeSets().size()
);
 
-        ChangeSet changeSet = (ChangeSet) changelogSets.getChangeSets().get( 0 );
+        ChangeSet changeSet = changelogSets.getChangeSets().get( 0 );
 
 
         Calendar cal = Calendar.getInstance(); // new cal with default TZ
@@ -68,14 +68,14 @@ public class ChangeLogTest
 
         assertEquals( "Test changelog 1 set 1 files", 1, changeSet.getFiles().size() );
 
-        ChangeFile changeFile = (ChangeFile) changeSet.getFiles().get( 0 );
+        ChangeFile changeFile = changeSet.getFiles().get( 0 );
 
         assertEquals( "Test changelog 1 set 1 file 1 filename", "/path/to/file.extension",
changeFile.getName() );
 
         assertEquals( "Test changelog 1 set 1 file 1 revision", "1", changeFile.getRevision()
);
 
 
-        changeSet = (ChangeSet) changelogSets.getChangeSets().get( 1 );
+        changeSet = changelogSets.getChangeSets().get( 1 );
 
         cal.set( 2005, 1, 24, 21, 30, 0 );
 
@@ -87,13 +87,13 @@ public class ChangeLogTest
 
         assertEquals( "Test changelog 1 set 2 files", 2, changeSet.getFiles().size() );
 
-        changeFile = (ChangeFile) changeSet.getFiles().get( 0 );
+        changeFile = changeSet.getFiles().get( 0 );
 
         assertEquals( "Test changelog 1 set 2 file 1 filename", "/path/to/file.extension",
changeFile.getName() );
 
         assertEquals( "Test changelog 1 set 2 file 1 revision", "2", changeFile.getRevision()
);
 
-        changeFile = (ChangeFile) changeSet.getFiles().get( 1 );
+        changeFile = changeSet.getFiles().get( 1 );
 
         assertEquals( "Test changelog 1 set 2 file 2 filename", "/path/to/file2.extension",
changeFile.getName() );
 
@@ -101,11 +101,11 @@ public class ChangeLogTest
 
 
 
-        changelogSets = (ChangeLogSet) changedLogs.get( 1 );
+        changelogSets = changedLogs.get( 1 );
 
         assertEquals( "Test number of revisions on changelog 2", 2, changelogSets.getChangeSets().size()
);
 
-        changeSet = (ChangeSet) changelogSets.getChangeSets().get( 0 );
+        changeSet = changelogSets.getChangeSets().get( 0 );
 
         cal.set( 2005, 1, 25, 22, 45, 0 );
 
@@ -117,14 +117,14 @@ public class ChangeLogTest
 
         assertEquals( "Test changelog 2 set 1 files", 1, changeSet.getFiles().size() );
 
-        changeFile = (ChangeFile) changeSet.getFiles().get( 0 );
+        changeFile = changeSet.getFiles().get( 0 );
 
         assertEquals( "Test changelog 2 set 1 file 1 filename", "/path/to/file.extension",
changeFile.getName() );
 
         assertEquals( "Test changelog 2 set 1 file 1 revision", "3", changeFile.getRevision()
);
 
 
-        changeSet = (ChangeSet) changelogSets.getChangeSets().get( 1 );
+        changeSet = changelogSets.getChangeSets().get( 1 );
 
         cal.set( 2100, 1, 25, 5, 30, 0 );
 
@@ -136,20 +136,20 @@ public class ChangeLogTest
 
         assertEquals( "Test changelog 2 set 2 files", 2, changeSet.getFiles().size() );
 
-        changeFile = (ChangeFile) changeSet.getFiles().get( 0 );
+        changeFile = changeSet.getFiles().get( 0 );
 
         assertEquals( "Test changelog 2 set 2 file 1 filename", "/path/to/file.extension",
changeFile.getName() );
 
         assertEquals( "Test changelog 2 set 2 file 1 revision", "4", changeFile.getRevision()
);
 
-        changeFile = (ChangeFile) changeSet.getFiles().get( 1 );
+        changeFile = changeSet.getFiles().get( 1 );
 
         assertEquals( "Test changelog 2 set 2 file 2 filename", "/path/to/file2.extension",
changeFile.getName() );
 
         assertEquals( "Test changelog 2 set 2 file 2 revision", "4", changeFile.getRevision()
);
     }
 
-    private List readChangeLogXml( String filename )
+    private List<ChangeLogSet> readChangeLogXml( String filename )
         throws Exception
     {
         File inputFile = new File( getBasedir(), "src/test/changelog-xml/" + filename );

Modified: maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/FileActivityComparatorTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/FileActivityComparatorTest.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/FileActivityComparatorTest.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/FileActivityComparatorTest.java
Sat Sep 22 11:02:22 2012
@@ -43,17 +43,17 @@ public class FileActivityComparatorTest
 
     public void testCompareByNumberOfCommits()
     {
-        List list1 = new ArrayList();
+        List<ChangeFile> list1 = new ArrayList<ChangeFile>();
         list1.add( new ChangeFile( "anything" ) );
 
-        List list2 = new ArrayList();
+        List<ChangeFile> list2 = new ArrayList<ChangeFile>();
 
         assertTrue( "Test compare by commits, less than", comparator.compare( list1, list2
) < 0 );
 
-        list1 = new ArrayList();
+        list1 = new ArrayList<ChangeFile>();
         list1.add( new ChangeFile( "anything" ) );
 
-        list2 = new ArrayList();
+        list2 = new ArrayList<ChangeFile>();
         list2.add( new ChangeFile( "one thing" ) );
         list2.add( new ChangeFile( "something") );
 
@@ -62,21 +62,21 @@ public class FileActivityComparatorTest
 
     public void testCompareByRevision()
     {
-        List list1 = new ArrayList();
+        List<ChangeFile> list1 = new ArrayList<ChangeFile>();
         list1.add( new ChangeFile( "changefile-1", "123" ) );
         list1.add( new ChangeFile( "changefile-1", "234" ) );
 
-        List list2 = new ArrayList();
+        List<ChangeFile> list2 = new ArrayList<ChangeFile>();
         list2.add( new ChangeFile( "changefile-2", "246" ) );
         list2.add( new ChangeFile( "changefile-2", "468" ) );
 
         assertTrue( "Test compare by revision, less than", comparator.compare( list1, list2
) < 0 );
 
-        list1 = new ArrayList();
+        list1 = new ArrayList<ChangeFile>();
         list1.add( new ChangeFile( "changefile-1", "246" ) );
         list1.add( new ChangeFile( "changefile-1", "468" ) );
 
-        list2 = new ArrayList();
+        list2 = new ArrayList<ChangeFile>();
         list2.add( new ChangeFile( "changefile-2", "123" ) );
         list2.add( new ChangeFile( "changefile-2", "234" ) );
 
@@ -85,21 +85,21 @@ public class FileActivityComparatorTest
 
     public void testCompareByName()
     {
-        List list1 = new ArrayList();
+        List<ChangeFile> list1 = new ArrayList<ChangeFile>();
         list1.add( new ChangeFile( "changefile-1", "123" ) );
         list1.add( new ChangeFile( "changefile-1", "468" ) );
 
-        List list2 = new ArrayList();
+        List<ChangeFile> list2 = new ArrayList<ChangeFile>();
         list2.add( new ChangeFile( "changefile-2", "246" ) );
         list2.add( new ChangeFile( "changefile-2", "468" ) );
 
         assertTrue( "Test compare by name, less than", comparator.compare( list1, list2 )
< 0 );
 
-        list1 = new ArrayList();
+        list1 = new ArrayList<ChangeFile>();
         list1.add( new ChangeFile( "changefile-1", "246" ) );
         list1.add( new ChangeFile( "changefile-1", "468" ) );
 
-        list2 = new ArrayList();
+        list2 = new ArrayList<ChangeFile>();
         list2.add( new ChangeFile( "changefile-2", "123" ) );
         list2.add( new ChangeFile( "changefile-2", "234" ) );
 

Modified: maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ChangeLogScmResultStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ChangeLogScmResultStub.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ChangeLogScmResultStub.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ChangeLogScmResultStub.java
Sat Sep 22 11:02:22 2012
@@ -19,6 +19,7 @@ package org.apache.maven.plugin.changelo
  * under the License.
  */
 
+import org.apache.maven.scm.ChangeSet;
 import org.apache.maven.scm.command.changelog.ChangeLogSet;
 
 import java.util.Collections;
@@ -44,6 +45,6 @@ public class ChangeLogScmResultStub
     /** {@inheritDoc} */
     public ChangeLogSet getChangeLog()
     {
-        return new ChangeLogSet( Collections.EMPTY_LIST, new Date( 360 ), new Date( 720 )
);
+        return new ChangeLogSet( Collections.<ChangeSet> emptyList(), new Date( 360
), new Date( 720 ) );
     }
 }

Modified: maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/DevelopersStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/DevelopersStub.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/DevelopersStub.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/DevelopersStub.java
Sat Sep 22 11:02:22 2012
@@ -29,13 +29,13 @@ import java.util.List;
  * @version $Id$
  */
 public class DevelopersStub
-    extends ArrayList
+    extends ArrayList<Developer>
 {
     public DevelopersStub()
     {
         super();
 
-        List developers = new ArrayList();
+        List<Developer> developers = new ArrayList<Developer>();
 
         Developer developer = new Developer();
         developer.setName( "Edwin Punzalan" );

Modified: maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmManagerStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmManagerStub.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmManagerStub.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmManagerStub.java
Sat Sep 22 11:02:22 2012
@@ -90,7 +90,7 @@ public class ScmManagerStub
     }
 
     /** {@inheritDoc} */
-    public List validateScmRepository( String string )
+    public List<String> validateScmRepository( String string )
     {
         return null;
     }

Modified: maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmProviderStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmProviderStub.java?rev=1388769&r1=1388768&r2=1388769&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmProviderStub.java
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/test/java/org/apache/maven/plugin/changelog/stubs/ScmProviderStub.java
Sat Sep 22 11:02:22 2012
@@ -461,7 +461,7 @@ public class ScmProviderStub
     }
 
     /** {@inheritDoc} */
-    public List validateScmUrl( String string, char c )
+    public List<String> validateScmUrl( String string, char c )
     {
         return null;
     }



Mime
View raw message