Use final.

This commit is contained in:
Gary Gregory 2020-06-27 09:24:58 -04:00
parent d68a7a4189
commit 75fa90e96c
3 changed files with 15 additions and 15 deletions

View File

@ -237,8 +237,8 @@ public class CharSequenceUtils {
}
}
int len1 = cs.length();
int len2 = searchChar.length();
final int len1 = cs.length();
final int len2 = searchChar.length();
if (start > len1) {
start = len1;
@ -266,7 +266,7 @@ public class CharSequenceUtils {
start = len1 - len2;
}
char char0 = searchChar.charAt(0);
final char char0 = searchChar.charAt(0);
int i = start;
while (true) {
@ -286,7 +286,7 @@ public class CharSequenceUtils {
}
}
private static boolean checkLaterThan1(final CharSequence cs, final CharSequence searchChar, int len2, int start1) {
private static boolean checkLaterThan1(final CharSequence cs, final CharSequence searchChar, final int len2, final int start1) {
for (int i = 1, j = len2 - 1; i <= j; i++, j--) {
if (cs.charAt(start1 + i) != searchChar.charAt(i)
||

View File

@ -189,9 +189,9 @@ public class CharSequenceUtilsTest {
}
static class WrapperString implements CharSequence {
private CharSequence inner;
private final CharSequence inner;
WrapperString(CharSequence inner) {
WrapperString(final CharSequence inner) {
this.inner = inner;
}
@ -201,12 +201,12 @@ public class CharSequenceUtilsTest {
}
@Override
public char charAt(int index) {
public char charAt(final int index) {
return inner.charAt(index);
}
@Override
public CharSequence subSequence(int start, int end) {
public CharSequence subSequence(final int start, final int end) {
return inner.subSequence(start, end);
}
@ -243,8 +243,8 @@ public class CharSequenceUtilsTest {
testNewLastIndexOfSingle("oraoraoraora", "r");
testNewLastIndexOfSingle("mudamudamudamuda", "d");
Random random = new Random();
StringBuilder seg = new StringBuilder();
final Random random = new Random();
final StringBuilder seg = new StringBuilder();
while (seg.length() <= CharSequenceUtils.TO_STRING_LIMIT) {
seg.append(random.nextInt());
}
@ -260,8 +260,8 @@ public class CharSequenceUtilsTest {
}
}
private void testNewLastIndexOfSingle(CharSequence a, CharSequence b) {
int maxa = Math.max(a.length(), b.length());
private void testNewLastIndexOfSingle(final CharSequence a, final CharSequence b) {
final int maxa = Math.max(a.length(), b.length());
for (int i = -maxa - 10; i <= maxa + 10; i++) {
testNewLastIndexOfSingle(a, b, i);
}
@ -269,12 +269,12 @@ public class CharSequenceUtilsTest {
testNewLastIndexOfSingle(a, b, Integer.MAX_VALUE);
}
private void testNewLastIndexOfSingle(CharSequence a, CharSequence b, int start) {
private void testNewLastIndexOfSingle(final CharSequence a, final CharSequence b, final int start) {
testNewLastIndexOfSingleSingle(a, b, start);
testNewLastIndexOfSingleSingle(b, a, start);
}
private void testNewLastIndexOfSingleSingle(CharSequence a, CharSequence b, int start) {
private void testNewLastIndexOfSingleSingle(final CharSequence a, final CharSequence b, final int start) {
assertEquals(
a.toString().lastIndexOf(b.toString(), start),
CharSequenceUtils.lastIndexOf(new WrapperString(a.toString()), new WrapperString(b.toString()), start),

View File

@ -732,7 +732,7 @@ public class FastDateParserTest {
testSingleLocale(buggyLocale);
}
private void testSingleLocale(Locale locale) throws ParseException {
private void testSingleLocale(final Locale locale) throws ParseException {
final Calendar cal = Calendar.getInstance(GMT);
cal.clear();
cal.set(2003, Calendar.FEBRUARY, 10);