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 final void parseVersion( String version )
}
}
if ( ( part1.indexOf( "." ) < 0 ) && !part1.startsWith( "0" ) )
if ( ( !part1.contains( "." ) ) && !part1.startsWith( "0" ) )
{
try
{
@ -178,7 +178,7 @@ public final void parseVersion( String version )
}
// 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;
}

View File

@ -290,7 +290,7 @@ protected String interpolateInternal( String src, List<ValueSource> valueSources
List<InterpolationPostProcessor> postProcessors, boolean debug )
throws ModelInterpolationException
{
if ( src.indexOf( "${" ) < 0 )
if ( !src.contains( "${" ) )
{
return src;
}

View File

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

View File

@ -172,7 +172,7 @@ public Object evaluate( String expr, Class<?> type )
}
// Was not an expression
if ( expression.indexOf( "$$" ) > -1 )
if ( expression.contains( "$$" ) )
{
return expression.replaceAll( "\\$\\$", "\\$" );
}

View File

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

View File

@ -216,7 +216,7 @@ protected String interpolateInternal( String src, List<? extends ValueSource> va
List<? extends InterpolationPostProcessor> postProcessors,
ModelProblemCollector problems )
{
if ( src.indexOf( "${" ) < 0 )
if ( !src.contains( "${" ) )
{
return src;
}

View File

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

View File

@ -131,7 +131,7 @@ public void testBadModelVersion()
assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( "modelVersion" ) > -1 );
assertTrue( result.getErrors().get( 0 ).contains( "modelVersion" ) );
}
public void testMissingArtifactId()
@ -193,7 +193,7 @@ public void testInvalidAggregatorPackaging()
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()
@ -203,8 +203,8 @@ public void testMissingDependencyArtifactId()
assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) > -1 );
assertTrue( result.getErrors().get( 0 ).contains(
"'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) );
}
public void testMissingDependencyGroupId()
@ -214,8 +214,8 @@ public void testMissingDependencyGroupId()
assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) > -1 );
assertTrue( result.getErrors().get( 0 ).contains(
"'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) );
}
public void testMissingDependencyVersion()
@ -225,8 +225,8 @@ public void testMissingDependencyVersion()
assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) > -1 );
assertTrue( result.getErrors().get( 0 ).contains(
"'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) );
}
public void testMissingDependencyManagementArtifactId()
@ -236,8 +236,8 @@ public void testMissingDependencyManagementArtifactId()
assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) > -1 );
assertTrue( result.getErrors().get( 0 ).contains(
"'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) );
}
public void testMissingDependencyManagementGroupId()
@ -247,8 +247,8 @@ public void testMissingDependencyManagementGroupId()
assertViolations( result, 0, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) > -1 );
assertTrue( result.getErrors().get( 0 ).contains(
"'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) );
}
public void testMissingAll()