Code cleanup - Maven requires Java 5+ : Replace String.indexOf() by String.contains()

This commit is contained in:
Arnaud Héritier 2013-06-11 22:19:20 +02:00
parent 9e5183f0ad
commit 1f84f8f296
8 changed files with 21 additions and 21 deletions

View File

@ -143,7 +143,7 @@ public class DefaultArtifactVersion
} }
} }
if ( ( part1.indexOf( "." ) < 0 ) && !part1.startsWith( "0" ) ) if ( ( !part1.contains( "." ) ) && !part1.startsWith( "0" ) )
{ {
try try
{ {
@ -178,7 +178,7 @@ public class DefaultArtifactVersion
} }
// string tokenzier won't detect these and ignores them // string tokenzier won't detect these and ignores them
if ( part1.indexOf( ".." ) >= 0 || part1.startsWith( "." ) || part1.endsWith( "." ) ) if ( part1.contains( ".." ) || part1.startsWith( "." ) || part1.endsWith( "." ) )
{ {
fallback = true; fallback = true;
} }

View File

@ -290,7 +290,7 @@ public abstract class AbstractStringBasedModelInterpolator
List<InterpolationPostProcessor> postProcessors, boolean debug ) List<InterpolationPostProcessor> postProcessors, boolean debug )
throws ModelInterpolationException throws ModelInterpolationException
{ {
if ( src.indexOf( "${" ) < 0 ) if ( !src.contains( "${" ) )
{ {
return src; return src;
} }

View File

@ -712,8 +712,8 @@ public class DefaultArtifactCollectorTest
} }
catch ( OverConstrainedVersionException e ) catch ( OverConstrainedVersionException e )
{ {
assertTrue( "Versions unordered", e.getMessage().indexOf( "[3.2.1-v3235e, 3.3.0-v3346]" ) != -1 ); assertTrue( "Versions unordered", e.getMessage().contains( "[3.2.1-v3235e, 3.3.0-v3346]" ) );
assertTrue( "DependencyTrail unresolved", e.getMessage().indexOf( "Path to dependency:" ) != -1 ); assertTrue( "DependencyTrail unresolved", e.getMessage().contains( "Path to dependency:" ) );
} }
} }

View File

@ -172,7 +172,7 @@ public class PluginParameterExpressionEvaluator
} }
// Was not an expression // Was not an expression
if ( expression.indexOf( "$$" ) > -1 ) if ( expression.contains( "$$" ) )
{ {
return expression.replaceAll( "\\$\\$", "\\$" ); return expression.replaceAll( "\\$\\$", "\\$" );
} }

View File

@ -69,6 +69,6 @@ public class ConcurrentBuildLoggerTest
b1.addWait( A, aPlan.next(), System.currentTimeMillis() ); b1.addWait( A, aPlan.next(), System.currentTimeMillis() );
b2.addWait( A, aPlan.next(), System.currentTimeMillis() ); b2.addWait( A, aPlan.next(), System.currentTimeMillis() );
final String response = concurrentBuildLogger.toGraph(); final String response = concurrentBuildLogger.toGraph();
assertTrue( response.indexOf( "digraph" ) >= 0 ); assertTrue( response.contains( "digraph" ) );
} }
} }

View File

@ -216,7 +216,7 @@ public abstract class AbstractStringBasedModelInterpolator
List<? extends InterpolationPostProcessor> postProcessors, List<? extends InterpolationPostProcessor> postProcessors,
ModelProblemCollector problems ) ModelProblemCollector problems )
{ {
if ( src.indexOf( "${" ) < 0 ) if ( !src.contains( "${" ) )
{ {
return src; return src;
} }

View File

@ -113,7 +113,7 @@ public class FileProfileActivator
} }
} ); } );
} }
else if ( path.indexOf( "${basedir}" ) >= 0 ) else if ( path.contains( "${basedir}" ) )
{ {
return false; return false;
} }

View File

@ -131,7 +131,7 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( "modelVersion" ) > -1 ); assertTrue( result.getErrors().get( 0 ).contains( "modelVersion" ) );
} }
public void testMissingArtifactId() public void testMissingArtifactId()
@ -193,7 +193,7 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( "Aggregator projects require 'pom' as packaging." ) > -1 ); assertTrue( result.getErrors().get( 0 ).contains( "Aggregator projects require 'pom' as packaging." ) );
} }
public void testMissingDependencyArtifactId() public void testMissingDependencyArtifactId()
@ -203,8 +203,8 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( assertTrue( result.getErrors().get( 0 ).contains(
"'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) > -1 ); "'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) );
} }
public void testMissingDependencyGroupId() public void testMissingDependencyGroupId()
@ -214,8 +214,8 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( assertTrue( result.getErrors().get( 0 ).contains(
"'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) > -1 ); "'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) );
} }
public void testMissingDependencyVersion() public void testMissingDependencyVersion()
@ -225,8 +225,8 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( assertTrue( result.getErrors().get( 0 ).contains(
"'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) > -1 ); "'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) );
} }
public void testMissingDependencyManagementArtifactId() public void testMissingDependencyManagementArtifactId()
@ -236,8 +236,8 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( assertTrue( result.getErrors().get( 0 ).contains(
"'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) > -1 ); "'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) );
} }
public void testMissingDependencyManagementGroupId() public void testMissingDependencyManagementGroupId()
@ -247,8 +247,8 @@ public class DefaultModelValidatorTest
assertViolations( result, 0, 1, 0 ); assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( assertTrue( result.getErrors().get( 0 ).contains(
"'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) > -1 ); "'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) );
} }
public void testMissingAll() public void testMissingAll()