String.indexOf() expressions can be replaced with a call to the String.contains() method available in Java 5 and newer.

This commit is contained in:
igor-suhorukov
2018-12-07 00:12:32 +03:00
committed by Juergen Hoeller
parent 81d77b9872
commit 93189a6733
18 changed files with 40 additions and 40 deletions

View File

@@ -29,7 +29,7 @@ public class BeanThatBroadcasts implements ApplicationContextAware {
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
if (applicationContext.getDisplayName().indexOf("listener") != -1) {
if (applicationContext.getDisplayName().contains("listener")) {
applicationContext.getBean("listener");
}
}

View File

@@ -564,7 +564,7 @@ public class DispatcherServletTests {
}
catch (ServletException ex) {
// expected
assertTrue(ex.getMessage().indexOf("No adapter for handler") != -1);
assertTrue(ex.getMessage().contains("No adapter for handler"));
}
}
@@ -584,7 +584,7 @@ public class DispatcherServletTests {
}
catch (ServletException ex) {
// expected
assertTrue(ex.getMessage().indexOf("failed0") != -1);
assertTrue(ex.getMessage().contains("failed0"));
}
}

View File

@@ -561,7 +561,7 @@ public class BindTagTests extends AbstractTagTests {
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
assertEquals("doctor", status.getExpression());
assertTrue(status.getValue() instanceof NestedTestBean);
assertTrue(status.getDisplayValue().indexOf("juergen&eva") != -1);
assertTrue(status.getDisplayValue().contains("juergen&eva"));
}
@Test

View File

@@ -255,11 +255,11 @@ public class RadioButtonTagTests extends AbstractFormTagTests {
}
private void assertTagOpened(String output) {
assertTrue(output.indexOf("<input ") > -1);
assertTrue(output.contains("<input "));
}
private void assertTagClosed(String output) {
assertTrue(output.indexOf("/>") > -1);
assertTrue(output.contains("/>"));
}
private Float getFloat() {

View File

@@ -133,7 +133,7 @@ public class XsltViewTests {
model.put("someKey", getProductDataResource());
model.put("title", "Product List");
doTestWithModel(model);
assertTrue(this.response.getContentAsString().indexOf("Product List") > -1);
assertTrue(this.response.getContentAsString().contains("Product List"));
}
@Test
@@ -148,7 +148,7 @@ public class XsltViewTests {
view.render(model, this.request, this.response);
assertHtmlOutput(this.response.getContentAsString());
assertTrue(this.response.getContentAsString().indexOf("Product List") > -1);
assertTrue(this.response.getContentAsString().contains("Product List"));
}