use Java 5 generics (merged ftom maven-3 r804537)
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-2/branches/maven-2.2.x@813421 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java b/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
index 9ea1034..ada8ea7 100644
--- a/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
+++ b/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
@@ -187,7 +187,7 @@
private void activateDefaultProfiles( Settings settings )
{
- List activeProfiles = settings.getActiveProfiles();
+ List<String> activeProfiles = settings.getActiveProfiles();
for ( Iterator profiles = settings.getProfiles().iterator(); profiles.hasNext(); )
{
@@ -241,13 +241,13 @@
// -------------------------------------------------------------------------------------
// Alright, here's the justification for all the regexp wizardry below...
//
- // Continuum and other server-like apps may need to locate the user-level and
+ // Continuum and other server-like apps may need to locate the user-level and
// global-level settings somewhere other than ${user.home} and ${maven.home},
// respectively. Using a simple replacement of these patterns will allow them
// to specify the absolute path to these files in a customized components.xml
// file. Ideally, we'd do full pattern-evaluation against the sysprops, but this
// is a first step. There are several replacements below, in order to normalize
- // the path character before we operate on the string as a regex input, and
+ // the path character before we operate on the string as a regex input, and
// in order to avoid surprises with the File construction...
// -------------------------------------------------------------------------------------
@@ -270,7 +270,7 @@
path = path.replaceAll( "\\\\", "/" );
// ---------------------------------------------------------------------------------
// I'm not sure if this last regexp was really intended to disallow the usage of
- // network paths as user.home directory. Unfortunately it did. I removed it and
+ // network paths as user.home directory. Unfortunately it did. I removed it and
// have not detected any problems yet.
// ---------------------------------------------------------------------------------
// path = path.replaceAll( "//", "/" );
diff --git a/maven-settings/src/main/java/org/apache/maven/settings/SettingsUtils.java b/maven-settings/src/main/java/org/apache/maven/settings/SettingsUtils.java
index 6a6e8b8..315721a 100644
--- a/maven-settings/src/main/java/org/apache/maven/settings/SettingsUtils.java
+++ b/maven-settings/src/main/java/org/apache/maven/settings/SettingsUtils.java
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -55,21 +54,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 );
@@ -79,21 +76,19 @@
}
}
- List dominantPluginGroupIds = dominant.getPluginGroups();
- List recessivePluginGroupIds = recessive.getPluginGroups();
+ List<String> dominantPluginGroupIds = dominant.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 );
@@ -121,14 +116,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 );
@@ -142,14 +136,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 );
}
@@ -221,21 +213,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 ) );
}
}