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 2012/08/15 23:35:50 UTC
svn commit: r1373637 - in
/maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck:
AbstractCheckDocumentationMojo.java CheckPluginDocumentationMojo.java
reports/DocumentationReporter.java
Author: hboutemy
Date: Wed Aug 15 21:35:50 2012
New Revision: 1373637
URL: http://svn.apache.org/viewvc?rev=1373637&view=rev
Log:
added generics
Modified:
maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java
maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java
maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java
Modified: maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java?rev=1373637&r1=1373636&r2=1373637&view=diff
==============================================================================
--- maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java (original)
+++ maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java Wed Aug 15 21:35:50 2012
@@ -52,7 +52,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -71,7 +70,7 @@ public abstract class AbstractCheckDocum
/**
*/
@Parameter( property = "reactorProjects", readonly = true, required = true )
- private List reactorProjects;
+ private List<MavenProject> reactorProjects;
/**
* An optional location where the results will be written to. If this is
@@ -105,7 +104,7 @@ public abstract class AbstractCheckDocum
private FileSetManager fileSetManager = new FileSetManager();
- private List validUrls = new ArrayList();
+ private List<String> validUrls = new ArrayList<String>();
protected AbstractCheckDocumentationMojo()
{
@@ -119,7 +118,7 @@ public abstract class AbstractCheckDocum
httpClient.getParams().setParameter( HttpMethodParams.USER_AGENT, httpUserAgent );
}
- protected List getReactorProjects()
+ protected List<MavenProject> getReactorProjects()
{
return reactorProjects;
}
@@ -134,13 +133,11 @@ public abstract class AbstractCheckDocum
getLog().info( "Writing documentation check results to: " + output );
}
- Map reporters = new LinkedHashMap();
+ Map<MavenProject, DocumentationReporter> reporters = new LinkedHashMap<MavenProject, DocumentationReporter>();
boolean hasErrors = false;
- for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+ for ( MavenProject project : reactorProjects )
{
- MavenProject project = (MavenProject) it.next();
-
if ( approveProjectPackaging( project.getPackaging() ) )
{
getLog().info( "Checking project: " + project.getName() );
@@ -232,17 +229,15 @@ public abstract class AbstractCheckDocum
}
}
- private String buildErrorMessages( Map reporters )
+ private String buildErrorMessages( Map<MavenProject, DocumentationReporter> reporters )
{
String messages = "";
StringBuffer buffer = new StringBuffer();
- for ( Iterator it = reporters.entrySet().iterator(); it.hasNext(); )
+ for ( Map.Entry<MavenProject, DocumentationReporter> entry : reporters.entrySet() )
{
- Map.Entry entry = (Map.Entry) it.next();
-
- MavenProject project = (MavenProject) entry.getKey();
- DocumentationReporter reporter = (DocumentationReporter) entry.getValue();
+ MavenProject project = entry.getKey();
+ DocumentationReporter reporter = entry.getValue();
if ( !reporter.getMessages().isEmpty() )
{
@@ -256,10 +251,8 @@ public abstract class AbstractCheckDocum
buffer.append( ")" );
buffer.append( "\n" );
- for ( Iterator errorIterator = reporter.getMessages().iterator(); errorIterator.hasNext(); )
+ for ( String error : reporter.getMessages() )
{
- String error = (String) errorIterator.next();
-
buffer.append( " " ).append( error ).append( "\n" );
}
}
@@ -421,7 +414,8 @@ public abstract class AbstractCheckDocum
private void checkProjectLicenses( MavenProject project, DocumentationReporter reporter )
{
- List licenses = project.getLicenses();
+ @SuppressWarnings( "unchecked" )
+ List<License> licenses = project.getLicenses();
if ( licenses == null || licenses.isEmpty() )
{
@@ -429,10 +423,8 @@ public abstract class AbstractCheckDocum
}
else
{
- for ( Iterator it = licenses.iterator(); it.hasNext(); )
+ for ( License license : licenses )
{
- License license = (License) it.next();
-
if ( StringUtils.isEmpty( license.getName() ) )
{
reporter.error( "pom.xml is missing the <licenses>/<license>/<name> tag." );
@@ -457,10 +449,8 @@ public abstract class AbstractCheckDocum
private String getURLProtocol( String url )
throws MalformedURLException
{
- String protocol;
-
URL licenseUrl = new URL( url );
- protocol = licenseUrl.getProtocol();
+ String protocol = licenseUrl.getProtocol();
if ( protocol != null )
{
Modified: maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java?rev=1373637&r1=1373636&r2=1373637&view=diff
==============================================================================
--- maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java (original)
+++ maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java Wed Aug 15 21:35:50 2012
@@ -38,7 +38,6 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
@@ -81,15 +80,14 @@ public class CheckPluginDocumentationMoj
if ( descriptor != null )
{
- List mojos = descriptor.getMojos();
+ @SuppressWarnings( "unchecked" )
+ List<MojoDescriptor> mojos = descriptor.getMojos();
// ensure that all mojo classes are documented
if ( mojos != null && !mojos.isEmpty() )
{
- for ( Iterator it = mojos.iterator(); it.hasNext(); )
+ for ( MojoDescriptor mojo : mojos )
{
- MojoDescriptor mojo = (MojoDescriptor) it.next();
-
String mojoDescription = mojo.getDescription();
if ( mojoDescription == null || mojoDescription.trim().length() < MIN_DESCRIPTION_LENGTH )
@@ -97,15 +95,14 @@ public class CheckPluginDocumentationMoj
reporter.error( "Mojo: \'" + mojo.getGoal() + "\' is missing a description." );
}
- List params = mojo.getParameters();
+ @SuppressWarnings( "unchecked" )
+ List<Parameter> params = mojo.getParameters();
// ensure that all parameters are documented
if ( params != null && !params.isEmpty() )
{
- for ( Iterator paramIterator = params.iterator(); paramIterator.hasNext(); )
+ for ( Parameter param : params )
{
- Parameter param = (Parameter) paramIterator.next();
-
if ( param.getRequirement() == null && param.isEditable() )
{
String paramDescription = param.getDescription();
@@ -220,15 +217,14 @@ public class CheckPluginDocumentationMoj
*/
private void checkConfiguredReportPlugins( MavenProject project, DocumentationReporter reporter )
{
- List expectedPlugins = getRequiredPlugins();
+ List<String> expectedPlugins = getRequiredPlugins();
- List reportPlugins = project.getReportPlugins();
+ @SuppressWarnings( "unchecked" )
+ List<ReportPlugin> reportPlugins = project.getReportPlugins();
if ( reportPlugins != null && reportPlugins.size() > 0 )
{
- for ( Iterator plugins = reportPlugins.iterator(); plugins.hasNext(); )
+ for ( ReportPlugin plugin : reportPlugins )
{
- ReportPlugin plugin = (ReportPlugin) plugins.next();
-
expectedPlugins.remove( plugin.getArtifactId() );
}
}
@@ -237,9 +233,9 @@ public class CheckPluginDocumentationMoj
reporter.error( "pom.xml has no report plugins configured." );
}
- for ( Iterator plugins = expectedPlugins.iterator(); plugins.hasNext(); )
+ for ( String expectedPlugin : expectedPlugins )
{
- reporter.error( "pom.xml is missing the report plugin: " + plugins.next().toString() + "." );
+ reporter.error( "pom.xml is missing the report plugin: " + expectedPlugin + "." );
}
}
@@ -248,9 +244,9 @@ public class CheckPluginDocumentationMoj
*
* @return List of report plugin artifactIds
*/
- private List getRequiredPlugins()
+ private List<String> getRequiredPlugins()
{
- List list = new ArrayList();
+ List<String> list = new ArrayList<String>();
list.add( "maven-javadoc-plugin" );
list.add( "maven-jxr-plugin" );
Modified: maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java?rev=1373637&r1=1373636&r2=1373637&view=diff
==============================================================================
--- maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java (original)
+++ maven/plugins/trunk/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java Wed Aug 15 21:35:50 2012
@@ -21,14 +21,13 @@ package org.apache.maven.plugin.docck.re
import java.util.List;
import java.util.ArrayList;
-import java.util.Iterator;
/**
* @author Edwin Punzalan
*/
public class DocumentationReporter
{
- private List reports = new ArrayList();
+ private List<DocumentationReport> reports = new ArrayList<DocumentationReport>();
public void info( String message )
{
@@ -45,14 +44,12 @@ public class DocumentationReporter
reports.add( new ErrorDocumentationReport( "[ERROR] " + message ) );
}
- public List getMessagesByType( int type )
+ public List<String> getMessagesByType( int type )
{
- List list = new ArrayList();
+ List<String> list = new ArrayList<String>();
- for ( Iterator iter = reports.iterator(); iter.hasNext(); )
+ for ( DocumentationReport report : reports )
{
- DocumentationReport report = (DocumentationReport) iter.next();
-
if ( report.getType() == type )
{
list.add( report.getMessage() );
@@ -62,14 +59,12 @@ public class DocumentationReporter
return list;
}
- public List getMessages()
+ public List<String> getMessages()
{
- List list = new ArrayList();
+ List<String> list = new ArrayList<String>();
- for ( Iterator iter = reports.iterator(); iter.hasNext(); )
+ for ( DocumentationReport report : reports )
{
- DocumentationReport report = (DocumentationReport) iter.next();
-
list.add( report.getMessage() );
}
@@ -78,13 +73,11 @@ public class DocumentationReporter
public boolean hasErrors()
{
- for ( Iterator iter = reports.iterator(); iter.hasNext(); )
+ for ( DocumentationReport report : reports )
{
- DocumentationReport report = (DocumentationReport) iter.next();
-
if ( report.getType() == DocumentationReport.TYPE_ERROR )
{
- //first occurrence will do
+ // first occurrence will do
return true;
}
}