From 43518f56f4d97f31cd94c49f8680cb4f274615df Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Tue, 14 Feb 2012 21:55:36 +0000 Subject: [PATCH] generics and Java 5 constructs git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1244229 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/project/DefaultMavenProjectHelper.java | 4 ++-- .../org/apache/maven/project/MavenProjectHelper.java | 4 ++-- .../maven/project/artifact/AttachedArtifact.java | 9 +++++---- .../maven/project/artifact/MavenMetadataSource.java | 1 - .../org/apache/maven/toolchain/DefaultToolchain.java | 10 ++++------ .../org/apache/maven/toolchain/ToolchainPrivate.java | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java index 25eb2464ad..37061c86f9 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java @@ -106,7 +106,7 @@ public class DefaultMavenProjectHelper } } - public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ) + public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ) { Resource resource = new Resource(); resource.setDirectory( resourceDirectory ); @@ -116,7 +116,7 @@ public class DefaultMavenProjectHelper project.addResource( resource ); } - public void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ) + public void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ) { Resource resource = new Resource(); resource.setDirectory( resourceDirectory ); diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java b/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java index c652661b05..58b4b2248e 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java @@ -32,8 +32,8 @@ public interface MavenProjectHelper void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ); - void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ); + void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ); - void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ); + void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ); } diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java b/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java index b2fdec3c23..fd2b956c24 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java @@ -25,6 +25,7 @@ import org.apache.maven.artifact.InvalidArtifactRTException; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import java.util.Collection; @@ -71,12 +72,12 @@ public class AttachedArtifact + " It is derived from the main artifact." ); } - public List getAvailableVersions() + public List getAvailableVersions() { return parent.getAvailableVersions(); } - public void setAvailableVersions( List availableVersions ) + public void setAvailableVersions( List availableVersions ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact." + " It is derived from the main artifact." ); @@ -176,9 +177,9 @@ public class AttachedArtifact // we must fail silently here to avoid problems with the artifact transformers. } - public Collection getMetadataList() + public Collection getMetadataList() { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } } diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 919f0ee2ef..76c95a6b89 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -52,7 +52,6 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java index 2052b52a51..74f6e4acc5 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java @@ -20,7 +20,6 @@ package org.apache.maven.toolchain; */ import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.apache.maven.toolchain.model.ToolchainModel; @@ -74,12 +73,11 @@ public abstract class DefaultToolchain } - public boolean matchesRequirements( Map requirements ) + public boolean matchesRequirements( Map requirements ) { - Iterator it = requirements.keySet().iterator(); - while ( it.hasNext() ) + for ( Map.Entry requirement : requirements.entrySet() ) { - String key = (String) it.next(); + String key = requirement.getKey(); RequirementMatcher matcher = provides.get( key ); @@ -88,7 +86,7 @@ public abstract class DefaultToolchain getLog().debug( "Toolchain " + this + " is missing required property: " + key ); return false; } - if ( !matcher.matches( (String) requirements.get( key ) ) ) + if ( !matcher.matches( requirement.getValue() ) ) { getLog().debug( "Toolchain " + this + " doesn't match required property: " + key ); return false; diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java index 93664f901f..571ed33dcb 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java @@ -37,7 +37,7 @@ public interface ToolchainPrivate * @param requirements Map key value pair * @return */ - boolean matchesRequirements( Map requirements ); + boolean matchesRequirements( Map requirements ); ToolchainModel getModel();