Use final.
This commit is contained in:
parent
d68a7a4189
commit
75fa90e96c
|
@ -237,8 +237,8 @@ public class CharSequenceUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int len1 = cs.length();
|
final int len1 = cs.length();
|
||||||
int len2 = searchChar.length();
|
final int len2 = searchChar.length();
|
||||||
|
|
||||||
if (start > len1) {
|
if (start > len1) {
|
||||||
start = len1;
|
start = len1;
|
||||||
|
@ -266,7 +266,7 @@ public class CharSequenceUtils {
|
||||||
start = len1 - len2;
|
start = len1 - len2;
|
||||||
}
|
}
|
||||||
|
|
||||||
char char0 = searchChar.charAt(0);
|
final char char0 = searchChar.charAt(0);
|
||||||
|
|
||||||
int i = start;
|
int i = start;
|
||||||
while (true) {
|
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--) {
|
for (int i = 1, j = len2 - 1; i <= j; i++, j--) {
|
||||||
if (cs.charAt(start1 + i) != searchChar.charAt(i)
|
if (cs.charAt(start1 + i) != searchChar.charAt(i)
|
||||||
||
|
||
|
||||||
|
|
|
@ -189,9 +189,9 @@ public class CharSequenceUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class WrapperString implements CharSequence {
|
static class WrapperString implements CharSequence {
|
||||||
private CharSequence inner;
|
private final CharSequence inner;
|
||||||
|
|
||||||
WrapperString(CharSequence inner) {
|
WrapperString(final CharSequence inner) {
|
||||||
this.inner = inner;
|
this.inner = inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,12 +201,12 @@ public class CharSequenceUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char charAt(int index) {
|
public char charAt(final int index) {
|
||||||
return inner.charAt(index);
|
return inner.charAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence subSequence(int start, int end) {
|
public CharSequence subSequence(final int start, final int end) {
|
||||||
return inner.subSequence(start, end);
|
return inner.subSequence(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ public class CharSequenceUtilsTest {
|
||||||
testNewLastIndexOfSingle("oraoraoraora", "r");
|
testNewLastIndexOfSingle("oraoraoraora", "r");
|
||||||
testNewLastIndexOfSingle("mudamudamudamuda", "d");
|
testNewLastIndexOfSingle("mudamudamudamuda", "d");
|
||||||
|
|
||||||
Random random = new Random();
|
final Random random = new Random();
|
||||||
StringBuilder seg = new StringBuilder();
|
final StringBuilder seg = new StringBuilder();
|
||||||
while (seg.length() <= CharSequenceUtils.TO_STRING_LIMIT) {
|
while (seg.length() <= CharSequenceUtils.TO_STRING_LIMIT) {
|
||||||
seg.append(random.nextInt());
|
seg.append(random.nextInt());
|
||||||
}
|
}
|
||||||
|
@ -260,8 +260,8 @@ public class CharSequenceUtilsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testNewLastIndexOfSingle(CharSequence a, CharSequence b) {
|
private void testNewLastIndexOfSingle(final CharSequence a, final CharSequence b) {
|
||||||
int maxa = Math.max(a.length(), b.length());
|
final int maxa = Math.max(a.length(), b.length());
|
||||||
for (int i = -maxa - 10; i <= maxa + 10; i++) {
|
for (int i = -maxa - 10; i <= maxa + 10; i++) {
|
||||||
testNewLastIndexOfSingle(a, b, i);
|
testNewLastIndexOfSingle(a, b, i);
|
||||||
}
|
}
|
||||||
|
@ -269,12 +269,12 @@ public class CharSequenceUtilsTest {
|
||||||
testNewLastIndexOfSingle(a, b, Integer.MAX_VALUE);
|
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(a, b, start);
|
||||||
testNewLastIndexOfSingleSingle(b, a, 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(
|
assertEquals(
|
||||||
a.toString().lastIndexOf(b.toString(), start),
|
a.toString().lastIndexOf(b.toString(), start),
|
||||||
CharSequenceUtils.lastIndexOf(new WrapperString(a.toString()), new WrapperString(b.toString()), start),
|
CharSequenceUtils.lastIndexOf(new WrapperString(a.toString()), new WrapperString(b.toString()), start),
|
||||||
|
|
|
@ -732,7 +732,7 @@ public class FastDateParserTest {
|
||||||
testSingleLocale(buggyLocale);
|
testSingleLocale(buggyLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSingleLocale(Locale locale) throws ParseException {
|
private void testSingleLocale(final Locale locale) throws ParseException {
|
||||||
final Calendar cal = Calendar.getInstance(GMT);
|
final Calendar cal = Calendar.getInstance(GMT);
|
||||||
cal.clear();
|
cal.clear();
|
||||||
cal.set(2003, Calendar.FEBRUARY, 10);
|
cal.set(2003, Calendar.FEBRUARY, 10);
|
||||||
|
|
Loading…
Reference in New Issue