Code cleanup - Maven requires Java 5+ : Replace for and while loops by for each

This commit is contained in:
Arnaud Héritier 2013-06-11 22:21:54 +02:00
parent 1f84f8f296
commit d92746dc25
20 changed files with 120 additions and 130 deletions

View File

@ -141,9 +141,9 @@ public class DefaultProfileManager
*/ */
public void explicitlyActivate( List profileIds ) public void explicitlyActivate( List profileIds )
{ {
for ( Iterator it = profileIds.iterator(); it.hasNext(); ) for ( Object profileId1 : profileIds )
{ {
String profileId = (String) it.next(); String profileId = (String) profileId1;
explicitlyActivate( profileId ); explicitlyActivate( profileId );
} }
@ -167,9 +167,9 @@ public class DefaultProfileManager
*/ */
public void explicitlyDeactivate( List profileIds ) public void explicitlyDeactivate( List profileIds )
{ {
for ( Iterator it = profileIds.iterator(); it.hasNext(); ) for ( Object profileId1 : profileIds )
{ {
String profileId = (String) it.next(); String profileId = (String) profileId1;
explicitlyDeactivate( profileId ); explicitlyDeactivate( profileId );
} }
@ -215,9 +215,9 @@ public class DefaultProfileManager
*/ */
public void addProfiles( List profiles ) public void addProfiles( List profiles )
{ {
for ( Iterator it = profiles.iterator(); it.hasNext(); ) for ( Object profile1 : profiles )
{ {
Profile profile = (Profile) it.next(); Profile profile = (Profile) profile1;
addProfile( profile ); addProfile( profile );
} }

View File

@ -100,21 +100,19 @@ public class ProfilesConversionUtils
List repos = profileXmlProfile.getRepositories(); List repos = profileXmlProfile.getRepositories();
if ( repos != null ) if ( repos != null )
{ {
for ( Iterator it = repos.iterator(); it.hasNext(); ) for ( Object repo : repos )
{ {
profile profile.addRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) repo ) );
.addRepository(
convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it.next() ) );
} }
} }
List pluginRepos = profileXmlProfile.getPluginRepositories(); List pluginRepos = profileXmlProfile.getPluginRepositories();
if ( pluginRepos != null ) if ( pluginRepos != null )
{ {
for ( Iterator it = pluginRepos.iterator(); it.hasNext(); ) for ( Object pluginRepo : pluginRepos )
{ {
profile.addPluginRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it profile.addPluginRepository(
.next() ) ); convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) pluginRepo ) );
} }
} }

View File

@ -323,15 +323,13 @@ public class DefaultModelInheritanceAssembler
List<Dependency> childDeps = childDepMgmt.getDependencies(); List<Dependency> childDeps = childDepMgmt.getDependencies();
Map<String, Dependency> mappedChildDeps = new TreeMap<String, Dependency>(); Map<String, Dependency> mappedChildDeps = new TreeMap<String, Dependency>();
for ( Iterator<Dependency> it = childDeps.iterator(); it.hasNext(); ) for ( Dependency dep : childDeps )
{ {
Dependency dep = it.next();
mappedChildDeps.put( dep.getManagementKey(), dep ); mappedChildDeps.put( dep.getManagementKey(), dep );
} }
for ( Iterator<Dependency> it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); ) for ( Dependency dep : parentDepMgmt.getDependencies() )
{ {
Dependency dep = it.next();
if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) ) if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
{ {
childDepMgmt.addDependency( dep ); childDepMgmt.addDependency( dep );
@ -382,14 +380,13 @@ public class DefaultModelInheritanceAssembler
Map childPlugins = child.getReportPluginsAsMap(); Map childPlugins = child.getReportPluginsAsMap();
for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) for ( Object parentPlugin1 : parentPlugins )
{ {
ReportPlugin parentPlugin = (ReportPlugin) it.next(); ReportPlugin parentPlugin = (ReportPlugin) parentPlugin1;
String parentInherited = parentPlugin.getInherited(); String parentInherited = parentPlugin.getInherited();
if ( !handleAsInheritance || ( parentInherited == null ) if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ) )
|| Boolean.valueOf( parentInherited ) )
{ {
ReportPlugin assembledPlugin = parentPlugin; ReportPlugin assembledPlugin = parentPlugin;

View File

@ -168,33 +168,35 @@ public class StringSearchModelInterpolator
fieldsByClass.put( cls, fields ); fieldsByClass.put( cls, fields );
} }
for ( int i = 0; i < fields.length; i++ ) for ( Field field : fields )
{ {
Class<?> type = fields[i].getType(); Class<?> type = field.getType();
if ( isQualifiedForInterpolation( fields[i], type ) ) if ( isQualifiedForInterpolation( field, type ) )
{ {
boolean isAccessible = fields[i].isAccessible(); boolean isAccessible = field.isAccessible();
fields[i].setAccessible( true ); field.setAccessible( true );
try try
{ {
try try
{ {
if ( String.class == type ) if ( String.class == type )
{ {
String value = (String) fields[i].get( target ); String value = (String) field.get( target );
if ( value != null ) if ( value != null )
{ {
String interpolated = modelInterpolator.interpolateInternal( value, valueSources, postProcessors, debugEnabled ); String interpolated =
modelInterpolator.interpolateInternal( value, valueSources, postProcessors,
debugEnabled );
if ( !interpolated.equals( value ) ) if ( !interpolated.equals( value ) )
{ {
fields[i].set( target, interpolated ); field.set( target, interpolated );
} }
} }
} }
else if ( Collection.class.isAssignableFrom( type ) ) else if ( Collection.class.isAssignableFrom( type ) )
{ {
Collection<Object> c = (Collection<Object>) fields[i].get( target ); Collection<Object> c = (Collection<Object>) field.get( target );
if ( c != null && !c.isEmpty() ) if ( c != null && !c.isEmpty() )
{ {
List<Object> originalValues = new ArrayList<Object>( c ); List<Object> originalValues = new ArrayList<Object>( c );
@ -206,8 +208,9 @@ public class StringSearchModelInterpolator
{ {
if ( debugEnabled && logger != null ) if ( debugEnabled && logger != null )
{ {
logger.debug( "Skipping interpolation of field: " + fields[i] + " in: " logger.debug( "Skipping interpolation of field: " + field + " in: "
+ cls.getName() + "; it is an unmodifiable collection." ); + cls.getName()
+ "; it is an unmodifiable collection." );
} }
continue; continue;
} }
@ -256,7 +259,7 @@ public class StringSearchModelInterpolator
} }
else if ( Map.class.isAssignableFrom( type ) ) else if ( Map.class.isAssignableFrom( type ) )
{ {
Map<Object, Object> m = (Map<Object, Object>) fields[i].get( target ); Map<Object, Object> m = (Map<Object, Object>) field.get( target );
if ( m != null && !m.isEmpty() ) if ( m != null && !m.isEmpty() )
{ {
for ( Map.Entry<Object, Object> entry : m.entrySet() ) for ( Map.Entry<Object, Object> entry : m.entrySet() )
@ -283,10 +286,11 @@ public class StringSearchModelInterpolator
{ {
if ( debugEnabled && logger != null ) if ( debugEnabled && logger != null )
{ {
logger.debug( "Skipping interpolation of field: " logger.debug(
+ fields[i] + " (key: " + entry.getKey() + ") in: " "Skipping interpolation of field: " + field
+ cls.getName() + " (key: " + entry.getKey() + ") in: "
+ "; it is an unmodifiable collection." ); + cls.getName()
+ "; it is an unmodifiable collection." );
} }
} }
} }
@ -308,10 +312,10 @@ public class StringSearchModelInterpolator
} }
else else
{ {
Object value = fields[i].get( target ); Object value = field.get( target );
if ( value != null ) if ( value != null )
{ {
if ( fields[i].getType().isArray() ) if ( field.getType().isArray() )
{ {
evaluateArray( value ); evaluateArray( value );
} }
@ -324,18 +328,18 @@ public class StringSearchModelInterpolator
} }
catch ( IllegalArgumentException e ) catch ( IllegalArgumentException e )
{ {
throw new ModelInterpolationException( "Failed to interpolate field: " + fields[i] throw new ModelInterpolationException(
+ " on class: " + cls.getName(), e ); "Failed to interpolate field: " + field + " on class: " + cls.getName(), e );
} }
catch ( IllegalAccessException e ) catch ( IllegalAccessException e )
{ {
throw new ModelInterpolationException( "Failed to interpolate field: " + fields[i] throw new ModelInterpolationException(
+ " on class: " + cls.getName(), e ); "Failed to interpolate field: " + field + " on class: " + cls.getName(), e );
} }
} }
finally finally
{ {
fields[i].setAccessible( isAccessible ); field.setAccessible( isAccessible );
} }
} }
} }

View File

@ -125,9 +125,9 @@ public class DefaultPathTranslator
if ( s != null ) if ( s != null )
{ {
String basedirExpr = null; String basedirExpr = null;
for ( int i = 0; i < BASEDIR_EXPRESSIONS.length; i++ ) for ( String BASEDIR_EXPRESSION : BASEDIR_EXPRESSIONS )
{ {
basedirExpr = BASEDIR_EXPRESSIONS[i]; basedirExpr = BASEDIR_EXPRESSION;
if ( s.startsWith( basedirExpr ) ) if ( s.startsWith( basedirExpr ) )
{ {
break; break;

View File

@ -55,13 +55,13 @@ public class ExpressionDocumenter
ClassLoader docLoader = initializeDocLoader(); ClassLoader docLoader = initializeDocLoader();
for ( int i = 0; i < EXPRESSION_ROOTS.length; i++ ) for ( String EXPRESSION_ROOT : EXPRESSION_ROOTS )
{ {
InputStream docStream = null; InputStream docStream = null;
try try
{ {
docStream = docLoader docStream =
.getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOTS[i] + ".paramdoc.xml" ); docLoader.getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOT + ".paramdoc.xml" );
if ( docStream != null ) if ( docStream != null )
{ {
@ -72,13 +72,13 @@ public class ExpressionDocumenter
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new ExpressionDocumentationException( "Failed to read documentation for expression root: " throw new ExpressionDocumentationException(
+ EXPRESSION_ROOTS[i], e ); "Failed to read documentation for expression root: " + EXPRESSION_ROOT, e );
} }
catch ( XmlPullParserException e ) catch ( XmlPullParserException e )
{ {
throw new ExpressionDocumentationException( "Failed to parse documentation for expression root: " throw new ExpressionDocumentationException(
+ EXPRESSION_ROOTS[i], e ); "Failed to parse documentation for expression root: " + EXPRESSION_ROOT, e );
} }
finally finally
{ {
@ -130,9 +130,9 @@ public class ExpressionDocumenter
if ( expressions != null && !expressions.isEmpty() ) if ( expressions != null && !expressions.isEmpty() )
{ {
for ( Iterator it = expressions.iterator(); it.hasNext(); ) for ( Object expression : expressions )
{ {
Expression expr = (Expression) it.next(); Expression expr = (Expression) expression;
bySyntax.put( expr.getSyntax(), expr ); bySyntax.put( expr.getSyntax(), expr );
} }

View File

@ -37,20 +37,20 @@ public class MockManager
public void replayAll() public void replayAll()
{ {
for ( Iterator it = mockControls.iterator(); it.hasNext(); ) for ( Object mockControl : mockControls )
{ {
MockControl control = ( MockControl ) it.next(); MockControl control = (MockControl) mockControl;
control.replay(); control.replay();
} }
} }
public void verifyAll() public void verifyAll()
{ {
for ( Iterator it = mockControls.iterator(); it.hasNext(); ) for ( Object mockControl : mockControls )
{ {
MockControl control = ( MockControl ) it.next(); MockControl control = (MockControl) mockControl;
control.verify(); control.verify();
} }
} }

View File

@ -157,9 +157,9 @@ public class ModelUtilsTest
if( configuration != null ) if( configuration != null )
{ {
for ( Iterator it = configuration.entrySet().iterator(); it.hasNext(); ) for ( Object o : configuration.entrySet() )
{ {
Map.Entry entry = (Map.Entry) it.next(); Map.Entry entry = (Map.Entry) o;
Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) ); Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) );
param.setValue( String.valueOf( entry.getValue() ) ); param.setValue( String.valueOf( entry.getValue() ) );

View File

@ -133,9 +133,8 @@ public class ProjectClasspathTest
private Artifact getArtifact( MavenProject project, String groupId, String artifactId ) private Artifact getArtifact( MavenProject project, String groupId, String artifactId )
{ {
System.out.println( "[ Looking for " + groupId + ":" + artifactId + " ]" ); System.out.println( "[ Looking for " + groupId + ":" + artifactId + " ]" );
for ( Iterator<Artifact> i = project.getArtifacts().iterator(); i.hasNext(); ) for ( Artifact a : project.getArtifacts() )
{ {
Artifact a = i.next();
System.out.println( a.toString() ); System.out.println( a.toString() );
if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) ) if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) )
{ {

View File

@ -70,12 +70,14 @@ public class ProjectInheritanceTest
assertTrue( "No Artifacts", set.size() > 0 ); assertTrue( "No Artifacts", set.size() > 0 );
assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 ); assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 );
Iterator iter = set.iterator(); for ( Object aSet : set )
while ( iter.hasNext() )
{ {
Artifact artifact = (Artifact) iter.next(); Artifact artifact = (Artifact) aSet;
System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() System.out.println(
+ " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (
artifact.isOptional()
? "true"
: "false" ) );
assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
artifact.getVersion().equals( "1.0" ) ); artifact.getVersion().equals( "1.0" ) );
} }

View File

@ -64,14 +64,15 @@ public class ProjectInheritanceTest
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull( "No artifacts", set ); assertNotNull( "No artifacts", set );
assertTrue( "No Artifacts", set.size() > 0 ); assertTrue( "No Artifacts", set.size() > 0 );
Iterator iter = set.iterator();
while ( iter.hasNext() ) for ( Object aSet : set )
{ {
Artifact artifact = (Artifact) iter.next(); Artifact artifact = (Artifact) aSet;
System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " System.out.println(
+ artifact.getVersion() + " Scope: " + artifact.getScope() ); "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: "
assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); + artifact.getScope() );
assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
artifact.getVersion().equals( "1.0" ) );
} }
} }

View File

@ -66,14 +66,17 @@ public class ProjectInheritanceTest
assertTrue("No Artifacts", set.size() > 0); assertTrue("No Artifacts", set.size() > 0);
assertTrue("Set size should be 3, is " + set.size(), set.size() == 3 ); assertTrue("Set size should be 3, is " + set.size(), set.size() == 3 );
Iterator iter = set.iterator(); for ( Object aSet : set )
while (iter.hasNext())
{ {
Artifact artifact = (Artifact)iter.next(); Artifact artifact = (Artifact) aSet;
assertFalse( "", artifact.getArtifactId().equals( "t07-d" ) ); assertFalse( "", artifact.getArtifactId().equals( "t07-d" ) );
System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (artifact.isOptional() ? "true" : "false")); System.out.println(
assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (
artifact.isOptional()
? "true"
: "false" ) );
assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
artifact.getVersion().equals( "1.0" ) );
} }
} }
} }

View File

@ -719,9 +719,9 @@ public class DefaultArtifactCollectorTest
private Artifact getArtifact( String id, Set artifacts ) private Artifact getArtifact( String id, Set artifacts )
{ {
for ( Iterator i = artifacts.iterator(); i.hasNext(); ) for ( Object artifact : artifacts )
{ {
Artifact a = (Artifact) i.next(); Artifact a = (Artifact) artifact;
if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) ) if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) )
{ {
return a; return a;
@ -886,9 +886,9 @@ public class DefaultArtifactCollectorTest
{ {
Set projectArtifacts = new HashSet(); Set projectArtifacts = new HashSet();
for ( Iterator i = dependencies.iterator(); i.hasNext(); ) for ( Object dependency : dependencies )
{ {
Artifact d = (Artifact) i.next(); Artifact d = (Artifact) dependency;
VersionRange versionRange; VersionRange versionRange;
if ( d.getVersionRange() != null ) if ( d.getVersionRange() != null )
@ -904,8 +904,8 @@ public class DefaultArtifactCollectorTest
{ {
/* don't call createDependencyArtifact as it'll ignore test and provided scopes */ /* don't call createDependencyArtifact as it'll ignore test and provided scopes */
artifact = artifact =
artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(),
d.getScope(), d.getType() ); d.getType() );
} }
else else
{ {

View File

@ -127,12 +127,12 @@ public class ReactorManager
if ( dependents != null && !dependents.isEmpty() ) if ( dependents != null && !dependents.isEmpty() )
{ {
for ( Iterator it = dependents.iterator(); it.hasNext(); ) for ( Object dependent : dependents )
{ {
String dependentId = (String) it.next(); String dependentId = (String) dependent;
if ( !buildSuccessesByProject.containsKey( dependentId ) if ( !buildSuccessesByProject.containsKey( dependentId ) && !buildFailuresByProject.containsKey(
&& !buildFailuresByProject.containsKey( dependentId ) ) dependentId ) )
{ {
blackList( dependentId ); blackList( dependentId );
} }

View File

@ -110,18 +110,16 @@ public class DefaultLifecycleBindingsInjector
Map<Object, Plugin> merged = new LinkedHashMap<Object, Plugin>( ( src.size() + tgt.size() ) * 2 ); Map<Object, Plugin> merged = new LinkedHashMap<Object, Plugin>( ( src.size() + tgt.size() ) * 2 );
for ( Iterator<Plugin> it = tgt.iterator(); it.hasNext(); ) for ( Plugin element : tgt )
{ {
Plugin element = it.next();
Object key = getPluginKey( element ); Object key = getPluginKey( element );
merged.put( key, element ); merged.put( key, element );
} }
Map<Object, Plugin> unmanaged = new LinkedHashMap<Object, Plugin>(); Map<Object, Plugin> unmanaged = new LinkedHashMap<Object, Plugin>();
for ( Iterator<Plugin> it = src.iterator(); it.hasNext(); ) for ( Plugin element : src )
{ {
Plugin element = it.next();
Object key = getPluginKey( element ); Object key = getPluginKey( element );
Plugin existing = merged.get( key ); Plugin existing = merged.get( key );
if ( existing != null ) if ( existing != null )
@ -140,9 +138,8 @@ public class DefaultLifecycleBindingsInjector
PluginManagement pluginMgmt = (PluginManagement) context.get( PLUGIN_MANAGEMENT ); PluginManagement pluginMgmt = (PluginManagement) context.get( PLUGIN_MANAGEMENT );
if ( pluginMgmt != null ) if ( pluginMgmt != null )
{ {
for ( Iterator<Plugin> it = pluginMgmt.getPlugins().iterator(); it.hasNext(); ) for ( Plugin managedPlugin : pluginMgmt.getPlugins() )
{ {
Plugin managedPlugin = it.next();
Object key = getPluginKey( managedPlugin ); Object key = getPluginKey( managedPlugin );
Plugin unmanagedPlugin = unmanaged.get( key ); Plugin unmanagedPlugin = unmanaged.get( key );
if ( unmanagedPlugin != null ) if ( unmanagedPlugin != null )

View File

@ -291,9 +291,8 @@ public class MavenProject
List<String> modules = getModules(); List<String> modules = getModules();
if ( modules != null ) if ( modules != null )
{ {
for ( Iterator<String> it = modules.iterator(); it.hasNext(); ) for ( String modulePath : modules )
{ {
String modulePath = it.next();
String moduleName = modulePath; String moduleName = modulePath;
if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) ) if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) )
@ -1248,10 +1247,8 @@ public class MavenProject
List<Extension> extensions = getBuildExtensions(); List<Extension> extensions = getBuildExtensions();
if ( extensions != null ) if ( extensions != null )
{ {
for ( Iterator<Extension> i = extensions.iterator(); i.hasNext(); ) for ( Extension ext : extensions )
{ {
Extension ext = i.next();
String version; String version;
if ( StringUtils.isEmpty( ext.getVersion() ) ) if ( StringUtils.isEmpty( ext.getVersion() ) )
{ {
@ -1262,7 +1259,8 @@ public class MavenProject
version = ext.getVersion(); version = ext.getVersion();
} }
Artifact artifact = repositorySystem.createArtifact( ext.getGroupId(), ext.getArtifactId(), version, null, "jar" ); Artifact artifact =
repositorySystem.createArtifact( ext.getGroupId(), ext.getArtifactId(), version, null, "jar" );
if ( artifact != null ) if ( artifact != null )
{ {
@ -1556,10 +1554,8 @@ public class MavenProject
if ( getReportPlugins() != null ) if ( getReportPlugins() != null )
{ {
for ( Iterator<ReportPlugin> iterator = getReportPlugins().iterator(); iterator.hasNext(); ) for ( ReportPlugin plugin : getReportPlugins() )
{ {
ReportPlugin plugin = iterator.next();
if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) )
{ {
dom = (Xpp3Dom) plugin.getConfiguration(); dom = (Xpp3Dom) plugin.getConfiguration();
@ -1668,10 +1664,8 @@ public class MavenProject
if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) ) if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) )
{ {
map = new HashMap<String, Artifact>(); map = new HashMap<String, Artifact>();
for ( Iterator<Dependency> i = dependencyManagement.getDependencies().iterator(); i.hasNext(); ) for ( Dependency d : dependencyManagement.getDependencies() )
{ {
Dependency d = i.next();
Artifact artifact = repositorySystem.createDependencyArtifact( d ); Artifact artifact = repositorySystem.createDependencyArtifact( d );
if ( artifact == null ) if ( artifact == null )

View File

@ -78,23 +78,22 @@ public class DefaultJavaToolchainFactory
//TODO possibly move at least parts to a utility method or abstract implementation. //TODO possibly move at least parts to a utility method or abstract implementation.
dom = (Xpp3Dom) model.getProvides(); dom = (Xpp3Dom) model.getProvides();
Xpp3Dom[] provides = dom.getChildren(); Xpp3Dom[] provides = dom.getChildren();
for ( int i = 0; i < provides.length; i++ ) for ( Xpp3Dom provide : provides )
{ {
String key = provides[i].getName(); String key = provide.getName();
String value = provides[i].getValue(); String value = provide.getValue();
if ( value == null ) if ( value == null )
{ {
throw new MisconfiguredToolchainException( "Provides token '" + key + "' doesn't have any value configured." ); throw new MisconfiguredToolchainException(
"Provides token '" + key + "' doesn't have any value configured." );
} }
if ( "version".equals( key ) ) if ( "version".equals( key ) )
{ {
jtc.addProvideToken( key, jtc.addProvideToken( key, RequirementMatcherFactory.createVersionMatcher( value ) );
RequirementMatcherFactory.createVersionMatcher( value ) );
} }
else else
{ {
jtc.addProvideToken( key, jtc.addProvideToken( key, RequirementMatcherFactory.createExactMatcher( value ) );
RequirementMatcherFactory.createExactMatcher( value ) );
} }
} }
return jtc; return jtc;

View File

@ -59,10 +59,8 @@ public class DefaultMavenProjectBuilderTest
if ( !filesToDelete.isEmpty() ) if ( !filesToDelete.isEmpty() )
{ {
for ( Iterator<File> it = filesToDelete.iterator(); it.hasNext(); ) for ( File file : filesToDelete )
{ {
File file = it.next();
if ( file.exists() ) if ( file.exists() )
{ {
if ( file.isDirectory() ) if ( file.isDirectory() )

View File

@ -161,10 +161,8 @@ public class CLIManager
StringBuilder currentArg = null; StringBuilder currentArg = null;
for ( int i = 0; i < args.length; i++ ) for ( String arg : args )
{ {
String arg = args[i];
boolean addedToBuffer = false; boolean addedToBuffer = false;
if ( arg.startsWith( "\"" ) ) if ( arg.startsWith( "\"" ) )

View File

@ -865,9 +865,9 @@ public class MavenCli
String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES );
if ( profileOptionValues != null ) if ( profileOptionValues != null )
{ {
for ( int i = 0; i < profileOptionValues.length; ++i ) for ( String profileOptionValue : profileOptionValues )
{ {
StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i], "," ); StringTokenizer profileTokens = new StringTokenizer( profileOptionValue, "," );
while ( profileTokens.hasMoreTokens() ) while ( profileTokens.hasMoreTokens() )
{ {
@ -978,9 +978,9 @@ public class MavenCli
{ {
String[] values = commandLine.getOptionValues( CLIManager.PROJECT_LIST ); String[] values = commandLine.getOptionValues( CLIManager.PROJECT_LIST );
List<String> projects = new ArrayList<String>(); List<String> projects = new ArrayList<String>();
for ( int i = 0; i < values.length; i++ ) for ( String value : values )
{ {
String[] tmp = StringUtils.split( values[i], "," ); String[] tmp = StringUtils.split( value, "," );
projects.addAll( Arrays.asList( tmp ) ); projects.addAll( Arrays.asList( tmp ) );
} }
request.setSelectedProjects( projects ); request.setSelectedProjects( projects );
@ -1076,9 +1076,9 @@ public class MavenCli
if ( defStrs != null ) if ( defStrs != null )
{ {
for ( int i = 0; i < defStrs.length; ++i ) for ( String defStr : defStrs )
{ {
setCliProperty( defStrs[i], userProperties ); setCliProperty( defStr, userProperties );
} }
} }
} }