array_style (#537)

This commit is contained in:
XenoAmess 2020-06-13 23:06:06 +08:00 committed by GitHub
parent 514f226b7d
commit 2238145f56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 52 additions and 52 deletions

View File

@ -541,7 +541,7 @@ public class StringUtils {
return str;
}
final int newCodePoints[] = new int[strLen]; // cannot be longer than the char array
final int[] newCodePoints = new int[strLen]; // cannot be longer than the char array
int outOffset = 0;
newCodePoints[outOffset++] = newCodePoint; // copy the first codepoint
for (int inOffset = Character.charCount(firstCodepoint); inOffset < strLen; ) {
@ -2311,7 +2311,7 @@ public class StringUtils {
m = t.length();
}
final int p[] = new int[n + 1];
final int[] p = new int[n + 1];
// indexes into strings s and t
int i; // iterates through s
int j; // iterates through t
@ -2452,9 +2452,9 @@ public class StringUtils {
m = t.length();
}
int p[] = new int[n + 1]; // 'previous' cost array, horizontally
int d[] = new int[n + 1]; // cost array, horizontally
int _d[]; // placeholder to assist in swapping p and d
int[] p = new int[n + 1]; // 'previous' cost array, horizontally
int[] d = new int[n + 1]; // cost array, horizontally
int[] _d; // placeholder to assist in swapping p and d
// fill in starting table values
final int boundary = Math.min(n, threshold) + 1;
@ -8863,7 +8863,7 @@ public class StringUtils {
}
final int strLen = str.length();
final int newCodePoints[] = new int[strLen]; // cannot be longer than the char array
final int[] newCodePoints = new int[strLen]; // cannot be longer than the char array
int outOffset = 0;
for (int i = 0; i < strLen; ) {
final int oldCodepoint = str.codePointAt(i);
@ -9207,7 +9207,7 @@ public class StringUtils {
return str;
}
final int newCodePoints[] = new int[strLen]; // cannot be longer than the char array
final int[] newCodePoints = new int[strLen]; // cannot be longer than the char array
int outOffset = 0;
newCodePoints[outOffset++] = newCodePoint; // copy the first codepoint
for (int inOffset = Character.charCount(firstCodepoint); inOffset < strLen; ) {

View File

@ -259,7 +259,7 @@ public class ExceptionUtils {
if (throwable == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
final Throwable throwables[] = getThrowables(throwable);
final Throwable[] throwables = getThrowables(throwable);
final int count = throwables.length;
final List<String> frames = new ArrayList<>();
List<String> nextTrace = getStackFrameList(throwables[count - 1]);
@ -633,7 +633,7 @@ public class ExceptionUtils {
return;
}
Validate.notNull(stream, "The PrintStream must not be null");
final String trace[] = getRootCauseStackTrace(throwable);
final String[] trace = getRootCauseStackTrace(throwable);
for (final String element : trace) {
stream.println(element);
}
@ -664,7 +664,7 @@ public class ExceptionUtils {
return;
}
Validate.notNull(writer, "The PrintWriter must not be null");
final String trace[] = getRootCauseStackTrace(throwable);
final String[] trace = getRootCauseStackTrace(throwable);
for (final String element : trace) {
writer.println(element);
}

View File

@ -81,7 +81,7 @@ public class ConstructorUtils {
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException {
args = ArrayUtils.nullToEmpty(args);
final Class<?> parameterTypes[] = ClassUtils.toClass(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args);
return invokeConstructor(cls, args, parameterTypes);
}
@ -145,7 +145,7 @@ public class ConstructorUtils {
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException {
args = ArrayUtils.nullToEmpty(args);
final Class<?> parameterTypes[] = ClassUtils.toClass(args);
final Class<?>[] parameterTypes = ClassUtils.toClass(args);
return invokeExactConstructor(cls, args, parameterTypes);
}

View File

@ -363,7 +363,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (size == 0) {
return ArrayUtils.EMPTY_CHAR_ARRAY;
}
final char chars[] = new char[size];
final char[] chars = new char[size];
System.arraycopy(buffer, 0, chars, 0, size);
return chars;
}
@ -384,7 +384,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (len == 0) {
return ArrayUtils.EMPTY_CHAR_ARRAY;
}
final char chars[] = new char[len];
final char[] chars = new char[len];
System.arraycopy(buffer, startIndex, chars, 0, len);
return chars;
}
@ -414,7 +414,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @throws NullPointerException if the array is null
* @throws IndexOutOfBoundsException if any index is invalid
*/
public void getChars(final int startIndex, final int endIndex, final char destination[], final int destinationIndex) {
public void getChars(final int startIndex, final int endIndex, final char[] destination, final int destinationIndex) {
if (startIndex < 0) {
throw new StringIndexOutOfBoundsException(startIndex);
}
@ -1640,7 +1640,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return this, to enable chaining
* @throws IndexOutOfBoundsException if the index is invalid
*/
public StrBuilder insert(final int index, final char chars[]) {
public StrBuilder insert(final int index, final char[] chars) {
validateIndex(index);
if (chars == null) {
return insert(index, nullText);
@ -1666,7 +1666,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return this, to enable chaining
* @throws IndexOutOfBoundsException if any index is invalid
*/
public StrBuilder insert(final int index, final char chars[], final int offset, final int length) {
public StrBuilder insert(final int index, final char[] chars, final int offset, final int length) {
validateIndex(index);
if (chars == null) {
return insert(index, nullText);
@ -2772,8 +2772,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (this.size != other.size) {
return false;
}
final char thisBuf[] = this.buffer;
final char otherBuf[] = other.buffer;
final char[] thisBuf = this.buffer;
final char[] otherBuf = other.buffer;
for (int i = size - 1; i >= 0; i--) {
final char c1 = thisBuf[i];
final char c2 = otherBuf[i];
@ -2801,8 +2801,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (this.size != other.size) {
return false;
}
final char thisBuf[] = this.buffer;
final char otherBuf[] = other.buffer;
final char[] thisBuf = this.buffer;
final char[] otherBuf = other.buffer;
for (int i = size - 1; i >= 0; i--) {
if (thisBuf[i] != otherBuf[i]) {
return false;
@ -2830,7 +2830,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
@Override
public int hashCode() {
final char buf[] = buffer;
final char[] buf = buffer;
int hash = 0;
for (int i = size - 1; i >= 0; i--) {
hash = 31 * hash + buf[i];
@ -2987,7 +2987,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
/** {@inheritDoc} */
@Override
public int read(final char b[], final int off, int len) {
public int read(final char[] b, final int off, int len) {
if (off < 0 || len < 0 || off > b.length ||
(off + len) > b.length || (off + len) < 0) {
throw new IndexOutOfBoundsException();

View File

@ -284,7 +284,7 @@ public abstract class StrMatcher {
*
* @param chars the characters to match, must not be null
*/
CharSetMatcher(final char chars[]) {
CharSetMatcher(final char[] chars) {
super();
this.chars = chars.clone();
Arrays.sort(this.chars);

View File

@ -110,9 +110,9 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
}
/** The text to work on. */
private char chars[];
private char[] chars;
/** The parsed tokens */
private String tokens[];
private String[] tokens;
/** The current iteration position */
private int tokenPos;

View File

@ -884,9 +884,9 @@ public class CompareToBuilderTest {
@Test
public void testRaggedArray() {
final long array1[][] = new long[2][];
final long array2[][] = new long[2][];
final long array3[][] = new long[3][];
final long[][] array1 = new long[2][];
final long[][] array2 = new long[2][];
final long[][] array3 = new long[3][];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];
@ -912,9 +912,9 @@ public class CompareToBuilderTest {
@Test
public void testMixedArray() {
final Object array1[] = new Object[2];
final Object array2[] = new Object[2];
final Object array3[] = new Object[2];
final Object[] array1 = new Object[2];
final Object[] array2 = new Object[2];
final Object[] array3 = new Object[2];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];

View File

@ -925,8 +925,8 @@ public class EqualsBuilderTest {
@Test
public void testRaggedArray() {
final long array1[][] = new long[2][];
final long array2[][] = new long[2][];
final long[][] array1 = new long[2][];
final long[][] array2 = new long[2][];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];
@ -943,8 +943,8 @@ public class EqualsBuilderTest {
@Test
public void testMixedArray() {
final Object array1[] = new Object[2];
final Object array2[] = new Object[2];
final Object[] array1 = new Object[2];
final Object[] array2 = new Object[2];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];

View File

@ -58,9 +58,9 @@ public class StrTokenizerTest {
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", ""};
final String[] expected = new String[]{"a", "b", "c", "d;\"e", "f", "", "", ""};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {
@ -79,9 +79,9 @@ public class StrTokenizerTest {
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", ""};
final String[] expected = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", ""};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {
@ -100,9 +100,9 @@ public class StrTokenizerTest {
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", ""};
final String[] expected = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", ""};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {
@ -121,9 +121,9 @@ public class StrTokenizerTest {
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(true);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f"};
final String[] expected = new String[]{"a", "b", "c", "d;\"e", "f"};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {
@ -143,9 +143,9 @@ public class StrTokenizerTest {
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null};
final String[] expected = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {
@ -165,9 +165,9 @@ public class StrTokenizerTest {
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
// tok.setTreatingEmptyAsNull(true);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null};
final String[] expected = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null};
int nextCount = 0;
while (tok.hasNext()) {
@ -198,9 +198,9 @@ public class StrTokenizerTest {
tok.setQuoteMatcher(StrMatcher.doubleQuoteMatcher());
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", ""};
final String[] expected = new String[]{"a", "", "", "b", "c", "d e", "f", ""};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {
@ -219,9 +219,9 @@ public class StrTokenizerTest {
tok.setQuoteMatcher(StrMatcher.doubleQuoteMatcher());
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(true);
final String tokens[] = tok.getTokenArray();
final String[] tokens = tok.getTokenArray();
final String expected[] = new String[]{"a", "b", "c", "d e", "f"};
final String[] expected = new String[]{"a", "b", "c", "d e", "f"};
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
for (int i = 0; i < expected.length; i++) {