Use final.

This commit is contained in:
Gary Gregory 2017-10-20 13:02:26 -06:00
parent 1f0dfc31b5
commit 88654b79c9
30 changed files with 189 additions and 187 deletions

View File

@ -49,32 +49,32 @@ public class ArchUtils {
}
private static void init_X86_32Bit() {
Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.X86);
final Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.X86);
addProcessors(processor, "x86", "i386", "i486", "i586", "i686", "pentium");
}
private static void init_X86_64Bit() {
Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.X86);
final Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.X86);
addProcessors(processor, "x86_64", "amd64", "em64t", "universal");
}
private static void init_IA64_32Bit() {
Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.IA_64);
final Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.IA_64);
addProcessors(processor, "ia64_32", "ia64n");
}
private static void init_IA64_64Bit() {
Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.IA_64);
final Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.IA_64);
addProcessors(processor, "ia64", "ia64w");
}
private static void init_PPC_32Bit() {
Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.PPC);
final Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.PPC);
addProcessors(processor, "ppc", "power", "powerpc", "power_pc", "power_rs");
}
private static void init_PPC_64Bit() {
Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.PPC);
final Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.PPC);
addProcessors(processor, "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64");
}
@ -85,11 +85,11 @@ public class ArchUtils {
* @param processor The {@link Processor} to add.
* @throws IllegalStateException If the key already exists.
*/
private static void addProcessor(String key, Processor processor) throws IllegalStateException {
private static void addProcessor(final String key, final Processor processor) throws IllegalStateException {
if (!ARCH_TO_PROCESSOR.containsKey(key)) {
ARCH_TO_PROCESSOR.put(key, processor);
} else {
String msg = "Key " + key + " already exists in processor map";
final String msg = "Key " + key + " already exists in processor map";
throw new IllegalStateException(msg);
}
}
@ -101,8 +101,8 @@ public class ArchUtils {
* @param processor The {@link Processor} to add.
* @throws IllegalStateException If the key already exists.
*/
private static void addProcessors(Processor processor, String... keys) throws IllegalStateException {
for (String key : keys) {
private static void addProcessors(final Processor processor, final String... keys) throws IllegalStateException {
for (final String key : keys) {
addProcessor(key, processor);
}
}
@ -128,7 +128,7 @@ public class ArchUtils {
* @param value A {@link String} like a value returned by the os.arch System Property.
* @return A {@link Processor} when it exists, else <code>null</code>.
*/
public static Processor getProcessor(String value) {
public static Processor getProcessor(final String value) {
return ARCH_TO_PROCESSOR.get(value);
}

View File

@ -8087,7 +8087,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
boolean[] result = new boolean[array.length + values.length];
final boolean[] result = new boolean[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8129,7 +8129,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
byte[] result = new byte[array.length + values.length];
final byte[] result = new byte[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8171,7 +8171,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
char[] result = new char[array.length + values.length];
final char[] result = new char[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8213,7 +8213,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
double[] result = new double[array.length + values.length];
final double[] result = new double[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8255,7 +8255,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
float[] result = new float[array.length + values.length];
final float[] result = new float[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8297,7 +8297,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
int[] result = new int[array.length + values.length];
final int[] result = new int[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8339,7 +8339,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
long[] result = new long[array.length + values.length];
final long[] result = new long[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8381,7 +8381,7 @@ public class ArrayUtils {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length);
}
short[] result = new short[array.length + values.length];
final short[] result = new short[array.length + values.length];
System.arraycopy(values, 0, result, index, values.length);
if (index > 0) {
@ -8435,6 +8435,7 @@ public class ArrayUtils {
final Class<?> type = array.getClass().getComponentType();
@SuppressWarnings("unchecked") // OK, because array and values are of type T
final
T[] result = (T[]) Array.newInstance(type, array.length + values.length);
System.arraycopy(values, 0, result, index, values.length);
@ -8454,7 +8455,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(Object[] array) {
public static void shuffle(final Object[] array) {
shuffle(array, new Random());
}
@ -8466,7 +8467,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(Object[] array, Random random) {
public static void shuffle(final Object[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8479,7 +8480,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(boolean[] array) {
public static void shuffle(final boolean[] array) {
shuffle(array, new Random());
}
@ -8491,7 +8492,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(boolean[] array, Random random) {
public static void shuffle(final boolean[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8504,7 +8505,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(byte[] array) {
public static void shuffle(final byte[] array) {
shuffle(array, new Random());
}
@ -8516,7 +8517,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(byte[] array, Random random) {
public static void shuffle(final byte[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8529,7 +8530,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(char[] array) {
public static void shuffle(final char[] array) {
shuffle(array, new Random());
}
@ -8541,7 +8542,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(char[] array, Random random) {
public static void shuffle(final char[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8554,7 +8555,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(short[] array) {
public static void shuffle(final short[] array) {
shuffle(array, new Random());
}
@ -8566,7 +8567,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(short[] array, Random random) {
public static void shuffle(final short[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8579,7 +8580,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(int[] array) {
public static void shuffle(final int[] array) {
shuffle(array, new Random());
}
@ -8591,7 +8592,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(int[] array, Random random) {
public static void shuffle(final int[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8604,7 +8605,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(long[] array) {
public static void shuffle(final long[] array) {
shuffle(array, new Random());
}
@ -8616,7 +8617,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(long[] array, Random random) {
public static void shuffle(final long[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8629,7 +8630,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(float[] array) {
public static void shuffle(final float[] array) {
shuffle(array, new Random());
}
@ -8641,7 +8642,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(float[] array, Random random) {
public static void shuffle(final float[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}
@ -8654,7 +8655,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(double[] array) {
public static void shuffle(final double[] array) {
shuffle(array, new Random());
}
@ -8666,7 +8667,7 @@ public class ArrayUtils {
* @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
* @since 3.6
*/
public static void shuffle(double[] array, Random random) {
public static void shuffle(final double[] array, final Random random) {
for (int i = array.length; i > 1; i--) {
swap(array, i - 1, random.nextInt(i), 1);
}

View File

@ -113,10 +113,10 @@ public class CharSequenceUtils {
}
//supplementary characters (LANG1300)
if (searchChar <= Character.MAX_CODE_POINT) {
char[] chars = Character.toChars(searchChar);
final char[] chars = Character.toChars(searchChar);
for (int i = start; i < sz - 1; i++) {
char high = cs.charAt(i);
char low = cs.charAt(i + 1);
final char high = cs.charAt(i);
final char low = cs.charAt(i + 1);
if (high == chars[0] && low == chars[1]) {
return i;
}
@ -193,14 +193,14 @@ public class CharSequenceUtils {
//supplementary characters (LANG1300)
//NOTE - we must do a forward traversal for this to avoid duplicating code points
if (searchChar <= Character.MAX_CODE_POINT) {
char[] chars = Character.toChars(searchChar);
final char[] chars = Character.toChars(searchChar);
//make sure it's not the last index
if (start == sz - 1) {
return NOT_FOUND;
}
for (int i = start; i >= 0; i--) {
char high = cs.charAt(i);
char low = cs.charAt(i + 1);
final char high = cs.charAt(i);
final char low = cs.charAt(i + 1);
if (chars[0] == high && chars[1] == low) {
return i;
}

View File

@ -175,7 +175,7 @@ public class CharSet implements Serializable {
*/
protected CharSet(final String... set) {
super();
for (String s : set) {
for (final String s : set) {
add(s);
}
}

View File

@ -232,7 +232,7 @@ public class CharSetUtils {
final CharSet chars = CharSet.getInstance(set);
final StringBuilder buffer = new StringBuilder(str.length());
final char[] chrs = str.toCharArray();
for (char chr : chrs) {
for (final char chr : chrs) {
if (chars.contains(chr) == expect) {
buffer.append(chr);
}

View File

@ -382,7 +382,7 @@ public class RandomStringUtils {
"or greater then (" + first_letter_ascii + ") for generating letters.");
}
StringBuilder builder = new StringBuilder(count);
final StringBuilder builder = new StringBuilder(count);
final int gap = end - start;
while (count-- != 0) {

View File

@ -7895,7 +7895,7 @@ public class StringUtils {
// find the min and max string lengths; this avoids checking to make
// sure we are not exceeding the length of the string each time through
// the bottom loop.
for (CharSequence cs : css) {
for (final CharSequence cs : css) {
if (cs == null) {
anyStringNull = true;
shortestStrLen = 0;
@ -9229,7 +9229,7 @@ public class StringUtils {
* @return an array of code points
* @since 3.6
*/
public static int[] toCodePoints(CharSequence str) {
public static int[] toCodePoints(final CharSequence str) {
if (str == null) {
return null;
}
@ -9237,8 +9237,8 @@ public class StringUtils {
return ArrayUtils.EMPTY_INT_ARRAY;
}
String s = str.toString();
int[] result = new int[s.codePointCount(0, s.length())];
final String s = str.toString();
final int[] result = new int[s.codePointCount(0, s.length())];
int index = 0;
for (int i = 0; i < result.length; i++) {
result[i] = s.codePointAt(index);

View File

@ -95,7 +95,7 @@ public class Processor {
* @param arch The processor architecture.
* @param type The processor type.
*/
public Processor(Arch arch, Type type) {
public Processor(final Arch arch, final Type type) {
this.arch = arch;
this.type = type;
}

View File

@ -355,7 +355,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
*/
public static <T> String toString(
final T object, final ToStringStyle style, final boolean outputTransients,
final boolean outputStatics, boolean excludeNullValues, final Class<? super T> reflectUpToClass) {
final boolean outputStatics, final boolean excludeNullValues, final Class<? super T> reflectUpToClass) {
return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNullValues)
.toString();
}

View File

@ -622,7 +622,7 @@ public class MethodUtils {
// Check the implemented interfaces of the parent class
final Class<?>[] interfaces = cls.getInterfaces();
for (Class<?> anInterface : interfaces) {
for (final Class<?> anInterface : interfaces) {
// Is this interface public?
if (!Modifier.isPublic(anInterface.getModifiers())) {
continue;
@ -875,7 +875,7 @@ public class MethodUtils {
* @since 3.6
*/
public static Method[] getMethodsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls,
boolean searchSupers, boolean ignoreAccess) {
final boolean searchSupers, final boolean ignoreAccess) {
final List<Method> annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls, searchSupers,
ignoreAccess);
return annotatedMethodsList.toArray(new Method[annotatedMethodsList.size()]);
@ -898,15 +898,15 @@ public class MethodUtils {
*/
public static List<Method> getMethodsListWithAnnotation(final Class<?> cls,
final Class<? extends Annotation> annotationCls,
boolean searchSupers, boolean ignoreAccess) {
final boolean searchSupers, final boolean ignoreAccess) {
Validate.isTrue(cls != null, "The class must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
final List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
: new ArrayList<Class<?>>());
classes.add(0, cls);
final List<Method> annotatedMethods = new ArrayList<>();
for (Class<?> acls : classes) {
for (final Class<?> acls : classes) {
final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods());
for (final Method method : methods) {
if (method.getAnnotation(annotationCls) != null) {
@ -941,7 +941,7 @@ public class MethodUtils {
* @since 3.6
*/
public static <A extends Annotation> A getAnnotation(final Method method, final Class<A> annotationCls,
boolean searchSupers, boolean ignoreAccess) {
final boolean searchSupers, final boolean ignoreAccess) {
Validate.isTrue(method != null, "The method must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
@ -952,14 +952,14 @@ public class MethodUtils {
A annotation = method.getAnnotation(annotationCls);
if (annotation == null && searchSupers) {
Class<?> mcls = method.getDeclaringClass();
List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls);
for (Class<?> acls : classes) {
final Class<?> mcls = method.getDeclaringClass();
final List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls);
for (final Class<?> acls : classes) {
Method equivalentMethod;
try {
equivalentMethod = (ignoreAccess ? acls.getDeclaredMethod(method.getName(), method.getParameterTypes())
: acls.getMethod(method.getName(), method.getParameterTypes()));
} catch (NoSuchMethodException e) {
} catch (final NoSuchMethodException e) {
// if not found, just keep searching
continue;
}
@ -989,9 +989,9 @@ public class MethodUtils {
}
final List<Class<?>> allSuperClassesAndInterfaces = new ArrayList<>();
List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(cls);
final List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(cls);
int superClassIndex = 0;
List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(cls);
final List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(cls);
int interfaceIndex = 0;
while (interfaceIndex < allInterfaces.size() ||
superClassIndex < allSuperclasses.size()) {

View File

@ -1811,7 +1811,7 @@ public class TypeUtils {
return buf.toString();
}
private static void appendRecursiveTypes(StringBuilder buf, int[] recursiveTypeIndexes, Type[] argumentTypes) {
private static void appendRecursiveTypes(final StringBuilder buf, final int[] recursiveTypeIndexes, final Type[] argumentTypes) {
for (int i = 0; i < recursiveTypeIndexes.length; i++) {
appendAllTo(buf.append('<'), ", ", argumentTypes[i].toString()).append('>');
}
@ -1823,8 +1823,8 @@ public class TypeUtils {
}
}
private static int[] findRecursiveTypes(ParameterizedType p) {
Type[] filteredArgumentTypes = Arrays.copyOf(p.getActualTypeArguments(), p.getActualTypeArguments().length);
private static int[] findRecursiveTypes(final ParameterizedType p) {
final Type[] filteredArgumentTypes = Arrays.copyOf(p.getActualTypeArguments(), p.getActualTypeArguments().length);
int[] indexesToRemove = new int[] {};
for (int i = 0; i < filteredArgumentTypes.length; i++) {
if (filteredArgumentTypes[i] instanceof TypeVariable<?>) {
@ -1836,7 +1836,7 @@ public class TypeUtils {
return indexesToRemove;
}
private static boolean containsVariableTypeSameParametrizedTypeBound(TypeVariable<?> typeVariable, ParameterizedType p) {
private static boolean containsVariableTypeSameParametrizedTypeBound(final TypeVariable<?> typeVariable, final ParameterizedType p) {
return ArrayUtils.contains(typeVariable.getBounds(), p);
}
@ -1887,7 +1887,7 @@ public class TypeUtils {
return buf;
}
private static <T> String toString(T object) {
private static <T> String toString(final T object) {
return object instanceof Type ? toString((Type) object) : object.toString();
}

View File

@ -888,7 +888,7 @@ public class FastDateParser implements DateParser, Serializable {
*/
@Override
void setCalendar(final FastDateParser parser, final Calendar cal, final String timeZone) {
TimeZone tz = FastTimeZone.getGmtTimeZone(timeZone);
final TimeZone tz = FastTimeZone.getGmtTimeZone(timeZone);
if (tz != null) {
cal.setTimeZone(tz);
} else {

View File

@ -46,15 +46,15 @@ public class FastTimeZone {
* @param pattern The GMT offset
* @return A TimeZone with offset from GMT or null, if pattern does not match.
*/
public static TimeZone getGmtTimeZone(String pattern) {
public static TimeZone getGmtTimeZone(final String pattern) {
if ("Z".equals(pattern) || "UTC".equals(pattern)) {
return GREENWICH;
}
Matcher m = GMT_PATTERN.matcher(pattern);
final Matcher m = GMT_PATTERN.matcher(pattern);
if (m.matches()) {
int hours = parseInt(m.group(2));
int minutes = parseInt(m.group(4));
final int hours = parseInt(m.group(2));
final int minutes = parseInt(m.group(4));
if (hours == 0 && minutes == 0) {
return GREENWICH;
}
@ -72,19 +72,19 @@ public class FastTimeZone {
* @param id A GMT custom id (or Olson id
* @return A timezone
*/
public static TimeZone getTimeZone(String id) {
TimeZone tz = getGmtTimeZone(id);
public static TimeZone getTimeZone(final String id) {
final TimeZone tz = getGmtTimeZone(id);
if (tz != null) {
return tz;
}
return TimeZone.getTimeZone(id);
}
private static int parseInt(String group) {
private static int parseInt(final String group) {
return group != null ? Integer.parseInt(group) : 0;
}
private static boolean parseSign(String group) {
private static boolean parseSign(final String group) {
return group != null && group.charAt(0) == '-';
}

View File

@ -36,14 +36,14 @@ class GmtTimeZone extends TimeZone {
private final int offset;
private final String zoneId;
GmtTimeZone(boolean negate, int hours, int minutes) {
GmtTimeZone(final boolean negate, final int hours, final int minutes) {
if (hours >= HOURS_PER_DAY) {
throw new IllegalArgumentException(hours + " hours out of range");
}
if (minutes >= MINUTES_PER_HOUR) {
throw new IllegalArgumentException(minutes + " minutes out of range");
}
int milliseconds = (minutes + (hours * MINUTES_PER_HOUR)) * MILLISECONDS_PER_MINUTE;
final int milliseconds = (minutes + (hours * MINUTES_PER_HOUR)) * MILLISECONDS_PER_MINUTE;
offset = negate ? -milliseconds : milliseconds;
zoneId = twoDigits(
twoDigits(new StringBuilder(9).append("GMT").append(negate ? '-' : '+'), hours)
@ -51,17 +51,17 @@ class GmtTimeZone extends TimeZone {
}
private static StringBuilder twoDigits(StringBuilder sb, int n) {
private static StringBuilder twoDigits(final StringBuilder sb, final int n) {
return sb.append((char) ('0' + (n / 10))).append((char) ('0' + (n % 10)));
}
@Override
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) {
public int getOffset(final int era, final int year, final int month, final int day, final int dayOfWeek, final int milliseconds) {
return offset;
}
@Override
public void setRawOffset(int offsetMillis) {
public void setRawOffset(final int offsetMillis) {
throw new UnsupportedOperationException();
}
@ -81,7 +81,7 @@ class GmtTimeZone extends TimeZone {
}
@Override
public boolean inDaylightTime(Date date) {
public boolean inDaylightTime(final Date date) {
return false;
}
@ -96,7 +96,7 @@ class GmtTimeZone extends TimeZone {
}
@Override
public boolean equals(Object other) {
public boolean equals(final Object other) {
if (!(other instanceof GmtTimeZone)) {
return false;
}

View File

@ -133,25 +133,25 @@ public class ArchUtilsTest {
assertNull(ArchUtils.getProcessor("NA"));
}
private void assertEqualsArchNotNull(Processor.Arch arch, Processor processor) {
private void assertEqualsArchNotNull(final Processor.Arch arch, final Processor processor) {
assertNotNull(arch);
assertNotNull(processor);
assertEquals(arch, processor.getArch());
}
private void assertNotEqualsArchNotNull(Processor.Arch arch, Processor processor) {
private void assertNotEqualsArchNotNull(final Processor.Arch arch, final Processor processor) {
assertNotNull(arch);
assertNotNull(processor);
assertNotEquals(arch, processor.getArch());
}
private void assertEqualsTypeNotNull(Processor.Type type, Processor processor) {
private void assertEqualsTypeNotNull(final Processor.Type type, final Processor processor) {
assertNotNull(type);
assertNotNull(processor);
assertEquals(type, processor.getType());
}
private void assertNotEqualsTypeNotNull(Processor.Type type, Processor processor) {
private void assertNotEqualsTypeNotNull(final Processor.Type type, final Processor processor) {
assertNotNull(type);
assertNotNull(processor);
assertNotEquals(type, processor.getType());

View File

@ -34,7 +34,7 @@ public class ArrayUtilsInsertTest {
final boolean[] array = {true,false,true};
final boolean[] values = {false,true,false};
boolean[] result = ArrayUtils.insert(42, array, null);
final boolean[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -45,14 +45,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -70,7 +70,7 @@ public class ArrayUtilsInsertTest {
final byte[] array = {1,2,3};
final byte[] values = {4,5,6};
byte[] result = ArrayUtils.insert(42, array, null);
final byte[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -81,14 +81,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -105,7 +105,7 @@ public class ArrayUtilsInsertTest {
final char[] array = {'a','b','c'};
final char[] values = {'d','e','f'};
char[] result = ArrayUtils.insert(42, array, null);
final char[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -116,14 +116,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -141,7 +141,7 @@ public class ArrayUtilsInsertTest {
final double[] values = {4,5,6};
final double delta = 0.000001;
double[] result = ArrayUtils.insert(42, array, null);
final double[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result, delta);
assertFalse(array == result);
@ -152,14 +152,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -177,7 +177,7 @@ public class ArrayUtilsInsertTest {
final float[] values = {4,5,6};
final float delta = 0.000001f;
float[] result = ArrayUtils.insert(42, array, null);
final float[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result, delta);
assertFalse(array == result);
@ -188,14 +188,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -212,7 +212,7 @@ public class ArrayUtilsInsertTest {
final int[] array = {1,2,3};
final int[] values = {4,5,6};
int[] result = ArrayUtils.insert(42, array, null);
final int[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -223,14 +223,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -248,7 +248,7 @@ public class ArrayUtilsInsertTest {
final long[] array = {1,2,3};
final long[] values = {4,5,6};
long[] result = ArrayUtils.insert(42, array, null);
final long[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -259,14 +259,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -284,7 +284,7 @@ public class ArrayUtilsInsertTest {
final short[] array = {1,2,3};
final short[] values = {4,5,6};
short[] result = ArrayUtils.insert(42, array, null);
final short[] result = ArrayUtils.insert(42, array, null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -295,14 +295,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
@ -320,7 +320,7 @@ public class ArrayUtilsInsertTest {
final String[] array = {"a","b","c"};
final String[] values = {"d","e","f"};
String[] result = ArrayUtils.insert(42, array, (String[]) null);
final String[] result = ArrayUtils.insert(42, array, (String[]) null);
assertArrayEquals(array, result);
assertFalse(array == result);
@ -331,14 +331,14 @@ public class ArrayUtilsInsertTest {
try {
ArrayUtils.insert(-1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}
try {
ArrayUtils.insert(array.length + 1, array, array);
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
} catch (final IndexOutOfBoundsException e) {
// expected
}

View File

@ -5004,20 +5004,20 @@ public class ArrayUtilsTest {
@Test
public void testShuffle() {
String[] array1 = new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
String[] array2 = ArrayUtils.clone(array1);
final String[] array1 = new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
final String[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (String element : array2) {
for (final String element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleBoolean() {
boolean[] array1 = new boolean[]{true, false, true, true, false, false, true, false, false, true};
boolean[] array2 = ArrayUtils.clone(array1);
final boolean[] array1 = new boolean[]{true, false, true, true, false, false, true, false, false, true};
final boolean[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
@ -5026,84 +5026,84 @@ public class ArrayUtilsTest {
@Test
public void testShuffleByte() {
byte[] array1 = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
byte[] array2 = ArrayUtils.clone(array1);
final byte[] array1 = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final byte[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (byte element : array2) {
for (final byte element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleChar() {
char[] array1 = new char[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
char[] array2 = ArrayUtils.clone(array1);
final char[] array1 = new char[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final char[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (char element : array2) {
for (final char element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleShort() {
short[] array1 = new short[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
short[] array2 = ArrayUtils.clone(array1);
final short[] array1 = new short[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final short[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (short element : array2) {
for (final short element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleInt() {
int[] array1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int[] array2 = ArrayUtils.clone(array1);
final int[] array1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final int[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (int element : array2) {
for (final int element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleLong() {
long[] array1 = new long[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
long[] array2 = ArrayUtils.clone(array1);
final long[] array1 = new long[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final long[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (long element : array2) {
for (final long element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleFloat() {
float[] array1 = new float[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
float[] array2 = ArrayUtils.clone(array1);
final float[] array1 = new float[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final float[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (float element : array2) {
for (final float element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}
@Test
public void testShuffleDouble() {
double[] array1 = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
double[] array2 = ArrayUtils.clone(array1);
final double[] array1 = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
final double[] array2 = ArrayUtils.clone(array1);
ArrayUtils.shuffle(array1);
assertFalse(Arrays.equals(array1, array2));
for (double element : array2) {
for (final double element : array2) {
assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
}
}

View File

@ -400,7 +400,7 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test(expected = UnsupportedOperationException.class)
public void testIteratorRemove() {
CharRange a = CharRange.is('a');
final CharRange a = CharRange.is('a');
final Iterator<Character> aIt = a.iterator();
aIt.remove();
}

View File

@ -544,20 +544,21 @@ public class RandomStringUtilsTest {
*/
@Test
public void testCharOverflow() throws Exception {
int start = Character.MAX_VALUE;
int end = Integer.MAX_VALUE;
final int start = Character.MAX_VALUE;
final int end = Integer.MAX_VALUE;
@SuppressWarnings("serial")
final
Random fixedRandom = new Random() {
@Override
public int nextInt(int n) {
public int nextInt(final int n) {
// Prevents selection of 'start' as the character
return super.nextInt(n - 1) + 1;
}
};
String result = RandomStringUtils.random(2, start, end, false, false, null, fixedRandom);
int c = result.codePointAt(0);
final String result = RandomStringUtils.random(2, start, end, false, false, null, fixedRandom);
final int c = result.codePointAt(0);
assertTrue(String.format("Character '%d' not in range [%d,%d).", c, start, end), c >= start && c < end);
}
}

View File

@ -97,7 +97,7 @@ public class RandomUtilsTest {
*/
@Test
public void testBoolean() {
boolean result = RandomUtils.nextBoolean();
final boolean result = RandomUtils.nextBoolean();
assertTrue(result == true || result == false);
}

View File

@ -307,7 +307,7 @@ public class StringUtilsEqualsIndexOfTest {
assertEquals(2, StringUtils.indexOf(builder, CODE_POINT, 1));
assertEquals(2, StringUtils.indexOf(builder.toString(), CODE_POINT, 1));
// inner branch on the supplementary character block
char[] tmp = { (char) 55361 };
final char[] tmp = { (char) 55361 };
builder = new StringBuilder();
builder.append(tmp);
assertEquals(-1, StringUtils.indexOf(builder, CODE_POINT, 0));
@ -561,7 +561,7 @@ public class StringUtilsEqualsIndexOfTest {
builder.append("aaaaa");
assertEquals(2, StringUtils.lastIndexOf(builder, CODE_POINT, 4));
// inner branch on the supplementary character block
char[] tmp = { (char) 55361 };
final char[] tmp = { (char) 55361 };
builder = new StringBuilder();
builder.append(tmp);
assertEquals(-1, StringUtils.lastIndexOf(builder, CODE_POINT, 0));

View File

@ -60,7 +60,7 @@ public class SystemUtilsTest {
@Test
public void testGetHostName() {
final String hostName = SystemUtils.getHostName();
String expected = SystemUtils.IS_OS_WINDOWS ? System.getenv("COMPUTERNAME") : System.getenv("HOSTNAME");
final String expected = SystemUtils.IS_OS_WINDOWS ? System.getenv("COMPUTERNAME") : System.getenv("HOSTNAME");
assertEquals(expected, hostName);
}

View File

@ -1343,18 +1343,18 @@ public class EqualsBuilderTest {
@Test
public void testIsRegistered() throws Exception {
Object firstObject = new Object();
Object secondObject = new Object();
final Object firstObject = new Object();
final Object secondObject = new Object();
try {
Method registerMethod = MethodUtils.getMatchingMethod(EqualsBuilder.class, "register", Object.class, Object.class);
final Method registerMethod = MethodUtils.getMatchingMethod(EqualsBuilder.class, "register", Object.class, Object.class);
registerMethod.setAccessible(true);
registerMethod.invoke(null, firstObject, secondObject);
assertTrue(EqualsBuilder.isRegistered(firstObject, secondObject));
assertTrue(EqualsBuilder.isRegistered(secondObject, firstObject)); // LANG-1349
} finally {
Method unregisterMethod = MethodUtils.getMatchingMethod(EqualsBuilder.class, "unregister", Object.class, Object.class);
final Method unregisterMethod = MethodUtils.getMatchingMethod(EqualsBuilder.class, "unregister", Object.class, Object.class);
unregisterMethod.setAccessible(true);
unregisterMethod.invoke(null, firstObject, secondObject);
}

View File

@ -30,7 +30,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
@SuppressWarnings("unused")
private final String testStringField;
TestFixture(Integer a, String b) {
TestFixture(final Integer a, final String b) {
this.testIntegerField = a;
this.testStringField = b;
}
@ -116,7 +116,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
@Test
public void test_ConstructorOptionNormal(){
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
assertFalse(builder.isExcludeNullValues());
String toString = builder.toString();
assertTrue(toString.contains(STRING_FIELD_NAME));
@ -153,7 +153,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
assertFalse(toString.contains(STRING_FIELD_NAME));
assertFalse(toString.contains(INTEGER_FIELD_NAME));
ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
final ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
oldBuilder.setExcludeNullValues(true);
assertTrue(oldBuilder.isExcludeNullValues());
toString = oldBuilder.toString();

View File

@ -620,9 +620,9 @@ public class ToStringBuilderTest {
@Test
public void testAppendAsObjectToString() {
String objectToAppend1 = "";
Boolean objectToAppend2 = Boolean.TRUE;
Object objectToAppend3 = new Object();
final String objectToAppend1 = "";
final Boolean objectToAppend2 = Boolean.TRUE;
final Object objectToAppend3 = new Object();
assertEquals(baseStr + "[" + toBaseString(objectToAppend1) + "]",
new ToStringBuilder(base).appendAsObjectToString(objectToAppend1).toString());
@ -634,7 +634,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendBooleanArrayWithFieldName() {
boolean[] array = new boolean[] { true, false, false };
final boolean[] array = new boolean[] { true, false, false };
assertEquals(baseStr + "[flags={true,false,false}]",
new ToStringBuilder(base).append("flags", array).toString());
assertEquals(baseStr + "[flags=<null>]",
@ -645,7 +645,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendBooleanArrayWithFieldNameAndFullDetatil() {
boolean[] array = new boolean[] { true, false, false };
final boolean[] array = new boolean[] { true, false, false };
assertEquals(baseStr + "[flags={true,false,false}]",
new ToStringBuilder(base).append("flags", array, true).toString());
assertEquals(baseStr + "[length=<size=3>]",
@ -658,7 +658,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendCharArrayWithFieldName() {
char[] array = new char[] { 'A', '2', '_', 'D' };
final char[] array = new char[] { 'A', '2', '_', 'D' };
assertEquals(baseStr + "[chars={A,2,_,D}]", new ToStringBuilder(base).append("chars", array).toString());
assertEquals(baseStr + "[letters={A,2,_,D}]", new ToStringBuilder(base).append("letters", array).toString());
assertEquals(baseStr + "[flags=<null>]",
@ -669,7 +669,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendCharArrayWithFieldNameAndFullDetatil() {
char[] array = new char[] { 'A', '2', '_', 'D' };
final char[] array = new char[] { 'A', '2', '_', 'D' };
assertEquals(baseStr + "[chars={A,2,_,D}]", new ToStringBuilder(base).append("chars", array, true).toString());
assertEquals(baseStr + "[letters=<size=4>]",
new ToStringBuilder(base).append("letters", array, false).toString());
@ -681,7 +681,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendDoubleArrayWithFieldName() {
double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
final double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
@ -692,7 +692,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendDoubleArrayWithFieldNameAndFullDetatil() {
double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
final double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=4>]",
@ -705,7 +705,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendObjectArrayWithFieldName() {
Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
final Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
assertEquals(baseStr + "[values={<null>,5,{3,6}}]",
new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
@ -716,7 +716,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendObjectArrayWithFieldNameAndFullDetatil() {
Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
final Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
assertEquals(baseStr + "[values={<null>,5,{3,6}}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=3>]",
@ -729,7 +729,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendLongArrayWithFieldName() {
long[] array = new long[] { 1, 2, -3, 4 };
final long[] array = new long[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
new ToStringBuilder(base).append("values", (boolean[]) null).toString());
@ -739,7 +739,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendLongArrayWithFieldNameAndFullDetatil() {
long[] array = new long[] { 1, 2, -3, 4 };
final long[] array = new long[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=4>]",
@ -752,7 +752,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendIntArrayWithFieldName() {
int[] array = new int[] { 1, 2, -3, 4 };
final int[] array = new int[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
new ToStringBuilder(base).append("values", (boolean[]) null).toString());
@ -762,7 +762,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendIntArrayWithFieldNameAndFullDetatil() {
int[] array = new int[] { 1, 2, -3, 4 };
final int[] array = new int[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=4>]",
@ -775,7 +775,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendShortArrayWithFieldName() {
short[] array = new short[] { 1, 2, -3, 4 };
final short[] array = new short[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
new ToStringBuilder(base).append("values", (boolean[]) null).toString());
@ -785,7 +785,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendShortArrayWithFieldNameAndFullDetatil() {
short[] array = new short[] { 1, 2, -3, 4 };
final short[] array = new short[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=4>]",
@ -798,7 +798,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendByteArrayWithFieldName() {
byte[] array = new byte[] { 1, 2, -3, 4 };
final byte[] array = new byte[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
new ToStringBuilder(base).append("values", (boolean[]) null).toString());
@ -808,7 +808,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendByteArrayWithFieldNameAndFullDetatil() {
byte[] array = new byte[] { 1, 2, -3, 4 };
final byte[] array = new byte[] { 1, 2, -3, 4 };
assertEquals(baseStr + "[values={1,2,-3,4}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=4>]",
@ -821,7 +821,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendFloatArrayWithFieldName() {
float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
final float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
new ToStringBuilder(base).append("values", array).toString());
assertEquals(baseStr + "[values=<null>]",
@ -832,7 +832,7 @@ public class ToStringBuilderTest {
@Test
public void testAppendFloatArrayWithFieldNameAndFullDetatil() {
float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
final float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
new ToStringBuilder(base).append("values", array, true).toString());
assertEquals(baseStr + "[length=<size=4>]",
@ -845,8 +845,8 @@ public class ToStringBuilderTest {
@Test
public void testConstructToStringBuilder(){
ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null);
ToStringBuilder stringBuilder2 = new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, new StringBuffer(1024));
final ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null);
final ToStringBuilder stringBuilder2 = new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, new StringBuffer(1024));
assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder1.getStyle());
assertNotNull(stringBuilder1.getStringBuffer());
assertNotNull(stringBuilder1.toString());

View File

@ -77,7 +77,7 @@ public class ConstructorUtilsTest {
varArgs = s;
}
public TestBean(final BaseClass bc, String... s) {
public TestBean(final BaseClass bc, final String... s) {
toString = "(BaseClass, String...)";
varArgs = s;
}

View File

@ -438,7 +438,7 @@ public class MethodUtilsTest {
MethodUtils.invokeMethod(testBean, "foo",
1, 2);
fail("should throw NoSuchMethodException");
} catch (NoSuchMethodException expected) {
} catch (final NoSuchMethodException expected) {
}
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),

View File

@ -752,7 +752,7 @@ public class TypeUtilsTest<B> {
public void testToStringLang1311() {
assertEquals("int[]", TypeUtils.toString(int[].class));
assertEquals("java.lang.Integer[]", TypeUtils.toString(Integer[].class));
Field stringListField = FieldUtils.getDeclaredField(getClass(), "stringListArray");
final Field stringListField = FieldUtils.getDeclaredField(getClass(), "stringListArray");
assertEquals("java.util.List<java.lang.String>[]", TypeUtils.toString(stringListField.getGenericType()));
}

View File

@ -113,7 +113,7 @@ public class ImmutablePairTest {
public void testNullPairTyped() {
// No compiler warnings
// How do we assert that?
ImmutablePair<String, String> pair = ImmutablePair.nullPair();
final ImmutablePair<String, String> pair = ImmutablePair.nullPair();
assertNotNull(pair);
}

View File

@ -116,7 +116,7 @@ public class ImmutableTripleTest {
public void testNullTripleTyped() {
// No compiler warnings
// How do we assert that?
ImmutableTriple<String, String, String> triple = ImmutableTriple.nullTriple();
final ImmutableTriple<String, String, String> triple = ImmutableTriple.nullTriple();
assertNotNull(triple);
}