Skip to content

Commit 4b2a116

Browse files
committedJul 4, 2019
Use String indexOf(char) and lastIndexOf(char) where possible
Closes spring-projectsgh-11416
1 parent 6a777a7 commit 4b2a116

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed
 

‎spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/StringSequenceTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ void indexOfCharShouldReturnIndexOf() {
127127
@Test
128128
void indexOfStringShouldReturnIndexOf() {
129129
StringSequence sequence = new StringSequence("aabbaacc");
130-
assertThat(sequence.indexOf("a")).isEqualTo(0);
131-
assertThat(sequence.indexOf("b")).isEqualTo(2);
132-
assertThat(sequence.subSequence(2).indexOf("a")).isEqualTo(2);
130+
assertThat(sequence.indexOf('a')).isEqualTo(0);
131+
assertThat(sequence.indexOf('b')).isEqualTo(2);
132+
assertThat(sequence.subSequence(2).indexOf('a')).isEqualTo(2);
133133
}
134134

135135
@Test

‎spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-profiles-fork/src/main/java/org/test/SampleApplication.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public static void main(String[] args) {
2828
if (!argument.startsWith("--spring.profiles.active=")) {
2929
throw new IllegalArgumentException("Invalid argument " + argument);
3030
}
31-
int index = args[0].indexOf("=");
31+
int index = args[0].indexOf('=');
3232
String profile = argument.substring(index + 1);
3333
System.out.println("I haz been run with profile(s) '" + profile + "'");
3434
}

‎spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-profiles/src/main/java/org/test/SampleApplication.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public static void main(String[] args) {
2828
if (!argument.startsWith("--spring.profiles.active=")) {
2929
throw new IllegalArgumentException("Invalid argument " + argument);
3030
}
31-
int index = args[0].indexOf("=");
31+
int index = args[0].indexOf('=');
3232
String profile = argument.substring(index + 1);
3333
System.out.println("I haz been run with profile(s) '" + profile + "'");
3434
}

‎spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void addEnvironment(AnnotationConfigApplicationContext context, String[]
108108
MutablePropertySources sources = context.getEnvironment().getPropertySources();
109109
Map<String, Object> map = new HashMap<>();
110110
for (String pair : environment) {
111-
int index = pair.indexOf("=");
111+
int index = pair.indexOf('=');
112112
String key = (index > 0) ? pair.substring(0, index) : pair;
113113
String value = (index > 0) ? pair.substring(index + 1) : "";
114114
map.put(key.trim(), value.trim());

‎spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void addEnvironment(AnnotationConfigApplicationContext context, String[]
119119
MutablePropertySources sources = context.getEnvironment().getPropertySources();
120120
Map<String, Object> map = new HashMap<>();
121121
for (String pair : environment) {
122-
int index = pair.indexOf("=");
122+
int index = pair.indexOf('=');
123123
String key = (index > 0) ? pair.substring(0, index) : pair;
124124
String value = (index > 0) ? pair.substring(index + 1) : "";
125125
map.put(key.trim(), value.trim());

‎spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void addEnvironment(AnnotationConfigApplicationContext context, String[]
9191
MutablePropertySources sources = context.getEnvironment().getPropertySources();
9292
Map<String, Object> map = new HashMap<>();
9393
for (String pair : environment) {
94-
int index = pair.indexOf("=");
94+
int index = pair.indexOf('=');
9595
String key = (index > 0) ? pair.substring(0, index) : pair;
9696
String value = (index > 0) ? pair.substring(index + 1) : "";
9797
map.put(key.trim(), value.trim());

‎spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/main/java/smoketest/data/jpa/service/CityServiceImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Page<City> findCities(CitySearchCriteria criteria, Pageable pageable) {
5050
}
5151

5252
String country = "";
53-
int splitPos = name.lastIndexOf(",");
53+
int splitPos = name.lastIndexOf(',');
5454

5555
if (splitPos >= 0) {
5656
country = name.substring(splitPos + 1);

0 commit comments

Comments
 (0)
Please sign in to comment.