little code improvements

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@932035 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Herve Boutemy 2010-04-08 18:01:20 +00:00
parent 5f7181d9b8
commit 70b0756d31
1 changed files with 8 additions and 11 deletions

View File

@ -268,16 +268,13 @@ public class VersionRange
ArtifactVersion version = null; ArtifactVersion version = null;
if ( restrictions.size() > 0 ) if ( restrictions.size() > 0 )
{ {
boolean found = false; for ( Restriction r : restrictions )
for ( Iterator i = restrictions.iterator(); i.hasNext() && !found; )
{ {
Restriction r = (Restriction) i.next();
if ( recommendedVersion != null && r.containsVersion( recommendedVersion ) ) if ( recommendedVersion != null && r.containsVersion( recommendedVersion ) )
{ {
// if we find the original, use that // if we find the original, use that
version = recommendedVersion; version = recommendedVersion;
found = true; break;
} }
else if ( version == null && restriction.getRecommendedVersion() != null else if ( version == null && restriction.getRecommendedVersion() != null
&& r.containsVersion( restriction.getRecommendedVersion() ) ) && r.containsVersion( restriction.getRecommendedVersion() ) )
@ -287,7 +284,7 @@ public class VersionRange
} }
} }
} }
// Either the original or the specified version ranges have no restructions // Either the original or the specified version ranges have no restrictions
else if ( recommendedVersion != null ) else if ( recommendedVersion != null )
{ {
// Use the original recommended version since it exists // Use the original recommended version since it exists
@ -408,7 +405,7 @@ public class VersionRange
// advance res2 // advance res2
if ( i2.hasNext() ) if ( i2.hasNext() )
{ {
res2 = (Restriction) i2.next(); res2 = i2.next();
} }
else else
{ {
@ -420,7 +417,7 @@ public class VersionRange
// advance res1 // advance res1
if ( i1.hasNext() ) if ( i1.hasNext() )
{ {
res1 = (Restriction) i1.next(); res1 = i1.next();
} }
else else
{ {
@ -433,7 +430,7 @@ public class VersionRange
// move on to next in r1 // move on to next in r1
if ( i1.hasNext() ) if ( i1.hasNext() )
{ {
res1 = (Restriction) i1.next(); res1 = i1.next();
} }
else else
{ {
@ -446,7 +443,7 @@ public class VersionRange
// move on to next in r2 // move on to next in r2
if ( i2.hasNext() ) if ( i2.hasNext() )
{ {
res2 = (Restriction) i2.next(); res2 = i2.next();
} }
else else
{ {
@ -513,7 +510,7 @@ public class VersionRange
if ( i.hasNext() ) if ( i.hasNext() )
{ {
buf.append( "," ); buf.append( ',' );
} }
} }
return buf.toString(); return buf.toString();