aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/apache/commons/lang3/AnnotationUtils.java37
-rw-r--r--src/main/java/org/apache/commons/lang3/ArrayUtils.java272
-rw-r--r--src/main/java/org/apache/commons/lang3/BooleanUtils.java48
-rw-r--r--src/main/java/org/apache/commons/lang3/CharEncoding.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/CharRange.java8
-rw-r--r--src/main/java/org/apache/commons/lang3/CharSequenceUtils.java8
-rw-r--r--src/main/java/org/apache/commons/lang3/CharSet.java12
-rw-r--r--src/main/java/org/apache/commons/lang3/CharSetUtils.java22
-rw-r--r--src/main/java/org/apache/commons/lang3/ClassUtils.java62
-rw-r--r--src/main/java/org/apache/commons/lang3/Conversion.java80
-rw-r--r--src/main/java/org/apache/commons/lang3/EnumUtils.java20
-rw-r--r--src/main/java/org/apache/commons/lang3/LocaleUtils.java12
-rw-r--r--src/main/java/org/apache/commons/lang3/ObjectUtils.java26
-rw-r--r--src/main/java/org/apache/commons/lang3/RandomStringUtils.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/Range.java7
-rw-r--r--src/main/java/org/apache/commons/lang3/SerializationUtils.java31
-rw-r--r--src/main/java/org/apache/commons/lang3/StringEscapeUtils.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/StringUtils.java326
-rw-r--r--src/main/java/org/apache/commons/lang3/SystemUtils.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/Validate.java6
-rw-r--r--src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java8
-rw-r--r--src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java32
-rw-r--r--src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java30
-rw-r--r--src/main/java/org/apache/commons/lang3/builder/IDKey.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java16
-rw-r--r--src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java22
-rw-r--r--src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java6
-rw-r--r--src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java12
-rw-r--r--src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java16
-rw-r--r--src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java11
-rw-r--r--src/main/java/org/apache/commons/lang3/event/EventUtils.java6
-rw-r--r--src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java68
-rw-r--r--src/main/java/org/apache/commons/lang3/math/Fraction.java58
-rw-r--r--src/main/java/org/apache/commons/lang3/math/NumberUtils.java56
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableByte.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableInt.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableLong.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableObject.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/mutable/MutableShort.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java17
-rw-r--r--src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java40
-rw-r--r--src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java8
-rw-r--r--src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java40
-rw-r--r--src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java122
-rw-r--r--src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java52
-rw-r--r--src/main/java/org/apache/commons/lang3/text/FormattableUtils.java6
-rw-r--r--src/main/java/org/apache/commons/lang3/text/StrBuilder.java150
-rw-r--r--src/main/java/org/apache/commons/lang3/text/StrLookup.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/text/StrMatcher.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java52
-rw-r--r--src/main/java/org/apache/commons/lang3/text/StrTokenizer.java36
-rw-r--r--src/main/java/org/apache/commons/lang3/text/WordUtils.java30
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java12
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java8
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java10
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java6
-rw-r--r--src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java4
-rw-r--r--src/main/java/org/apache/commons/lang3/time/DateUtils.java58
-rw-r--r--src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java34
-rw-r--r--src/main/java/org/apache/commons/lang3/time/FastDateFormat.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/time/FastDateParser.java44
-rw-r--r--src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java60
-rw-r--r--src/main/java/org/apache/commons/lang3/time/FormatCache.java14
-rw-r--r--src/main/java/org/apache/commons/lang3/tuple/MutablePair.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/tuple/Pair.java2
-rw-r--r--src/main/java/org/apache/commons/lang3/tuple/Triple.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java12
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java94
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java38
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java56
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java521
-rw-r--r--src/test/java/org/apache/commons/lang3/BitFieldTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/CharRangeTest.java115
-rw-r--r--src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/CharSetTest.java36
-rw-r--r--src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/CharUtilsTest.java34
-rw-r--r--src/test/java/org/apache/commons/lang3/ClassUtilsTest.java96
-rw-r--r--src/test/java/org/apache/commons/lang3/ConversionTest.java56
-rw-r--r--src/test/java/org/apache/commons/lang3/EnumUtilsTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java38
-rw-r--r--src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java82
-rw-r--r--src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java100
-rw-r--r--src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java72
-rw-r--r--src/test/java/org/apache/commons/lang3/RangeTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java121
-rw-r--r--src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java110
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java64
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsTest.java154
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java12
-rw-r--r--src/test/java/org/apache/commons/lang3/SystemUtilsTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/ValidateTest.java256
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java302
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java218
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java4
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java92
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java28
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java110
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java24
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java52
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java80
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java81
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java58
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java80
-rw-r--r--src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java36
-rw-r--r--src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java26
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java20
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java20
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java48
-rw-r--r--src/test/java/org/apache/commons/lang3/math/FractionTest.java148
-rw-r--r--src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java24
-rw-r--r--src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java92
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java20
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java212
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java38
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java102
-rw-r--r--src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java78
-rw-r--r--src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java194
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java228
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrLookupTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java28
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java76
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java210
-rw-r--r--src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java26
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java12
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java48
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java120
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java40
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java210
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java58
-rw-r--r--src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java90
-rw-r--r--src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java114
-rw-r--r--src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java76
-rw-r--r--src/test/java/org/apache/commons/lang3/time/StopWatchTest.java80
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/PairTest.java34
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/TripleTest.java36
182 files changed, 4218 insertions, 4173 deletions
diff --git a/src/main/java/org/apache/commons/lang3/AnnotationUtils.java b/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
index a0cba08bd..b3692690b 100644
--- a/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
+++ b/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
@@ -71,9 +71,10 @@ public class AnnotationUtils {
@Override
protected String getShortClassName(final java.lang.Class<?> cls) {
Class<? extends Annotation> annotationType = null;
- for (Class<?> iface : ClassUtils.getAllInterfaces(cls)) {
+ for (final Class<?> iface : ClassUtils.getAllInterfaces(cls)) {
if (Annotation.class.isAssignableFrom(iface)) {
@SuppressWarnings("unchecked") // OK because we just checked the assignability
+ final
Class<? extends Annotation> found = (Class<? extends Annotation>) iface;
annotationType = found;
break;
@@ -125,27 +126,27 @@ public class AnnotationUtils {
if (a1 == null || a2 == null) {
return false;
}
- Class<? extends Annotation> type = a1.annotationType();
- Class<? extends Annotation> type2 = a2.annotationType();
+ final Class<? extends Annotation> type = a1.annotationType();
+ final Class<? extends Annotation> type2 = a2.annotationType();
Validate.notNull(type, "Annotation %s with null annotationType()", a1);
Validate.notNull(type2, "Annotation %s with null annotationType()", a2);
if (!type.equals(type2)) {
return false;
}
try {
- for (Method m : type.getDeclaredMethods()) {
+ for (final Method m : type.getDeclaredMethods()) {
if (m.getParameterTypes().length == 0
&& isValidAnnotationMemberType(m.getReturnType())) {
- Object v1 = m.invoke(a1);
- Object v2 = m.invoke(a2);
+ final Object v1 = m.invoke(a1);
+ final Object v2 = m.invoke(a2);
if (!memberEquals(m.getReturnType(), v1, v2)) {
return false;
}
}
}
- } catch (IllegalAccessException ex) {
+ } catch (final IllegalAccessException ex) {
return false;
- } catch (InvocationTargetException ex) {
+ } catch (final InvocationTargetException ex) {
return false;
}
return true;
@@ -165,18 +166,18 @@ public class AnnotationUtils {
*/
public static int hashCode(final Annotation a) {
int result = 0;
- Class<? extends Annotation> type = a.annotationType();
- for (Method m : type.getDeclaredMethods()) {
+ final Class<? extends Annotation> type = a.annotationType();
+ for (final Method m : type.getDeclaredMethods()) {
try {
- Object value = m.invoke(a);
+ final Object value = m.invoke(a);
if (value == null) {
throw new IllegalStateException(
String.format("Annotation method %s returned null", m));
}
result += hashMember(m.getName(), value);
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw ex;
- } catch (Exception ex) {
+ } catch (final Exception ex) {
throw new RuntimeException(ex);
}
}
@@ -192,16 +193,16 @@ public class AnnotationUtils {
* {@code null}
*/
public static String toString(final Annotation a) {
- ToStringBuilder builder = new ToStringBuilder(a, TO_STRING_STYLE);
- for (Method m : a.annotationType().getDeclaredMethods()) {
+ final ToStringBuilder builder = new ToStringBuilder(a, TO_STRING_STYLE);
+ for (final Method m : a.annotationType().getDeclaredMethods()) {
if (m.getParameterTypes().length > 0) {
continue; //wtf?
}
try {
builder.append(m.getName(), m.invoke(a));
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw ex;
- } catch (Exception ex) {
+ } catch (final Exception ex) {
throw new RuntimeException(ex);
}
}
@@ -239,7 +240,7 @@ public class AnnotationUtils {
* @return a hash code for this member
*/
private static int hashMember(final String name, final Object value) {
- int part1 = name.hashCode() * 127;
+ final int part1 = name.hashCode() * 127;
if (value.getClass().isArray()) {
return part1 ^ arrayMemberHash(value.getClass().getComponentType(), value);
}
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index 84914aca4..a0a499a98 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -237,12 +237,12 @@ public class ArrayUtils {
}
final Map<Object, Object> map = new HashMap<Object, Object>((int) (array.length * 1.5));
for (int i = 0; i < array.length; i++) {
- Object object = array[i];
+ final Object object = array[i];
if (object instanceof Map.Entry<?, ?>) {
- Map.Entry<?,?> entry = (Map.Entry<?,?>) object;
+ final Map.Entry<?,?> entry = (Map.Entry<?,?>) object;
map.put(entry.getKey(), entry.getValue());
} else if (object instanceof Object[]) {
- Object[] entry = (Object[]) object;
+ final Object[] entry = (Object[]) object;
if (entry.length < 2) {
throw new IllegalArgumentException("Array element " + i + ", '"
+ object
@@ -853,14 +853,15 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
- Class<?> type = array.getClass().getComponentType();
+ final int newSize = endIndexExclusive - startIndexInclusive;
+ final Class<?> type = array.getClass().getComponentType();
if (newSize <= 0) {
@SuppressWarnings("unchecked") // OK, because array is of type T
final T[] emptyArray = (T[]) Array.newInstance(type, 0);
return emptyArray;
}
@SuppressWarnings("unchecked") // OK, because array is of type T
+ final
T[] subarray = (T[]) Array.newInstance(type, newSize);
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
@@ -895,12 +896,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_LONG_ARRAY;
}
- long[] subarray = new long[newSize];
+ final long[] subarray = new long[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -934,12 +935,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_INT_ARRAY;
}
- int[] subarray = new int[newSize];
+ final int[] subarray = new int[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -973,12 +974,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_SHORT_ARRAY;
}
- short[] subarray = new short[newSize];
+ final short[] subarray = new short[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -1012,12 +1013,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_CHAR_ARRAY;
}
- char[] subarray = new char[newSize];
+ final char[] subarray = new char[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -1051,12 +1052,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_BYTE_ARRAY;
}
- byte[] subarray = new byte[newSize];
+ final byte[] subarray = new byte[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -1090,12 +1091,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_DOUBLE_ARRAY;
}
- double[] subarray = new double[newSize];
+ final double[] subarray = new double[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -1129,12 +1130,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_FLOAT_ARRAY;
}
- float[] subarray = new float[newSize];
+ final float[] subarray = new float[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -1168,12 +1169,12 @@ public class ArrayUtils {
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
- int newSize = endIndexExclusive - startIndexInclusive;
+ final int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_BOOLEAN_ARRAY;
}
- boolean[] subarray = new boolean[newSize];
+ final boolean[] subarray = new boolean[newSize];
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -2327,8 +2328,8 @@ public class ArrayUtils {
if (startIndex < 0) {
startIndex = 0;
}
- double min = valueToFind - tolerance;
- double max = valueToFind + tolerance;
+ final double min = valueToFind - tolerance;
+ final double max = valueToFind + tolerance;
for (int i = startIndex; i < array.length; i++) {
if (array[i] >= min && array[i] <= max) {
return i;
@@ -2425,8 +2426,8 @@ public class ArrayUtils {
} else if (startIndex >= array.length) {
startIndex = array.length - 1;
}
- double min = valueToFind - tolerance;
- double max = valueToFind + tolerance;
+ final double min = valueToFind - tolerance;
+ final double max = valueToFind + tolerance;
for (int i = startIndex; i >= 0; i--) {
if (array[i] >= min && array[i] <= max) {
return i;
@@ -2717,7 +2718,7 @@ public class ArrayUtils {
}
final char[] result = new char[array.length];
for (int i = 0; i < array.length; i++) {
- Character b = array[i];
+ final Character b = array[i];
result[i] = (b == null ? valueForNull : b.charValue());
}
return result;
@@ -2785,7 +2786,7 @@ public class ArrayUtils {
}
final long[] result = new long[array.length];
for (int i = 0; i < array.length; i++) {
- Long b = array[i];
+ final Long b = array[i];
result[i] = (b == null ? valueForNull : b.longValue());
}
return result;
@@ -2853,7 +2854,7 @@ public class ArrayUtils {
}
final int[] result = new int[array.length];
for (int i = 0; i < array.length; i++) {
- Integer b = array[i];
+ final Integer b = array[i];
result[i] = (b == null ? valueForNull : b.intValue());
}
return result;
@@ -2921,7 +2922,7 @@ public class ArrayUtils {
}
final short[] result = new short[array.length];
for (int i = 0; i < array.length; i++) {
- Short b = array[i];
+ final Short b = array[i];
result[i] = (b == null ? valueForNull : b.shortValue());
}
return result;
@@ -2989,7 +2990,7 @@ public class ArrayUtils {
}
final byte[] result = new byte[array.length];
for (int i = 0; i < array.length; i++) {
- Byte b = array[i];
+ final Byte b = array[i];
result[i] = (b == null ? valueForNull : b.byteValue());
}
return result;
@@ -3057,7 +3058,7 @@ public class ArrayUtils {
}
final double[] result = new double[array.length];
for (int i = 0; i < array.length; i++) {
- Double b = array[i];
+ final Double b = array[i];
result[i] = (b == null ? valueForNull : b.doubleValue());
}
return result;
@@ -3125,7 +3126,7 @@ public class ArrayUtils {
}
final float[] result = new float[array.length];
for (int i = 0; i < array.length; i++) {
- Float b = array[i];
+ final Float b = array[i];
result[i] = (b == null ? valueForNull : b.floatValue());
}
return result;
@@ -3193,7 +3194,7 @@ public class ArrayUtils {
}
final boolean[] result = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
- Boolean b = array[i];
+ final Boolean b = array[i];
result[i] = (b == null ? valueForNull : b.booleanValue());
}
return result;
@@ -3453,11 +3454,12 @@ public class ArrayUtils {
}
final Class<?> type1 = array1.getClass().getComponentType();
@SuppressWarnings("unchecked") // OK, because array is of type T
+ final
T[] joinedArray = (T[]) Array.newInstance(type1, array1.length + array2.length);
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
try {
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
- } catch (ArrayStoreException ase) {
+ } catch (final ArrayStoreException ase) {
// Check if problem was due to incompatible types
/*
* We do this here, rather than before the copy because:
@@ -3497,7 +3499,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- boolean[] joinedArray = new boolean[array1.length + array2.length];
+ final boolean[] joinedArray = new boolean[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3526,7 +3528,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- char[] joinedArray = new char[array1.length + array2.length];
+ final char[] joinedArray = new char[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3555,7 +3557,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- byte[] joinedArray = new byte[array1.length + array2.length];
+ final byte[] joinedArray = new byte[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3584,7 +3586,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- short[] joinedArray = new short[array1.length + array2.length];
+ final short[] joinedArray = new short[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3613,7 +3615,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- int[] joinedArray = new int[array1.length + array2.length];
+ final int[] joinedArray = new int[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3642,7 +3644,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- long[] joinedArray = new long[array1.length + array2.length];
+ final long[] joinedArray = new long[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3671,7 +3673,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- float[] joinedArray = new float[array1.length + array2.length];
+ final float[] joinedArray = new float[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3700,7 +3702,7 @@ public class ArrayUtils {
} else if (array2 == null) {
return clone(array1);
}
- double[] joinedArray = new double[array1.length + array2.length];
+ final double[] joinedArray = new double[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
@@ -3745,6 +3747,7 @@ public class ArrayUtils {
throw new IllegalArgumentException("Arguments cannot both be null");
}
@SuppressWarnings("unchecked") // type must be T
+ final
T[] newArray = (T[]) copyArrayGrow1(array, type);
newArray[newArray.length - 1] = element;
return newArray;
@@ -3772,7 +3775,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static boolean[] add(final boolean[] array, final boolean element) {
- boolean[] newArray = (boolean[])copyArrayGrow1(array, Boolean.TYPE);
+ final boolean[] newArray = (boolean[])copyArrayGrow1(array, Boolean.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3799,7 +3802,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static byte[] add(final byte[] array, final byte element) {
- byte[] newArray = (byte[])copyArrayGrow1(array, Byte.TYPE);
+ final byte[] newArray = (byte[])copyArrayGrow1(array, Byte.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3826,7 +3829,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static char[] add(final char[] array, final char element) {
- char[] newArray = (char[])copyArrayGrow1(array, Character.TYPE);
+ final char[] newArray = (char[])copyArrayGrow1(array, Character.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3853,7 +3856,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static double[] add(final double[] array, final double element) {
- double[] newArray = (double[])copyArrayGrow1(array, Double.TYPE);
+ final double[] newArray = (double[])copyArrayGrow1(array, Double.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3880,7 +3883,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static float[] add(final float[] array, final float element) {
- float[] newArray = (float[])copyArrayGrow1(array, Float.TYPE);
+ final float[] newArray = (float[])copyArrayGrow1(array, Float.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3907,7 +3910,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static int[] add(final int[] array, final int element) {
- int[] newArray = (int[])copyArrayGrow1(array, Integer.TYPE);
+ final int[] newArray = (int[])copyArrayGrow1(array, Integer.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3934,7 +3937,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static long[] add(final long[] array, final long element) {
- long[] newArray = (long[])copyArrayGrow1(array, Long.TYPE);
+ final long[] newArray = (long[])copyArrayGrow1(array, Long.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3961,7 +3964,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static short[] add(final short[] array, final short element) {
- short[] newArray = (short[])copyArrayGrow1(array, Short.TYPE);
+ final short[] newArray = (short[])copyArrayGrow1(array, Short.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
}
@@ -3977,8 +3980,8 @@ public class ArrayUtils {
*/
private static Object copyArrayGrow1(final Object array, final Class<?> newArrayComponentType) {
if (array != null) {
- int arrayLength = Array.getLength(array);
- Object newArray = Array.newInstance(array.getClass().getComponentType(), arrayLength + 1);
+ final int arrayLength = Array.getLength(array);
+ final Object newArray = Array.newInstance(array.getClass().getComponentType(), arrayLength + 1);
System.arraycopy(array, 0, newArray, 0, arrayLength);
return newArray;
}
@@ -4294,15 +4297,15 @@ public class ArrayUtils {
if (index != 0) {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: 0");
}
- Object joinedArray = Array.newInstance(clss, 1);
+ final Object joinedArray = Array.newInstance(clss, 1);
Array.set(joinedArray, 0, element);
return joinedArray;
}
- int length = Array.getLength(array);
+ final int length = Array.getLength(array);
if (index > length || index < 0) {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
}
- Object result = Array.newInstance(clss, length + 1);
+ final Object result = Array.newInstance(clss, length + 1);
System.arraycopy(array, 0, result, 0, index);
Array.set(result, index, element);
if (index < length) {
@@ -4372,7 +4375,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static <T> T[] removeElement(final T[] array, final Object element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4437,7 +4440,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static boolean[] removeElement(final boolean[] array, final boolean element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4502,7 +4505,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static byte[] removeElement(final byte[] array, final byte element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4567,7 +4570,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static char[] removeElement(final char[] array, final char element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4632,7 +4635,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static double[] removeElement(final double[] array, final double element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4697,7 +4700,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static float[] removeElement(final float[] array, final float element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4762,7 +4765,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static int[] removeElement(final int[] array, final int element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4827,7 +4830,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static long[] removeElement(final long[] array, final long element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4892,7 +4895,7 @@ public class ArrayUtils {
* @since 2.1
*/
public static short[] removeElement(final short[] array, final short element) {
- int index = indexOf(array, element);
+ final int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
@@ -4921,12 +4924,12 @@ public class ArrayUtils {
* @since 2.1
*/
private static Object remove(final Object array, final int index) {
- int length = getLength(array);
+ final int length = getLength(array);
if (index < 0 || index >= length) {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
}
- Object result = Array.newInstance(array.getClass().getComponentType(), length - 1);
+ final Object result = Array.newInstance(array.getClass().getComponentType(), length - 1);
System.arraycopy(array, 0, result, 0, index);
if (index < length - 1) {
System.arraycopy(array, index + 1, result, index, length - index - 1);
@@ -4998,18 +5001,18 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(values.length);
- for (T v : values) {
- MutableInt count = occurrences.get(v);
+ final HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(values.length);
+ for (final T v : values) {
+ final MutableInt count = occurrences.get(v);
if (count == null) {
occurrences.put(v, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<T, MutableInt> e : occurrences.entrySet()) {
- T v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<T, MutableInt> e : occurrences.entrySet()) {
+ final T v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v, found);
@@ -5020,6 +5023,7 @@ public class ArrayUtils {
}
}
@SuppressWarnings("unchecked") // removeAll() always creates an array of the same type as its input
+ final
T[] result = (T[]) removeAll(array, toRemove);
return result;
}
@@ -5088,19 +5092,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Byte, MutableInt> occurrences = new HashMap<Byte, MutableInt>(values.length);
- for (byte v : values) {
- Byte boxed = Byte.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Byte, MutableInt> occurrences = new HashMap<Byte, MutableInt>(values.length);
+ for (final byte v : values) {
+ final Byte boxed = Byte.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Byte, MutableInt> e : occurrences.entrySet()) {
- Byte v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Byte, MutableInt> e : occurrences.entrySet()) {
+ final Byte v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.byteValue(), found);
@@ -5177,19 +5181,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Short, MutableInt> occurrences = new HashMap<Short, MutableInt>(values.length);
- for (short v : values) {
- Short boxed = Short.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Short, MutableInt> occurrences = new HashMap<Short, MutableInt>(values.length);
+ for (final short v : values) {
+ final Short boxed = Short.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Short, MutableInt> e : occurrences.entrySet()) {
- Short v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Short, MutableInt> e : occurrences.entrySet()) {
+ final Short v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.shortValue(), found);
@@ -5266,19 +5270,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Integer, MutableInt> occurrences = new HashMap<Integer, MutableInt>(values.length);
- for (int v : values) {
- Integer boxed = Integer.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Integer, MutableInt> occurrences = new HashMap<Integer, MutableInt>(values.length);
+ for (final int v : values) {
+ final Integer boxed = Integer.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Integer, MutableInt> e : occurrences.entrySet()) {
- Integer v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Integer, MutableInt> e : occurrences.entrySet()) {
+ final Integer v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.intValue(), found);
@@ -5355,19 +5359,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Character, MutableInt> occurrences = new HashMap<Character, MutableInt>(values.length);
- for (char v : values) {
- Character boxed = Character.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Character, MutableInt> occurrences = new HashMap<Character, MutableInt>(values.length);
+ for (final char v : values) {
+ final Character boxed = Character.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Character, MutableInt> e : occurrences.entrySet()) {
- Character v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Character, MutableInt> e : occurrences.entrySet()) {
+ final Character v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.charValue(), found);
@@ -5444,19 +5448,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Long, MutableInt> occurrences = new HashMap<Long, MutableInt>(values.length);
- for (long v : values) {
- Long boxed = Long.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Long, MutableInt> occurrences = new HashMap<Long, MutableInt>(values.length);
+ for (final long v : values) {
+ final Long boxed = Long.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Long, MutableInt> e : occurrences.entrySet()) {
- Long v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Long, MutableInt> e : occurrences.entrySet()) {
+ final Long v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.longValue(), found);
@@ -5533,19 +5537,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Float, MutableInt> occurrences = new HashMap<Float, MutableInt>(values.length);
- for (float v : values) {
- Float boxed = Float.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Float, MutableInt> occurrences = new HashMap<Float, MutableInt>(values.length);
+ for (final float v : values) {
+ final Float boxed = Float.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Float, MutableInt> e : occurrences.entrySet()) {
- Float v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Float, MutableInt> e : occurrences.entrySet()) {
+ final Float v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.floatValue(), found);
@@ -5622,19 +5626,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Double, MutableInt> occurrences = new HashMap<Double, MutableInt>(values.length);
- for (double v : values) {
- Double boxed = Double.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Double, MutableInt> occurrences = new HashMap<Double, MutableInt>(values.length);
+ for (final double v : values) {
+ final Double boxed = Double.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Double, MutableInt> e : occurrences.entrySet()) {
- Double v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Double, MutableInt> e : occurrences.entrySet()) {
+ final Double v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.doubleValue(), found);
@@ -5707,19 +5711,19 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) {
return clone(array);
}
- HashMap<Boolean, MutableInt> occurrences = new HashMap<Boolean, MutableInt>(2); // only two possible values here
- for (boolean v : values) {
- Boolean boxed = Boolean.valueOf(v);
- MutableInt count = occurrences.get(boxed);
+ final HashMap<Boolean, MutableInt> occurrences = new HashMap<Boolean, MutableInt>(2); // only two possible values here
+ for (final boolean v : values) {
+ final Boolean boxed = Boolean.valueOf(v);
+ final MutableInt count = occurrences.get(boxed);
if (count == null) {
occurrences.put(boxed, new MutableInt(1));
} else {
count.increment();
}
}
- BitSet toRemove = new BitSet();
- for (Map.Entry<Boolean, MutableInt> e : occurrences.entrySet()) {
- Boolean v = e.getKey();
+ final BitSet toRemove = new BitSet();
+ for (final Map.Entry<Boolean, MutableInt> e : occurrences.entrySet()) {
+ final Boolean v = e.getKey();
int found = 0;
for (int i = 0, ct = e.getValue().intValue(); i < ct; i++) {
found = indexOf(array, v.booleanValue(), found);
@@ -5741,7 +5745,7 @@ public class ArrayUtils {
*/
// package protected for access by unit tests
static Object removeAll(final Object array, final int... indices) {
- int length = getLength(array);
+ final int length = getLength(array);
int diff = 0; // number of distinct indexes, i.e. number of entries that will be removed
if (isNotEmpty(indices)) {
@@ -5750,7 +5754,7 @@ public class ArrayUtils {
int i = indices.length;
int prevIndex = length;
while (--i >= 0) {
- int index = indices[i];
+ final int index = indices[i];
if (index < 0 || index >= length) {
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
}
@@ -5761,14 +5765,14 @@ public class ArrayUtils {
prevIndex = index;
}
}
- Object result = Array.newInstance(array.getClass().getComponentType(), length - diff);
+ final Object result = Array.newInstance(array.getClass().getComponentType(), length - diff);
if (diff < length) {
int end = length; // index just after last copy
int dest = length - diff; // number of entries so far not copied
for (int i = indices.length - 1; i >= 0; i--) {
- int index = indices[i];
+ final int index = indices[i];
if (end - index > 1) { // same as (cp > 0)
- int cp = end - index - 1;
+ final int cp = end - index - 1;
dest -= cp;
System.arraycopy(array, index + 1, result, dest, cp);
// Afer this copy, we still have room for dest items.
@@ -5800,7 +5804,7 @@ public class ArrayUtils {
// throw new IndexOutOfBoundsException("Index: " + (maxIndex-1) + ", Length: " + srcLength);
// }
final int removals = indices.cardinality(); // true bits are items to remove
- Object result = Array.newInstance(array.getClass().getComponentType(), srcLength - removals);
+ final Object result = Array.newInstance(array.getClass().getComponentType(), srcLength - removals);
int srcIndex=0;
int destIndex=0;
int count;
diff --git a/src/main/java/org/apache/commons/lang3/BooleanUtils.java b/src/main/java/org/apache/commons/lang3/BooleanUtils.java
index a7bae1210..9b8046efa 100644
--- a/src/main/java/org/apache/commons/lang3/BooleanUtils.java
+++ b/src/main/java/org/apache/commons/lang3/BooleanUtils.java
@@ -550,7 +550,7 @@ public class BooleanUtils {
}
switch (str.length()) {
case 1: {
- char ch0 = str.charAt(0);
+ final char ch0 = str.charAt(0);
if (ch0 == 'y' || ch0 == 'Y' ||
ch0 == 't' || ch0 == 'T') {
return Boolean.TRUE;
@@ -562,8 +562,8 @@ public class BooleanUtils {
break;
}
case 2: {
- char ch0 = str.charAt(0);
- char ch1 = str.charAt(1);
+ final char ch0 = str.charAt(0);
+ final char ch1 = str.charAt(1);
if ((ch0 == 'o' || ch0 == 'O') &&
(ch1 == 'n' || ch1 == 'N') ) {
return Boolean.TRUE;
@@ -575,9 +575,9 @@ public class BooleanUtils {
break;
}
case 3: {
- char ch0 = str.charAt(0);
- char ch1 = str.charAt(1);
- char ch2 = str.charAt(2);
+ final char ch0 = str.charAt(0);
+ final char ch1 = str.charAt(1);
+ final char ch2 = str.charAt(2);
if ((ch0 == 'y' || ch0 == 'Y') &&
(ch1 == 'e' || ch1 == 'E') &&
(ch2 == 's' || ch2 == 'S') ) {
@@ -591,10 +591,10 @@ public class BooleanUtils {
break;
}
case 4: {
- char ch0 = str.charAt(0);
- char ch1 = str.charAt(1);
- char ch2 = str.charAt(2);
- char ch3 = str.charAt(3);
+ final char ch0 = str.charAt(0);
+ final char ch1 = str.charAt(1);
+ final char ch2 = str.charAt(2);
+ final char ch3 = str.charAt(3);
if ((ch0 == 't' || ch0 == 'T') &&
(ch1 == 'r' || ch1 == 'R') &&
(ch2 == 'u' || ch2 == 'U') &&
@@ -604,11 +604,11 @@ public class BooleanUtils {
break;
}
case 5: {
- char ch0 = str.charAt(0);
- char ch1 = str.charAt(1);
- char ch2 = str.charAt(2);
- char ch3 = str.charAt(3);
- char ch4 = str.charAt(4);
+ final char ch0 = str.charAt(0);
+ final char ch1 = str.charAt(1);
+ final char ch2 = str.charAt(2);
+ final char ch3 = str.charAt(3);
+ final char ch4 = str.charAt(4);
if ((ch0 == 'f' || ch0 == 'F') &&
(ch1 == 'a' || ch1 == 'A') &&
(ch2 == 'l' || ch2 == 'L') &&
@@ -894,7 +894,7 @@ public class BooleanUtils {
if (array.length == 0) {
throw new IllegalArgumentException("Array is empty");
}
- for (boolean element : array) {
+ for (final boolean element : array) {
if (!element) {
return false;
}
@@ -929,9 +929,9 @@ public class BooleanUtils {
throw new IllegalArgumentException("Array is empty");
}
try {
- boolean[] primitive = ArrayUtils.toPrimitive(array);
+ final boolean[] primitive = ArrayUtils.toPrimitive(array);
return and(primitive) ? Boolean.TRUE : Boolean.FALSE;
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
throw new IllegalArgumentException("The array must not contain any null elements");
}
}
@@ -962,7 +962,7 @@ public class BooleanUtils {
if (array.length == 0) {
throw new IllegalArgumentException("Array is empty");
}
- for (boolean element : array) {
+ for (final boolean element : array) {
if (element) {
return true;
}
@@ -998,9 +998,9 @@ public class BooleanUtils {
throw new IllegalArgumentException("Array is empty");
}
try {
- boolean[] primitive = ArrayUtils.toPrimitive(array);
+ final boolean[] primitive = ArrayUtils.toPrimitive(array);
return or(primitive) ? Boolean.TRUE : Boolean.FALSE;
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
throw new IllegalArgumentException("The array must not contain any null elements");
}
}
@@ -1033,7 +1033,7 @@ public class BooleanUtils {
// Loops through array, comparing each item
int trueCount = 0;
- for (boolean element : array) {
+ for (final boolean element : array) {
// If item is true, and trueCount is < 1, increments count
// Else, xor fails
if (element) {
@@ -1072,9 +1072,9 @@ public class BooleanUtils {
throw new IllegalArgumentException("Array is empty");
}
try {
- boolean[] primitive = ArrayUtils.toPrimitive(array);
+ final boolean[] primitive = ArrayUtils.toPrimitive(array);
return xor(primitive) ? Boolean.TRUE : Boolean.FALSE;
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
throw new IllegalArgumentException("The array must not contain any null elements");
}
}
diff --git a/src/main/java/org/apache/commons/lang3/CharEncoding.java b/src/main/java/org/apache/commons/lang3/CharEncoding.java
index 02410bf0c..4bc959430 100644
--- a/src/main/java/org/apache/commons/lang3/CharEncoding.java
+++ b/src/main/java/org/apache/commons/lang3/CharEncoding.java
@@ -97,7 +97,7 @@ public class CharEncoding {
}
try {
return Charset.isSupported(name);
- } catch (IllegalCharsetNameException ex) {
+ } catch (final IllegalCharsetNameException ex) {
return false;
}
}
diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java
index 37c122555..39b26f9fc 100644
--- a/src/main/java/org/apache/commons/lang3/CharRange.java
+++ b/src/main/java/org/apache/commons/lang3/CharRange.java
@@ -67,7 +67,7 @@ final class CharRange implements Iterable<Character>, Serializable {
private CharRange(char start, char end, final boolean negated) {
super();
if (start > end) {
- char temp = start;
+ final char temp = start;
start = end;
end = temp;
}
@@ -212,7 +212,7 @@ final class CharRange implements Iterable<Character>, Serializable {
if (obj instanceof CharRange == false) {
return false;
}
- CharRange other = (CharRange) obj;
+ final CharRange other = (CharRange) obj;
return start == other.start && end == other.end && negated == other.negated;
}
@@ -234,7 +234,7 @@ final class CharRange implements Iterable<Character>, Serializable {
@Override
public String toString() {
if (iToString == null) {
- StringBuilder buf = new StringBuilder(4);
+ final StringBuilder buf = new StringBuilder(4);
if (isNegated()) {
buf.append('^');
}
@@ -341,7 +341,7 @@ final class CharRange implements Iterable<Character>, Serializable {
if (hasNext == false) {
throw new NoSuchElementException();
}
- char cur = current;
+ final char cur = current;
prepareNext();
return Character.valueOf(cur);
}
diff --git a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
index 7478e2b24..0b096c974 100644
--- a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
+++ b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
@@ -70,7 +70,7 @@ public class CharSequenceUtils {
if (cs instanceof String) {
return ((String) cs).indexOf(searchChar, start);
} else {
- int sz = cs.length();
+ final int sz = cs.length();
if (start < 0) {
start = 0;
}
@@ -117,7 +117,7 @@ public class CharSequenceUtils {
if (cs instanceof String) {
return ((String) cs).lastIndexOf(searchChar, start);
} else {
- int sz = cs.length();
+ final int sz = cs.length();
if (start < 0) {
return -1;
}
@@ -164,8 +164,8 @@ public class CharSequenceUtils {
if (cs instanceof String) {
return ((String) cs).toCharArray();
} else {
- int sz = cs.length();
- char[] array = new char[cs.length()];
+ final int sz = cs.length();
+ final char[] array = new char[cs.length()];
for (int i = 0; i < sz; i++) {
array[i] = cs.charAt(i);
}
diff --git a/src/main/java/org/apache/commons/lang3/CharSet.java b/src/main/java/org/apache/commons/lang3/CharSet.java
index 05f082275..82f0b9a8c 100644
--- a/src/main/java/org/apache/commons/lang3/CharSet.java
+++ b/src/main/java/org/apache/commons/lang3/CharSet.java
@@ -140,7 +140,7 @@ public class CharSet implements Serializable {
return null;
}
if (setStrs.length == 1) {
- CharSet common = COMMON.get(setStrs[0]);
+ final CharSet common = COMMON.get(setStrs[0]);
if (common != null) {
return common;
}
@@ -158,7 +158,7 @@ public class CharSet implements Serializable {
*/
protected CharSet(final String... set) {
super();
- int sz = set.length;
+ final int sz = set.length;
for (int i = 0; i < sz; i++) {
add(set[i]);
}
@@ -175,10 +175,10 @@ public class CharSet implements Serializable {
return;
}
- int len = str.length();
+ final int len = str.length();
int pos = 0;
while (pos < len) {
- int remainder = len - pos;
+ final int remainder = len - pos;
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') {
// negated range
set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3)));
@@ -221,7 +221,7 @@ public class CharSet implements Serializable {
* @return {@code true} if the set contains the characters
*/
public boolean contains(final char ch) {
- for (CharRange range : set) {
+ for (final CharRange range : set) {
if (range.contains(ch)) {
return true;
}
@@ -250,7 +250,7 @@ public class CharSet implements Serializable {
if (obj instanceof CharSet == false) {
return false;
}
- CharSet other = (CharSet) obj;
+ final CharSet other = (CharSet) obj;
return set.equals(other.set);
}
diff --git a/src/main/java/org/apache/commons/lang3/CharSetUtils.java b/src/main/java/org/apache/commons/lang3/CharSetUtils.java
index 490d89020..354a11543 100644
--- a/src/main/java/org/apache/commons/lang3/CharSetUtils.java
+++ b/src/main/java/org/apache/commons/lang3/CharSetUtils.java
@@ -65,10 +65,10 @@ public class CharSetUtils {
if (StringUtils.isEmpty(str) || deepEmpty(set)) {
return str;
}
- CharSet chars = CharSet.getInstance(set);
- StringBuilder buffer = new StringBuilder(str.length());
- char[] chrs = str.toCharArray();
- int sz = chrs.length;
+ final CharSet chars = CharSet.getInstance(set);
+ final StringBuilder buffer = new StringBuilder(str.length());
+ final char[] chrs = str.toCharArray();
+ final int sz = chrs.length;
char lastChar = ' ';
char ch = ' ';
for (int i = 0; i < sz; i++) {
@@ -107,9 +107,9 @@ public class CharSetUtils {
if (StringUtils.isEmpty(str) || deepEmpty(set)) {
return 0;
}
- CharSet chars = CharSet.getInstance(set);
+ final CharSet chars = CharSet.getInstance(set);
int count = 0;
- for (char c : str.toCharArray()) {
+ for (final char c : str.toCharArray()) {
if (chars.contains(c)) {
count++;
}
@@ -185,10 +185,10 @@ public class CharSetUtils {
* @return the modified String, not null
*/
private static String modify(final String str, final String[] set, final boolean expect) {
- CharSet chars = CharSet.getInstance(set);
- StringBuilder buffer = new StringBuilder(str.length());
- char[] chrs = str.toCharArray();
- int sz = chrs.length;
+ final CharSet chars = CharSet.getInstance(set);
+ final StringBuilder buffer = new StringBuilder(str.length());
+ final char[] chrs = str.toCharArray();
+ final int sz = chrs.length;
for(int i=0; i<sz; i++) {
if(chars.contains(chrs[i]) == expect) {
buffer.append(chrs[i]);
@@ -206,7 +206,7 @@ public class CharSetUtils {
*/
private static boolean deepEmpty(final String[] strings) {
if (strings != null) {
- for (String s : strings) {
+ for (final String s : strings) {
if (StringUtils.isNotEmpty(s)) {
return false;
}
diff --git a/src/main/java/org/apache/commons/lang3/ClassUtils.java b/src/main/java/org/apache/commons/lang3/ClassUtils.java
index 679b8db77..13c5bc577 100644
--- a/src/main/java/org/apache/commons/lang3/ClassUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java
@@ -83,8 +83,8 @@ public class ClassUtils {
*/
private static final Map<Class<?>, Class<?>> wrapperPrimitiveMap = new HashMap<Class<?>, Class<?>>();
static {
- for (Class<?> primitiveClass : primitiveWrapperMap.keySet()) {
- Class<?> wrapperClass = primitiveWrapperMap.get(primitiveClass);
+ for (final Class<?> primitiveClass : primitiveWrapperMap.keySet()) {
+ final Class<?> wrapperClass = primitiveWrapperMap.get(primitiveClass);
if (!primitiveClass.equals(wrapperClass)) {
wrapperPrimitiveMap.put(wrapperClass, primitiveClass);
}
@@ -188,7 +188,7 @@ public class ClassUtils {
return StringUtils.EMPTY;
}
- StringBuilder arrayPrefix = new StringBuilder();
+ final StringBuilder arrayPrefix = new StringBuilder();
// Handle array encoding
if (className.startsWith("[")) {
@@ -206,8 +206,8 @@ public class ClassUtils {
className = reverseAbbreviationMap.get(className);
}
- int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
- int innerIdx = className.indexOf(
+ final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
+ final int innerIdx = className.indexOf(
INNER_CLASS_SEPARATOR_CHAR, lastDotIdx == -1 ? 0 : lastDotIdx + 1);
String out = className.substring(lastDotIdx + 1);
if (innerIdx != -1) {
@@ -299,7 +299,7 @@ public class ClassUtils {
className = className.substring(1);
}
- int i = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
+ final int i = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
if (i == -1) {
return StringUtils.EMPTY;
}
@@ -319,7 +319,7 @@ public class ClassUtils {
if (cls == null) {
return null;
}
- List<Class<?>> classes = new ArrayList<Class<?>>();
+ final List<Class<?>> classes = new ArrayList<Class<?>>();
Class<?> superclass = cls.getSuperclass();
while (superclass != null) {
classes.add(superclass);
@@ -346,7 +346,7 @@ public class ClassUtils {
return null;
}
- LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>();
+ final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>();
getAllInterfaces(cls, interfacesFound);
return new ArrayList<Class<?>>(interfacesFound);
@@ -360,9 +360,9 @@ public class ClassUtils {
*/
private static void getAllInterfaces(Class<?> cls, final HashSet<Class<?>> interfacesFound) {
while (cls != null) {
- Class<?>[] interfaces = cls.getInterfaces();
+ final Class<?>[] interfaces = cls.getInterfaces();
- for (Class<?> i : interfaces) {
+ for (final Class<?> i : interfaces) {
if (interfacesFound.add(i)) {
getAllInterfaces(i, interfacesFound);
}
@@ -390,11 +390,11 @@ public class ClassUtils {
if (classNames == null) {
return null;
}
- List<Class<?>> classes = new ArrayList<Class<?>>(classNames.size());
- for (String className : classNames) {
+ final List<Class<?>> classes = new ArrayList<Class<?>>(classNames.size());
+ for (final String className : classNames) {
try {
classes.add(Class.forName(className));
- } catch (Exception ex) {
+ } catch (final Exception ex) {
classes.add(null);
}
}
@@ -417,8 +417,8 @@ public class ClassUtils {
if (classes == null) {
return null;
}
- List<String> classNames = new ArrayList<String>(classes.size());
- for (Class<?> cls : classes) {
+ final List<String> classNames = new ArrayList<String>(classes.size());
+ for (final Class<?> cls : classes) {
if (cls == null) {
classNames.add(null);
} else {
@@ -725,7 +725,7 @@ public class ClassUtils {
return classes;
}
- Class<?>[] convertedClasses = new Class[classes.length];
+ final Class<?>[] convertedClasses = new Class[classes.length];
for (int i = 0; i < classes.length; i++) {
convertedClasses[i] = primitiveToWrapper(classes[i]);
}
@@ -775,7 +775,7 @@ public class ClassUtils {
return classes;
}
- Class<?>[] convertedClasses = new Class[classes.length];
+ final Class<?>[] convertedClasses = new Class[classes.length];
for (int i = 0; i < classes.length; i++) {
convertedClasses[i] = wrapperToPrimitive(classes[i]);
}
@@ -814,22 +814,22 @@ public class ClassUtils {
try {
Class<?> clazz;
if (abbreviationMap.containsKey(className)) {
- String clsName = "[" + abbreviationMap.get(className);
+ final String clsName = "[" + abbreviationMap.get(className);
clazz = Class.forName(clsName, initialize, classLoader).getComponentType();
} else {
clazz = Class.forName(toCanonicalName(className), initialize, classLoader);
}
return clazz;
- } catch (ClassNotFoundException ex) {
+ } catch (final ClassNotFoundException ex) {
// allow path separators (.) as inner class name separators
- int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
+ final int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
if (lastDotIndex != -1) {
try {
return getClass(classLoader, className.substring(0, lastDotIndex) +
INNER_CLASS_SEPARATOR_CHAR + className.substring(lastDotIndex + 1),
initialize);
- } catch (ClassNotFoundException ex2) { // NOPMD
+ } catch (final ClassNotFoundException ex2) { // NOPMD
// ignore exception
}
}
@@ -881,8 +881,8 @@ public class ClassUtils {
* @throws ClassNotFoundException if the class is not found
*/
public static Class<?> getClass(final String className, final boolean initialize) throws ClassNotFoundException {
- ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
- ClassLoader loader = contextCL == null ? ClassUtils.class.getClassLoader() : contextCL;
+ final ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
+ final ClassLoader loader = contextCL == null ? ClassUtils.class.getClassLoader() : contextCL;
return getClass(loader, className, initialize);
}
@@ -912,23 +912,23 @@ public class ClassUtils {
public static Method getPublicMethod(final Class<?> cls, final String methodName, final Class<?>... parameterTypes)
throws SecurityException, NoSuchMethodException {
- Method declaredMethod = cls.getMethod(methodName, parameterTypes);
+ final Method declaredMethod = cls.getMethod(methodName, parameterTypes);
if (Modifier.isPublic(declaredMethod.getDeclaringClass().getModifiers())) {
return declaredMethod;
}
- List<Class<?>> candidateClasses = new ArrayList<Class<?>>();
+ final List<Class<?>> candidateClasses = new ArrayList<Class<?>>();
candidateClasses.addAll(getAllInterfaces(cls));
candidateClasses.addAll(getAllSuperclasses(cls));
- for (Class<?> candidateClass : candidateClasses) {
+ for (final Class<?> candidateClass : candidateClasses) {
if (!Modifier.isPublic(candidateClass.getModifiers())) {
continue;
}
Method candidateMethod;
try {
candidateMethod = candidateClass.getMethod(methodName, parameterTypes);
- } catch (NoSuchMethodException ex) {
+ } catch (final NoSuchMethodException ex) {
continue;
}
if (Modifier.isPublic(candidateMethod.getDeclaringClass().getModifiers())) {
@@ -952,12 +952,12 @@ public class ClassUtils {
if (className == null) {
throw new NullPointerException("className must not be null.");
} else if (className.endsWith("[]")) {
- StringBuilder classNameBuffer = new StringBuilder();
+ final StringBuilder classNameBuffer = new StringBuilder();
while (className.endsWith("[]")) {
className = className.substring(0, className.length() - 2);
classNameBuffer.append("[");
}
- String abbreviation = abbreviationMap.get(className);
+ final String abbreviation = abbreviationMap.get(className);
if (abbreviation != null) {
classNameBuffer.append(abbreviation);
} else {
@@ -984,7 +984,7 @@ public class ClassUtils {
} else if (array.length == 0) {
return ArrayUtils.EMPTY_CLASS_ARRAY;
}
- Class<?>[] classes = new Class[array.length];
+ final Class<?>[] classes = new Class[array.length];
for (int i = 0; i < array.length; i++) {
classes[i] = array[i] == null ? null : array[i].getClass();
}
@@ -1120,7 +1120,7 @@ public class ClassUtils {
className = reverseAbbreviationMap.get(className.substring(0, 1));
}
}
- StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
+ final StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
for (int i = 0; i < dim; i++) {
canonicalClassNameBuffer.append("[]");
}
diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index 1d88b2857..91131ad83 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -512,9 +512,9 @@ public class Conversion {
if (src.length == 0) {
throw new IllegalArgumentException("Cannot convert an empty array.");
}
- int beSrcPos = src.length - 1 - srcPos;
- int srcLen = Math.min(4, beSrcPos + 1);
- boolean[] paddedSrc = new boolean[4];
+ final int beSrcPos = src.length - 1 - srcPos;
+ final int srcLen = Math.min(4, beSrcPos + 1);
+ final boolean[] paddedSrc = new boolean[4];
System.arraycopy(src, beSrcPos + 1 - srcLen, paddedSrc, 4 - srcLen, srcLen);
src = paddedSrc;
srcPos = 0;
@@ -600,7 +600,7 @@ public class Conversion {
* @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15}
*/
public static char intToHexDigit(final int nibble) {
- char c = Character.forDigit(nibble, 16);
+ final char c = Character.forDigit(nibble, 16);
if (c == Character.MIN_VALUE) {
throw new IllegalArgumentException("nibble value not between 0 and 15: " + nibble);
}
@@ -693,8 +693,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nInts; i++ ) {
shift = i * 32 + dstPos;
- long bits = ((0xffffffffL & src[i + srcPos]) << shift);
- long mask = 0xffffffffL << shift;
+ final long bits = ((0xffffffffL & src[i + srcPos]) << shift);
+ final long mask = 0xffffffffL << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -730,8 +730,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nShorts; i++ ) {
shift = i * 16 + dstPos;
- long bits = (0xffffL & src[i + srcPos]) << shift;
- long mask = 0xffffL << shift;
+ final long bits = (0xffffL & src[i + srcPos]) << shift;
+ final long mask = 0xffffL << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -767,8 +767,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nShorts; i++ ) {
shift = i * 16 + dstPos;
- int bits = (0xffff & src[i + srcPos]) << shift;
- int mask = 0xffff << shift;
+ final int bits = (0xffff & src[i + srcPos]) << shift;
+ final int mask = 0xffff << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -804,8 +804,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBytes; i++ ) {
shift = i * 8 + dstPos;
- long bits = (0xffL & src[i + srcPos]) << shift;
- long mask = 0xffL << shift;
+ final long bits = (0xffL & src[i + srcPos]) << shift;
+ final long mask = 0xffL << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -840,8 +840,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBytes; i++ ) {
shift = i * 8 + dstPos;
- int bits = (0xff & src[i + srcPos]) << shift;
- int mask = 0xff << shift;
+ final int bits = (0xff & src[i + srcPos]) << shift;
+ final int mask = 0xff << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -877,8 +877,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBytes; i++ ) {
shift = i * 8 + dstPos;
- int bits = (0xff & src[i + srcPos]) << shift;
- int mask = 0xff << shift;
+ final int bits = (0xff & src[i + srcPos]) << shift;
+ final int mask = 0xff << shift;
out = (short)((out & ~mask) | bits);
}
return out;
@@ -911,8 +911,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nHex; i++ ) {
shift = i * 4 + dstPos;
- long bits = (0xfL & hexDigitToInt(src.charAt(i + srcPos))) << shift;
- long mask = 0xfL << shift;
+ final long bits = (0xfL & hexDigitToInt(src.charAt(i + srcPos))) << shift;
+ final long mask = 0xfL << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -945,8 +945,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nHex; i++ ) {
shift = i * 4 + dstPos;
- int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
- int mask = 0xf << shift;
+ final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
+ final int mask = 0xf << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -979,8 +979,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nHex; i++ ) {
shift = i * 4 + dstPos;
- int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
- int mask = 0xf << shift;
+ final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
+ final int mask = 0xf << shift;
out = (short)((out & ~mask) | bits);
}
return out;
@@ -1013,8 +1013,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nHex; i++ ) {
shift = i * 4 + dstPos;
- int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
- int mask = 0xf << shift;
+ final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
+ final int mask = 0xf << shift;
out = (byte)((out & ~mask) | bits);
}
return out;
@@ -1050,8 +1050,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBools; i++ ) {
shift = i * 1 + dstPos;
- long bits = (src[i + srcPos] ? 1L : 0) << shift;
- long mask = 0x1L << shift;
+ final long bits = (src[i + srcPos] ? 1L : 0) << shift;
+ final long mask = 0x1L << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -1086,8 +1086,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBools; i++ ) {
shift = i * 1 + dstPos;
- int bits = (src[i + srcPos] ? 1 : 0) << shift;
- int mask = 0x1 << shift;
+ final int bits = (src[i + srcPos] ? 1 : 0) << shift;
+ final int mask = 0x1 << shift;
out = (out & ~mask) | bits;
}
return out;
@@ -1123,8 +1123,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBools; i++ ) {
shift = i * 1 + dstPos;
- int bits = (src[i + srcPos] ? 1 : 0) << shift;
- int mask = 0x1 << shift;
+ final int bits = (src[i + srcPos] ? 1 : 0) << shift;
+ final int mask = 0x1 << shift;
out = (short)((out & ~mask) | bits);
}
return out;
@@ -1159,8 +1159,8 @@ public class Conversion {
int shift = 0;
for (int i = 0; i < nBools; i++ ) {
shift = i * 1 + dstPos;
- int bits = (src[i + srcPos] ? 1 : 0) << shift;
- int mask = 0x1 << shift;
+ final int bits = (src[i + srcPos] ? 1 : 0) << shift;
+ final int mask = 0x1 << shift;
out = (byte)((out & ~mask) | bits);
}
return out;
@@ -1392,12 +1392,12 @@ public class Conversion {
throw new IllegalArgumentException(
"(nHexs-1)*4+srcPos is greather or equal to than 64");
}
- StringBuilder sb = new StringBuilder(dstInit);
+ final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0;
int append = sb.length();
for (int i = 0; i < nHexs; i++ ) {
shift = i * 4 + srcPos;
- int bits = (int)(0xF & (src >> shift));
+ final int bits = (int)(0xF & (src >> shift));
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
@@ -1432,12 +1432,12 @@ public class Conversion {
throw new IllegalArgumentException(
"(nHexs-1)*4+srcPos is greather or equal to than 32");
}
- StringBuilder sb = new StringBuilder(dstInit);
+ final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0;
int append = sb.length();
for (int i = 0; i < nHexs; i++ ) {
shift = i * 4 + srcPos;
- int bits = 0xF & (src >> shift);
+ final int bits = 0xF & (src >> shift);
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
@@ -1472,12 +1472,12 @@ public class Conversion {
throw new IllegalArgumentException(
"(nHexs-1)*4+srcPos is greather or equal to than 16");
}
- StringBuilder sb = new StringBuilder(dstInit);
+ final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0;
int append = sb.length();
for (int i = 0; i < nHexs; i++ ) {
shift = i * 4 + srcPos;
- int bits = 0xF & (src >> shift);
+ final int bits = 0xF & (src >> shift);
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
@@ -1512,12 +1512,12 @@ public class Conversion {
throw new IllegalArgumentException(
"(nHexs-1)*4+srcPos is greather or equal to than 8");
}
- StringBuilder sb = new StringBuilder(dstInit);
+ final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0;
int append = sb.length();
for (int i = 0; i < nHexs; i++ ) {
shift = i * 4 + srcPos;
- int bits = 0xF & (src >> shift);
+ final int bits = 0xF & (src >> shift);
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
diff --git a/src/main/java/org/apache/commons/lang3/EnumUtils.java b/src/main/java/org/apache/commons/lang3/EnumUtils.java
index 04776bd79..7a03b5970 100644
--- a/src/main/java/org/apache/commons/lang3/EnumUtils.java
+++ b/src/main/java/org/apache/commons/lang3/EnumUtils.java
@@ -56,8 +56,8 @@ public class EnumUtils {
* @return the modifiable map of enum names to enums, never null
*/
public static <E extends Enum<E>> Map<String, E> getEnumMap(final Class<E> enumClass) {
- Map<String, E> map = new LinkedHashMap<String, E>();
- for (E e: enumClass.getEnumConstants()) {
+ final Map<String, E> map = new LinkedHashMap<String, E>();
+ for (final E e: enumClass.getEnumConstants()) {
map.put(e.name(), e);
}
return map;
@@ -94,7 +94,7 @@ public class EnumUtils {
try {
Enum.valueOf(enumClass, enumName);
return true;
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return false;
}
}
@@ -116,7 +116,7 @@ public class EnumUtils {
}
try {
return Enum.valueOf(enumClass, enumName);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return null;
}
}
@@ -143,7 +143,7 @@ public class EnumUtils {
checkBitVectorable(enumClass);
Validate.notNull(values);
long total = 0;
- for (E constant : values) {
+ for (final E constant : values) {
Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED);
total |= 1 << constant.ordinal();
}
@@ -170,12 +170,12 @@ public class EnumUtils {
asEnum(enumClass);
Validate.notNull(values);
final EnumSet<E> condensed = EnumSet.noneOf(enumClass);
- for (E constant : values) {
+ for (final E constant : values) {
Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED);
condensed.add(constant);
}
final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1];
- for (E value : condensed) {
+ for (final E value : condensed) {
result[value.ordinal() / Long.SIZE] |= 1 << (value.ordinal() % Long.SIZE);
}
ArrayUtils.reverse(result);
@@ -226,7 +226,7 @@ public class EnumUtils {
final EnumSet<E> condensed = EnumSet.noneOf(enumClass);
Collections.addAll(condensed, values);
final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1];
- for (E value : condensed) {
+ for (final E value : condensed) {
result[value.ordinal() / Long.SIZE] |= 1 << (value.ordinal() % Long.SIZE);
}
ArrayUtils.reverse(result);
@@ -268,8 +268,8 @@ public class EnumUtils {
final EnumSet<E> results = EnumSet.noneOf(asEnum(enumClass));
values = ArrayUtils.clone(Validate.notNull(values));
ArrayUtils.reverse(values);
- for (E constant : enumClass.getEnumConstants()) {
- int block = constant.ordinal() / Long.SIZE;
+ for (final E constant : enumClass.getEnumConstants()) {
+ final int block = constant.ordinal() / Long.SIZE;
if (block < values.length && (values[block] & 1 << (constant.ordinal() % Long.SIZE)) != 0) {
results.add(constant);
}
diff --git a/src/main/java/org/apache/commons/lang3/LocaleUtils.java b/src/main/java/org/apache/commons/lang3/LocaleUtils.java
index 73c3520ae..8a1203a0c 100644
--- a/src/main/java/org/apache/commons/lang3/LocaleUtils.java
+++ b/src/main/java/org/apache/commons/lang3/LocaleUtils.java
@@ -184,7 +184,7 @@ public class LocaleUtils {
* @return the unmodifiable list of Locale objects, 0 being locale, not null
*/
public static List<Locale> localeLookupList(final Locale locale, final Locale defaultLocale) {
- List<Locale> list = new ArrayList<Locale>(4);
+ final List<Locale> list = new ArrayList<Locale>(4);
if (locale != null) {
list.add(locale);
if (locale.getVariant().length() > 0) {
@@ -256,9 +256,9 @@ public class LocaleUtils {
List<Locale> langs = cLanguagesByCountry.get(countryCode);
if (langs == null) {
langs = new ArrayList<Locale>();
- List<Locale> locales = availableLocaleList();
+ final List<Locale> locales = availableLocaleList();
for (int i = 0; i < locales.size(); i++) {
- Locale locale = locales.get(i);
+ final Locale locale = locales.get(i);
if (countryCode.equals(locale.getCountry()) &&
locale.getVariant().isEmpty()) {
langs.add(locale);
@@ -288,9 +288,9 @@ public class LocaleUtils {
List<Locale> countries = cCountriesByLanguage.get(languageCode);
if (countries == null) {
countries = new ArrayList<Locale>();
- List<Locale> locales = availableLocaleList();
+ final List<Locale> locales = availableLocaleList();
for (int i = 0; i < locales.size(); i++) {
- Locale locale = locales.get(i);
+ final Locale locale = locales.get(i);
if (languageCode.equals(locale.getLanguage()) &&
locale.getCountry().length() != 0 &&
locale.getVariant().isEmpty()) {
@@ -313,7 +313,7 @@ public class LocaleUtils {
private static final Set<Locale> AVAILABLE_LOCALE_SET;
static {
- List<Locale> list = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales())); // extra safe
+ final List<Locale> list = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales())); // extra safe
AVAILABLE_LOCALE_LIST = Collections.unmodifiableList(list);
AVAILABLE_LOCALE_SET = Collections.unmodifiableSet(new HashSet<Locale>(list));
}
diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
index 69f7a84a3..9a09ecb20 100644
--- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
@@ -118,7 +118,7 @@ public class ObjectUtils {
*/
public static <T> T firstNonNull(final T... values) {
if (values != null) {
- for (T val : values) {
+ for (final T val : values) {
if (val != null) {
return val;
}
@@ -222,7 +222,7 @@ public class ObjectUtils {
public static int hashCodeMulti(final Object... objects) {
int hash = 1;
if (objects != null) {
- for (Object object : objects) {
+ for (final Object object : objects) {
hash = hash * 31 + ObjectUtils.hashCode(object);
}
}
@@ -251,7 +251,7 @@ public class ObjectUtils {
if (object == null) {
return null;
}
- StringBuffer buffer = new StringBuffer();
+ final StringBuffer buffer = new StringBuffer();
identityToString(buffer, object);
return buffer.toString();
}
@@ -344,7 +344,7 @@ public class ObjectUtils {
public static <T extends Comparable<? super T>> T min(final T... values) {
T result = null;
if (values != null) {
- for (T value : values) {
+ for (final T value : values) {
if (compare(value, result, true) < 0) {
result = value;
}
@@ -369,7 +369,7 @@ public class ObjectUtils {
public static <T extends Comparable<? super T>> T max(final T... values) {
T result = null;
if (values != null) {
- for (T value : values) {
+ for (final T value : values) {
if (compare(value, result, false) > 0) {
result = value;
}
@@ -429,9 +429,10 @@ public class ObjectUtils {
public static <T extends Comparable<? super T>> T median(final T... items) {
Validate.notEmpty(items);
Validate.noNullElements(items);
- TreeSet<T> sort = new TreeSet<T>();
+ final TreeSet<T> sort = new TreeSet<T>();
Collections.addAll(sort, items);
@SuppressWarnings("unchecked") //we know all items added were T instances
+ final
T result = (T) sort.toArray()[(sort.size() - 1) / 2];
return result;
}
@@ -451,9 +452,10 @@ public class ObjectUtils {
Validate.notEmpty(items, "null/empty items");
Validate.noNullElements(items);
Validate.notNull(comparator, "null comparator");
- TreeSet<T> sort = new TreeSet<T>(comparator);
+ final TreeSet<T> sort = new TreeSet<T>(comparator);
Collections.addAll(sort, items);
@SuppressWarnings("unchecked") //we know all items added were T instances
+ final
T result = (T) sort.toArray()[(sort.size() - 1) / 2];
return result;
}
@@ -470,9 +472,9 @@ public class ObjectUtils {
*/
public static <T> T mode(final T... items) {
if (ArrayUtils.isNotEmpty(items)) {
- HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(items.length);
- for (T t : items) {
- MutableInt count = occurrences.get(t);
+ final HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(items.length);
+ for (final T t : items) {
+ final MutableInt count = occurrences.get(t);
if (count == null) {
occurrences.put(t, new MutableInt(1));
} else {
@@ -481,8 +483,8 @@ public class ObjectUtils {
}
T result = null;
int max = 0;
- for (Map.Entry<T, MutableInt> e : occurrences.entrySet()) {
- int cmp = e.getValue().intValue();
+ for (final Map.Entry<T, MutableInt> e : occurrences.entrySet()) {
+ final int cmp = e.getValue().intValue();
if (cmp == max) {
result = null;
} else if (cmp > max) {
diff --git a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
index db4ea4873..75355747e 100644
--- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
@@ -248,8 +248,8 @@ public class RandomStringUtils {
}
}
- char[] buffer = new char[count];
- int gap = end - start;
+ final char[] buffer = new char[count];
+ final int gap = end - start;
while (count-- != 0) {
char ch;
diff --git a/src/main/java/org/apache/commons/lang3/Range.java b/src/main/java/org/apache/commons/lang3/Range.java
index 504c84832..7a8655893 100644
--- a/src/main/java/org/apache/commons/lang3/Range.java
+++ b/src/main/java/org/apache/commons/lang3/Range.java
@@ -386,8 +386,8 @@ public final class Range<T> implements Serializable {
if (this.equals(other)) {
return this;
}
- T min = getComparator().compare(minimum, other.minimum) < 0 ? other.minimum : minimum;
- T max = getComparator().compare(maximum, other.maximum) < 0 ? maximum : other.maximum;
+ final T min = getComparator().compare(minimum, other.minimum) < 0 ? other.minimum : minimum;
+ final T max = getComparator().compare(maximum, other.maximum) < 0 ? maximum : other.maximum;
return between(min, max, getComparator());
}
@@ -411,6 +411,7 @@ public final class Range<T> implements Serializable {
return false;
} else {
@SuppressWarnings("unchecked") // OK because we checked the class above
+ final
Range<T> range = (Range<T>) obj;
return minimum.equals(range.minimum) &&
maximum.equals(range.maximum);
@@ -446,7 +447,7 @@ public final class Range<T> implements Serializable {
public String toString() {
String result = toString;
if (result == null) {
- StringBuilder buf = new StringBuilder(32);
+ final StringBuilder buf = new StringBuilder(32);
buf.append('[');
buf.append(minimum);
buf.append("..");
diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java
index 9ea7e83e4..588d40867 100644
--- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java
+++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java
@@ -79,8 +79,8 @@ public class SerializationUtils {
if (object == null) {
return null;
}
- byte[] objectData = serialize(object);
- ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
+ final byte[] objectData = serialize(object);
+ final ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
ClassLoaderAwareObjectInputStream in = null;
try {
@@ -92,19 +92,20 @@ public class SerializationUtils {
* is of the same type as the original serialized object
*/
@SuppressWarnings("unchecked") // see above
+ final
T readObject = (T) in.readObject();
return readObject;
- } catch (ClassNotFoundException ex) {
+ } catch (final ClassNotFoundException ex) {
throw new SerializationException("ClassNotFoundException while reading cloned object data", ex);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
throw new SerializationException("IOException while reading cloned object data", ex);
} finally {
try {
if (in != null) {
in.close();
}
- } catch (IOException ex) {
+ } catch (final IOException ex) {
throw new SerializationException("IOException on closing cloned object data InputStream.", ex);
}
}
@@ -137,14 +138,14 @@ public class SerializationUtils {
out = new ObjectOutputStream(outputStream);
out.writeObject(obj);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
throw new SerializationException(ex);
} finally {
try {
if (out != null) {
out.close();
}
- } catch (IOException ex) { // NOPMD
+ } catch (final IOException ex) { // NOPMD
// ignore close exception
}
}
@@ -159,7 +160,7 @@ public class SerializationUtils {
* @throws SerializationException (runtime) if the serialization fails
*/
public static byte[] serialize(final Serializable obj) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
serialize(obj, baos);
return baos.toByteArray();
}
@@ -207,16 +208,16 @@ public class SerializationUtils {
in = new ObjectInputStream(inputStream);
return (T) in.readObject();
- } catch (ClassNotFoundException ex) {
+ } catch (final ClassNotFoundException ex) {
throw new SerializationException(ex);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
throw new SerializationException(ex);
} finally {
try {
if (in != null) {
in.close();
}
- } catch (IOException ex) { // NOPMD
+ } catch (final IOException ex) { // NOPMD
// ignore close exception
}
}
@@ -300,14 +301,14 @@ public class SerializationUtils {
*/
@Override
protected Class<?> resolveClass(final ObjectStreamClass desc) throws IOException, ClassNotFoundException {
- String name = desc.getName();
+ final String name = desc.getName();
try {
return Class.forName(name, false, classLoader);
- } catch (ClassNotFoundException ex) {
+ } catch (final ClassNotFoundException ex) {
try {
return Class.forName(name, false, Thread.currentThread().getContextClassLoader());
- } catch (ClassNotFoundException cnfe) {
- Class<?> cls = primitiveTypes.get(name);
+ } catch (final ClassNotFoundException cnfe) {
+ final Class<?> cls = primitiveTypes.get(name);
if (cls != null) {
return cls;
} else {
diff --git a/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java b/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
index 05f6ac4fe..e7ec37b8f 100644
--- a/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
@@ -286,7 +286,7 @@ public class StringEscapeUtils {
}
// strip quotes
- String quoteless = input.subSequence(1, input.length() - 1).toString();
+ final String quoteless = input.subSequence(1, input.length() - 1).toString();
if ( StringUtils.containsAny(quoteless, CSV_SEARCH_CHARS) ) {
// deal with escaped quotes; ie) ""
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 4008eb7c7..11c18c5b4 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -316,7 +316,7 @@ public class StringUtils {
* @since 2.0
*/
public static String trimToNull(final String str) {
- String ts = trim(str);
+ final String ts = trim(str);
return isEmpty(ts) ? null : ts;
}
@@ -608,7 +608,7 @@ public class StringUtils {
if (strs == null || (strsLen = strs.length) == 0) {
return strs;
}
- String[] newArr = new String[strsLen];
+ final String[] newArr = new String[strsLen];
for (int i = 0; i < strsLen; i++) {
newArr[i] = strip(strs[i], stripChars);
}
@@ -637,8 +637,8 @@ public class StringUtils {
if(input == null) {
return null;
}
- Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");//$NON-NLS-1$
- String decomposed = Normalizer.normalize(input, Normalizer.Form.NFD);
+ final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");//$NON-NLS-1$
+ final String decomposed = Normalizer.normalize(input, Normalizer.Form.NFD);
// Note that this doesn't correctly remove ligatures...
return pattern.matcher(decomposed).replaceAll("");//$NON-NLS-1$
}
@@ -988,7 +988,7 @@ public class StringUtils {
if (startPos < 0) {
startPos = 0;
}
- int endLimit = str.length() - searchStr.length() + 1;
+ final int endLimit = str.length() - searchStr.length() + 1;
if (startPos > endLimit) {
return INDEX_NOT_FOUND;
}
@@ -1338,8 +1338,8 @@ public class StringUtils {
if (str == null || searchStr == null) {
return false;
}
- int len = searchStr.length();
- int max = str.length() - len;
+ final int len = searchStr.length();
+ final int max = str.length() - len;
for (int i = 0; i <= max; i++) {
if (CharSequenceUtils.regionMatches(str, true, i, searchStr, 0, len)) {
return true;
@@ -1361,7 +1361,7 @@ public class StringUtils {
if (isEmpty(seq)) {
return false;
}
- int strLen = seq.length();
+ final int strLen = seq.length();
for (int i = 0; i < strLen; i++) {
if (Character.isWhitespace(seq.charAt(i))) {
return true;
@@ -1399,12 +1399,12 @@ public class StringUtils {
if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
- int csLen = cs.length();
- int csLast = csLen - 1;
- int searchLen = searchChars.length;
- int searchLast = searchLen - 1;
+ final int csLen = cs.length();
+ final int csLast = csLen - 1;
+ final int searchLen = searchChars.length;
+ final int searchLast = searchLen - 1;
for (int i = 0; i < csLen; i++) {
- char ch = cs.charAt(i);
+ final char ch = cs.charAt(i);
for (int j = 0; j < searchLen; j++) {
if (searchChars[j] == ch) {
if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {
@@ -1481,12 +1481,12 @@ public class StringUtils {
if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
return false;
}
- int csLength = cs.length();
- int searchLength = searchChars.length;
- int csLast = csLength - 1;
- int searchLast = searchLength - 1;
+ final int csLength = cs.length();
+ final int searchLength = searchChars.length;
+ final int csLast = csLength - 1;
+ final int searchLast = searchLength - 1;
for (int i = 0; i < csLength; i++) {
- char ch = cs.charAt(i);
+ final char ch = cs.charAt(i);
for (int j = 0; j < searchLength; j++) {
if (searchChars[j] == ch) {
if (Character.isHighSurrogate(ch)) {
@@ -1572,13 +1572,13 @@ public class StringUtils {
if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
- int csLen = cs.length();
- int csLast = csLen - 1;
- int searchLen = searchChars.length;
- int searchLast = searchLen - 1;
+ final int csLen = cs.length();
+ final int csLast = csLen - 1;
+ final int searchLen = searchChars.length;
+ final int searchLast = searchLen - 1;
outer:
for (int i = 0; i < csLen; i++) {
- char ch = cs.charAt(i);
+ final char ch = cs.charAt(i);
for (int j = 0; j < searchLen; j++) {
if (searchChars[j] == ch) {
if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {
@@ -1622,12 +1622,12 @@ public class StringUtils {
if (isEmpty(seq) || isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
- int strLen = seq.length();
+ final int strLen = seq.length();
for (int i = 0; i < strLen; i++) {
- char ch = seq.charAt(i);
- boolean chFound = CharSequenceUtils.indexOf(searchChars, ch, 0) >= 0;
+ final char ch = seq.charAt(i);
+ final boolean chFound = CharSequenceUtils.indexOf(searchChars, ch, 0) >= 0;
if (i + 1 < strLen && Character.isHighSurrogate(ch)) {
- char ch2 = seq.charAt(i + 1);
+ final char ch2 = seq.charAt(i + 1);
if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0) {
return i;
}
@@ -1737,12 +1737,12 @@ public class StringUtils {
if (cs == null || searchChars == null) {
return true;
}
- int csLen = cs.length();
- int csLast = csLen - 1;
- int searchLen = searchChars.length;
- int searchLast = searchLen - 1;
+ final int csLen = cs.length();
+ final int csLast = csLen - 1;
+ final int searchLen = searchChars.length;
+ final int searchLast = searchLen - 1;
for (int i = 0; i < csLen; i++) {
- char ch = cs.charAt(i);
+ final char ch = cs.charAt(i);
for (int j = 0; j < searchLen; j++) {
if (searchChars[j] == ch) {
if (Character.isHighSurrogate(ch)) {
@@ -1826,14 +1826,14 @@ public class StringUtils {
if (str == null || searchStrs == null) {
return INDEX_NOT_FOUND;
}
- int sz = searchStrs.length;
+ final int sz = searchStrs.length;
// String's can't have a MAX_VALUEth index.
int ret = Integer.MAX_VALUE;
int tmp = 0;
for (int i = 0; i < sz; i++) {
- CharSequence search = searchStrs[i];
+ final CharSequence search = searchStrs[i];
if (search == null) {
continue;
}
@@ -1880,11 +1880,11 @@ public class StringUtils {
if (str == null || searchStrs == null) {
return INDEX_NOT_FOUND;
}
- int sz = searchStrs.length;
+ final int sz = searchStrs.length;
int ret = INDEX_NOT_FOUND;
int tmp = 0;
for (int i = 0; i < sz; i++) {
- CharSequence search = searchStrs[i];
+ final CharSequence search = searchStrs[i];
if (search == null) {
continue;
}
@@ -2155,7 +2155,7 @@ public class StringUtils {
if (separator.length() == 0) {
return EMPTY;
}
- int pos = str.indexOf(separator);
+ final int pos = str.indexOf(separator);
if (pos == INDEX_NOT_FOUND) {
return str;
}
@@ -2197,7 +2197,7 @@ public class StringUtils {
if (separator == null) {
return EMPTY;
}
- int pos = str.indexOf(separator);
+ final int pos = str.indexOf(separator);
if (pos == INDEX_NOT_FOUND) {
return EMPTY;
}
@@ -2235,7 +2235,7 @@ public class StringUtils {
if (isEmpty(str) || isEmpty(separator)) {
return str;
}
- int pos = str.lastIndexOf(separator);
+ final int pos = str.lastIndexOf(separator);
if (pos == INDEX_NOT_FOUND) {
return str;
}
@@ -2278,7 +2278,7 @@ public class StringUtils {
if (isEmpty(separator)) {
return EMPTY;
}
- int pos = str.lastIndexOf(separator);
+ final int pos = str.lastIndexOf(separator);
if (pos == INDEX_NOT_FOUND || pos == str.length() - separator.length()) {
return EMPTY;
}
@@ -2343,9 +2343,9 @@ public class StringUtils {
if (str == null || open == null || close == null) {
return null;
}
- int start = str.indexOf(open);
+ final int start = str.indexOf(open);
if (start != INDEX_NOT_FOUND) {
- int end = str.indexOf(close, start + open.length());
+ final int end = str.indexOf(close, start + open.length());
if (end != INDEX_NOT_FOUND) {
return str.substring(start + open.length(), end);
}
@@ -2379,13 +2379,13 @@ public class StringUtils {
if (str == null || isEmpty(open) || isEmpty(close)) {
return null;
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
- int closeLen = close.length();
- int openLen = open.length();
- List<String> list = new ArrayList<String>();
+ final int closeLen = close.length();
+ final int openLen = open.length();
+ final List<String> list = new ArrayList<String>();
int pos = 0;
while (pos < strLen - closeLen) {
int start = str.indexOf(open, pos);
@@ -2393,7 +2393,7 @@ public class StringUtils {
break;
}
start += openLen;
- int end = str.indexOf(close, start);
+ final int end = str.indexOf(close, start);
if (end < 0) {
break;
}
@@ -2668,7 +2668,7 @@ public class StringUtils {
return null;
}
- int len = str.length();
+ final int len = str.length();
if (len == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY;
@@ -2679,9 +2679,9 @@ public class StringUtils {
return splitWorker(str, null, max, preserveAllTokens);
}
- int separatorLength = separator.length();
+ final int separatorLength = separator.length();
- ArrayList<String> substrings = new ArrayList<String>();
+ final ArrayList<String> substrings = new ArrayList<String>();
int numberOfSubstrings = 0;
int beg = 0;
int end = 0;
@@ -2811,11 +2811,11 @@ public class StringUtils {
if (str == null) {
return null;
}
- int len = str.length();
+ final int len = str.length();
if (len == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
int i = 0, start = 0;
boolean match = false;
boolean lastMatch = false;
@@ -2938,11 +2938,11 @@ public class StringUtils {
if (str == null) {
return null;
}
- int len = str.length();
+ final int len = str.length();
if (len == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
int sizePlus1 = 1;
int i = 0, start = 0;
boolean match = false;
@@ -2969,7 +2969,7 @@ public class StringUtils {
}
} else if (separatorChars.length() == 1) {
// Optimise 1 character case
- char sep = separatorChars.charAt(0);
+ final char sep = separatorChars.charAt(0);
while (i < len) {
if (str.charAt(i) == sep) {
if (match || preserveAllTokens) {
@@ -3087,17 +3087,17 @@ public class StringUtils {
if (str.length() == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
- char[] c = str.toCharArray();
- List<String> list = new ArrayList<String>();
+ final char[] c = str.toCharArray();
+ final List<String> list = new ArrayList<String>();
int tokenStart = 0;
int currentType = Character.getType(c[tokenStart]);
for (int pos = tokenStart + 1; pos < c.length; pos++) {
- int type = Character.getType(c[pos]);
+ final int type = Character.getType(c[pos]);
if (type == currentType) {
continue;
}
if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) {
- int newTokenStart = pos - 1;
+ final int newTokenStart = pos - 1;
if (newTokenStart != tokenStart) {
list.add(new String(c, tokenStart, newTokenStart - tokenStart));
tokenStart = newTokenStart;
@@ -3424,11 +3424,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3475,11 +3475,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3524,11 +3524,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3573,11 +3573,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3622,11 +3622,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3671,11 +3671,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3720,11 +3720,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3769,11 +3769,11 @@ public class StringUtils {
if (array == null) {
return null;
}
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
buf.append(separator);
@@ -3859,12 +3859,12 @@ public class StringUtils {
// endIndex - startIndex > 0: Len = NofStrings *(len(firstString) + len(separator))
// (Assuming that all Strings are roughly equally long)
- int noOfItems = endIndex - startIndex;
+ final int noOfItems = endIndex - startIndex;
if (noOfItems <= 0) {
return EMPTY;
}
- StringBuilder buf = new StringBuilder(noOfItems * 16);
+ final StringBuilder buf = new StringBuilder(noOfItems * 16);
for (int i = startIndex; i < endIndex; i++) {
if (i > startIndex) {
@@ -3900,20 +3900,20 @@ public class StringUtils {
if (!iterator.hasNext()) {
return EMPTY;
}
- Object first = iterator.next();
+ final Object first = iterator.next();
if (!iterator.hasNext()) {
return ObjectUtils.toString(first);
}
// two or more elements
- StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
+ final StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
if (first != null) {
buf.append(first);
}
while (iterator.hasNext()) {
buf.append(separator);
- Object obj = iterator.next();
+ final Object obj = iterator.next();
if (obj != null) {
buf.append(obj);
}
@@ -3944,13 +3944,13 @@ public class StringUtils {
if (!iterator.hasNext()) {
return EMPTY;
}
- Object first = iterator.next();
+ final Object first = iterator.next();
if (!iterator.hasNext()) {
return ObjectUtils.toString(first);
}
// two or more elements
- StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
+ final StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
if (first != null) {
buf.append(first);
}
@@ -3959,7 +3959,7 @@ public class StringUtils {
if (separator != null) {
buf.append(separator);
}
- Object obj = iterator.next();
+ final Object obj = iterator.next();
if (obj != null) {
buf.append(obj);
}
@@ -4029,8 +4029,8 @@ public class StringUtils {
if (isEmpty(str)) {
return str;
}
- int sz = str.length();
- char[] chs = new char[sz];
+ final int sz = str.length();
+ final char[] chs = new char[sz];
int count = 0;
for (int i = 0; i < sz; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
@@ -4237,7 +4237,7 @@ public class StringUtils {
if (isEmpty(str) || str.indexOf(remove) == INDEX_NOT_FOUND) {
return str;
}
- char[] chars = str.toCharArray();
+ final char[] chars = str.toCharArray();
int pos = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] != remove) {
@@ -4380,11 +4380,11 @@ public class StringUtils {
if (end == INDEX_NOT_FOUND) {
return text;
}
- int replLength = searchString.length();
+ final int replLength = searchString.length();
int increase = replacement.length() - replLength;
increase = increase < 0 ? 0 : increase;
increase *= max < 0 ? 16 : max > 64 ? 64 : max;
- StringBuilder buf = new StringBuilder(text.length() + increase);
+ final StringBuilder buf = new StringBuilder(text.length() + increase);
while (end != INDEX_NOT_FOUND) {
buf.append(text.substring(start, end)).append(replacement);
start = end + replLength;
@@ -4487,7 +4487,7 @@ public class StringUtils {
public static String replaceEachRepeatedly(final String text, final String[] searchList, final String[] replacementList) {
// timeToLive should be 0 if not used or nothing to replace, else it's
// the length of the replace array
- int timeToLive = searchList == null ? 0 : searchList.length;
+ final int timeToLive = searchList == null ? 0 : searchList.length;
return replaceEach(text, searchList, replacementList, true, timeToLive);
}
@@ -4556,8 +4556,8 @@ public class StringUtils {
"output of one loop is the input of another");
}
- int searchLength = searchList.length;
- int replacementLength = replacementList.length;
+ final int searchLength = searchList.length;
+ final int replacementLength = replacementList.length;
// make sure lengths are ok, these need to be equal
if (searchLength != replacementLength) {
@@ -4568,7 +4568,7 @@ public class StringUtils {
}
// keep track of which still have matches
- boolean[] noMoreMatchesForReplIndex = new boolean[searchLength];
+ final boolean[] noMoreMatchesForReplIndex = new boolean[searchLength];
// index on index that the match was found
int textIndex = -1;
@@ -4611,7 +4611,7 @@ public class StringUtils {
if (searchList[i] == null || replacementList[i] == null) {
continue;
}
- int greater = replacementList[i].length() - searchList[i].length();
+ final int greater = replacementList[i].length() - searchList[i].length();
if (greater > 0) {
increase += 3 * greater; // assume 3 matches
}
@@ -4619,7 +4619,7 @@ public class StringUtils {
// have upper-bound at 20% increase, then let Java take over
increase = Math.min(increase, text.length() / 5);
- StringBuilder buf = new StringBuilder(text.length() + increase);
+ final StringBuilder buf = new StringBuilder(text.length() + increase);
while (textIndex != -1) {
@@ -4655,11 +4655,11 @@ public class StringUtils {
// NOTE: logic duplicated above END
}
- int textLength = text.length();
+ final int textLength = text.length();
for (int i = start; i < textLength; i++) {
buf.append(text.charAt(i));
}
- String result = buf.toString();
+ final String result = buf.toString();
if (!repeat) {
return result;
}
@@ -4740,12 +4740,12 @@ public class StringUtils {
replaceChars = EMPTY;
}
boolean modified = false;
- int replaceCharsLength = replaceChars.length();
- int strLength = str.length();
- StringBuilder buf = new StringBuilder(strLength);
+ final int replaceCharsLength = replaceChars.length();
+ final int strLength = str.length();
+ final StringBuilder buf = new StringBuilder(strLength);
for (int i = 0; i < strLength; i++) {
- char ch = str.charAt(i);
- int index = searchChars.indexOf(ch);
+ final char ch = str.charAt(i);
+ final int index = searchChars.indexOf(ch);
if (index >= 0) {
modified = true;
if (index < replaceCharsLength) {
@@ -4799,7 +4799,7 @@ public class StringUtils {
if (overlay == null) {
overlay = EMPTY;
}
- int len = str.length();
+ final int len = str.length();
if (start < 0) {
start = 0;
}
@@ -4813,7 +4813,7 @@ public class StringUtils {
end = len;
}
if (start > end) {
- int temp = start;
+ final int temp = start;
start = end;
end = temp;
}
@@ -4857,7 +4857,7 @@ public class StringUtils {
}
if (str.length() == 1) {
- char ch = str.charAt(0);
+ final char ch = str.charAt(0);
if (ch == CharUtils.CR || ch == CharUtils.LF) {
return EMPTY;
}
@@ -4865,7 +4865,7 @@ public class StringUtils {
}
int lastIdx = str.length() - 1;
- char last = str.charAt(lastIdx);
+ final char last = str.charAt(lastIdx);
if (last == CharUtils.LF) {
if (str.charAt(lastIdx - 1) == CharUtils.CR) {
@@ -4938,13 +4938,13 @@ public class StringUtils {
if (str == null) {
return null;
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen < 2) {
return EMPTY;
}
- int lastIdx = strLen - 1;
- String ret = str.substring(0, lastIdx);
- char last = str.charAt(lastIdx);
+ final int lastIdx = strLen - 1;
+ final String ret = str.substring(0, lastIdx);
+ final char last = str.charAt(lastIdx);
if (last == CharUtils.LF && ret.charAt(lastIdx - 1) == CharUtils.CR) {
return ret.substring(0, lastIdx - 1);
}
@@ -4983,7 +4983,7 @@ public class StringUtils {
if (repeat <= 0) {
return EMPTY;
}
- int inputLength = str.length();
+ final int inputLength = str.length();
if (repeat == 1 || inputLength == 0) {
return str;
}
@@ -4991,21 +4991,21 @@ public class StringUtils {
return repeat(str.charAt(0), repeat);
}
- int outputLength = inputLength * repeat;
+ final int outputLength = inputLength * repeat;
switch (inputLength) {
case 1 :
return repeat(str.charAt(0), repeat);
case 2 :
- char ch0 = str.charAt(0);
- char ch1 = str.charAt(1);
- char[] output2 = new char[outputLength];
+ final char ch0 = str.charAt(0);
+ final char ch1 = str.charAt(1);
+ final char[] output2 = new char[outputLength];
for (int i = repeat * 2 - 2; i >= 0; i--, i--) {
output2[i] = ch0;
output2[i + 1] = ch1;
}
return new String(output2);
default :
- StringBuilder buf = new StringBuilder(outputLength);
+ final StringBuilder buf = new StringBuilder(outputLength);
for (int i = 0; i < repeat; i++) {
buf.append(str);
}
@@ -5038,7 +5038,7 @@ public class StringUtils {
return repeat(str, repeat);
} else {
// given that repeat(String, int) is quite optimized, better to rely on it than try and splice this into it
- String result = repeat(str + separator, repeat);
+ final String result = repeat(str + separator, repeat);
return removeEnd(result, separator);
}
}
@@ -5066,7 +5066,7 @@ public class StringUtils {
* @see #repeat(String, int)
*/
public static String repeat(final char ch, final int repeat) {
- char[] buf = new char[repeat];
+ final char[] buf = new char[repeat];
for (int i = repeat - 1; i >= 0; i--) {
buf[i] = ch;
}
@@ -5121,7 +5121,7 @@ public class StringUtils {
if (str == null) {
return null;
}
- int pads = size - str.length();
+ final int pads = size - str.length();
if (pads <= 0) {
return str; // returns original String when possible
}
@@ -5161,9 +5161,9 @@ public class StringUtils {
if (isEmpty(padStr)) {
padStr = SPACE;
}
- int padLen = padStr.length();
- int strLen = str.length();
- int pads = size - strLen;
+ final int padLen = padStr.length();
+ final int strLen = str.length();
+ final int pads = size - strLen;
if (pads <= 0) {
return str; // returns original String when possible
}
@@ -5176,8 +5176,8 @@ public class StringUtils {
} else if (pads < padLen) {
return str.concat(padStr.substring(0, pads));
} else {
- char[] padding = new char[pads];
- char[] padChars = padStr.toCharArray();
+ final char[] padding = new char[pads];
+ final char[] padChars = padStr.toCharArray();
for (int i = 0; i < pads; i++) {
padding[i] = padChars[i % padLen];
}
@@ -5233,7 +5233,7 @@ public class StringUtils {
if (str == null) {
return null;
}
- int pads = size - str.length();
+ final int pads = size - str.length();
if (pads <= 0) {
return str; // returns original String when possible
}
@@ -5273,9 +5273,9 @@ public class StringUtils {
if (isEmpty(padStr)) {
padStr = SPACE;
}
- int padLen = padStr.length();
- int strLen = str.length();
- int pads = size - strLen;
+ final int padLen = padStr.length();
+ final int strLen = str.length();
+ final int pads = size - strLen;
if (pads <= 0) {
return str; // returns original String when possible
}
@@ -5288,8 +5288,8 @@ public class StringUtils {
} else if (pads < padLen) {
return padStr.substring(0, pads).concat(str);
} else {
- char[] padding = new char[pads];
- char[] padChars = padStr.toCharArray();
+ final char[] padding = new char[pads];
+ final char[] padChars = padStr.toCharArray();
for (int i = 0; i < pads; i++) {
padding[i] = padChars[i % padLen];
}
@@ -5369,8 +5369,8 @@ public class StringUtils {
if (str == null || size <= 0) {
return str;
}
- int strLen = str.length();
- int pads = size - strLen;
+ final int strLen = str.length();
+ final int pads = size - strLen;
if (pads <= 0) {
return str;
}
@@ -5412,8 +5412,8 @@ public class StringUtils {
if (isEmpty(padStr)) {
padStr = SPACE;
}
- int strLen = str.length();
- int pads = size - strLen;
+ final int strLen = str.length();
+ final int pads = size - strLen;
if (pads <= 0) {
return str;
}
@@ -5616,10 +5616,10 @@ public class StringUtils {
return str;
}
- char[] buffer = str.toCharArray();
+ final char[] buffer = str.toCharArray();
for (int i = 0; i < buffer.length; i++) {
- char ch = buffer[i];
+ final char ch = buffer[i];
if (Character.isUpperCase(ch)) {
buffer[i] = Character.toLowerCase(ch);
} else if (Character.isTitleCase(ch)) {
@@ -5692,7 +5692,7 @@ public class StringUtils {
if (cs == null || cs.length() == 0) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isLetter(cs.charAt(i)) == false) {
return false;
@@ -5727,7 +5727,7 @@ public class StringUtils {
if (cs == null) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isLetter(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
return false;
@@ -5762,7 +5762,7 @@ public class StringUtils {
if (cs == null || cs.length() == 0) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isLetterOrDigit(cs.charAt(i)) == false) {
return false;
@@ -5797,7 +5797,7 @@ public class StringUtils {
if (cs == null) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isLetterOrDigit(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
return false;
@@ -5836,7 +5836,7 @@ public class StringUtils {
if (cs == null) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (CharUtils.isAsciiPrintable(cs.charAt(i)) == false) {
return false;
@@ -5879,7 +5879,7 @@ public class StringUtils {
if (cs == null || cs.length() == 0) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isDigit(cs.charAt(i)) == false) {
return false;
@@ -5916,7 +5916,7 @@ public class StringUtils {
if (cs == null) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isDigit(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
return false;
@@ -5949,7 +5949,7 @@ public class StringUtils {
if (cs == null) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isWhitespace(cs.charAt(i)) == false) {
return false;
@@ -5981,7 +5981,7 @@ public class StringUtils {
if (cs == null || isEmpty(cs)) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isLowerCase(cs.charAt(i)) == false) {
return false;
@@ -6013,7 +6013,7 @@ public class StringUtils {
if (cs == null || isEmpty(cs)) {
return false;
}
- int sz = cs.length();
+ final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (Character.isUpperCase(cs.charAt(i)) == false) {
return false;
@@ -6157,7 +6157,7 @@ public class StringUtils {
}
// could implement manually, but simple way is to reuse other,
// probably slower, methods.
- String[] strs = split(str, separatorChar);
+ final String[] strs = split(str, separatorChar);
ArrayUtils.reverse(strs);
return join(strs, separatorChar);
}
@@ -6302,11 +6302,11 @@ public class StringUtils {
return str;
}
- int targetSting = length-middle.length();
- int startOffset = targetSting/2+targetSting%2;
- int endOffset = str.length()-targetSting/2;
+ final int targetSting = length-middle.length();
+ final int startOffset = targetSting/2+targetSting%2;
+ final int endOffset = str.length()-targetSting/2;
- StringBuilder builder = new StringBuilder(length);
+ final StringBuilder builder = new StringBuilder(length);
builder.append(str.substring(0,startOffset));
builder.append(middle);
builder.append(str.substring(endOffset));
@@ -6348,7 +6348,7 @@ public class StringUtils {
if (str2 == null) {
return str1;
}
- int at = indexOfDifference(str1, str2);
+ final int at = indexOfDifference(str1, str2);
if (at == INDEX_NOT_FOUND) {
return EMPTY;
}
@@ -6437,7 +6437,7 @@ public class StringUtils {
}
boolean anyStringNull = false;
boolean allStringsNull = true;
- int arrayLen = css.length;
+ final int arrayLen = css.length;
int shortestStrLen = Integer.MAX_VALUE;
int longestStrLen = 0;
@@ -6468,7 +6468,7 @@ public class StringUtils {
// find the position with the first difference across all strings
int firstDiff = -1;
for (int stringPos = 0; stringPos < shortestStrLen; stringPos++) {
- char comparisonChar = css[0].charAt(stringPos);
+ final char comparisonChar = css[0].charAt(stringPos);
for (int arrayPos = 1; arrayPos < arrayLen; arrayPos++) {
if (css[arrayPos].charAt(stringPos) != comparisonChar) {
firstDiff = stringPos;
@@ -6526,7 +6526,7 @@ public class StringUtils {
if (strs == null || strs.length == 0) {
return EMPTY;
}
- int smallestIndexOfDiff = indexOfDifference(strs);
+ final int smallestIndexOfDiff = indexOfDifference(strs);
if (smallestIndexOfDiff == INDEX_NOT_FOUND) {
// all strings were identical
if (strs[0] == null) {
@@ -6613,7 +6613,7 @@ public class StringUtils {
if (n > m) {
// swap the input strings to consume less memory
- CharSequence tmp = s;
+ final CharSequence tmp = s;
s = t;
t = tmp;
n = m;
@@ -6753,7 +6753,7 @@ public class StringUtils {
if (n > m) {
// swap the two strings to consume less memory
- CharSequence tmp = s;
+ final CharSequence tmp = s;
s = t;
t = tmp;
n = m;
@@ -6765,7 +6765,7 @@ public class StringUtils {
int _d[]; // placeholder to assist in swapping p and d
// fill in starting table values
- int boundary = Math.min(n, threshold) + 1;
+ final int boundary = Math.min(n, threshold) + 1;
for (int i = 0; i < boundary; i++) {
p[i] = i;
}
@@ -6776,12 +6776,12 @@ public class StringUtils {
// iterates through t
for (int j = 1; j <= m; j++) {
- char t_j = t.charAt(j - 1); // jth character of t
+ final char t_j = t.charAt(j - 1); // jth character of t
d[0] = j;
// compute stripe indices, constrain to array size
- int min = Math.max(1, j - threshold);
- int max = Math.min(n, j + threshold);
+ final int min = Math.max(1, j - threshold);
+ final int max = Math.min(n, j + threshold);
// the stripe may lead off of the table if s and t are of different sizes
if (min > max) {
@@ -6918,7 +6918,7 @@ public class StringUtils {
if (isEmpty(string) || ArrayUtils.isEmpty(searchStrings)) {
return false;
}
- for (CharSequence searchString : searchStrings) {
+ for (final CharSequence searchString : searchStrings) {
if (StringUtils.startsWith(string, searchString)) {
return true;
}
@@ -7001,7 +7001,7 @@ public class StringUtils {
if (suffix.length() > str.length()) {
return false;
}
- int strOffset = str.length() - suffix.length();
+ final int strOffset = str.length() - suffix.length();
return CharSequenceUtils.regionMatches(str, ignoreCase, strOffset, suffix, 0, suffix.length());
}
@@ -7075,7 +7075,7 @@ public class StringUtils {
if (isEmpty(string) || ArrayUtils.isEmpty(searchStrings)) {
return false;
}
- for (CharSequence searchString : searchStrings) {
+ for (final CharSequence searchString : searchStrings) {
if (StringUtils.endsWith(string, searchString)) {
return true;
}
diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java
index 62f83c2d8..97dbb3222 100644
--- a/src/main/java/org/apache/commons/lang3/SystemUtils.java
+++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java
@@ -1319,7 +1319,7 @@ public class SystemUtils {
private static String getSystemProperty(final String property) {
try {
return System.getProperty(property);
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
// we are not allowed to look at this property
System.err.println("Caught a SecurityException reading the system property '" + property
+ "'; the SystemUtils property value will default to null.");
diff --git a/src/main/java/org/apache/commons/lang3/Validate.java b/src/main/java/org/apache/commons/lang3/Validate.java
index fd6eeff25..a791e523a 100644
--- a/src/main/java/org/apache/commons/lang3/Validate.java
+++ b/src/main/java/org/apache/commons/lang3/Validate.java
@@ -506,7 +506,7 @@ public class Validate {
Validate.notNull(array);
for (int i = 0; i < array.length; i++) {
if (array[i] == null) {
- Object[] values2 = ArrayUtils.add(values, Integer.valueOf(i));
+ final Object[] values2 = ArrayUtils.add(values, Integer.valueOf(i));
throw new IllegalArgumentException(String.format(message, values2));
}
}
@@ -567,9 +567,9 @@ public class Validate {
public static <T extends Iterable<?>> T noNullElements(final T iterable, final String message, final Object... values) {
Validate.notNull(iterable);
int i = 0;
- for (Iterator<?> it = iterable.iterator(); it.hasNext(); i++) {
+ for (final Iterator<?> it = iterable.iterator(); it.hasNext(); i++) {
if (it.next() == null) {
- Object[] values2 = ArrayUtils.addAll(values, Integer.valueOf(i));
+ final Object[] values2 = ArrayUtils.addAll(values, Integer.valueOf(i));
throw new IllegalArgumentException(String.format(message, values2));
}
}
diff --git a/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java b/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
index 76d7b2845..8182fa6a4 100644
--- a/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
@@ -282,7 +282,7 @@ public class CompareToBuilder implements Builder<Integer> {
if (!lhsClazz.isInstance(rhs)) {
throw new ClassCastException();
}
- CompareToBuilder compareToBuilder = new CompareToBuilder();
+ final CompareToBuilder compareToBuilder = new CompareToBuilder();
reflectionAppend(lhs, rhs, lhsClazz, compareToBuilder, compareTransients, excludeFields);
while (lhsClazz.getSuperclass() != null && lhsClazz != reflectUpToClass) {
lhsClazz = lhsClazz.getSuperclass();
@@ -310,17 +310,17 @@ public class CompareToBuilder implements Builder<Integer> {
final boolean useTransients,
final String[] excludeFields) {
- Field[] fields = clazz.getDeclaredFields();
+ final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
- Field f = fields[i];
+ final Field f = fields[i];
if (!ArrayUtils.contains(excludeFields, f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// This can't happen. Would get a Security exception instead.
// Throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
diff --git a/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java b/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
index 933c2dbdc..81d7a7fba 100644
--- a/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
@@ -132,8 +132,8 @@ public class EqualsBuilder implements Builder<Boolean> {
* @return the pair
*/
static Pair<IDKey, IDKey> getRegisterPair(final Object lhs, final Object rhs) {
- IDKey left = new IDKey(lhs);
- IDKey right = new IDKey(rhs);
+ final IDKey left = new IDKey(lhs);
+ final IDKey right = new IDKey(rhs);
return Pair.of(left, right);
}
@@ -151,9 +151,9 @@ public class EqualsBuilder implements Builder<Boolean> {
* @since 3.0
*/
static boolean isRegistered(final Object lhs, final Object rhs) {
- Set<Pair<IDKey, IDKey>> registry = getRegistry();
- Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
- Pair<IDKey, IDKey> swappedPair = Pair.of(pair.getLeft(), pair.getRight());
+ final Set<Pair<IDKey, IDKey>> registry = getRegistry();
+ final Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
+ final Pair<IDKey, IDKey> swappedPair = Pair.of(pair.getLeft(), pair.getRight());
return registry != null
&& (registry.contains(pair) || registry.contains(swappedPair));
@@ -175,8 +175,8 @@ public class EqualsBuilder implements Builder<Boolean> {
}
}
- Set<Pair<IDKey, IDKey>> registry = getRegistry();
- Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
+ final Set<Pair<IDKey, IDKey>> registry = getRegistry();
+ final Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
registry.add(pair);
}
@@ -195,7 +195,7 @@ public class EqualsBuilder implements Builder<Boolean> {
static void unregister(final Object lhs, final Object rhs) {
Set<Pair<IDKey, IDKey>> registry = getRegistry();
if (registry != null) {
- Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
+ final Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
registry.remove(pair);
synchronized (EqualsBuilder.class) {
//read again
@@ -333,8 +333,8 @@ public class EqualsBuilder implements Builder<Boolean> {
// class or in classes between the leaf and root.
// If we are not testing transients or a subclass has no ivars,
// then a subclass can test equals to a superclass.
- Class<?> lhsClass = lhs.getClass();
- Class<?> rhsClass = rhs.getClass();
+ final Class<?> lhsClass = lhs.getClass();
+ final Class<?> rhsClass = rhs.getClass();
Class<?> testClass;
if (lhsClass.isInstance(rhs)) {
testClass = lhsClass;
@@ -352,14 +352,14 @@ public class EqualsBuilder implements Builder<Boolean> {
// The two classes are not related.
return false;
}
- EqualsBuilder equalsBuilder = new EqualsBuilder();
+ final EqualsBuilder equalsBuilder = new EqualsBuilder();
try {
reflectionAppend(lhs, rhs, testClass, equalsBuilder, testTransients, excludeFields);
while (testClass.getSuperclass() != null && testClass != reflectUpToClass) {
testClass = testClass.getSuperclass();
reflectionAppend(lhs, rhs, testClass, equalsBuilder, testTransients, excludeFields);
}
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// In this case, we tried to test a subclass vs. a superclass and
// the subclass has ivars or the ivars are transient and
// we are testing transients.
@@ -395,17 +395,17 @@ public class EqualsBuilder implements Builder<Boolean> {
try {
register(lhs, rhs);
- Field[] fields = clazz.getDeclaredFields();
+ final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.isEquals; i++) {
- Field f = fields[i];
+ final Field f = fields[i];
if (!ArrayUtils.contains(excludeFields, f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
//this can't happen. Would get a Security exception instead
//throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
@@ -455,7 +455,7 @@ public class EqualsBuilder implements Builder<Boolean> {
this.setEquals(false);
return this;
}
- Class<?> lhsClass = lhs.getClass();
+ final Class<?> lhsClass = lhs.getClass();
if (!lhsClass.isArray()) {
// The simple case, not an array, just test the element
isEquals = lhs.equals(rhs);
diff --git a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
index 2728e8495..851177623 100644
--- a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
@@ -148,7 +148,7 @@ public class HashCodeBuilder implements Builder<Integer> {
* @since 2.3
*/
static boolean isRegistered(final Object value) {
- Set<IDKey> registry = getRegistry();
+ final Set<IDKey> registry = getRegistry();
return registry != null && registry.contains(new IDKey(value));
}
@@ -175,17 +175,17 @@ public class HashCodeBuilder implements Builder<Integer> {
}
try {
register(object);
- Field[] fields = clazz.getDeclaredFields();
+ final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
- for (Field field : fields) {
+ for (final Field field : fields) {
if (!ArrayUtils.contains(excludeFields, field.getName())
&& (field.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(field.getModifiers()))
&& (!Modifier.isStatic(field.getModifiers()))) {
try {
- Object fieldValue = field.get(object);
+ final Object fieldValue = field.get(object);
builder.append(fieldValue);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// this can't happen. Would get a Security exception instead
// throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
@@ -335,7 +335,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (object == null) {
throw new IllegalArgumentException("The object to build a hash code for must not be null");
}
- HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
+ final HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
Class<?> clazz = object.getClass();
reflectionAppend(object, clazz, builder, testTransients, excludeFields);
while (clazz.getSuperclass() != null && clazz != reflectUpToClass) {
@@ -591,7 +591,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (boolean element : array) {
+ for (final boolean element : array) {
append(element);
}
}
@@ -629,7 +629,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (byte element : array) {
+ for (final byte element : array) {
append(element);
}
}
@@ -663,7 +663,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (char element : array) {
+ for (final char element : array) {
append(element);
}
}
@@ -696,7 +696,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (double element : array) {
+ for (final double element : array) {
append(element);
}
}
@@ -730,7 +730,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (float element : array) {
+ for (final float element : array) {
append(element);
}
}
@@ -764,7 +764,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (int element : array) {
+ for (final int element : array) {
append(element);
}
}
@@ -802,7 +802,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (long element : array) {
+ for (final long element : array) {
append(element);
}
}
@@ -866,7 +866,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (Object element : array) {
+ for (final Object element : array) {
append(element);
}
}
@@ -900,7 +900,7 @@ public class HashCodeBuilder implements Builder<Integer> {
if (array == null) {
iTotal = iTotal * iConstant;
} else {
- for (short element : array) {
+ for (final short element : array) {
append(element);
}
}
diff --git a/src/main/java/org/apache/commons/lang3/builder/IDKey.java b/src/main/java/org/apache/commons/lang3/builder/IDKey.java
index 1dca416ca..4f209196c 100644
--- a/src/main/java/org/apache/commons/lang3/builder/IDKey.java
+++ b/src/main/java/org/apache/commons/lang3/builder/IDKey.java
@@ -64,7 +64,7 @@ final class IDKey {
if (!(other instanceof IDKey)) {
return false;
}
- IDKey idKey = (IDKey) other;
+ final IDKey idKey = (IDKey) other;
if (id != idKey.id) {
return false;
}
diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
index 3225ee432..b7847a83d 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -322,8 +322,8 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* @return The given array or a new array without null.
*/
static String[] toNoNullStringArray(final Object[] array) {
- List<String> list = new ArrayList<String>(array.length);
- for (Object e : array) {
+ final List<String> list = new ArrayList<String>(array.length);
+ for (final Object e : array) {
if (e != null) {
list.add(e.toString());
}
@@ -510,17 +510,17 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
this.reflectionAppendArray(this.getObject());
return;
}
- Field[] fields = clazz.getDeclaredFields();
+ final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
- for (Field field : fields) {
- String fieldName = field.getName();
+ for (final Field field : fields) {
+ final String fieldName = field.getName();
if (this.accept(field)) {
try {
// Warning: Field.get(Object) creates wrappers objects
// for primitive types.
- Object fieldValue = this.getValue(field);
+ final Object fieldValue = this.getValue(field);
this.append(fieldName, fieldValue);
- } catch (IllegalAccessException ex) {
+ } catch (final IllegalAccessException ex) {
//this can't happen. Would get a Security exception
// instead
//throw a runtime exception in case the impossible
@@ -659,7 +659,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
*/
public void setUpToClass(final Class<?> clazz) {
if (clazz != null) {
- Object object = getObject();
+ final Object object = getObject();
if (object != null && clazz.isInstance(object) == false) {
throw new IllegalArgumentException("Specified class is not a superclass of the object");
}
diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
index b45a21730..f41a3eaaa 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
@@ -169,7 +169,7 @@ public abstract class ToStringStyle implements Serializable {
* object.
*/
static boolean isRegistered(final Object value) {
- Map<Object, Object> m = getRegistry();
+ final Map<Object, Object> m = getRegistry();
return m != null && m.containsKey(value);
}
@@ -184,7 +184,7 @@ public abstract class ToStringStyle implements Serializable {
*/
static void register(final Object value) {
if (value != null) {
- Map<Object, Object> m = getRegistry();
+ final Map<Object, Object> m = getRegistry();
if (m == null) {
REGISTRY.set(new WeakHashMap<Object, Object>());
}
@@ -206,7 +206,7 @@ public abstract class ToStringStyle implements Serializable {
*/
static void unregister(final Object value) {
if (value != null) {
- Map<Object, Object> m = getRegistry();
+ final Map<Object, Object> m = getRegistry();
if (m != null) {
m.remove(value);
if (m.isEmpty()) {
@@ -354,10 +354,10 @@ public abstract class ToStringStyle implements Serializable {
*/
public void appendToString(final StringBuffer buffer, final String toString) {
if (toString != null) {
- int pos1 = toString.indexOf(contentStart) + contentStart.length();
- int pos2 = toString.lastIndexOf(contentEnd);
+ final int pos1 = toString.indexOf(contentStart) + contentStart.length();
+ final int pos2 = toString.lastIndexOf(contentEnd);
if (pos1 != pos2 && pos1 >= 0 && pos2 >= 0) {
- String data = toString.substring(pos1, pos2);
+ final String data = toString.substring(pos1, pos2);
if (fieldSeparatorAtStart) {
removeLastFieldSeparator(buffer);
}
@@ -406,8 +406,8 @@ public abstract class ToStringStyle implements Serializable {
* @since 2.0
*/
protected void removeLastFieldSeparator(final StringBuffer buffer) {
- int len = buffer.length();
- int sepLen = fieldSeparator.length();
+ final int len = buffer.length();
+ final int sepLen = fieldSeparator.length();
if (len > 0 && sepLen > 0 && len >= sepLen) {
boolean match = true;
for (int i = 0; i < sepLen; i++) {
@@ -898,7 +898,7 @@ public abstract class ToStringStyle implements Serializable {
protected void appendDetail(final StringBuffer buffer, final String fieldName, final Object[] array) {
buffer.append(arrayStart);
for (int i = 0; i < array.length; i++) {
- Object item = array[i];
+ final Object item = array[i];
if (i > 0) {
buffer.append(arraySeparator);
}
@@ -923,9 +923,9 @@ public abstract class ToStringStyle implements Serializable {
*/
protected void reflectionAppendArrayDetail(final StringBuffer buffer, final String fieldName, final Object array) {
buffer.append(arrayStart);
- int length = Array.getLength(array);
+ final int length = Array.getLength(array);
for (int i = 0; i < length; i++) {
- Object item = Array.get(array, i);
+ final Object item = Array.get(array, i);
if (i > 0) {
buffer.append(arraySeparator);
}
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java
index 489873f87..305aa55ec 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java
@@ -210,10 +210,10 @@ public abstract class BackgroundInitializer<T> implements
public T get() throws ConcurrentException {
try {
return getFuture().get();
- } catch (ExecutionException execex) {
+ } catch (final ExecutionException execex) {
ConcurrentUtils.handleCause(execex);
return null; // should not be reached
- } catch (InterruptedException iex) {
+ } catch (final InterruptedException iex) {
// reset interrupted state
Thread.currentThread().interrupt();
throw new ConcurrentException(iex);
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java b/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
index e4785cf49..818f5d129 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
@@ -202,7 +202,7 @@ public class BasicThreadFactory implements ThreadFactory {
*/
@Override
public Thread newThread(final Runnable r) {
- Thread t = getWrappedFactory().newThread(r);
+ final Thread t = getWrappedFactory().newThread(r);
initializeThread(t);
return t;
@@ -219,7 +219,7 @@ public class BasicThreadFactory implements ThreadFactory {
private void initializeThread(final Thread t) {
if (getNamingPattern() != null) {
- Long count = Long.valueOf(threadCounter.incrementAndGet());
+ final Long count = Long.valueOf(threadCounter.incrementAndGet());
t.setName(String.format(getNamingPattern(), count));
}
@@ -375,7 +375,7 @@ public class BasicThreadFactory implements ThreadFactory {
*/
@Override
public BasicThreadFactory build() {
- BasicThreadFactory factory = new BasicThreadFactory(this);
+ final BasicThreadFactory factory = new BasicThreadFactory(this);
reset();
return factory;
}
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java b/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
index 290a01b25..1bc080a0e 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
@@ -103,7 +103,7 @@ public class ConcurrentUtils {
*/
public static void handleCause(final ExecutionException ex)
throws ConcurrentException {
- ConcurrentException cex = extractCause(ex);
+ final ConcurrentException cex = extractCause(ex);
if (cex != null) {
throw cex;
@@ -124,7 +124,7 @@ public class ConcurrentUtils {
* wrapped in the thrown runtime exception
*/
public static void handleCauseUnchecked(final ExecutionException ex) {
- ConcurrentRuntimeException crex = extractCauseUnchecked(ex);
+ final ConcurrentRuntimeException crex = extractCauseUnchecked(ex);
if (crex != null) {
throw crex;
@@ -200,7 +200,7 @@ public class ConcurrentUtils {
public static <T> T initializeUnchecked(final ConcurrentInitializer<T> initializer) {
try {
return initialize(initializer);
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
throw new ConcurrentRuntimeException(cex.getCause());
}
}
@@ -243,7 +243,7 @@ public class ConcurrentUtils {
return null;
}
- V result = map.putIfAbsent(key, value);
+ final V result = map.putIfAbsent(key, value);
return result != null ? result : value;
}
@@ -273,7 +273,7 @@ public class ConcurrentUtils {
return null;
}
- V value = map.get(key);
+ final V value = map.get(key);
if (value == null) {
return putIfAbsent(map, key, init.get());
}
@@ -299,7 +299,7 @@ public class ConcurrentUtils {
final K key, final ConcurrentInitializer<V> init) {
try {
return createIfAbsent(map, key, init);
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
throw new ConcurrentRuntimeException(cex.getCause());
}
}
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java
index 255ca8229..62a715eb9 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java
@@ -110,7 +110,7 @@ public class ConstantInitializer<T> implements ConcurrentInitializer<T> {
return false;
}
- ConstantInitializer<?> c = (ConstantInitializer<?>) obj;
+ final ConstantInitializer<?> c = (ConstantInitializer<?>) obj;
return ObjectUtils.equals(getObject(), c.getObject());
}
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
index 71f491fe6..86baaefdb 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
@@ -164,7 +164,7 @@ public class MultiBackgroundInitializer
protected int getTaskCount() {
int result = 1;
- for (BackgroundInitializer<?> bi : childInitializers.values()) {
+ for (final BackgroundInitializer<?> bi : childInitializers.values()) {
result += bi.getTaskCount();
}
@@ -191,8 +191,8 @@ public class MultiBackgroundInitializer
}
// start the child initializers
- ExecutorService exec = getActiveExecutor();
- for (BackgroundInitializer<?> bi : inits.values()) {
+ final ExecutorService exec = getActiveExecutor();
+ for (final BackgroundInitializer<?> bi : inits.values()) {
if (bi.getExternalExecutor() == null) {
// share the executor service if necessary
bi.setExternalExecutor(exec);
@@ -201,12 +201,12 @@ public class MultiBackgroundInitializer
}
// collect the results
- Map<String, Object> results = new HashMap<String, Object>();
- Map<String, ConcurrentException> excepts = new HashMap<String, ConcurrentException>();
- for (Map.Entry<String, BackgroundInitializer<?>> e : inits.entrySet()) {
+ final Map<String, Object> results = new HashMap<String, Object>();
+ final Map<String, ConcurrentException> excepts = new HashMap<String, ConcurrentException>();
+ for (final Map.Entry<String, BackgroundInitializer<?>> e : inits.entrySet()) {
try {
results.put(e.getKey(), e.getValue().get());
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
excepts.put(e.getKey(), cex);
}
}
@@ -340,7 +340,7 @@ public class MultiBackgroundInitializer
* @throws NoSuchElementException if the name is unknown
*/
private BackgroundInitializer<?> checkName(final String name) {
- BackgroundInitializer<?> init = initializers.get(name);
+ final BackgroundInitializer<?> init = initializers.get(name);
if (init == null) {
throw new NoSuchElementException(
"No child initializer with name " + name);
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java b/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java
index 74bcce0a1..a3e457022 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java
@@ -210,7 +210,7 @@ public class TimedSemaphore {
executorService = service;
ownExecutor = false;
} else {
- ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(
+ final ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(
THREAD_POOL_SIZE);
s.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
s.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
diff --git a/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java b/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
index e46b4f425..2c696985b 100644
--- a/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
+++ b/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
@@ -218,15 +218,15 @@ public class EventListenerSupport<L> implements Serializable {
* @throws IOException if an IO error occurs
*/
private void writeObject(final ObjectOutputStream objectOutputStream) throws IOException {
- ArrayList<L> serializableListeners = new ArrayList<L>();
+ final ArrayList<L> serializableListeners = new ArrayList<L>();
// don't just rely on instanceof Serializable:
ObjectOutputStream testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream());
- for (L listener : listeners) {
+ for (final L listener : listeners) {
try {
testObjectOutputStream.writeObject(listener);
serializableListeners.add(listener);
- } catch (IOException exception) {
+ } catch (final IOException exception) {
//recreate test stream in case of indeterminate state
testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream());
}
@@ -246,11 +246,13 @@ public class EventListenerSupport<L> implements Serializable {
*/
private void readObject(final ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
+ final
L[] listeners = (L[]) objectInputStream.readObject();
this.listeners = new CopyOnWriteArrayList<L>(listeners);
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
+ final
Class<L> listenerInterface = (Class<L>) listeners.getClass().getComponentType();
initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader());
@@ -263,6 +265,7 @@ public class EventListenerSupport<L> implements Serializable {
*/
private void initializeTransientFields(final Class<L> listenerInterface, final ClassLoader classLoader) {
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
+ final
L[] array = (L[]) Array.newInstance(listenerInterface, 0);
this.prototypeArray = array;
createProxy(listenerInterface, classLoader);
@@ -306,7 +309,7 @@ public class EventListenerSupport<L> implements Serializable {
*/
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
- for (L listener : listeners) {
+ for (final L listener : listeners) {
method.invoke(listener, args);
}
return null;
diff --git a/src/main/java/org/apache/commons/lang3/event/EventUtils.java b/src/main/java/org/apache/commons/lang3/event/EventUtils.java
index 9804d0b7a..cf07adc83 100644
--- a/src/main/java/org/apache/commons/lang3/event/EventUtils.java
+++ b/src/main/java/org/apache/commons/lang3/event/EventUtils.java
@@ -48,15 +48,15 @@ public class EventUtils {
public static <L> void addEventListener(final Object eventSource, final Class<L> listenerType, final L listener) {
try {
MethodUtils.invokeMethod(eventSource, "add" + listenerType.getSimpleName(), listener);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
throw new IllegalArgumentException("Class " + eventSource.getClass().getName()
+ " does not have a public add" + listenerType.getSimpleName()
+ " method which takes a parameter of type " + listenerType.getName() + ".");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new IllegalArgumentException("Class " + eventSource.getClass().getName()
+ " does not have an accessible add" + listenerType.getSimpleName ()
+ " method which takes a parameter of type " + listenerType.getName() + ".");
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
throw new RuntimeException("Unable to add listener.", e.getCause());
}
}
diff --git a/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java b/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java
index 12af50c38..adaf058b2 100644
--- a/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java
+++ b/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java
@@ -125,7 +125,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
*/
@Override
public String getFormattedExceptionMessage(final String baseMessage){
- StringBuilder buffer = new StringBuilder(256);
+ final StringBuilder buffer = new StringBuilder(256);
if (baseMessage != null) {
buffer.append(baseMessage);
}
@@ -150,7 +150,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
String valueStr;
try {
valueStr = value.toString();
- } catch (Exception e) {
+ } catch (final Exception e) {
valueStr = "Exception thrown on toString(): " + ExceptionUtils.getStackTrace(e);
}
buffer.append(valueStr);
diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
index 19ae9e842..7e803ddc2 100644
--- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
+++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
@@ -147,9 +147,9 @@ public class ExceptionUtils {
methodNames = CAUSE_METHOD_NAMES;
}
- for (String methodName : methodNames) {
+ for (final String methodName : methodNames) {
if (methodName != null) {
- Throwable cause = getCauseUsingMethodName(throwable, methodName);
+ final Throwable cause = getCauseUsingMethodName(throwable, methodName);
if (cause != null) {
return cause;
}
@@ -177,7 +177,7 @@ public class ExceptionUtils {
* <code>null</code> if none found or null throwable input
*/
public static Throwable getRootCause(final Throwable throwable) {
- List<Throwable> list = getThrowableList(throwable);
+ final List<Throwable> list = getThrowableList(throwable);
return list.size() < 2 ? null : (Throwable)list.get(list.size() - 1);
}
@@ -193,20 +193,20 @@ public class ExceptionUtils {
Method method = null;
try {
method = throwable.getClass().getMethod(methodName);
- } catch (NoSuchMethodException ignored) { // NOPMD
+ } catch (final NoSuchMethodException ignored) { // NOPMD
// exception ignored
- } catch (SecurityException ignored) { // NOPMD
+ } catch (final SecurityException ignored) { // NOPMD
// exception ignored
}
if (method != null && Throwable.class.isAssignableFrom(method.getReturnType())) {
try {
return (Throwable) method.invoke(throwable);
- } catch (IllegalAccessException ignored) { // NOPMD
+ } catch (final IllegalAccessException ignored) { // NOPMD
// exception ignored
- } catch (IllegalArgumentException ignored) { // NOPMD
+ } catch (final IllegalArgumentException ignored) { // NOPMD
// exception ignored
- } catch (InvocationTargetException ignored) { // NOPMD
+ } catch (final InvocationTargetException ignored) { // NOPMD
// exception ignored
}
}
@@ -254,7 +254,7 @@ public class ExceptionUtils {
* @return the array of throwables, never null
*/
public static Throwable[] getThrowables(final Throwable throwable) {
- List<Throwable> list = getThrowableList(throwable);
+ final List<Throwable> list = getThrowableList(throwable);
return list.toArray(new Throwable[list.size()]);
}
@@ -278,7 +278,7 @@ public class ExceptionUtils {
* @since Commons Lang 2.2
*/
public static List<Throwable> getThrowableList(Throwable throwable) {
- List<Throwable> list = new ArrayList<Throwable>();
+ final List<Throwable> list = new ArrayList<Throwable>();
while (throwable != null && list.contains(throwable) == false) {
list.add(throwable);
throwable = ExceptionUtils.getCause(throwable);
@@ -390,7 +390,7 @@ public class ExceptionUtils {
if (fromIndex < 0) {
fromIndex = 0;
}
- Throwable[] throwables = ExceptionUtils.getThrowables(throwable);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(throwable);
if (fromIndex >= throwables.length) {
return -1;
}
@@ -459,8 +459,8 @@ public class ExceptionUtils {
if (stream == null) {
throw new IllegalArgumentException("The PrintStream must not be null");
}
- String trace[] = getRootCauseStackTrace(throwable);
- for (String element : trace) {
+ final String trace[] = getRootCauseStackTrace(throwable);
+ for (final String element : trace) {
stream.println(element);
}
stream.flush();
@@ -492,8 +492,8 @@ public class ExceptionUtils {
if (writer == null) {
throw new IllegalArgumentException("The PrintWriter must not be null");
}
- String trace[] = getRootCauseStackTrace(throwable);
- for (String element : trace) {
+ final String trace[] = getRootCauseStackTrace(throwable);
+ for (final String element : trace) {
writer.println(element);
}
writer.flush();
@@ -517,12 +517,12 @@ public class ExceptionUtils {
if (throwable == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
- Throwable throwables[] = getThrowables(throwable);
- int count = throwables.length;
- List<String> frames = new ArrayList<String>();
+ final Throwable throwables[] = getThrowables(throwable);
+ final int count = throwables.length;
+ final List<String> frames = new ArrayList<String>();
List<String> nextTrace = getStackFrameList(throwables[count - 1]);
for (int i = count; --i >= 0;) {
- List<String> trace = nextTrace;
+ final List<String> trace = nextTrace;
if (i != 0) {
nextTrace = getStackFrameList(throwables[i - 1]);
removeCommonFrames(trace, nextTrace);
@@ -556,8 +556,8 @@ public class ExceptionUtils {
while (causeFrameIndex >= 0 && wrapperFrameIndex >= 0) {
// Remove the frame from the cause trace if it is the same
// as in the wrapper trace
- String causeFrame = causeFrames.get(causeFrameIndex);
- String wrapperFrame = wrapperFrames.get(wrapperFrameIndex);
+ final String causeFrame = causeFrames.get(causeFrameIndex);
+ final String wrapperFrame = wrapperFrames.get(wrapperFrameIndex);
if (causeFrame.equals(wrapperFrame)) {
causeFrames.remove(causeFrameIndex);
}
@@ -580,8 +580,8 @@ public class ExceptionUtils {
* <code>printStackTrace(PrintWriter)</code> method
*/
public static String getStackTrace(final Throwable throwable) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw, true);
+ final StringWriter sw = new StringWriter();
+ final PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw);
return sw.getBuffer().toString();
}
@@ -616,9 +616,9 @@ public class ExceptionUtils {
* @return an array where each element is a line from the argument
*/
static String[] getStackFrames(final String stackTrace) {
- String linebreak = SystemUtils.LINE_SEPARATOR;
- StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
- List<String> list = new ArrayList<String>();
+ final String linebreak = SystemUtils.LINE_SEPARATOR;
+ final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
+ final List<String> list = new ArrayList<String>();
while (frames.hasMoreTokens()) {
list.add(frames.nextToken());
}
@@ -638,15 +638,15 @@ public class ExceptionUtils {
* @return List of stack frames
*/
static List<String> getStackFrameList(final Throwable t) {
- String stackTrace = getStackTrace(t);
- String linebreak = SystemUtils.LINE_SEPARATOR;
- StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
- List<String> list = new ArrayList<String>();
+ final String stackTrace = getStackTrace(t);
+ final String linebreak = SystemUtils.LINE_SEPARATOR;
+ final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
+ final List<String> list = new ArrayList<String>();
boolean traceStarted = false;
while (frames.hasMoreTokens()) {
- String token = frames.nextToken();
+ final String token = frames.nextToken();
// Determine if the line starts with <whitespace>at
- int at = token.indexOf("at");
+ final int at = token.indexOf("at");
if (at != -1 && token.substring(0, at).trim().isEmpty()) {
traceStarted = true;
list.add(token);
@@ -672,8 +672,8 @@ public class ExceptionUtils {
if (th == null) {
return "";
}
- String clsName = ClassUtils.getShortClassName(th, null);
- String msg = th.getMessage();
+ final String clsName = ClassUtils.getShortClassName(th, null);
+ final String msg = th.getMessage();
return clsName + ": " + StringUtils.defaultString(msg);
}
diff --git a/src/main/java/org/apache/commons/lang3/math/Fraction.java b/src/main/java/org/apache/commons/lang3/math/Fraction.java
index 57b8afbf7..a722ffe2d 100644
--- a/src/main/java/org/apache/commons/lang3/math/Fraction.java
+++ b/src/main/java/org/apache/commons/lang3/math/Fraction.java
@@ -226,7 +226,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
denominator = -denominator;
}
// simplify fraction.
- int gcd = greatestCommonDivisor(numerator, denominator);
+ final int gcd = greatestCommonDivisor(numerator, denominator);
numerator /= gcd;
denominator /= gcd;
return new Fraction(numerator, denominator);
@@ -247,13 +247,13 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* @throws ArithmeticException if the the algorithm does not converge
*/
public static Fraction getFraction(double value) {
- int sign = value < 0 ? -1 : 1;
+ final int sign = value < 0 ? -1 : 1;
value = Math.abs(value);
if (value > Integer.MAX_VALUE || Double.isNaN(value)) {
throw new ArithmeticException
("The value must not be greater than Integer.MAX_VALUE or NaN");
}
- int wholeNumber = (int) value;
+ final int wholeNumber = (int) value;
value -= wholeNumber;
int numer0 = 0; // the pre-previous
@@ -329,14 +329,14 @@ public final class Fraction extends Number implements Comparable<Fraction> {
// parse X Y/Z format
pos = str.indexOf(' ');
if (pos > 0) {
- int whole = Integer.parseInt(str.substring(0, pos));
+ final int whole = Integer.parseInt(str.substring(0, pos));
str = str.substring(pos + 1);
pos = str.indexOf('/');
if (pos < 0) {
throw new NumberFormatException("The fraction could not be parsed as the format X Y/Z");
} else {
- int numer = Integer.parseInt(str.substring(0, pos));
- int denom = Integer.parseInt(str.substring(pos + 1));
+ final int numer = Integer.parseInt(str.substring(0, pos));
+ final int denom = Integer.parseInt(str.substring(pos + 1));
return getFraction(whole, numer, denom);
}
}
@@ -347,8 +347,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
// simple whole number
return getFraction(Integer.parseInt(str), 1);
} else {
- int numer = Integer.parseInt(str.substring(0, pos));
- int denom = Integer.parseInt(str.substring(pos + 1));
+ final int numer = Integer.parseInt(str.substring(0, pos));
+ final int denom = Integer.parseInt(str.substring(pos + 1));
return getFraction(numer, denom);
}
}
@@ -470,7 +470,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
if (numerator == 0) {
return equals(ZERO) ? this : ZERO;
}
- int gcd = greatestCommonDivisor(Math.abs(numerator), denominator);
+ final int gcd = greatestCommonDivisor(Math.abs(numerator), denominator);
if (gcd == 1) {
return this;
}
@@ -554,7 +554,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
}
return this.invert().pow(-power);
} else {
- Fraction f = this.multiplyBy(this);
+ final Fraction f = this.multiplyBy(this);
if (power % 2 == 0) { // if even...
return f.pow(power/2);
} else { // if odd...
@@ -637,7 +637,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* an int
*/
private static int mulAndCheck(final int x, final int y) {
- long m = (long)x*(long)y;
+ final long m = (long)x*(long)y;
if (m < Integer.MIN_VALUE ||
m > Integer.MAX_VALUE) {
throw new ArithmeticException("overflow: mul");
@@ -656,7 +656,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
*/
private static int mulPosAndCheck(final int x, final int y) {
/* assert x>=0 && y>=0; */
- long m = (long)x*(long)y;
+ final long m = (long)x*(long)y;
if (m > Integer.MAX_VALUE) {
throw new ArithmeticException("overflow: mulPos");
}
@@ -673,7 +673,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* an int
*/
private static int addAndCheck(final int x, final int y) {
- long s = (long)x+(long)y;
+ final long s = (long)x+(long)y;
if (s < Integer.MIN_VALUE ||
s > Integer.MAX_VALUE) {
throw new ArithmeticException("overflow: add");
@@ -691,7 +691,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* an int
*/
private static int subAndCheck(final int x, final int y) {
- long s = (long)x-(long)y;
+ final long s = (long)x-(long)y;
if (s < Integer.MIN_VALUE ||
s > Integer.MAX_VALUE) {
throw new ArithmeticException("overflow: add");
@@ -750,11 +750,11 @@ public final class Fraction extends Number implements Comparable<Fraction> {
}
// if denominators are randomly distributed, d1 will be 1 about 61%
// of the time.
- int d1 = greatestCommonDivisor(denominator, fraction.denominator);
+ final int d1 = greatestCommonDivisor(denominator, fraction.denominator);
if (d1==1) {
// result is ( (u*v' +/- u'v) / u'v')
- int uvp = mulAndCheck(numerator, fraction.denominator);
- int upv = mulAndCheck(fraction.numerator, denominator);
+ final int uvp = mulAndCheck(numerator, fraction.denominator);
+ final int upv = mulAndCheck(fraction.numerator, denominator);
return new Fraction
(isAdd ? addAndCheck(uvp, upv) : subAndCheck(uvp, upv),
mulPosAndCheck(denominator, fraction.denominator));
@@ -762,18 +762,18 @@ public final class Fraction extends Number implements Comparable<Fraction> {
// the quantity 't' requires 65 bits of precision; see knuth 4.5.1
// exercise 7. we're going to use a BigInteger.
// t = u(v'/d1) +/- v(u'/d1)
- BigInteger uvp = BigInteger.valueOf(numerator)
+ final BigInteger uvp = BigInteger.valueOf(numerator)
.multiply(BigInteger.valueOf(fraction.denominator/d1));
- BigInteger upv = BigInteger.valueOf(fraction.numerator)
+ final BigInteger upv = BigInteger.valueOf(fraction.numerator)
.multiply(BigInteger.valueOf(denominator/d1));
- BigInteger t = isAdd ? uvp.add(upv) : uvp.subtract(upv);
+ final BigInteger t = isAdd ? uvp.add(upv) : uvp.subtract(upv);
// but d2 doesn't need extra precision because
// d2 = gcd(t,d1) = gcd(t mod d1, d1)
- int tmodd1 = t.mod(BigInteger.valueOf(d1)).intValue();
- int d2 = tmodd1==0?d1:greatestCommonDivisor(tmodd1, d1);
+ final int tmodd1 = t.mod(BigInteger.valueOf(d1)).intValue();
+ final int d2 = tmodd1==0?d1:greatestCommonDivisor(tmodd1, d1);
// result is (t/d2) / (u'/d1)(v'/d2)
- BigInteger w = t.divide(BigInteger.valueOf(d2));
+ final BigInteger w = t.divide(BigInteger.valueOf(d2));
if (w.bitLength() > 31) {
throw new ArithmeticException
("overflow: numerator too large after multiply");
@@ -802,8 +802,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
}
// knuth 4.5.1
// make sure we don't overflow unless the result *must* overflow.
- int d1 = greatestCommonDivisor(numerator, fraction.denominator);
- int d2 = greatestCommonDivisor(fraction.numerator, denominator);
+ final int d1 = greatestCommonDivisor(numerator, fraction.denominator);
+ final int d2 = greatestCommonDivisor(fraction.numerator, denominator);
return getReducedFraction
(mulAndCheck(numerator/d1, fraction.numerator/d2),
mulPosAndCheck(denominator/d2, fraction.denominator/d1));
@@ -848,7 +848,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
if (obj instanceof Fraction == false) {
return false;
}
- Fraction other = (Fraction) obj;
+ final Fraction other = (Fraction) obj;
return getNumerator() == other.getNumerator() &&
getDenominator() == other.getDenominator();
}
@@ -889,8 +889,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
}
// otherwise see which is less
- long first = (long) numerator * (long) other.denominator;
- long second = (long) other.numerator * (long) denominator;
+ final long first = (long) numerator * (long) other.denominator;
+ final long second = (long) other.numerator * (long) denominator;
if (first == second) {
return 0;
} else if (first < second) {
@@ -940,7 +940,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
// NEGATIVE (not positive) numbers, since negative numbers
// have a larger range. otherwise numerator==Integer.MIN_VALUE
// is handled incorrectly.
- int properNumerator = getProperNumerator();
+ final int properNumerator = getProperNumerator();
if (properNumerator == 0) {
toProperString = Integer.toString(getProperWhole());
} else {
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index 0d3cf0088..7d0f8af0d 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -123,7 +123,7 @@ public class NumberUtils {
}
try {
return Integer.parseInt(str);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return defaultValue;
}
}
@@ -172,7 +172,7 @@ public class NumberUtils {
}
try {
return Long.parseLong(str);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return defaultValue;
}
}
@@ -224,7 +224,7 @@ public class NumberUtils {
}
try {
return Float.parseFloat(str);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return defaultValue;
}
}
@@ -276,7 +276,7 @@ public class NumberUtils {
}
try {
return Double.parseDouble(str);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return defaultValue;
}
}
@@ -326,7 +326,7 @@ public class NumberUtils {
}
try {
return Byte.parseByte(str);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return defaultValue;
}
}
@@ -375,7 +375,7 @@ public class NumberUtils {
}
try {
return Short.parseShort(str);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
return defaultValue;
}
}
@@ -453,14 +453,14 @@ public class NumberUtils {
// Need to deal with all possible hex prefixes here
final String[] hex_prefixes = {"0x", "0X", "-0x", "-0X", "#", "-#"};
int pfxLen = 0;
- for(String pfx : hex_prefixes) {
+ for(final String pfx : hex_prefixes) {
if (str.startsWith(pfx)) {
pfxLen += pfx.length();
break;
}
}
if (pfxLen > 0) {
- int hexDigits = str.length() - pfxLen;
+ final int hexDigits = str.length() - pfxLen;
if (hexDigits > 16) { // too many for Long
return createBigInteger(str);
}
@@ -469,12 +469,12 @@ public class NumberUtils {
}
return createInteger(str);
}
- char lastChar = str.charAt(str.length() - 1);
+ final char lastChar = str.charAt(str.length() - 1);
String mant;
String dec;
String exp;
- int decPos = str.indexOf('.');
- int expPos = str.indexOf('e') + str.indexOf('E') + 1;
+ final int decPos = str.indexOf('.');
+ final int expPos = str.indexOf('e') + str.indexOf('E') + 1;
if (decPos > -1) {
@@ -505,8 +505,8 @@ public class NumberUtils {
exp = null;
}
//Requesting a specific type..
- String numeric = str.substring(0, str.length() - 1);
- boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
+ final String numeric = str.substring(0, str.length() - 1);
+ final boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
switch (lastChar) {
case 'l' :
case 'L' :
@@ -515,7 +515,7 @@ public class NumberUtils {
&& (numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
try {
return createLong(numeric);
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// Too big for a long
}
return createBigInteger(numeric);
@@ -525,30 +525,30 @@ public class NumberUtils {
case 'f' :
case 'F' :
try {
- Float f = NumberUtils.createFloat(numeric);
+ final Float f = NumberUtils.createFloat(numeric);
if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
//If it's too big for a float or the float value = 0 and the string
//has non-zeros in it, then float does not have the precision we want
return f;
}
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
//$FALL-THROUGH$
case 'd' :
case 'D' :
try {
- Double d = NumberUtils.createDouble(numeric);
+ final Double d = NumberUtils.createDouble(numeric);
if (!(d.isInfinite() || (d.floatValue() == 0.0D && !allZeros))) {
return d;
}
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
return createBigDecimal(numeric);
- } catch (NumberFormatException e) { // NOPMD
+ } catch (final NumberFormatException e) { // NOPMD
// ignore the bad number
}
//$FALL-THROUGH$
@@ -568,33 +568,33 @@ public class NumberUtils {
//Must be an int,long,bigint
try {
return createInteger(str);
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
return createLong(str);
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
return createBigInteger(str);
} else {
//Must be a float,double,BigDec
- boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
+ final boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
try {
- Float f = createFloat(str);
+ final Float f = createFloat(str);
if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
return f;
}
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
- Double d = createDouble(str);
+ final Double d = createDouble(str);
if (!(d.isInfinite() || (d.doubleValue() == 0.0D && !allZeros))) {
return d;
}
- } catch (NumberFormatException nfe) { // NOPMD
+ } catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
@@ -1311,14 +1311,14 @@ public class NumberUtils {
if (StringUtils.isEmpty(str)) {
return false;
}
- char[] chars = str.toCharArray();
+ final char[] chars = str.toCharArray();
int sz = chars.length;
boolean hasExp = false;
boolean hasDecPoint = false;
boolean allowSigns = false;
boolean foundDigit = false;
// deal with any possible sign up front
- int start = (chars[0] == '-') ? 1 : 0;
+ final int start = (chars[0] == '-') ? 1 : 0;
if (sz > start + 1 && chars[start] == '0' && chars[start + 1] == 'x') {
int i = start + 2;
if (i == sz) {
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java
index 6f0175f1f..a07a055dc 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java
@@ -178,7 +178,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl
*/
@Override
public int compareTo(final MutableBoolean other) {
- boolean anotherVal = other.value;
+ final boolean anotherVal = other.value;
return value == anotherVal ? 0 : (value ? 1 : -1);
}
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java b/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
index 28e217256..3700597f2 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
@@ -268,7 +268,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta
*/
@Override
public int compareTo(final MutableByte other) {
- byte anotherVal = other.value;
+ final byte anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java b/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
index b425198fc..fe35a0136 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
@@ -284,7 +284,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
*/
@Override
public int hashCode() {
- long bits = Double.doubleToLongBits(value);
+ final long bits = Double.doubleToLongBits(value);
return (int) (bits ^ bits >>> 32);
}
@@ -297,7 +297,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
*/
@Override
public int compareTo(final MutableDouble other) {
- double anotherVal = other.value;
+ final double anotherVal = other.value;
return Double.compare(value, anotherVal);
}
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java b/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
index caea98e42..1326de228 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
@@ -298,7 +298,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
*/
@Override
public int compareTo(final MutableFloat other) {
- float anotherVal = other.value;
+ final float anotherVal = other.value;
return Float.compare(value, anotherVal);
}
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java b/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
index ee18f1fcb..088f66948 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
@@ -258,7 +258,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl
*/
@Override
public int compareTo(final MutableInt other) {
- int anotherVal = other.value;
+ final int anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java b/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
index 48e10f84f..8ed50d850 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
@@ -258,7 +258,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta
*/
@Override
public int compareTo(final MutableLong other) {
- long anotherVal = other.value;
+ final long anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java b/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java
index 2615260ef..c2a8701e1 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java
@@ -97,7 +97,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable {
return true;
}
if (this.getClass() == obj.getClass()) {
- MutableObject<?> that = (MutableObject<?>) obj;
+ final MutableObject<?> that = (MutableObject<?>) obj;
return this.value.equals(that.value);
} else {
return false;
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java b/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
index 81a2e4e06..5a2b3e2db 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
@@ -268,7 +268,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu
*/
@Override
public int compareTo(final MutableShort other) {
- short anotherVal = other.value;
+ final short anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
diff --git a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
index 31fa524f3..4484f1be3 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
@@ -81,7 +81,7 @@ public class ConstructorUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Class<?> parameterTypes[] = ClassUtils.toClass(args);
+ final Class<?> parameterTypes[] = ClassUtils.toClass(args);
return invokeConstructor(cls, args, parameterTypes);
}
@@ -113,7 +113,7 @@ public class ConstructorUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Constructor<T> ctor = getMatchingAccessibleConstructor(cls, parameterTypes);
+ final Constructor<T> ctor = getMatchingAccessibleConstructor(cls, parameterTypes);
if (ctor == null) {
throw new NoSuchMethodException(
"No such accessible constructor on object: " + cls.getName());
@@ -145,7 +145,7 @@ public class ConstructorUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Class<?> parameterTypes[] = ClassUtils.toClass(args);
+ final Class<?> parameterTypes[] = ClassUtils.toClass(args);
return invokeExactConstructor(cls, args, parameterTypes);
}
@@ -177,7 +177,7 @@ public class ConstructorUtils {
if (parameterTypes == null) {
parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
}
- Constructor<T> ctor = getAccessibleConstructor(cls, parameterTypes);
+ final Constructor<T> ctor = getAccessibleConstructor(cls, parameterTypes);
if (ctor == null) {
throw new NoSuchMethodException(
"No such accessible constructor on object: "+ cls.getName());
@@ -203,7 +203,7 @@ public class ConstructorUtils {
final Class<?>... parameterTypes) {
try {
return getAccessibleConstructor(cls.getConstructor(parameterTypes));
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
return null;
}
}
@@ -245,17 +245,17 @@ public class ConstructorUtils {
// see if we can find the constructor directly
// most of the time this works and it's much faster
try {
- Constructor<T> ctor = cls.getConstructor(parameterTypes);
+ final Constructor<T> ctor = cls.getConstructor(parameterTypes);
MemberUtils.setAccessibleWorkaround(ctor);
return ctor;
- } catch (NoSuchMethodException e) { // NOPMD - Swallow
+ } catch (final NoSuchMethodException e) { // NOPMD - Swallow
}
Constructor<T> result = null;
/*
* (1) Class.getConstructors() is documented to return Constructor<T> so as
* long as the array is not subsequently modified, everything's fine.
*/
- Constructor<?>[] ctors = cls.getConstructors();
+ final Constructor<?>[] ctors = cls.getConstructors();
// return best match:
for (Constructor<?> ctor : ctors) {
@@ -270,6 +270,7 @@ public class ConstructorUtils {
.getParameterTypes(), parameterTypes) < 0) {
// temporary variable for annotation, see comment above (1)
@SuppressWarnings("unchecked")
+ final
Constructor<T> constructor = (Constructor<T>)ctor;
result = constructor;
}
diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
index 180df6a75..dc60e29ae 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
@@ -54,7 +54,7 @@ public class FieldUtils {
* @throws IllegalArgumentException if the class or field name is null
*/
public static Field getField(final Class<?> cls, final String fieldName) {
- Field field = getField(cls, fieldName, false);
+ final Field field = getField(cls, fieldName, false);
MemberUtils.setAccessibleWorkaround(field);
return field;
}
@@ -94,7 +94,7 @@ public class FieldUtils {
// check up the superclass hierarchy
for (Class<?> acls = cls; acls != null; acls = acls.getSuperclass()) {
try {
- Field field = acls.getDeclaredField(fieldName);
+ final Field field = acls.getDeclaredField(fieldName);
// getDeclaredField checks for non-public scopes as well
// and it returns accurate results
if (!Modifier.isPublic(field.getModifiers())) {
@@ -105,7 +105,7 @@ public class FieldUtils {
}
}
return field;
- } catch (NoSuchFieldException ex) { // NOPMD
+ } catch (final NoSuchFieldException ex) { // NOPMD
// ignore
}
}
@@ -113,15 +113,15 @@ public class FieldUtils {
// incase there is a public supersuperclass field hidden by a private/package
// superclass field.
Field match = null;
- for (Class<?> class1 : ClassUtils.getAllInterfaces(cls)) {
+ for (final Class<?> class1 : ClassUtils.getAllInterfaces(cls)) {
try {
- Field test = ((Class<?>) class1).getField(fieldName);
+ final Field test = ((Class<?>) class1).getField(fieldName);
if (match != null) {
throw new IllegalArgumentException("Reference to field " + fieldName + " is ambiguous relative to " + cls
+ "; a matching field exists on two or more implemented interfaces.");
}
match = test;
- } catch (NoSuchFieldException ex) { // NOPMD
+ } catch (final NoSuchFieldException ex) { // NOPMD
// ignore
}
}
@@ -161,7 +161,7 @@ public class FieldUtils {
}
try {
// only consider the specified class by using getDeclaredField()
- Field field = cls.getDeclaredField(fieldName);
+ final Field field = cls.getDeclaredField(fieldName);
if (!MemberUtils.isAccessible(field)) {
if (forceAccess) {
field.setAccessible(true);
@@ -170,7 +170,7 @@ public class FieldUtils {
}
}
return field;
- } catch (NoSuchFieldException e) { // NOPMD
+ } catch (final NoSuchFieldException e) { // NOPMD
// ignore
}
return null;
@@ -231,7 +231,7 @@ public class FieldUtils {
*/
public static Object readStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess)
throws IllegalAccessException {
- Field field = getField(cls, fieldName, forceAccess);
+ final Field field = getField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate field " + fieldName + " on " + cls);
}
@@ -268,7 +268,7 @@ public class FieldUtils {
*/
public static Object readDeclaredStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess)
throws IllegalAccessException {
- Field field = getDeclaredField(cls, fieldName, forceAccess);
+ final Field field = getDeclaredField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate declared field " + cls.getName() + "." + fieldName);
}
@@ -337,8 +337,8 @@ public class FieldUtils {
if (target == null) {
throw new IllegalArgumentException("target object must not be null");
}
- Class<?> cls = target.getClass();
- Field field = getField(cls, fieldName, forceAccess);
+ final Class<?> cls = target.getClass();
+ final Field field = getField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate field " + fieldName + " on " + cls);
}
@@ -376,8 +376,8 @@ public class FieldUtils {
if (target == null) {
throw new IllegalArgumentException("target object must not be null");
}
- Class<?> cls = target.getClass();
- Field field = getDeclaredField(cls, fieldName, forceAccess);
+ final Class<?> cls = target.getClass();
+ final Field field = getDeclaredField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate declared field " + cls.getName() + "." + fieldName);
}
@@ -441,7 +441,7 @@ public class FieldUtils {
*/
public static void writeStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException {
- Field field = getField(cls, fieldName, forceAccess);
+ final Field field = getField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate field " + fieldName + " on " + cls);
}
@@ -475,7 +475,7 @@ public class FieldUtils {
*/
public static void writeDeclaredStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException {
- Field field = getDeclaredField(cls, fieldName, forceAccess);
+ final Field field = getDeclaredField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate declared field " + cls.getName() + "." + fieldName);
}
@@ -547,8 +547,8 @@ public class FieldUtils {
if (target == null) {
throw new IllegalArgumentException("target object must not be null");
}
- Class<?> cls = target.getClass();
- Field field = getField(cls, fieldName, forceAccess);
+ final Class<?> cls = target.getClass();
+ final Field field = getField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate declared field " + cls.getName() + "." + fieldName);
}
@@ -584,8 +584,8 @@ public class FieldUtils {
if (target == null) {
throw new IllegalArgumentException("target object must not be null");
}
- Class<?> cls = target.getClass();
- Field field = getDeclaredField(cls, fieldName, forceAccess);
+ final Class<?> cls = target.getClass();
+ final Field field = getDeclaredField(cls, fieldName, forceAccess);
if (field == null) {
throw new IllegalArgumentException("Cannot locate declared field " + cls.getName() + "." + fieldName);
}
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
index 66bf15ea3..006fcb710 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
@@ -55,12 +55,12 @@ abstract class MemberUtils {
if (o == null || o.isAccessible()) {
return;
}
- Member m = (Member) o;
+ final Member m = (Member) o;
if (Modifier.isPublic(m.getModifiers())
&& isPackageAccess(m.getDeclaringClass().getModifiers())) {
try {
o.setAccessible(true);
- } catch (SecurityException e) { // NOPMD
+ } catch (final SecurityException e) { // NOPMD
// ignore in favor of subsequent IllegalAccessException
}
}
@@ -97,8 +97,8 @@ abstract class MemberUtils {
* @return int consistent with <code>compare</code> semantics
*/
static int compareParameterTypes(final Class<?>[] left, final Class<?>[] right, final Class<?>[] actual) {
- float leftCost = getTotalTransformationCost(actual, left);
- float rightCost = getTotalTransformationCost(actual, right);
+ final float leftCost = getTotalTransformationCost(actual, left);
+ final float rightCost = getTotalTransformationCost(actual, right);
return leftCost < rightCost ? -1 : rightCost < leftCost ? 1 : 0;
}
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 8aec2e946..b86ea2829 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -86,7 +86,7 @@ public class MethodUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Class<?>[] parameterTypes = ClassUtils.toClass(args);
+ final Class<?>[] parameterTypes = ClassUtils.toClass(args);
return invokeMethod(object, methodName, args, parameterTypes);
}
@@ -119,7 +119,7 @@ public class MethodUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Method method = getMatchingAccessibleMethod(object.getClass(),
+ final Method method = getMatchingAccessibleMethod(object.getClass(),
methodName, parameterTypes);
if (method == null) {
throw new NoSuchMethodException("No such accessible method: "
@@ -153,7 +153,7 @@ public class MethodUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Class<?>[] parameterTypes = ClassUtils.toClass(args);
+ final Class<?>[] parameterTypes = ClassUtils.toClass(args);
return invokeExactMethod(object, methodName, args, parameterTypes);
}
@@ -186,7 +186,7 @@ public class MethodUtils {
if (parameterTypes == null) {
parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
}
- Method method = getAccessibleMethod(object.getClass(), methodName,
+ final Method method = getAccessibleMethod(object.getClass(), methodName,
parameterTypes);
if (method == null) {
throw new NoSuchMethodException("No such accessible method: "
@@ -225,7 +225,7 @@ public class MethodUtils {
if (parameterTypes == null) {
parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
}
- Method method = getAccessibleMethod(cls, methodName, parameterTypes);
+ final Method method = getAccessibleMethod(cls, methodName, parameterTypes);
if (method == null) {
throw new NoSuchMethodException("No such accessible method: "
+ methodName + "() on class: " + cls.getName());
@@ -263,7 +263,7 @@ public class MethodUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Class<?>[] parameterTypes = ClassUtils.toClass(args);
+ final Class<?>[] parameterTypes = ClassUtils.toClass(args);
return invokeStaticMethod(cls, methodName, args, parameterTypes);
}
@@ -299,7 +299,7 @@ public class MethodUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Method method = getMatchingAccessibleMethod(cls, methodName,
+ final Method method = getMatchingAccessibleMethod(cls, methodName,
parameterTypes);
if (method == null) {
throw new NoSuchMethodException("No such accessible method: "
@@ -332,7 +332,7 @@ public class MethodUtils {
if (args == null) {
args = ArrayUtils.EMPTY_OBJECT_ARRAY;
}
- Class<?>[] parameterTypes = ClassUtils.toClass(args);
+ final Class<?>[] parameterTypes = ClassUtils.toClass(args);
return invokeExactStaticMethod(cls, methodName, args, parameterTypes);
}
@@ -353,7 +353,7 @@ public class MethodUtils {
try {
return getAccessibleMethod(cls.getMethod(methodName,
parameterTypes));
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
return null;
}
}
@@ -371,12 +371,12 @@ public class MethodUtils {
return null;
}
// If the declaring class is public, we are done
- Class<?> cls = method.getDeclaringClass();
+ final Class<?> cls = method.getDeclaringClass();
if (Modifier.isPublic(cls.getModifiers())) {
return method;
}
- String methodName = method.getName();
- Class<?>[] parameterTypes = method.getParameterTypes();
+ final String methodName = method.getName();
+ final Class<?>[] parameterTypes = method.getParameterTypes();
// Check the implemented interfaces and subinterfaces
method = getAccessibleMethodFromInterfaceNest(cls, methodName,
@@ -407,7 +407,7 @@ public class MethodUtils {
if (Modifier.isPublic(parentClass.getModifiers())) {
try {
return parentClass.getMethod(methodName, parameterTypes);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
return null;
}
}
@@ -439,7 +439,7 @@ public class MethodUtils {
for (; cls != null; cls = cls.getSuperclass()) {
// Check the implemented interfaces of the parent class
- Class<?>[] interfaces = cls.getInterfaces();
+ final Class<?>[] interfaces = cls.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
// Is this interface public?
if (!Modifier.isPublic(interfaces[i].getModifiers())) {
@@ -449,7 +449,7 @@ public class MethodUtils {
try {
method = interfaces[i].getDeclaredMethod(methodName,
parameterTypes);
- } catch (NoSuchMethodException e) { // NOPMD
+ } catch (final NoSuchMethodException e) { // NOPMD
/*
* Swallow, if no method is found after the loop then this
* method returns null.
@@ -492,19 +492,19 @@ public class MethodUtils {
public static Method getMatchingAccessibleMethod(final Class<?> cls,
final String methodName, final Class<?>... parameterTypes) {
try {
- Method method = cls.getMethod(methodName, parameterTypes);
+ final Method method = cls.getMethod(methodName, parameterTypes);
MemberUtils.setAccessibleWorkaround(method);
return method;
- } catch (NoSuchMethodException e) { // NOPMD - Swallow the exception
+ } catch (final NoSuchMethodException e) { // NOPMD - Swallow the exception
}
// search through all methods
Method bestMatch = null;
- Method[] methods = cls.getMethods();
- for (Method method : methods) {
+ final Method[] methods = cls.getMethods();
+ for (final Method method : methods) {
// compare name and parameters
if (method.getName().equals(methodName) && ClassUtils.isAssignable(parameterTypes, method.getParameterTypes(), true)) {
// get accessible version of method
- Method accessibleMethod = getAccessibleMethod(method);
+ final Method accessibleMethod = getAccessibleMethod(method);
if (accessibleMethod != null && (bestMatch == null || MemberUtils.compareParameterTypes(
accessibleMethod.getParameterTypes(),
bestMatch.getParameterTypes(),
diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
index 7e220abe3..58eef3c7c 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
@@ -140,7 +140,7 @@ public class TypeUtils {
if (type instanceof TypeVariable<?>) {
// if any of the bounds are assignable to the class, then the
// type is assignable to the class.
- for (Type bound : ((TypeVariable<?>) type).getBounds()) {
+ for (final Type bound : ((TypeVariable<?>) type).getBounds()) {
if (isAssignable(bound, toClass)) {
return true;
}
@@ -194,10 +194,10 @@ public class TypeUtils {
}
// get the target type's raw type
- Class<?> toClass = getRawType(toParameterizedType);
+ final Class<?> toClass = getRawType(toParameterizedType);
// get the subject type's type arguments including owner type arguments
// and supertype arguments up to and including the target class.
- Map<TypeVariable<?>, Type> fromTypeVarAssigns = getTypeArguments(type, toClass, null);
+ final Map<TypeVariable<?>, Type> fromTypeVarAssigns = getTypeArguments(type, toClass, null);
// null means the two types are not compatible
if (fromTypeVarAssigns == null) {
@@ -212,13 +212,13 @@ public class TypeUtils {
}
// get the target type's type arguments including owner type arguments
- Map<TypeVariable<?>, Type> toTypeVarAssigns = getTypeArguments(toParameterizedType,
+ final Map<TypeVariable<?>, Type> toTypeVarAssigns = getTypeArguments(toParameterizedType,
toClass, typeVarAssigns);
// now to check each type argument
- for (TypeVariable<?> var : toTypeVarAssigns.keySet()) {
- Type toTypeArg = unrollVariableAssignments(var, toTypeVarAssigns);
- Type fromTypeArg = unrollVariableAssignments(var, fromTypeVarAssigns);
+ for (final TypeVariable<?> var : toTypeVarAssigns.keySet()) {
+ final Type toTypeArg = unrollVariableAssignments(var, toTypeVarAssigns);
+ final Type fromTypeArg = unrollVariableAssignments(var, fromTypeVarAssigns);
// parameters must either be absent from the subject type, within
// the bounds of the wildcard type, or be an exact match to the
@@ -274,10 +274,10 @@ public class TypeUtils {
return true;
}
- Type toComponentType = toGenericArrayType.getGenericComponentType();
+ final Type toComponentType = toGenericArrayType.getGenericComponentType();
if (type instanceof Class<?>) {
- Class<?> cls = (Class<?>) type;
+ final Class<?> cls = (Class<?>) type;
// compare the component types
return cls.isArray()
@@ -292,7 +292,7 @@ public class TypeUtils {
if (type instanceof WildcardType) {
// so long as one of the upper bounds is assignable, it's good
- for (Type bound : getImplicitUpperBounds((WildcardType) type)) {
+ for (final Type bound : getImplicitUpperBounds((WildcardType) type)) {
if (isAssignable(bound, toGenericArrayType)) {
return true;
}
@@ -304,7 +304,7 @@ public class TypeUtils {
if (type instanceof TypeVariable<?>) {
// probably should remove the following logic and just return false.
// type variables cannot specify arrays as bounds.
- for (Type bound : getImplicitBounds((TypeVariable<?>) type)) {
+ for (final Type bound : getImplicitBounds((TypeVariable<?>) type)) {
if (isAssignable(bound, toGenericArrayType)) {
return true;
}
@@ -350,13 +350,13 @@ public class TypeUtils {
return true;
}
- Type[] toUpperBounds = getImplicitUpperBounds(toWildcardType);
- Type[] toLowerBounds = getImplicitLowerBounds(toWildcardType);
+ final Type[] toUpperBounds = getImplicitUpperBounds(toWildcardType);
+ final Type[] toLowerBounds = getImplicitLowerBounds(toWildcardType);
if (type instanceof WildcardType) {
- WildcardType wildcardType = (WildcardType) type;
- Type[] upperBounds = getImplicitUpperBounds(wildcardType);
- Type[] lowerBounds = getImplicitLowerBounds(wildcardType);
+ final WildcardType wildcardType = (WildcardType) type;
+ final Type[] upperBounds = getImplicitUpperBounds(wildcardType);
+ final Type[] lowerBounds = getImplicitLowerBounds(wildcardType);
for (Type toBound : toUpperBounds) {
// if there are assignments for unresolved type variables,
@@ -366,7 +366,7 @@ public class TypeUtils {
// each upper bound of the subject type has to be assignable to
// each
// upper bound of the target type
- for (Type bound : upperBounds) {
+ for (final Type bound : upperBounds) {
if (!isAssignable(bound, toBound, typeVarAssigns)) {
return false;
}
@@ -381,7 +381,7 @@ public class TypeUtils {
// each lower bound of the target type has to be assignable to
// each
// lower bound of the subject type
- for (Type bound : lowerBounds) {
+ for (final Type bound : lowerBounds) {
if (!isAssignable(toBound, bound, typeVarAssigns)) {
return false;
}
@@ -391,7 +391,7 @@ public class TypeUtils {
return true;
}
- for (Type toBound : toUpperBounds) {
+ for (final Type toBound : toUpperBounds) {
// if there are assignments for unresolved type variables,
// now's the time to substitute them.
if (!isAssignable(type, substituteTypeVariables(toBound, typeVarAssigns),
@@ -400,7 +400,7 @@ public class TypeUtils {
}
}
- for (Type toBound : toLowerBounds) {
+ for (final Type toBound : toLowerBounds) {
// if there are assignments for unresolved type variables,
// now's the time to substitute them.
if (!isAssignable(substituteTypeVariables(toBound, typeVarAssigns), type,
@@ -443,9 +443,9 @@ public class TypeUtils {
// a type variable is assignable to another type variable, if
// and only if the former is the latter, extends the latter, or
// is otherwise a descendant of the latter.
- Type[] bounds = getImplicitBounds((TypeVariable<?>) type);
+ final Type[] bounds = getImplicitBounds((TypeVariable<?>) type);
- for (Type bound : bounds) {
+ for (final Type bound : bounds) {
if (isAssignable(bound, toTypeVariable, typeVarAssigns)) {
return true;
}
@@ -470,7 +470,7 @@ public class TypeUtils {
*/
private static Type substituteTypeVariables(final Type type, final Map<TypeVariable<?>, Type> typeVarAssigns) {
if (type instanceof TypeVariable<?> && typeVarAssigns != null) {
- Type replacementType = typeVarAssigns.get(type);
+ final Type replacementType = typeVarAssigns.get(type);
if (replacementType == null) {
throw new IllegalArgumentException("missing assignment type for type variable "
@@ -560,7 +560,7 @@ public class TypeUtils {
// since wildcard types are not assignable to classes, should this just
// return null?
if (type instanceof WildcardType) {
- for (Type bound : getImplicitUpperBounds((WildcardType) type)) {
+ for (final Type bound : getImplicitUpperBounds((WildcardType) type)) {
// find the first bound that is assignable to the target class
if (isAssignable(bound, toClass)) {
return getTypeArguments(bound, toClass, subtypeVarAssigns);
@@ -572,7 +572,7 @@ public class TypeUtils {
// *
if (type instanceof TypeVariable<?>) {
- for (Type bound : getImplicitBounds((TypeVariable<?>) type)) {
+ for (final Type bound : getImplicitBounds((TypeVariable<?>) type)) {
// find the first bound that is assignable to the target class
if (isAssignable(bound, toClass)) {
return getTypeArguments(bound, toClass, subtypeVarAssigns);
@@ -597,19 +597,19 @@ public class TypeUtils {
private static Map<TypeVariable<?>, Type> getTypeArguments(
final ParameterizedType parameterizedType, final Class<?> toClass,
final Map<TypeVariable<?>, Type> subtypeVarAssigns) {
- Class<?> cls = getRawType(parameterizedType);
+ final Class<?> cls = getRawType(parameterizedType);
// make sure they're assignable
if (!isAssignable(cls, toClass)) {
return null;
}
- Type ownerType = parameterizedType.getOwnerType();
+ final Type ownerType = parameterizedType.getOwnerType();
Map<TypeVariable<?>, Type> typeVarAssigns;
if (ownerType instanceof ParameterizedType) {
// get the owner type arguments first
- ParameterizedType parameterizedOwnerType = (ParameterizedType) ownerType;
+ final ParameterizedType parameterizedOwnerType = (ParameterizedType) ownerType;
typeVarAssigns = getTypeArguments(parameterizedOwnerType,
getRawType(parameterizedOwnerType), subtypeVarAssigns);
} else {
@@ -619,13 +619,13 @@ public class TypeUtils {
}
// get the subject parameterized type's arguments
- Type[] typeArgs = parameterizedType.getActualTypeArguments();
+ final Type[] typeArgs = parameterizedType.getActualTypeArguments();
// and get the corresponding type variables from the raw class
- TypeVariable<?>[] typeParams = cls.getTypeParameters();
+ final TypeVariable<?>[] typeParams = cls.getTypeParameters();
// map the arguments to their respective type variables
for (int i = 0; i < typeParams.length; i++) {
- Type typeArg = typeArgs[i];
+ final Type typeArg = typeArgs[i];
typeVarAssigns.put(typeParams[i], typeVarAssigns.containsKey(typeArg) ? typeVarAssigns
.get(typeArg) : typeArg);
}
@@ -668,7 +668,7 @@ public class TypeUtils {
}
// create a copy of the incoming map, or an empty one if it's null
- HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
+ final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
: new HashMap<TypeVariable<?>, Type>(subtypeVarAssigns);
// has target class been reached?
@@ -709,7 +709,7 @@ public class TypeUtils {
*/
public static Map<TypeVariable<?>, Type> determineTypeArguments(final Class<?> cls,
final ParameterizedType superType) {
- Class<?> superClass = getRawType(superType);
+ final Class<?> superClass = getRawType(superType);
// compatibility check
if (!isAssignable(cls, superClass)) {
@@ -721,18 +721,18 @@ public class TypeUtils {
}
// get the next class in the inheritance hierarchy
- Type midType = getClosestParentType(cls, superClass);
+ final Type midType = getClosestParentType(cls, superClass);
// can only be a class or a parameterized type
if (midType instanceof Class<?>) {
return determineTypeArguments((Class<?>) midType, superType);
}
- ParameterizedType midParameterizedType = (ParameterizedType) midType;
- Class<?> midClass = getRawType(midParameterizedType);
+ final ParameterizedType midParameterizedType = (ParameterizedType) midType;
+ final Class<?> midClass = getRawType(midParameterizedType);
// get the type variables of the mid class that map to the type
// arguments of the super class
- Map<TypeVariable<?>, Type> typeVarAssigns = determineTypeArguments(midClass, superType);
+ final Map<TypeVariable<?>, Type> typeVarAssigns = determineTypeArguments(midClass, superType);
// map the arguments of the mid type to the class type variables
mapTypeVariablesToArguments(cls, midParameterizedType, typeVarAssigns);
@@ -750,7 +750,7 @@ public class TypeUtils {
private static <T> void mapTypeVariablesToArguments(final Class<T> cls,
final ParameterizedType parameterizedType, final Map<TypeVariable<?>, Type> typeVarAssigns) {
// capture the type variables from the owner type that have assignments
- Type ownerType = parameterizedType.getOwnerType();
+ final Type ownerType = parameterizedType.getOwnerType();
if (ownerType instanceof ParameterizedType) {
// recursion to make sure the owner's owner type gets processed
@@ -761,19 +761,19 @@ public class TypeUtils {
// hierarchy of said interface/class) implemented/extended by the class
// cls. Find out which type variables of cls are type arguments of
// parameterizedType:
- Type[] typeArgs = parameterizedType.getActualTypeArguments();
+ final Type[] typeArgs = parameterizedType.getActualTypeArguments();
// of the cls's type variables that are arguments of parameterizedType,
// find out which ones can be determined from the super type's arguments
- TypeVariable<?>[] typeVars = getRawType(parameterizedType).getTypeParameters();
+ final TypeVariable<?>[] typeVars = getRawType(parameterizedType).getTypeParameters();
// use List view of type parameters of cls so the contains() method can be used:
- List<TypeVariable<Class<T>>> typeVarList = Arrays.asList(cls
+ final List<TypeVariable<Class<T>>> typeVarList = Arrays.asList(cls
.getTypeParameters());
for (int i = 0; i < typeArgs.length; i++) {
- TypeVariable<?> typeVar = typeVars[i];
- Type typeArg = typeArgs[i];
+ final TypeVariable<?> typeVar = typeVars[i];
+ final Type typeArg = typeArgs[i];
// argument of parameterizedType is a type variable of cls
if (typeVarList.contains(typeArg)
@@ -798,12 +798,12 @@ public class TypeUtils {
// only look at the interfaces if the super class is also an interface
if (superClass.isInterface()) {
// get the generic interfaces of the subject class
- Type[] interfaceTypes = cls.getGenericInterfaces();
+ final Type[] interfaceTypes = cls.getGenericInterfaces();
// will hold the best generic interface match found
Type genericInterface = null;
// find the interface closest to the super class
- for (Type midType : interfaceTypes) {
+ for (final Type midType : interfaceTypes) {
Class<?> midClass = null;
if (midType instanceof ParameterizedType) {
@@ -878,12 +878,12 @@ public class TypeUtils {
return bounds;
}
- Set<Type> types = new HashSet<Type>(bounds.length);
+ final Set<Type> types = new HashSet<Type>(bounds.length);
- for (Type type1 : bounds) {
+ for (final Type type1 : bounds) {
boolean subtypeFound = false;
- for (Type type2 : bounds) {
+ for (final Type type2 : bounds) {
if (type1 != type2 && isAssignable(type2, type1, null)) {
subtypeFound = true;
break;
@@ -908,7 +908,7 @@ public class TypeUtils {
* @return a non-empty array containing the bounds of the type variable.
*/
public static Type[] getImplicitBounds(final TypeVariable<?> typeVariable) {
- Type[] bounds = typeVariable.getBounds();
+ final Type[] bounds = typeVariable.getBounds();
return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds);
}
@@ -924,7 +924,7 @@ public class TypeUtils {
* type.
*/
public static Type[] getImplicitUpperBounds(final WildcardType wildcardType) {
- Type[] bounds = wildcardType.getUpperBounds();
+ final Type[] bounds = wildcardType.getUpperBounds();
return bounds.length == 0 ? new Type[] { Object.class } : normalizeUpperBounds(bounds);
}
@@ -939,7 +939,7 @@ public class TypeUtils {
* type.
*/
public static Type[] getImplicitLowerBounds(final WildcardType wildcardType) {
- Type[] bounds = wildcardType.getLowerBounds();
+ final Type[] bounds = wildcardType.getLowerBounds();
return bounds.length == 0 ? new Type[] { null } : bounds;
}
@@ -960,11 +960,11 @@ public class TypeUtils {
public static boolean typesSatisfyVariables(final Map<TypeVariable<?>, Type> typeVarAssigns) {
// all types must be assignable to all the bounds of the their mapped
// type variable.
- for (Map.Entry<TypeVariable<?>, Type> entry : typeVarAssigns.entrySet()) {
- TypeVariable<?> typeVar = entry.getKey();
- Type type = entry.getValue();
+ for (final Map.Entry<TypeVariable<?>, Type> entry : typeVarAssigns.entrySet()) {
+ final TypeVariable<?> typeVar = entry.getKey();
+ final Type type = entry.getValue();
- for (Type bound : getImplicitBounds(typeVar)) {
+ for (final Type bound : getImplicitBounds(typeVar)) {
if (!isAssignable(type, substituteTypeVariables(bound, typeVarAssigns),
typeVarAssigns)) {
return false;
@@ -983,7 +983,7 @@ public class TypeUtils {
* @throws IllegalStateException if the conversion fails
*/
private static Class<?> getRawType(final ParameterizedType parameterizedType) {
- Type rawType = parameterizedType.getRawType();
+ final Type rawType = parameterizedType.getRawType();
// check if raw type is a Class object
// not currently necessary, but since the return type is Type instead of
@@ -1026,7 +1026,7 @@ public class TypeUtils {
}
// get the entity declaring this type variable
- Object genericDeclaration = ((TypeVariable<?>) type).getGenericDeclaration();
+ final Object genericDeclaration = ((TypeVariable<?>) type).getGenericDeclaration();
// can't get the raw type of a method- or constructor-declared type
// variable
@@ -1036,7 +1036,7 @@ public class TypeUtils {
// get the type arguments for the declaring class/interface based
// on the enclosing type
- Map<TypeVariable<?>, Type> typeVarAssigns = getTypeArguments(assigningType,
+ final Map<TypeVariable<?>, Type> typeVarAssigns = getTypeArguments(assigningType,
(Class<?>) genericDeclaration);
// enclosingType has to be a subclass (or subinterface) of the
@@ -1046,7 +1046,7 @@ public class TypeUtils {
}
// get the argument assigned to this type variable
- Type typeArgument = typeVarAssigns.get(type);
+ final Type typeArgument = typeVarAssigns.get(type);
if (typeArgument == null) {
return null;
@@ -1058,7 +1058,7 @@ public class TypeUtils {
if (type instanceof GenericArrayType) {
// get raw component type
- Class<?> rawComponentType = getRawType(((GenericArrayType) type)
+ final Class<?> rawComponentType = getRawType(((GenericArrayType) type)
.getGenericComponentType(), assigningType);
// create array type from raw component type and return its class
@@ -1089,7 +1089,7 @@ public class TypeUtils {
*/
public static Type getArrayComponentType(final Type type) {
if (type instanceof Class<?>) {
- Class<?> clazz = (Class<?>) type;
+ final Class<?> clazz = (Class<?>) type;
return clazz.isArray() ? clazz.getComponentType() : null;
}
if (type instanceof GenericArrayType) {
diff --git a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java
index dc94c7f2a..722d3b5a7 100644
--- a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java
+++ b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java
@@ -148,12 +148,12 @@ public class ExtendedMessageFormat extends MessageFormat {
toPattern = super.toPattern();
return;
}
- ArrayList<Format> foundFormats = new ArrayList<Format>();
- ArrayList<String> foundDescriptions = new ArrayList<String>();
- StringBuilder stripCustom = new StringBuilder(pattern.length());
+ final ArrayList<Format> foundFormats = new ArrayList<Format>();
+ final ArrayList<String> foundDescriptions = new ArrayList<String>();
+ final StringBuilder stripCustom = new StringBuilder(pattern.length());
- ParsePosition pos = new ParsePosition(0);
- char[] c = pattern.toCharArray();
+ final ParsePosition pos = new ParsePosition(0);
+ final char[] c = pattern.toCharArray();
int fmtCount = 0;
while (pos.getIndex() < pattern.length()) {
switch (c[pos.getIndex()]) {
@@ -163,8 +163,8 @@ public class ExtendedMessageFormat extends MessageFormat {
case START_FE:
fmtCount++;
seekNonWs(pattern, pos);
- int start = pos.getIndex();
- int index = readArgumentIndex(pattern, next(pos));
+ final int start = pos.getIndex();
+ final int index = readArgumentIndex(pattern, next(pos));
stripCustom.append(START_FE).append(index);
seekNonWs(pattern, pos);
Format format = null;
@@ -194,12 +194,12 @@ public class ExtendedMessageFormat extends MessageFormat {
super.applyPattern(stripCustom.toString());
toPattern = insertFormats(super.toPattern(), foundDescriptions);
if (containsElements(foundFormats)) {
- Format[] origFormats = getFormats();
+ final Format[] origFormats = getFormats();
// only loop over what we know we have, as MessageFormat on Java 1.3
// seems to provide an extra format element:
int i = 0;
- for (Iterator<Format> it = foundFormats.iterator(); it.hasNext(); i++) {
- Format f = it.next();
+ for (final Iterator<Format> it = foundFormats.iterator(); it.hasNext(); i++) {
+ final Format f = it.next();
if (f != null) {
origFormats[i] = f;
}
@@ -274,7 +274,7 @@ public class ExtendedMessageFormat extends MessageFormat {
if (ObjectUtils.notEqual(getClass(), obj.getClass())) {
return false;
}
- ExtendedMessageFormat rhs = (ExtendedMessageFormat)obj;
+ final ExtendedMessageFormat rhs = (ExtendedMessageFormat)obj;
if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) {
return false;
}
@@ -307,12 +307,12 @@ public class ExtendedMessageFormat extends MessageFormat {
if (registry != null) {
String name = desc;
String args = null;
- int i = desc.indexOf(START_FMT);
+ final int i = desc.indexOf(START_FMT);
if (i > 0) {
name = desc.substring(0, i).trim();
args = desc.substring(i + 1).trim();
}
- FormatFactory factory = registry.get(name);
+ final FormatFactory factory = registry.get(name);
if (factory != null) {
return factory.getFormat(name, args, getLocale());
}
@@ -328,9 +328,9 @@ public class ExtendedMessageFormat extends MessageFormat {
* @return argument index
*/
private int readArgumentIndex(final String pattern, final ParsePosition pos) {
- int start = pos.getIndex();
+ final int start = pos.getIndex();
seekNonWs(pattern, pos);
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
boolean error = false;
for (; !error && pos.getIndex() < pattern.length(); next(pos)) {
char c = pattern.charAt(pos.getIndex());
@@ -345,7 +345,7 @@ public class ExtendedMessageFormat extends MessageFormat {
if ((c == START_FMT || c == END_FE) && result.length() > 0) {
try {
return Integer.parseInt(result.toString());
- } catch (NumberFormatException e) { // NOPMD
+ } catch (final NumberFormatException e) { // NOPMD
// we've already ensured only digits, so unless something
// outlandishly large was specified we should be okay.
}
@@ -370,9 +370,9 @@ public class ExtendedMessageFormat extends MessageFormat {
* @return Format description String
*/
private String parseFormatDescription(final String pattern, final ParsePosition pos) {
- int start = pos.getIndex();
+ final int start = pos.getIndex();
seekNonWs(pattern, pos);
- int text = pos.getIndex();
+ final int text = pos.getIndex();
int depth = 1;
for (; pos.getIndex() < pattern.length(); next(pos)) {
switch (pattern.charAt(pos.getIndex())) {
@@ -405,12 +405,12 @@ public class ExtendedMessageFormat extends MessageFormat {
if (!containsElements(customPatterns)) {
return pattern;
}
- StringBuilder sb = new StringBuilder(pattern.length() * 2);
- ParsePosition pos = new ParsePosition(0);
+ final StringBuilder sb = new StringBuilder(pattern.length() * 2);
+ final ParsePosition pos = new ParsePosition(0);
int fe = -1;
int depth = 0;
while (pos.getIndex() < pattern.length()) {
- char c = pattern.charAt(pos.getIndex());
+ final char c = pattern.charAt(pos.getIndex());
switch (c) {
case QUOTE:
appendQuotedString(pattern, pos, sb, false);
@@ -421,7 +421,7 @@ public class ExtendedMessageFormat extends MessageFormat {
fe++;
sb.append(START_FE).append(
readArgumentIndex(pattern, next(pos)));
- String customPattern = customPatterns.get(fe);
+ final String customPattern = customPatterns.get(fe);
if (customPattern != null) {
sb.append(START_FMT).append(customPattern);
}
@@ -446,7 +446,7 @@ public class ExtendedMessageFormat extends MessageFormat {
*/
private void seekNonWs(final String pattern, final ParsePosition pos) {
int len = 0;
- char[] buffer = pattern.toCharArray();
+ final char[] buffer = pattern.toCharArray();
do {
len = StrMatcher.splitMatcher().isMatch(buffer, pos.getIndex());
pos.setIndex(pos.getIndex() + len);
@@ -476,8 +476,8 @@ public class ExtendedMessageFormat extends MessageFormat {
*/
private StringBuilder appendQuotedString(final String pattern, final ParsePosition pos,
final StringBuilder appendTo, final boolean escapingOn) {
- int start = pos.getIndex();
- char[] c = pattern.toCharArray();
+ final int start = pos.getIndex();
+ final char[] c = pattern.toCharArray();
if (escapingOn && c[start] == QUOTE) {
next(pos);
return appendTo == null ? null : appendTo.append(QUOTE);
@@ -525,7 +525,7 @@ public class ExtendedMessageFormat extends MessageFormat {
if (coll == null || coll.isEmpty()) {
return false;
}
- for (Object name : coll) {
+ for (final Object name : coll) {
if (name != null) {
return true;
}
diff --git a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
index 4b5e9ef8e..abdd1149c 100644
--- a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
+++ b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
@@ -135,12 +135,12 @@ public class FormattableUtils {
final int precision, final char padChar, final CharSequence ellipsis) {
Validate.isTrue(ellipsis == null || precision < 0 || ellipsis.length() <= precision,
"Specified ellipsis '%1$s' exceeds precision of %2$s", ellipsis, Integer.valueOf(precision));
- StringBuilder buf = new StringBuilder(seq);
+ final StringBuilder buf = new StringBuilder(seq);
if (precision >= 0 && precision < seq.length()) {
- CharSequence _ellipsis = ObjectUtils.defaultIfNull(ellipsis, StringUtils.EMPTY);
+ final CharSequence _ellipsis = ObjectUtils.defaultIfNull(ellipsis, StringUtils.EMPTY);
buf.replace(precision - _ellipsis.length(), seq.length(), _ellipsis.toString());
}
- boolean leftJustify = (flags & LEFT_JUSTIFY) == LEFT_JUSTIFY;
+ final boolean leftJustify = (flags & LEFT_JUSTIFY) == LEFT_JUSTIFY;
for (int i = buf.length(); i < width; i++) {
buf.insert(leftJustify ? i : 0, padChar);
}
diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
index 8e3305dcf..1cfce4c4b 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
@@ -204,8 +204,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
size = length;
} else if (length > size) {
ensureCapacity(length);
- int oldEnd = size;
- int newEnd = length;
+ final int oldEnd = size;
+ final int newEnd = length;
size = length;
for (int i = oldEnd; i < newEnd; i++) {
buffer[i] = '\0';
@@ -232,7 +232,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public StrBuilder ensureCapacity(final int capacity) {
if (capacity > buffer.length) {
- char[] old = buffer;
+ final char[] old = buffer;
buffer = new char[capacity * 2];
System.arraycopy(old, 0, buffer, 0, size);
}
@@ -246,7 +246,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public StrBuilder minimizeCapacity() {
if (buffer.length > length()) {
- char[] old = buffer;
+ final char[] old = buffer;
buffer = new char[length()];
System.arraycopy(old, 0, buffer, 0, size);
}
@@ -357,7 +357,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (size == 0) {
return ArrayUtils.EMPTY_CHAR_ARRAY;
}
- char chars[] = new char[size];
+ final char chars[] = new char[size];
System.arraycopy(buffer, 0, chars, 0, size);
return chars;
}
@@ -374,11 +374,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public char[] toCharArray(final int startIndex, int endIndex) {
endIndex = validateRange(startIndex, endIndex);
- int len = endIndex - startIndex;
+ final int len = endIndex - startIndex;
if (len == 0) {
return ArrayUtils.EMPTY_CHAR_ARRAY;
}
- char chars[] = new char[len];
+ final char chars[] = new char[len];
System.arraycopy(buffer, startIndex, chars, 0, len);
return chars;
}
@@ -390,7 +390,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return the input array, unless that was null or too small
*/
public char[] getChars(char[] destination) {
- int len = length();
+ final int len = length();
if (destination == null || destination.length < len) {
destination = new char[len];
}
@@ -510,9 +510,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
return appendNull();
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + strLen);
str.getChars(0, strLen, buffer, len);
size += strLen;
@@ -541,7 +541,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
throw new StringIndexOutOfBoundsException("length must be valid");
}
if (length > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + length);
str.getChars(startIndex, startIndex + length, buffer, len);
size += length;
@@ -573,9 +573,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
return appendNull();
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + strLen);
str.getChars(0, strLen, buffer, len);
size += strLen;
@@ -603,7 +603,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
throw new StringIndexOutOfBoundsException("length must be valid");
}
if (length > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + length);
str.getChars(startIndex, startIndex + length, buffer, len);
size += length;
@@ -623,9 +623,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
return appendNull();
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + strLen);
str.getChars(0, strLen, buffer, len);
size += strLen;
@@ -654,7 +654,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
throw new StringIndexOutOfBoundsException("length must be valid");
}
if (length > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + length);
str.getChars(startIndex, startIndex + length, buffer, len);
size += length;
@@ -673,9 +673,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
return appendNull();
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + strLen);
System.arraycopy(str.buffer, 0, buffer, len, strLen);
size += strLen;
@@ -703,7 +703,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
throw new StringIndexOutOfBoundsException("length must be valid");
}
if (length > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + length);
str.getChars(startIndex, startIndex + length, buffer, len);
size += length;
@@ -722,9 +722,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (chars == null) {
return appendNull();
}
- int strLen = chars.length;
+ final int strLen = chars.length;
if (strLen > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + strLen);
System.arraycopy(chars, 0, buffer, len, strLen);
size += strLen;
@@ -752,7 +752,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
throw new StringIndexOutOfBoundsException("Invalid length: " + length);
}
if (length > 0) {
- int len = length();
+ final int len = length();
ensureCapacity(len + length);
System.arraycopy(chars, startIndex, buffer, len, length);
size += length;
@@ -793,7 +793,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
@Override
public StrBuilder append(final char ch) {
- int len = length();
+ final int len = length();
ensureCapacity(len + 1);
buffer[size++] = ch;
return this;
@@ -1073,7 +1073,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public <T> StrBuilder appendAll(final T... array) {
if (array != null && array.length > 0) {
- for (Object element : array) {
+ for (final Object element : array) {
append(element);
}
}
@@ -1091,7 +1091,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public StrBuilder appendAll(final Iterable<?> iterable) {
if (iterable != null) {
- for (Object o : iterable) {
+ for (final Object o : iterable) {
append(o);
}
}
@@ -1152,7 +1152,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
public StrBuilder appendWithSeparators(final Iterable<?> iterable, String separator) {
if (iterable != null) {
separator = ObjectUtils.toString(separator);
- Iterator<?> it = iterable.iterator();
+ final Iterator<?> it = iterable.iterator();
while (it.hasNext()) {
append(it.next());
if (it.hasNext()) {
@@ -1239,7 +1239,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @since 2.5
*/
public StrBuilder appendSeparator(final String standard, final String defaultIfEmpty) {
- String str = isEmpty() ? defaultIfEmpty : standard;
+ final String str = isEmpty() ? defaultIfEmpty : standard;
if (str != null) {
append(str);
}
@@ -1383,11 +1383,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
str = "";
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen >= width) {
str.getChars(strLen - width, strLen, buffer, size);
} else {
- int padLen = width - strLen;
+ final int padLen = width - strLen;
for (int i = 0; i < padLen; i++) {
buffer[size + i] = padChar;
}
@@ -1430,11 +1430,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
str = "";
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen >= width) {
str.getChars(0, width, buffer, size);
} else {
- int padLen = width - strLen;
+ final int padLen = width - strLen;
str.getChars(0, strLen, buffer, size);
for (int i = 0; i < padLen; i++) {
buffer[size + strLen + i] = padChar;
@@ -1491,9 +1491,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
str = nullText;
}
- int strLen = (str == null ? 0 : str.length());
+ final int strLen = (str == null ? 0 : str.length());
if (strLen > 0) {
- int newSize = size + strLen;
+ final int newSize = size + strLen;
ensureCapacity(newSize);
System.arraycopy(buffer, index, buffer, index + strLen, size - index);
size = newSize;
@@ -1516,7 +1516,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (chars == null) {
return insert(index, nullText);
}
- int len = chars.length;
+ final int len = chars.length;
if (len > 0) {
ensureCapacity(size + len);
System.arraycopy(buffer, index, buffer, index + len, size - index);
@@ -1678,7 +1678,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public StrBuilder delete(final int startIndex, int endIndex) {
endIndex = validateRange(startIndex, endIndex);
- int len = endIndex - startIndex;
+ final int len = endIndex - startIndex;
if (len > 0) {
deleteImpl(startIndex, endIndex, len);
}
@@ -1695,13 +1695,13 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
public StrBuilder deleteAll(final char ch) {
for (int i = 0; i < size; i++) {
if (buffer[i] == ch) {
- int start = i;
+ final int start = i;
while (++i < size) {
if (buffer[i] != ch) {
break;
}
}
- int len = i - start;
+ final int len = i - start;
deleteImpl(start, i, len);
i -= len;
}
@@ -1733,7 +1733,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return this, to enable chaining
*/
public StrBuilder deleteAll(final String str) {
- int len = (str == null ? 0 : str.length());
+ final int len = (str == null ? 0 : str.length());
if (len > 0) {
int index = indexOf(str, 0);
while (index >= 0) {
@@ -1751,9 +1751,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return this, to enable chaining
*/
public StrBuilder deleteFirst(final String str) {
- int len = (str == null ? 0 : str.length());
+ final int len = (str == null ? 0 : str.length());
if (len > 0) {
- int index = indexOf(str, 0);
+ final int index = indexOf(str, 0);
if (index >= 0) {
deleteImpl(index, index + len, len);
}
@@ -1802,7 +1802,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @throws IndexOutOfBoundsException if any index is invalid
*/
private void replaceImpl(final int startIndex, final int endIndex, final int removeLen, final String insertStr, final int insertLen) {
- int newSize = size - removeLen + insertLen;
+ final int newSize = size - removeLen + insertLen;
if (insertLen != removeLen) {
ensureCapacity(newSize);
System.arraycopy(buffer, endIndex, buffer, startIndex + insertLen, size - endIndex);
@@ -1826,7 +1826,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public StrBuilder replace(final int startIndex, int endIndex, final String replaceStr) {
endIndex = validateRange(startIndex, endIndex);
- int insertLen = (replaceStr == null ? 0 : replaceStr.length());
+ final int insertLen = (replaceStr == null ? 0 : replaceStr.length());
replaceImpl(startIndex, endIndex, endIndex - startIndex, replaceStr, insertLen);
return this;
}
@@ -1880,9 +1880,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return this, to enable chaining
*/
public StrBuilder replaceAll(final String searchStr, final String replaceStr) {
- int searchLen = (searchStr == null ? 0 : searchStr.length());
+ final int searchLen = (searchStr == null ? 0 : searchStr.length());
if (searchLen > 0) {
- int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+ final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
int index = indexOf(searchStr, 0);
while (index >= 0) {
replaceImpl(index, index + searchLen, searchLen, replaceStr, replaceLen);
@@ -1900,11 +1900,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return this, to enable chaining
*/
public StrBuilder replaceFirst(final String searchStr, final String replaceStr) {
- int searchLen = (searchStr == null ? 0 : searchStr.length());
+ final int searchLen = (searchStr == null ? 0 : searchStr.length());
if (searchLen > 0) {
- int index = indexOf(searchStr, 0);
+ final int index = indexOf(searchStr, 0);
if (index >= 0) {
- int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+ final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
replaceImpl(index, index + searchLen, searchLen, replaceStr, replaceLen);
}
}
@@ -1987,10 +1987,10 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (matcher == null || size == 0) {
return this;
}
- int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
- char[] buf = buffer;
+ final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+ final char[] buf = buffer;
for (int i = from; i < to && replaceCount != 0; i++) {
- int removeLen = matcher.isMatch(buf, i, from, to);
+ final int removeLen = matcher.isMatch(buf, i, from, to);
if (removeLen > 0) {
replaceImpl(i, i + removeLen, removeLen, replaceStr, replaceLen);
to = to - removeLen + replaceLen;
@@ -2014,10 +2014,10 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
return this;
}
- int half = size / 2;
- char[] buf = buffer;
+ final int half = size / 2;
+ final char[] buf = buffer;
for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++,rightIdx--) {
- char swap = buf[leftIdx];
+ final char swap = buf[leftIdx];
buf[leftIdx] = buf[rightIdx];
buf[rightIdx] = swap;
}
@@ -2036,7 +2036,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
return this;
}
int len = size;
- char[] buf = buffer;
+ final char[] buf = buffer;
int pos = 0;
while (pos < len && buf[pos] <= ' ') {
pos++;
@@ -2066,7 +2066,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
return false;
}
- int len = str.length();
+ final int len = str.length();
if (len == 0) {
return true;
}
@@ -2093,7 +2093,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null) {
return false;
}
- int len = str.length();
+ final int len = str.length();
if (len == 0) {
return true;
}
@@ -2239,7 +2239,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return true if the builder contains the character
*/
public boolean contains(final char ch) {
- char[] thisBuf = buffer;
+ final char[] thisBuf = buffer;
for (int i = 0; i < this.size; i++) {
if (thisBuf[i] == ch) {
return true;
@@ -2296,7 +2296,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (startIndex >= size) {
return -1;
}
- char[] thisBuf = buffer;
+ final char[] thisBuf = buffer;
for (int i = startIndex; i < size; i++) {
if (thisBuf[i] == ch) {
return i;
@@ -2332,7 +2332,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null || startIndex >= size) {
return -1;
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen == 1) {
return indexOf(str.charAt(0), startIndex);
}
@@ -2342,8 +2342,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (strLen > size) {
return -1;
}
- char[] thisBuf = buffer;
- int len = size - strLen + 1;
+ final char[] thisBuf = buffer;
+ final int len = size - strLen + 1;
outer:
for (int i = startIndex; i < len; i++) {
for (int j = 0; j < strLen; j++) {
@@ -2387,8 +2387,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (matcher == null || startIndex >= size) {
return -1;
}
- int len = size;
- char[] buf = buffer;
+ final int len = size;
+ final char[] buf = buffer;
for (int i = startIndex; i < len; i++) {
if (matcher.isMatch(buf, i, startIndex, len) > 0) {
return i;
@@ -2455,7 +2455,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (str == null || startIndex < 0) {
return -1;
}
- int strLen = str.length();
+ final int strLen = str.length();
if (strLen > 0 && strLen <= size) {
if (strLen == 1) {
return lastIndexOf(str.charAt(0), startIndex);
@@ -2508,8 +2508,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (matcher == null || startIndex < 0) {
return -1;
}
- char[] buf = buffer;
- int endIndex = startIndex + 1;
+ final char[] buf = buffer;
+ final int endIndex = startIndex + 1;
for (int i = startIndex; i >= 0; i--) {
if (matcher.isMatch(buf, i, 0, endIndex) > 0) {
return i;
@@ -2649,11 +2649,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (this.size != other.size) {
return false;
}
- char thisBuf[] = this.buffer;
- char otherBuf[] = other.buffer;
+ final char thisBuf[] = this.buffer;
+ final char otherBuf[] = other.buffer;
for (int i = size - 1; i >= 0; i--) {
- char c1 = thisBuf[i];
- char c2 = otherBuf[i];
+ final char c1 = thisBuf[i];
+ final char c2 = otherBuf[i];
if (c1 != c2 && Character.toUpperCase(c1) != Character.toUpperCase(c2)) {
return false;
}
@@ -2675,8 +2675,8 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
if (this.size != other.size) {
return false;
}
- char thisBuf[] = this.buffer;
- 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;
@@ -2707,7 +2707,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
@Override
public int hashCode() {
- char buf[] = buffer;
+ final char buf[] = buffer;
int hash = 0;
for (int i = size - 1; i >= 0; i--) {
hash = 31 * hash + buf[i];
@@ -2823,7 +2823,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
/** {@inheritDoc} */
@Override
public String getContent() {
- String str = super.getContent();
+ final String str = super.getContent();
if (str == null) {
return StrBuilder.this.toString();
} else {
diff --git a/src/main/java/org/apache/commons/lang3/text/StrLookup.java b/src/main/java/org/apache/commons/lang3/text/StrLookup.java
index edfe576ca..3459f680b 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrLookup.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrLookup.java
@@ -52,7 +52,7 @@ public abstract class StrLookup<V> {
@SuppressWarnings("unchecked") // System property keys and values are always Strings
final Map<String, String> properties = (Map<String, String>) propMap;
lookup = new MapStrLookup<String>(properties);
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
lookup = NONE_LOOKUP;
}
SYSTEM_PROPERTIES_LOOKUP = lookup;
@@ -162,7 +162,7 @@ public abstract class StrLookup<V> {
if (map == null) {
return null;
}
- Object obj = map.get(key);
+ final Object obj = map.get(key);
if (obj == null) {
return null;
}
diff --git a/src/main/java/org/apache/commons/lang3/text/StrMatcher.java b/src/main/java/org/apache/commons/lang3/text/StrMatcher.java
index df1309671..15148185b 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrMatcher.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrMatcher.java
@@ -364,7 +364,7 @@ public abstract class StrMatcher {
*/
@Override
public int isMatch(final char[] buffer, int pos, final int bufferStart, final int bufferEnd) {
- int len = chars.length;
+ final int len = chars.length;
if (pos + len > bufferEnd) {
return 0;
}
diff --git a/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java b/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java
index 0912af554..4f65f727d 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java
@@ -179,11 +179,11 @@ public class StrSubstitutor {
if (valueProperties == null) {
return source.toString();
}
- Map<String,String> valueMap = new HashMap<String,String>();
- Enumeration<?> propNames = valueProperties.propertyNames();
+ final Map<String,String> valueMap = new HashMap<String,String>();
+ final Enumeration<?> propNames = valueProperties.propertyNames();
while (propNames.hasMoreElements()) {
- String propName = (String)propNames.nextElement();
- String propValue = valueProperties.getProperty(propName);
+ final String propName = (String)propNames.nextElement();
+ final String propValue = valueProperties.getProperty(propName);
valueMap.put(propName, propValue);
}
return StrSubstitutor.replace(source, valueMap);
@@ -301,7 +301,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(source);
+ final StrBuilder buf = new StrBuilder(source);
if (substitute(buf, 0, source.length()) == false) {
return source;
}
@@ -324,7 +324,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(length).append(source, offset, length);
+ final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
if (substitute(buf, 0, length) == false) {
return source.substring(offset, offset + length);
}
@@ -344,7 +344,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(source.length).append(source);
+ final StrBuilder buf = new StrBuilder(source.length).append(source);
substitute(buf, 0, source.length);
return buf.toString();
}
@@ -366,7 +366,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(length).append(source, offset, length);
+ final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
substitute(buf, 0, length);
return buf.toString();
}
@@ -384,7 +384,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(source.length()).append(source);
+ final StrBuilder buf = new StrBuilder(source.length()).append(source);
substitute(buf, 0, buf.length());
return buf.toString();
}
@@ -406,7 +406,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(length).append(source, offset, length);
+ final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
substitute(buf, 0, length);
return buf.toString();
}
@@ -424,7 +424,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(source.length()).append(source);
+ final StrBuilder buf = new StrBuilder(source.length()).append(source);
substitute(buf, 0, buf.length());
return buf.toString();
}
@@ -446,7 +446,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder(length).append(source, offset, length);
+ final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
substitute(buf, 0, length);
return buf.toString();
}
@@ -464,7 +464,7 @@ public class StrSubstitutor {
if (source == null) {
return null;
}
- StrBuilder buf = new StrBuilder().append(source);
+ final StrBuilder buf = new StrBuilder().append(source);
substitute(buf, 0, buf.length());
return buf.toString();
}
@@ -502,7 +502,7 @@ public class StrSubstitutor {
if (source == null) {
return false;
}
- StrBuilder buf = new StrBuilder(length).append(source, offset, length);
+ final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
if (substitute(buf, 0, length) == false) {
return false;
}
@@ -576,18 +576,18 @@ public class StrSubstitutor {
* represents a boolean flag as to whether any change occurred.
*/
private int substitute(final StrBuilder buf, final int offset, final int length, List<String> priorVariables) {
- StrMatcher prefixMatcher = getVariablePrefixMatcher();
- StrMatcher suffixMatcher = getVariableSuffixMatcher();
- char escape = getEscapeChar();
+ final StrMatcher prefixMatcher = getVariablePrefixMatcher();
+ final StrMatcher suffixMatcher = getVariableSuffixMatcher();
+ final char escape = getEscapeChar();
- boolean top = priorVariables == null;
+ final boolean top = priorVariables == null;
boolean altered = false;
int lengthChange = 0;
char[] chars = buf.buffer;
int bufEnd = offset + length;
int pos = offset;
while (pos < bufEnd) {
- int startMatchLen = prefixMatcher.isMatch(chars, pos, offset,
+ final int startMatchLen = prefixMatcher.isMatch(chars, pos, offset,
bufEnd);
if (startMatchLen == 0) {
pos++;
@@ -602,7 +602,7 @@ public class StrSubstitutor {
bufEnd--;
} else {
// find suffix
- int startPos = pos;
+ final int startPos = pos;
pos += startMatchLen;
int endMatchLen = 0;
int nestedVarCount = 0;
@@ -627,12 +627,12 @@ public class StrSubstitutor {
+ startMatchLen, pos - startPos
- startMatchLen);
if (isEnableSubstitutionInVariables()) {
- StrBuilder bufName = new StrBuilder(varName);
+ final StrBuilder bufName = new StrBuilder(varName);
substitute(bufName, 0, bufName.length());
varName = bufName.toString();
}
pos += endMatchLen;
- int endPos = pos;
+ final int endPos = pos;
// on the first call initialize priorVariables
if (priorVariables == null) {
@@ -646,11 +646,11 @@ public class StrSubstitutor {
priorVariables.add(varName);
// resolve the variable
- String varValue = resolveVariable(varName, buf,
+ final String varValue = resolveVariable(varName, buf,
startPos, endPos);
if (varValue != null) {
// recursive replace
- int varLen = varValue.length();
+ final int varLen = varValue.length();
buf.replace(startPos, endPos, varValue);
altered = true;
int change = substitute(buf, startPos,
@@ -693,7 +693,7 @@ public class StrSubstitutor {
if (priorVariables.contains(varName) == false) {
return;
}
- StrBuilder buf = new StrBuilder(256);
+ final StrBuilder buf = new StrBuilder(256);
buf.append("Infinite loop in property interpolation of ");
buf.append(priorVariables.remove(0));
buf.append(": ");
@@ -719,7 +719,7 @@ public class StrSubstitutor {
* @return the variable's value or <b>null</b> if the variable is unknown
*/
protected String resolveVariable(final String variableName, final StrBuilder buf, final int startPos, final int endPos) {
- StrLookup<?> resolver = getVariableResolver();
+ final StrLookup<?> resolver = getVariableResolver();
if (resolver == null) {
return null;
}
diff --git a/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java b/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java
index 2412424a3..7430b1cb5 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java
@@ -162,7 +162,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
* @return a new tokenizer instance which parses Comma Separated Value strings
*/
public static StrTokenizer getCSVInstance(final String input) {
- StrTokenizer tok = getCSVClone();
+ final StrTokenizer tok = getCSVClone();
tok.reset(input);
return tok;
}
@@ -177,7 +177,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
* @return a new tokenizer instance which parses Comma Separated Value strings
*/
public static StrTokenizer getCSVInstance(final char[] input) {
- StrTokenizer tok = getCSVClone();
+ final StrTokenizer tok = getCSVClone();
tok.reset(input);
return tok;
}
@@ -212,7 +212,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
* @return a new tokenizer instance which parses Tab Separated Value strings.
*/
public static StrTokenizer getTSVInstance(final String input) {
- StrTokenizer tok = getTSVClone();
+ final StrTokenizer tok = getTSVClone();
tok.reset(input);
return tok;
}
@@ -225,7 +225,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
* @return a new tokenizer instance which parses Tab Separated Value strings.
*/
public static StrTokenizer getTSVInstance(final char[] input) {
- StrTokenizer tok = getTSVClone();
+ final StrTokenizer tok = getTSVClone();
tok.reset(input);
return tok;
}
@@ -441,8 +441,8 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
*/
public List<String> getTokenList() {
checkTokenized();
- List<String> list = new ArrayList<String>(tokens.length);
- for (String element : tokens) {
+ final List<String> list = new ArrayList<String>(tokens.length);
+ for (final String element : tokens) {
list.add(element);
}
return list;
@@ -603,10 +603,10 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
if (tokens == null) {
if (chars == null) {
// still call tokenize as subclass may do some work
- List<String> split = tokenize(null, 0, 0);
+ final List<String> split = tokenize(null, 0, 0);
tokens = split.toArray(new String[split.size()]);
} else {
- List<String> split = tokenize(chars, 0, chars.length);
+ final List<String> split = tokenize(chars, 0, chars.length);
tokens = split.toArray(new String[split.size()]);
}
}
@@ -636,8 +636,8 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
if (chars == null || count == 0) {
return Collections.emptyList();
}
- StrBuilder buf = new StrBuilder();
- List<String> tokens = new ArrayList<String>();
+ final StrBuilder buf = new StrBuilder();
+ final List<String> tokens = new ArrayList<String>();
int pos = offset;
// loop around the entire buffer
@@ -686,7 +686,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
// skip all leading whitespace, unless it is the
// field delimiter or the quote character
while (start < len) {
- int removeLen = Math.max(
+ final int removeLen = Math.max(
getIgnoredMatcher().isMatch(chars, start, start, len),
getTrimmerMatcher().isMatch(chars, start, start, len));
if (removeLen == 0 ||
@@ -704,14 +704,14 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
}
// handle empty token
- int delimLen = getDelimiterMatcher().isMatch(chars, start, start, len);
+ final int delimLen = getDelimiterMatcher().isMatch(chars, start, start, len);
if (delimLen > 0) {
addToken(tokens, "");
return start + delimLen;
}
// handle found token
- int quoteLen = getQuoteMatcher().isMatch(chars, start, start, len);
+ final int quoteLen = getQuoteMatcher().isMatch(chars, start, start, len);
if (quoteLen > 0) {
return readWithQuotes(chars, start + quoteLen, len, workArea, tokens, start, quoteLen);
}
@@ -775,7 +775,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
// Not in quoting mode
// check for delimiter, and thus end of token
- int delimLen = getDelimiterMatcher().isMatch(chars, pos, start, len);
+ final int delimLen = getDelimiterMatcher().isMatch(chars, pos, start, len);
if (delimLen > 0) {
// return condition when end of token found
addToken(tokens, workArea.substring(0, trimStart));
@@ -790,7 +790,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
}
// check for ignored (outside quotes), and ignore
- int ignoredLen = getIgnoredMatcher().isMatch(chars, pos, start, len);
+ final int ignoredLen = getIgnoredMatcher().isMatch(chars, pos, start, len);
if (ignoredLen > 0) {
pos += ignoredLen;
continue;
@@ -799,7 +799,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
// check for trimmed character
// don't yet know if its at the end, so copy to workArea
// use trimStart to keep track of trim at the end
- int trimmedLen = getTrimmerMatcher().isMatch(chars, pos, start, len);
+ final int trimmedLen = getTrimmerMatcher().isMatch(chars, pos, start, len);
if (trimmedLen > 0) {
workArea.append(chars, pos, trimmedLen);
pos += trimmedLen;
@@ -1075,7 +1075,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
public Object clone() {
try {
return cloneReset();
- } catch (CloneNotSupportedException ex) {
+ } catch (final CloneNotSupportedException ex) {
return null;
}
}
@@ -1089,7 +1089,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
*/
Object cloneReset() throws CloneNotSupportedException {
// this method exists to enable 100% test coverage
- StrTokenizer cloned = (StrTokenizer) super.clone();
+ final StrTokenizer cloned = (StrTokenizer) super.clone();
if (cloned.chars != null) {
cloned.chars = cloned.chars.clone();
}
diff --git a/src/main/java/org/apache/commons/lang3/text/WordUtils.java b/src/main/java/org/apache/commons/lang3/text/WordUtils.java
index 1faec9eec..7f29b59f8 100644
--- a/src/main/java/org/apache/commons/lang3/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/lang3/text/WordUtils.java
@@ -95,9 +95,9 @@ public class WordUtils {
if (wrapLength < 1) {
wrapLength = 1;
}
- int inputLineLength = str.length();
+ final int inputLineLength = str.length();
int offset = 0;
- StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
+ final StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
while (inputLineLength - offset > wrapLength) {
if (str.charAt(offset) == ' ') {
@@ -198,14 +198,14 @@ public class WordUtils {
* @since 2.1
*/
public static String capitalize(final String str, final char... delimiters) {
- int delimLen = delimiters == null ? -1 : delimiters.length;
+ final int delimLen = delimiters == null ? -1 : delimiters.length;
if (StringUtils.isEmpty(str) || delimLen == 0) {
return str;
}
- char[] buffer = str.toCharArray();
+ final char[] buffer = str.toCharArray();
boolean capitalizeNext = true;
for (int i = 0; i < buffer.length; i++) {
- char ch = buffer[i];
+ final char ch = buffer[i];
if (isDelimiter(ch, delimiters)) {
capitalizeNext = true;
} else if (capitalizeNext) {
@@ -267,7 +267,7 @@ public class WordUtils {
* @since 2.1
*/
public static String capitalizeFully(String str, final char... delimiters) {
- int delimLen = delimiters == null ? -1 : delimiters.length;
+ final int delimLen = delimiters == null ? -1 : delimiters.length;
if (StringUtils.isEmpty(str) || delimLen == 0) {
return str;
}
@@ -323,14 +323,14 @@ public class WordUtils {
* @since 2.1
*/
public static String uncapitalize(final String str, final char... delimiters) {
- int delimLen = delimiters == null ? -1 : delimiters.length;
+ final int delimLen = delimiters == null ? -1 : delimiters.length;
if (StringUtils.isEmpty(str) || delimLen == 0) {
return str;
}
- char[] buffer = str.toCharArray();
+ final char[] buffer = str.toCharArray();
boolean uncapitalizeNext = true;
for (int i = 0; i < buffer.length; i++) {
- char ch = buffer[i];
+ final char ch = buffer[i];
if (isDelimiter(ch, delimiters)) {
uncapitalizeNext = true;
} else if (uncapitalizeNext) {
@@ -368,12 +368,12 @@ public class WordUtils {
if (StringUtils.isEmpty(str)) {
return str;
}
- char[] buffer = str.toCharArray();
+ final char[] buffer = str.toCharArray();
boolean whitespace = true;
for (int i = 0; i < buffer.length; i++) {
- char ch = buffer[i];
+ final char ch = buffer[i];
if (Character.isUpperCase(ch)) {
buffer[i] = Character.toLowerCase(ch);
whitespace = false;
@@ -455,12 +455,12 @@ public class WordUtils {
if (delimiters != null && delimiters.length == 0) {
return "";
}
- int strLen = str.length();
- char[] buf = new char[strLen / 2 + 1];
+ final int strLen = str.length();
+ final char[] buf = new char[strLen / 2 + 1];
int count = 0;
boolean lastWasGap = true;
for (int i = 0; i < strLen; i++) {
- char ch = str.charAt(i);
+ final char ch = str.charAt(i);
if (isDelimiter(ch, delimiters)) {
lastWasGap = true;
@@ -486,7 +486,7 @@ public class WordUtils {
if (delimiters == null) {
return Character.isWhitespace(ch);
}
- for (char delimiter : delimiters) {
+ for (final char delimiter : delimiters) {
if (ch == delimiter) {
return true;
}
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java
index 8e871194a..51e4e1d7d 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java
@@ -48,8 +48,8 @@ public class AggregateTranslator extends CharSequenceTranslator {
*/
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
- for (CharSequenceTranslator translator : translators) {
- int consumed = translator.translate(input, index, out);
+ for (final CharSequenceTranslator translator : translators) {
+ final int consumed = translator.translate(input, index, out);
if(consumed != 0) {
return consumed;
}
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java
index 265528a1a..0ed29282d 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java
@@ -55,10 +55,10 @@ public abstract class CharSequenceTranslator {
return null;
}
try {
- StringWriter writer = new StringWriter(input.length() * 2);
+ final StringWriter writer = new StringWriter(input.length() * 2);
translate(input, writer);
return writer.toString();
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
// this should never ever happen while writing to a StringWriter
throw new RuntimeException(ioe);
}
@@ -80,11 +80,11 @@ public abstract class CharSequenceTranslator {
return;
}
int pos = 0;
- int len = input.length();
+ final int len = input.length();
while (pos < len) {
- int consumed = translate(input, pos, out);
+ final int consumed = translate(input, pos, out);
if (consumed == 0) {
- char[] c = Character.toChars(Character.codePointAt(input, pos));
+ final char[] c = Character.toChars(Character.codePointAt(input, pos));
out.write(c);
pos+= c.length;
continue;
@@ -105,7 +105,7 @@ public abstract class CharSequenceTranslator {
* @return CharSequenceTranslator merging this translator with the others
*/
public final CharSequenceTranslator with(final CharSequenceTranslator... translators) {
- CharSequenceTranslator[] newArray = new CharSequenceTranslator[translators.length + 1];
+ final CharSequenceTranslator[] newArray = new CharSequenceTranslator[translators.length + 1];
newArray[0] = this;
System.arraycopy(translators, 0, newArray, 1, translators.length);
return new AggregateTranslator(newArray);
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java
index d0da17e9d..e18756c2c 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java
@@ -34,8 +34,8 @@ public abstract class CodePointTranslator extends CharSequenceTranslator {
*/
@Override
public final int translate(final CharSequence input, final int index, final Writer out) throws IOException {
- int codepoint = Character.codePointAt(input, index);
- boolean consumed = translate(codepoint, out);
+ final int codepoint = Character.codePointAt(input, index);
+ final boolean consumed = translate(codepoint, out);
if (consumed) {
return 1;
} else {
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
index 26e4681b0..23695758f 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
@@ -414,7 +414,7 @@ public class EntityArrays {
* @return String[][] inverted array
*/
public static String[][] invert(final String[][] array) {
- String[][] newarray = new String[array.length][2];
+ final String[][] newarray = new String[array.length][2];
for(int i = 0; i<array.length; i++) {
newarray[i][0] = array[i][1];
newarray[i][1] = array[i][0];
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java b/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java
index f18462d87..03ec7df19 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java
@@ -90,7 +90,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
*/
@Override
protected String toUtf16Escape(final int codepoint) {
- char[] surrogatePair = Character.toChars(codepoint);
+ final char[] surrogatePair = Character.toChars(codepoint);
return "\\u" + hex(surrogatePair[0]) + "\\u" + hex(surrogatePair[1]);
}
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java
index ad3eda844..72d69299c 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java
@@ -42,9 +42,9 @@ public class LookupTranslator extends CharSequenceTranslator {
int _shortest = Integer.MAX_VALUE;
int _longest = 0;
if (lookup != null) {
- for (CharSequence[] seq : lookup) {
+ for (final CharSequence[] seq : lookup) {
this.lookupMap.put(seq[0], seq[1]);
- int sz = seq[0].length();
+ final int sz = seq[0].length();
if (sz < _shortest) {
_shortest = sz;
}
@@ -68,8 +68,8 @@ public class LookupTranslator extends CharSequenceTranslator {
}
// descend so as to get a greedy algorithm
for (int i = max; i >= shortest; i--) {
- CharSequence subSeq = input.subSequence(index, index + i);
- CharSequence result = lookupMap.get(subSeq);
+ final CharSequence subSeq = input.subSequence(index, index + i);
+ final CharSequence result = lookupMap.get(subSeq);
if (result != null) {
out.write(result.toString());
return i;
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
index 9ff4d5851..a0744f9af 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
@@ -76,13 +76,13 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
*/
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
- int seqEnd = input.length();
+ final int seqEnd = input.length();
// Uses -2 to ensure there is something after the &#
if(input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {
int start = index + 2;
boolean isHex = false;
- char firstChar = input.charAt(start);
+ final char firstChar = input.charAt(start);
if(firstChar == 'x' || firstChar == 'X') {
start++;
isHex = true;
@@ -102,7 +102,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
end++;
}
- boolean semiNext = end != seqEnd && input.charAt(end) == ';';
+ final boolean semiNext = end != seqEnd && input.charAt(end) == ';';
if(!semiNext) {
if(isSet(OPTION.semiColonRequired)) {
@@ -120,12 +120,12 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
} else {
entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 10);
}
- } catch(NumberFormatException nfe) {
+ } catch(final NumberFormatException nfe) {
return 0;
}
if(entityValue > 0xFFFF) {
- char[] chrs = Character.toChars(entityValue);
+ final char[] chrs = Character.toChars(entityValue);
out.write(chrs[0]);
out.write(chrs[1]);
} else {
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
index e0271489d..52b40c432 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
@@ -41,7 +41,7 @@ public class OctalUnescaper extends CharSequenceTranslator {
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
if(input.charAt(index) == '\\' && index < (input.length() - 1) && Character.isDigit(input.charAt(index + 1)) ) {
- int start = index + 1;
+ final int start = index + 1;
int end = index + 2;
while ( end < input.length() && Character.isDigit(input.charAt(end)) ) {
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
index 50bf5045a..3c477d41f 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
@@ -47,12 +47,12 @@ public class UnicodeUnescaper extends CharSequenceTranslator {
if (index + i + 4 <= input.length()) {
// Get 4 hex digits
- CharSequence unicode = input.subSequence(index + i, index + i + 4);
+ final CharSequence unicode = input.subSequence(index + i, index + i + 4);
try {
- int value = Integer.parseInt(unicode.toString(), 16);
+ final int value = Integer.parseInt(unicode.toString(), 16);
out.write((char) value);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
throw new IllegalArgumentException("Unable to parse unicode value: " + unicode, nfe);
}
return i + 4;
diff --git a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
index f525171ad..be671a928 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
@@ -300,7 +300,7 @@ public class DateFormatUtils {
* @return the formatted date
*/
public static String format(final Date date, final String pattern, final TimeZone timeZone, final Locale locale) {
- FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
+ final FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
return df.format(date);
}
@@ -316,7 +316,7 @@ public class DateFormatUtils {
* @since 2.4
*/
public static String format(final Calendar calendar, final String pattern, final TimeZone timeZone, final Locale locale) {
- FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
+ final FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
return df.format(calendar);
}
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index 93931d3bf..b16af53d4 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -155,9 +155,9 @@ public class DateUtils {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar cal1 = Calendar.getInstance();
+ final Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
- Calendar cal2 = Calendar.getInstance();
+ final Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return isSameDay(cal1, cal2);
}
@@ -363,8 +363,8 @@ public class DateUtils {
}
parser.setLenient(lenient);
- ParsePosition pos = new ParsePosition(0);
- for (String parsePattern : parsePatterns) {
+ final ParsePosition pos = new ParsePosition(0);
+ for (final String parsePattern : parsePatterns) {
String pattern = parsePattern;
@@ -382,7 +382,7 @@ public class DateUtils {
str2 = str.replaceAll("([-+][0-9][0-9]):([0-9][0-9])$", "$1$2");
}
- Date date = parser.parse(str2, pos);
+ final Date date = parser.parse(str2, pos);
if (date != null && pos.getIndex() == str2.length()) {
return date;
}
@@ -517,7 +517,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar c = Calendar.getInstance();
+ final Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
@@ -647,7 +647,7 @@ public class DateUtils {
throw new IllegalArgumentException("The date must not be null");
}
// getInstance() returns a new object, so this method is thread safe.
- Calendar c = Calendar.getInstance();
+ final Calendar c = Calendar.getInstance();
c.setLenient(false);
c.setTime(date);
c.set(calendarField, amount);
@@ -664,7 +664,7 @@ public class DateUtils {
* @since 3.0
*/
public static Calendar toCalendar(final Date date) {
- Calendar c = Calendar.getInstance();
+ final Calendar c = Calendar.getInstance();
c.setTime(date);
return c;
}
@@ -700,7 +700,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(date);
modify(gval, field, MODIFY_ROUND);
return gval.getTime();
@@ -737,7 +737,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar rounded = (Calendar) date.clone();
+ final Calendar rounded = (Calendar) date.clone();
modify(rounded, field, MODIFY_ROUND);
return rounded;
}
@@ -803,7 +803,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(date);
modify(gval, field, MODIFY_TRUNCATE);
return gval.getTime();
@@ -828,7 +828,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar truncated = (Calendar) date.clone();
+ final Calendar truncated = (Calendar) date.clone();
modify(truncated, field, MODIFY_TRUNCATE);
return truncated;
}
@@ -883,7 +883,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(date);
modify(gval, field, MODIFY_CEILING);
return gval.getTime();
@@ -909,7 +909,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar ceiled = (Calendar) date.clone();
+ final Calendar ceiled = (Calendar) date.clone();
modify(ceiled, field, MODIFY_CEILING);
return ceiled;
}
@@ -968,12 +968,12 @@ public class DateUtils {
// Manually truncate milliseconds, seconds and minutes, rather than using
// Calendar methods.
- Date date = val.getTime();
+ final Date date = val.getTime();
long time = date.getTime();
boolean done = false;
// truncate milliseconds
- int millisecs = val.get(Calendar.MILLISECOND);
+ final int millisecs = val.get(Calendar.MILLISECOND);
if (MODIFY_TRUNCATE == modType || millisecs < 500) {
time = time - millisecs;
}
@@ -982,7 +982,7 @@ public class DateUtils {
}
// truncate seconds
- int seconds = val.get(Calendar.SECOND);
+ final int seconds = val.get(Calendar.SECOND);
if (!done && (MODIFY_TRUNCATE == modType || seconds < 30)) {
time = time - (seconds * 1000L);
}
@@ -991,7 +991,7 @@ public class DateUtils {
}
// truncate minutes
- int minutes = val.get(Calendar.MINUTE);
+ final int minutes = val.get(Calendar.MINUTE);
if (!done && (MODIFY_TRUNCATE == modType || minutes < 30)) {
time = time - (minutes * 60000L);
}
@@ -1004,8 +1004,8 @@ public class DateUtils {
// ----------------- Fix for LANG-59 ----------------------- END ----------------
boolean roundUp = false;
- for (int[] aField : fields) {
- for (int element : aField) {
+ for (final int[] aField : fields) {
+ for (final int element : aField) {
if (element == field) {
//This is our field... we stop looping
if (modType == MODIFY_CEILING || (modType == MODIFY_ROUND && roundUp)) {
@@ -1075,8 +1075,8 @@ public class DateUtils {
break;
}
if (!offsetSet) {
- int min = val.getActualMinimum(aField[0]);
- int max = val.getActualMaximum(aField[0]);
+ final int min = val.getActualMinimum(aField[0]);
+ final int max = val.getActualMaximum(aField[0]);
//Calculate the offset from the minimum allowed value
offset = val.get(aField[0]) - min;
//Set roundUp if this is more than half way between the minimum and maximum
@@ -1120,7 +1120,7 @@ public class DateUtils {
if (focus == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(focus);
return iterator(gval, rangeStyle);
}
@@ -1663,7 +1663,7 @@ public class DateUtils {
if(date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar calendar = Calendar.getInstance();
+ final Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getFragment(calendar, fragment, unit);
}
@@ -1683,7 +1683,7 @@ public class DateUtils {
if(calendar == null) {
throw new IllegalArgumentException("The date must not be null");
}
- long millisPerUnit = getMillisPerUnit(unit);
+ final long millisPerUnit = getMillisPerUnit(unit);
long result = 0;
// Fragments bigger than a day require a breakdown to days
@@ -1770,8 +1770,8 @@ public class DateUtils {
* @since 3.0
*/
public static int truncatedCompareTo(final Calendar cal1, final Calendar cal2, final int field) {
- Calendar truncatedCal1 = truncate(cal1, field);
- Calendar truncatedCal2 = truncate(cal2, field);
+ final Calendar truncatedCal1 = truncate(cal1, field);
+ final Calendar truncatedCal2 = truncate(cal2, field);
return truncatedCal1.compareTo(truncatedCal2);
}
@@ -1790,8 +1790,8 @@ public class DateUtils {
* @since 3.0
*/
public static int truncatedCompareTo(final Date date1, final Date date2, final int field) {
- Date truncatedDate1 = truncate(date1, field);
- Date truncatedDate2 = truncate(date2, field);
+ final Date truncatedDate1 = truncate(date1, field);
+ final Date truncatedDate2 = truncate(date2, field);
return truncatedDate1.compareTo(truncatedDate2);
}
diff --git a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
index 0676e3737..691ed5877 100644
--- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
@@ -121,7 +121,7 @@ public class DurationFormatUtils {
*/
public static String formatDuration(long durationMillis, final String format, final boolean padWithZeros) {
- Token[] tokens = lexx(format);
+ final Token[] tokens = lexx(format);
int days = 0;
int hours = 0;
@@ -275,13 +275,13 @@ public class DurationFormatUtils {
// TODO: Compare performance to see if anything was lost by
// losing this optimisation.
- Token[] tokens = lexx(format);
+ final Token[] tokens = lexx(format);
// timezones get funky around 0, so normalizing everything to GMT
// stops the hours being off
- Calendar start = Calendar.getInstance(timezone);
+ final Calendar start = Calendar.getInstance(timezone);
start.setTime(new Date(startMillis));
- Calendar end = Calendar.getInstance(timezone);
+ final Calendar end = Calendar.getInstance(timezone);
end.setTime(new Date(endMillis));
// initial estimates
@@ -413,13 +413,13 @@ public class DurationFormatUtils {
*/
static String format(final Token[] tokens, final int years, final int months, final int days, final int hours, final int minutes, final int seconds,
int milliseconds, final boolean padWithZeros) {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
boolean lastOutputSeconds = false;
- int sz = tokens.length;
+ final int sz = tokens.length;
for (int i = 0; i < sz; i++) {
- Token token = tokens[i];
- Object value = token.getValue();
- int count = token.getCount();
+ final Token token = tokens[i];
+ final Object value = token.getValue();
+ final int count = token.getCount();
if (value instanceof StringBuilder) {
buffer.append(value.toString());
} else {
@@ -450,7 +450,7 @@ public class DurationFormatUtils {
} else if (value == S) {
if (lastOutputSeconds) {
milliseconds += 1000;
- String str = padWithZeros
+ final String str = padWithZeros
? StringUtils.leftPad(Integer.toString(milliseconds), count, '0')
: Integer.toString(milliseconds);
buffer.append(str.substring(1));
@@ -481,17 +481,17 @@ public class DurationFormatUtils {
* @return array of Token[]
*/
static Token[] lexx(final String format) {
- char[] array = format.toCharArray();
- ArrayList<Token> list = new ArrayList<Token>(array.length);
+ final char[] array = format.toCharArray();
+ final ArrayList<Token> list = new ArrayList<Token>(array.length);
boolean inLiteral = false;
// Although the buffer is stored in a Token, the Tokens are only
// used internally, so cannot be accessed by other threads
StringBuilder buffer = null;
Token previous = null;
- int sz = array.length;
+ final int sz = array.length;
for(int i=0; i<sz; i++) {
- char ch = array[i];
+ final char ch = array[i];
if(inLiteral && ch != '\'') {
buffer.append(ch); // buffer can't be null if inLiteral is true
continue;
@@ -528,7 +528,7 @@ public class DurationFormatUtils {
if(previous != null && previous.getValue() == value) {
previous.increment();
} else {
- Token token = new Token(value);
+ final Token token = new Token(value);
list.add(token);
previous = token;
}
@@ -552,7 +552,7 @@ public class DurationFormatUtils {
* @return boolean <code>true</code> if contained
*/
static boolean containsTokenWithValue(final Token[] tokens, final Object value) {
- int sz = tokens.length;
+ final int sz = tokens.length;
for (int i = 0; i < sz; i++) {
if (tokens[i].getValue() == value) {
return true;
@@ -620,7 +620,7 @@ public class DurationFormatUtils {
@Override
public boolean equals(final Object obj2) {
if (obj2 instanceof Token) {
- Token tok2 = (Token) obj2;
+ final Token tok2 = (Token) obj2;
if (this.value.getClass() != tok2.value.getClass()) {
return false;
}
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java b/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
index 75fce5017..09632e89e 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
@@ -548,7 +548,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
if (obj instanceof FastDateFormat == false) {
return false;
}
- FastDateFormat other = (FastDateFormat) obj;
+ final FastDateFormat other = (FastDateFormat) obj;
// no need to check parser, as it has same invariants as printer
return printer.equals(other.printer);
}
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
index 9e484f114..e77d5a4c0 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
@@ -106,13 +106,13 @@ public class FastDateParser implements DateParser, Serializable {
* This is called from constructor and from readObject (de-serialization)
*/
private void init() {
- Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
+ final Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
thisYear= definingCalendar.get(Calendar.YEAR);
- StringBuilder regex= new StringBuilder();
- List<Strategy> collector = new ArrayList<Strategy>();
+ final StringBuilder regex= new StringBuilder();
+ final List<Strategy> collector = new ArrayList<Strategy>();
- Matcher patternMatcher= formatPattern.matcher(pattern);
+ final Matcher patternMatcher= formatPattern.matcher(pattern);
if(!patternMatcher.lookingAt()) {
throw new IllegalArgumentException(
"Illegal pattern character '" + pattern.charAt(patternMatcher.regionStart()) + "'");
@@ -126,7 +126,7 @@ public class FastDateParser implements DateParser, Serializable {
nextStrategy = null;
break;
}
- String nextFormatField= patternMatcher.group();
+ final String nextFormatField= patternMatcher.group();
nextStrategy = getStrategy(nextFormatField, definingCalendar);
if(currentStrategy.addRegex(this, regex)) {
collector.add(currentStrategy);
@@ -189,7 +189,7 @@ public class FastDateParser implements DateParser, Serializable {
if (! (obj instanceof FastDateParser) ) {
return false;
}
- FastDateParser other = (FastDateParser) obj;
+ final FastDateParser other = (FastDateParser) obj;
return pattern.equals(other.pattern)
&& timeZone.equals(other.timeZone)
&& locale.equals(other.locale);
@@ -243,7 +243,7 @@ public class FastDateParser implements DateParser, Serializable {
*/
@Override
public Date parse(final String source) throws ParseException {
- Date date= parse(source, new ParsePosition(0));
+ final Date date= parse(source, new ParsePosition(0));
if(date==null) {
// Add a note re supported date range
if (locale.equals(JAPANESE_IMPERIAL)) {
@@ -269,17 +269,17 @@ public class FastDateParser implements DateParser, Serializable {
*/
@Override
public Date parse(final String source, final ParsePosition pos) {
- int offset= pos.getIndex();
- Matcher matcher= parsePattern.matcher(source.substring(offset));
+ final int offset= pos.getIndex();
+ final Matcher matcher= parsePattern.matcher(source.substring(offset));
if(!matcher.lookingAt()) {
return null;
}
// timing tests indicate getting new instance is 19% faster than cloning
- Calendar cal= Calendar.getInstance(timeZone, locale);
+ final Calendar cal= Calendar.getInstance(timeZone, locale);
cal.clear();
for(int i=0; i<strategies.length;) {
- Strategy strategy= strategies[i++];
+ final Strategy strategy= strategies[i++];
strategy.setCalendar(this, cal, matcher.group(i));
}
pos.setIndex(offset+matcher.end());
@@ -352,7 +352,7 @@ public class FastDateParser implements DateParser, Serializable {
* @return A value within -80 and +20 years from instantiation of this instance
*/
int adjustYear(final int twoDigitYear) {
- int trial= twoDigitYear + thisYear - thisYear%100;
+ final int trial= twoDigitYear + thisYear - thisYear%100;
if(trial < thisYear+20) {
return trial;
}
@@ -498,13 +498,13 @@ public class FastDateParser implements DateParser, Serializable {
* @return a TextStrategy for the field and Locale
*/
private Strategy getLocaleSpecificStrategy(final int field, final Calendar definingCalendar) {
- ConcurrentMap<Locale,Strategy> cache = getCache(field);
+ final ConcurrentMap<Locale,Strategy> cache = getCache(field);
Strategy strategy= cache.get(Integer.valueOf(field));
if(strategy==null) {
strategy= field==Calendar.ZONE_OFFSET
? new TimeZoneStrategy(locale)
: new TextStrategy(field, definingCalendar, locale);
- Strategy inCache= cache.putIfAbsent(locale, strategy);
+ final Strategy inCache= cache.putIfAbsent(locale, strategy);
if(inCache!=null) {
return inCache;
}
@@ -570,7 +570,7 @@ public class FastDateParser implements DateParser, Serializable {
@Override
boolean addRegex(final FastDateParser parser, final StringBuilder regex) {
regex.append('(');
- for(String textKeyValue : keyValues.keySet()) {
+ for(final String textKeyValue : keyValues.keySet()) {
escapeRegex(regex, textKeyValue, false).append('|');
}
regex.setCharAt(regex.length()-1, ')');
@@ -582,11 +582,11 @@ public class FastDateParser implements DateParser, Serializable {
*/
@Override
void setCalendar(final FastDateParser parser, final Calendar cal, final String value) {
- Integer iVal = keyValues.get(value);
+ final Integer iVal = keyValues.get(value);
if(iVal == null) {
- StringBuilder sb= new StringBuilder(value);
+ final StringBuilder sb= new StringBuilder(value);
sb.append(" not in (");
- for(String textKeyValue : keyValues.keySet()) {
+ for(final String textKeyValue : keyValues.keySet()) {
sb.append(textKeyValue).append(' ');
}
sb.setCharAt(sb.length()-1, ')');
@@ -678,11 +678,11 @@ public class FastDateParser implements DateParser, Serializable {
* @param locale The Locale
*/
TimeZoneStrategy(final Locale locale) {
- for(String id : TimeZone.getAvailableIDs()) {
+ for(final String id : TimeZone.getAvailableIDs()) {
if(id.startsWith("GMT")) {
continue;
}
- TimeZone tz= TimeZone.getTimeZone(id);
+ final TimeZone tz= TimeZone.getTimeZone(id);
tzNames.put(tz.getDisplayName(false, TimeZone.SHORT, locale), tz);
tzNames.put(tz.getDisplayName(false, TimeZone.LONG, locale), tz);
if(tz.useDaylightTime()) {
@@ -690,9 +690,9 @@ public class FastDateParser implements DateParser, Serializable {
tzNames.put(tz.getDisplayName(true, TimeZone.LONG, locale), tz);
}
}
- StringBuilder sb= new StringBuilder();
+ final StringBuilder sb= new StringBuilder();
sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
- for(String id : tzNames.keySet()) {
+ for(final String id : tzNames.keySet()) {
escapeRegex(sb, id, false).append('|');
}
sb.setCharAt(sb.length()-1, ')');
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
index c141fc58d..18c896493 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
@@ -145,7 +145,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
* <p>Initializes the instance for first use.</p>
*/
private void init() {
- List<Rule> rulesList = parsePattern();
+ final List<Rule> rulesList = parsePattern();
mRules = rulesList.toArray(new Rule[rulesList.size()]);
int len = 0;
@@ -165,31 +165,31 @@ public class FastDatePrinter implements DatePrinter, Serializable {
* @throws IllegalArgumentException if pattern is invalid
*/
protected List<Rule> parsePattern() {
- DateFormatSymbols symbols = new DateFormatSymbols(mLocale);
- List<Rule> rules = new ArrayList<Rule>();
+ final DateFormatSymbols symbols = new DateFormatSymbols(mLocale);
+ final List<Rule> rules = new ArrayList<Rule>();
- String[] ERAs = symbols.getEras();
- String[] months = symbols.getMonths();
- String[] shortMonths = symbols.getShortMonths();
- String[] weekdays = symbols.getWeekdays();
- String[] shortWeekdays = symbols.getShortWeekdays();
- String[] AmPmStrings = symbols.getAmPmStrings();
+ final String[] ERAs = symbols.getEras();
+ final String[] months = symbols.getMonths();
+ final String[] shortMonths = symbols.getShortMonths();
+ final String[] weekdays = symbols.getWeekdays();
+ final String[] shortWeekdays = symbols.getShortWeekdays();
+ final String[] AmPmStrings = symbols.getAmPmStrings();
- int length = mPattern.length();
- int[] indexRef = new int[1];
+ final int length = mPattern.length();
+ final int[] indexRef = new int[1];
for (int i = 0; i < length; i++) {
indexRef[0] = i;
- String token = parseToken(mPattern, indexRef);
+ final String token = parseToken(mPattern, indexRef);
i = indexRef[0];
- int tokenLen = token.length();
+ final int tokenLen = token.length();
if (tokenLen == 0) {
break;
}
Rule rule;
- char c = token.charAt(0);
+ final char c = token.charAt(0);
switch (c) {
case 'G': // era designator (text)
@@ -270,7 +270,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
}
break;
case '\'': // literal text
- String sub = token.substring(1);
+ final String sub = token.substring(1);
if (sub.length() == 1) {
rule = new CharacterLiteral(sub.charAt(0));
} else {
@@ -295,10 +295,10 @@ public class FastDatePrinter implements DatePrinter, Serializable {
* @return parsed token
*/
protected String parseToken(final String pattern, final int[] indexRef) {
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
int i = indexRef[0];
- int length = pattern.length();
+ final int length = pattern.length();
char c = pattern.charAt(i);
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') {
@@ -307,7 +307,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
buf.append(c);
while (i + 1 < length) {
- char peek = pattern.charAt(i + 1);
+ final char peek = pattern.charAt(i + 1);
if (peek == c) {
buf.append(c);
i++;
@@ -394,7 +394,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*/
@Override
public String format(final long millis) {
- Calendar c = newCalendar(); // hard code GregorianCalendar
+ final Calendar c = newCalendar(); // hard code GregorianCalendar
c.setTimeInMillis(millis);
return applyRulesToString(c);
}
@@ -413,7 +413,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*/
@Override
public String format(final Date date) {
- Calendar c = newCalendar(); // hard code GregorianCalendar
+ final Calendar c = newCalendar(); // hard code GregorianCalendar
c.setTime(date);
return applyRulesToString(c);
}
@@ -439,7 +439,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*/
@Override
public StringBuffer format(final Date date, final StringBuffer buf) {
- Calendar c = newCalendar(); // hard code GregorianCalendar
+ final Calendar c = newCalendar(); // hard code GregorianCalendar
c.setTime(date);
return applyRules(c, buf);
}
@@ -461,7 +461,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
* @return the specified string buffer
*/
protected StringBuffer applyRules(final Calendar calendar, final StringBuffer buf) {
- for (Rule rule : mRules) {
+ for (final Rule rule : mRules) {
rule.appendTo(buf, calendar);
}
return buf;
@@ -519,7 +519,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
if (obj instanceof FastDatePrinter == false) {
return false;
}
- FastDatePrinter other = (FastDatePrinter) obj;
+ final FastDatePrinter other = (FastDatePrinter) obj;
return mPattern.equals(other.mPattern)
&& mTimeZone.equals(other.mTimeZone)
&& mLocale.equals(other.mLocale);
@@ -687,7 +687,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
public int estimateLength() {
int max = 0;
for (int i=mValues.length; --i >= 0; ) {
- int len = mValues[i].length();
+ final int len = mValues[i].length();
if (len > max) {
max = len;
}
@@ -1087,12 +1087,12 @@ public class FastDatePrinter implements DatePrinter, Serializable {
* @return the textual name of the time zone
*/
static String getTimeZoneDisplay(final TimeZone tz, final boolean daylight, final int style, final Locale locale) {
- TimeZoneDisplayKey key = new TimeZoneDisplayKey(tz, daylight, style, locale);
+ final TimeZoneDisplayKey key = new TimeZoneDisplayKey(tz, daylight, style, locale);
String value = cTimeZoneDisplayCache.get(key);
if (value == null) {
// This is a very slow call, so cache the results.
value = tz.getDisplayName(daylight, style, locale);
- String prior = cTimeZoneDisplayCache.putIfAbsent(key, value);
+ final String prior = cTimeZoneDisplayCache.putIfAbsent(key, value);
if (prior != null) {
value= prior;
}
@@ -1140,7 +1140,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*/
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
- TimeZone zone = calendar.getTimeZone();
+ final TimeZone zone = calendar.getTimeZone();
if (zone.useDaylightTime()
&& calendar.get(Calendar.DST_OFFSET) != 0) {
buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
@@ -1191,7 +1191,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
buffer.append('+');
}
- int hours = offset / (60 * 60 * 1000);
+ final int hours = offset / (60 * 60 * 1000);
buffer.append((char)(hours / 10 + '0'));
buffer.append((char)(hours % 10 + '0'));
@@ -1199,7 +1199,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
buffer.append(':');
}
- int minutes = offset / (60 * 1000) - 60 * hours;
+ final int minutes = offset / (60 * 1000) - 60 * hours;
buffer.append((char)(minutes / 10 + '0'));
buffer.append((char)(minutes % 10 + '0'));
}
@@ -1249,7 +1249,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
return true;
}
if (obj instanceof TimeZoneDisplayKey) {
- TimeZoneDisplayKey other = (TimeZoneDisplayKey)obj;
+ final TimeZoneDisplayKey other = (TimeZoneDisplayKey)obj;
return
mTimeZone.equals(other.mTimeZone) &&
mStyle == other.mStyle &&
diff --git a/src/main/java/org/apache/commons/lang3/time/FormatCache.java b/src/main/java/org/apache/commons/lang3/time/FormatCache.java
index 14b0016f3..21ba4405d 100644
--- a/src/main/java/org/apache/commons/lang3/time/FormatCache.java
+++ b/src/main/java/org/apache/commons/lang3/time/FormatCache.java
@@ -76,11 +76,11 @@ abstract class FormatCache<F extends Format> {
if (locale == null) {
locale = Locale.getDefault();
}
- MultipartKey key = new MultipartKey(pattern, timeZone, locale);
+ final MultipartKey key = new MultipartKey(pattern, timeZone, locale);
F format = cInstanceCache.get(key);
if (format == null) {
format = createInstance(pattern, timeZone, locale);
- F previousValue= cInstanceCache.putIfAbsent(key, format);
+ final F previousValue= cInstanceCache.putIfAbsent(key, format);
if (previousValue != null) {
// another thread snuck in and did the same work
// we should return the instance that is in ConcurrentMap
@@ -120,7 +120,7 @@ abstract class FormatCache<F extends Format> {
if (locale == null) {
locale = Locale.getDefault();
}
- String pattern = getPatternForStyle(dateStyle, timeStyle, locale);
+ final String pattern = getPatternForStyle(dateStyle, timeStyle, locale);
return getInstance(pattern, timeZone, locale);
}
@@ -134,7 +134,7 @@ abstract class FormatCache<F extends Format> {
* @throws IllegalArgumentException if the Locale has no date/time pattern defined
*/
public static String getPatternForStyle(final Integer dateStyle, final Integer timeStyle, final Locale locale) {
- MultipartKey key = new MultipartKey(dateStyle, timeStyle, locale);
+ final MultipartKey key = new MultipartKey(dateStyle, timeStyle, locale);
String pattern = cDateTimeInstanceCache.get(key);
if (pattern == null) {
@@ -150,14 +150,14 @@ abstract class FormatCache<F extends Format> {
formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(), locale);
}
pattern = ((SimpleDateFormat)formatter).toPattern();
- String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern);
+ final String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern);
if (previous != null) {
// even though it doesn't matter if another thread put the pattern
// it's still good practice to return the String instance that is
// actually in the ConcurrentMap
pattern= previous;
}
- } catch (ClassCastException ex) {
+ } catch (final ClassCastException ex) {
throw new IllegalArgumentException("No date time pattern for locale: " + locale);
}
}
@@ -198,7 +198,7 @@ abstract class FormatCache<F extends Format> {
public int hashCode() {
if(hashCode==0) {
int rc= 0;
- for(Object key : keys) {
+ for(final Object key : keys) {
if(key!=null) {
rc= rc*7 + key.hashCode();
}
diff --git a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java
index 72781d813..2e37b9f57 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java
@@ -116,7 +116,7 @@ public class MutablePair<L, R> extends Pair<L, R> {
*/
@Override
public R setValue(final R value) {
- R result = getRight();
+ final R result = getRight();
setRight(value);
return result;
}
diff --git a/src/main/java/org/apache/commons/lang3/tuple/Pair.java b/src/main/java/org/apache/commons/lang3/tuple/Pair.java
index 08fa0df04..36d97a326 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/Pair.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/Pair.java
@@ -131,7 +131,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
return true;
}
if (obj instanceof Map.Entry<?, ?>) {
- Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
+ final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return ObjectUtils.equals(getKey(), other.getKey())
&& ObjectUtils.equals(getValue(), other.getValue());
}
diff --git a/src/main/java/org/apache/commons/lang3/tuple/Triple.java b/src/main/java/org/apache/commons/lang3/tuple/Triple.java
index 6c92e35db..5de1c4cf3 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/Triple.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/Triple.java
@@ -110,7 +110,7 @@ public abstract class Triple<L, M, R> implements Comparable<Triple<L, M, R>>, Se
return true;
}
if (obj instanceof Triple<?, ?, ?>) {
- Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
+ final Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
return ObjectUtils.equals(getLeft(), other.getLeft())
&& ObjectUtils.equals(getMiddle(), other.getMiddle())
&& ObjectUtils.equals(getRight(), other.getRight());
diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
index c0e081d54..446e8d916 100644
--- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
@@ -430,14 +430,14 @@ public class AnnotationUtilsTest {
@Test
public void testIsValidAnnotationMemberType() {
- for (Class<?> type : new Class[] { byte.class, short.class, int.class, char.class,
+ for (final Class<?> type : new Class[] { byte.class, short.class, int.class, char.class,
long.class, float.class, double.class, boolean.class, String.class, Class.class,
NestAnnotation.class, TestAnnotation.class, Stooge.class, ElementType.class }) {
assertTrue(AnnotationUtils.isValidAnnotationMemberType(type));
assertTrue(AnnotationUtils.isValidAnnotationMemberType(Array.newInstance(type, 0)
.getClass()));
}
- for (Class<?> type : new Class[] { Object.class, Map.class, Collection.class }) {
+ for (final Class<?> type : new Class[] { Object.class, Map.class, Collection.class }) {
assertFalse(AnnotationUtils.isValidAnnotationMemberType(type));
assertFalse(AnnotationUtils.isValidAnnotationMemberType(Array.newInstance(type, 0)
.getClass()));
@@ -449,7 +449,7 @@ public class AnnotationUtilsTest {
final Test real = getClass().getDeclaredMethod(
"testGeneratedAnnotationEquivalentToRealAnnotation").getAnnotation(Test.class);
- InvocationHandler generatedTestInvocationHandler = new InvocationHandler() {
+ final InvocationHandler generatedTestInvocationHandler = new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
@@ -466,7 +466,7 @@ public class AnnotationUtilsTest {
}
};
- Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread()
+ final Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { Test.class },
generatedTestInvocationHandler);
assertTrue(real.equals(generated));
@@ -474,7 +474,7 @@ public class AnnotationUtilsTest {
assertTrue(AnnotationUtils.equals(generated, real));
assertTrue(AnnotationUtils.equals(real, generated));
- Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread()
+ final Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { Test.class },
generatedTestInvocationHandler);
assertFalse(generated.equals(generated2));
@@ -497,7 +497,7 @@ public class AnnotationUtilsTest {
public void testToString() throws Exception {
final Test testAnno = getClass().getDeclaredMethod("testToString")
.getAnnotation(Test.class);
- String toString = AnnotationUtils.toString(testAnno);
+ final String toString = AnnotationUtils.toString(testAnno);
assertTrue(toString.startsWith("@org.junit.Test("));
assertTrue(toString.endsWith(")"));
assertTrue(toString.contains("expected=class org.junit.Test$None"));
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
index 711b61013..6c18f6210 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
@@ -46,7 +46,7 @@ public class ArrayUtilsAddTest {
// Invalid - can't store Long in Integer array
n = ArrayUtils.addAll(new Integer[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)});
fail("Should have generated IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
}
@@ -59,7 +59,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((boolean[])null, true);
assertTrue(Arrays.equals(new boolean[]{true}, newArray));
assertEquals(Boolean.TYPE, newArray.getClass().getComponentType());
- boolean[] array1 = new boolean[]{true, false, true};
+ final boolean[] array1 = new boolean[]{true, false, true};
newArray = ArrayUtils.add(array1, false);
assertTrue(Arrays.equals(new boolean[]{true, false, true, false}, newArray));
assertEquals(Boolean.TYPE, newArray.getClass().getComponentType());
@@ -74,7 +74,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((byte[])null, (byte)1);
assertTrue(Arrays.equals(new byte[]{1}, newArray));
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
- byte[] array1 = new byte[]{1, 2, 3};
+ final byte[] array1 = new byte[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (byte)0);
assertTrue(Arrays.equals(new byte[]{1, 2, 3, 0}, newArray));
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
@@ -92,7 +92,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((char[])null, (char)1);
assertTrue(Arrays.equals(new char[]{1}, newArray));
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
- char[] array1 = new char[]{1, 2, 3};
+ final char[] array1 = new char[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (char)0);
assertTrue(Arrays.equals(new char[]{1, 2, 3, 0}, newArray));
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
@@ -110,7 +110,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((double[])null, 1);
assertTrue(Arrays.equals(new double[]{1}, newArray));
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
- double[] array1 = new double[]{1, 2, 3};
+ final double[] array1 = new double[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new double[]{1, 2, 3, 0}, newArray));
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
@@ -128,7 +128,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((float[])null, 1);
assertTrue(Arrays.equals(new float[]{1}, newArray));
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
- float[] array1 = new float[]{1, 2, 3};
+ final float[] array1 = new float[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new float[]{1, 2, 3, 0}, newArray));
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
@@ -146,7 +146,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((int[])null, 1);
assertTrue(Arrays.equals(new int[]{1}, newArray));
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
- int[] array1 = new int[]{1, 2, 3};
+ final int[] array1 = new int[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new int[]{1, 2, 3, 0}, newArray));
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
@@ -164,7 +164,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((long[])null, 1);
assertTrue(Arrays.equals(new long[]{1}, newArray));
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
- long[] array1 = new long[]{1, 2, 3};
+ final long[] array1 = new long[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new long[]{1, 2, 3, 0}, newArray));
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
@@ -182,7 +182,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((short[])null, (short)1);
assertTrue(Arrays.equals(new short[]{1}, newArray));
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
- short[] array1 = new short[]{1, 2, 3};
+ final short[] array1 = new short[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (short)0);
assertTrue(Arrays.equals(new short[]{1, 2, 3, 0}, newArray));
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
@@ -202,12 +202,12 @@ public class ArrayUtilsAddTest {
assertEquals(String.class, newArray.getClass().getComponentType());
//show that not casting to Object[] is okay and will assume String based on "a"
- String[] newStringArray = ArrayUtils.add(null, "a");
+ final String[] newStringArray = ArrayUtils.add(null, "a");
assertTrue(Arrays.equals(new String[]{"a"}, newStringArray));
assertTrue(Arrays.equals(new Object[]{"a"}, newStringArray));
assertEquals(String.class, newStringArray.getClass().getComponentType());
- String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
newArray = ArrayUtils.add(stringArray1, null);
assertTrue(Arrays.equals(new String[]{"a", "b", "c", null}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -229,20 +229,22 @@ public class ArrayUtilsAddTest {
@Test
public void testLANG571(){
- String[] stringArray=null;
- String aString=null;
+ final String[] stringArray=null;
+ final String aString=null;
try {
@SuppressWarnings("unused")
+ final
String[] sa = ArrayUtils.add(stringArray, aString);
fail("Should have caused IllegalArgumentException");
- } catch (IllegalArgumentException iae){
+ } catch (final IllegalArgumentException iae){
//expected
}
try {
@SuppressWarnings("unused")
+ final
String[] sa = ArrayUtils.add(stringArray, 0, aString);
fail("Should have caused IllegalArgumentException");
- } catch (IllegalArgumentException iae){
+ } catch (final IllegalArgumentException iae){
//expected
}
}
@@ -251,8 +253,8 @@ public class ArrayUtilsAddTest {
public void testAddObjectArrayToObjectArray() {
assertNull(ArrayUtils.addAll((Object[]) null, (Object[]) null));
Object[] newArray;
- String[] stringArray1 = new String[]{"a", "b", "c"};
- String[] stringArray2 = new String[]{"1", "2", "3"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray2 = new String[]{"1", "2", "3"};
newArray = ArrayUtils.addAll(stringArray1, (String[]) null);
assertNotSame(stringArray1, newArray);
assertTrue(Arrays.equals(stringArray1, newArray));
@@ -278,7 +280,7 @@ public class ArrayUtilsAddTest {
assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, newArray));
assertTrue(Arrays.equals(new String[]{}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
- String[] stringArrayNull = new String []{null};
+ final String[] stringArrayNull = new String []{null};
newArray = ArrayUtils.addAll(stringArrayNull, stringArrayNull);
assertTrue(Arrays.equals(new String[]{null, null}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -372,7 +374,7 @@ public class ArrayUtilsAddTest {
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
- String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
newArray = ArrayUtils.add(stringArray1, 0, null);
assertTrue(Arrays.equals(new String[]{null, "a", "b", "c"}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -387,9 +389,9 @@ public class ArrayUtilsAddTest {
assertEquals(String.class, newArray.getClass().getComponentType());
assertEquals(String.class, newArray.getClass().getComponentType());
- Object[] o = new Object[] {"1", "2", "4"};
- Object[] result = ArrayUtils.add(o, 2, "3");
- Object[] result2 = ArrayUtils.add(o, 3, "5");
+ final Object[] o = new Object[] {"1", "2", "4"};
+ final Object[] result = ArrayUtils.add(o, 2, "3");
+ final Object[] result2 = ArrayUtils.add(o, 3, "5");
assertNotNull(result);
assertEquals(4, result.length);
@@ -409,7 +411,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new boolean[] { true }, booleanArray ) );
try {
booleanArray = ArrayUtils.add( null, -1, true );
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
booleanArray = ArrayUtils.add( new boolean[] { true }, 0, false);
@@ -420,12 +422,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new boolean[] { true, true, false }, booleanArray ) );
try {
booleanArray = ArrayUtils.add( new boolean[] { true, false }, 4, true);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
booleanArray = ArrayUtils.add( new boolean[] { true, false }, -1, true);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -434,7 +436,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new char[] { 'a' }, charArray ) );
try {
charArray = ArrayUtils.add( (char[]) null, -1, 'a' );
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
charArray = ArrayUtils.add( new char[] { 'a' }, 0, 'b');
@@ -447,12 +449,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new char[] { 'a', 't', 'b', 'c' }, charArray ) );
try {
charArray = ArrayUtils.add( new char[] { 'a', 'b' }, 4, 'c');
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
charArray = ArrayUtils.add( new char[] { 'a', 'b' }, -1, 'c');
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -461,7 +463,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new short[] { 2, 1 }, shortArray ) );
try {
shortArray = ArrayUtils.add( (short[]) null, -1, (short) 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
shortArray = ArrayUtils.add( new short[] { 2, 6 }, 2, (short) 10);
@@ -472,12 +474,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new short[] { 2, 6, 1, 3 }, shortArray ) );
try {
shortArray = ArrayUtils.add( new short[] { 2, 6 }, 4, (short) 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
shortArray = ArrayUtils.add( new short[] { 2, 6 }, -1, (short) 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -486,7 +488,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new byte[] { 2, 1 }, byteArray ) );
try {
byteArray = ArrayUtils.add( (byte[]) null, -1, (byte) 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, 2, (byte) 3);
@@ -497,12 +499,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new byte[] { 2, 6, 1, 3 }, byteArray ) );
try {
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, 4, (byte) 3);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, -1, (byte) 3);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -511,7 +513,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new int[] { 2, 1 }, intArray ) );
try {
intArray = ArrayUtils.add( (int[]) null, -1, 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
intArray = ArrayUtils.add( new int[] { 2, 6 }, 2, 10);
@@ -522,12 +524,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new int[] { 2, 6, 1, 3 }, intArray ) );
try {
intArray = ArrayUtils.add( new int[] { 2, 6 }, 4, 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
intArray = ArrayUtils.add( new int[] { 2, 6 }, -1, 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -536,7 +538,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new long[] { 2L, 1L }, longArray ) );
try {
longArray = ArrayUtils.add( (long[]) null, -1, 2L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
longArray = ArrayUtils.add( new long[] { 2L, 6L }, 2, 10L);
@@ -547,12 +549,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new long[] { 2L, 6L, 1L, 3L }, longArray ) );
try {
longArray = ArrayUtils.add( new long[] { 2L, 6L }, 4, 10L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
longArray = ArrayUtils.add( new long[] { 2L, 6L }, -1, 10L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -561,7 +563,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new float[] { 2.2f, 1.1f }, floatArray ) );
try {
floatArray = ArrayUtils.add( (float[]) null, -1, 2.2f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, 2, 10.5f);
@@ -572,12 +574,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new float[] { 2.9f, 6.0f, 1.0f, 0.3f }, floatArray ) );
try {
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, 4, 10.5f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, -1, 10.5f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -586,7 +588,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new double[] { 2.2, 1.1 }, doubleArray ) );
try {
doubleArray = ArrayUtils.add( (double[]) null, -1, 2.2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, 2, 10.5);
@@ -597,12 +599,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new double[] { 2.9, 6.0, 1.0, 0.3 }, doubleArray ) );
try {
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, 4, 10.5);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, -1, 10.5);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
index 7b1a0561f..ba01c8092 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
@@ -74,8 +74,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllObjectArrayRemoveNone() {
- Object[] array1 = new Object[] { "foo", "bar", "baz" };
- Object[] array2 = ArrayUtils.removeAll(array1);
+ final Object[] array1 = new Object[] { "foo", "bar", "baz" };
+ final Object[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(Object.class, array2.getClass().getComponentType());
@@ -98,7 +98,7 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllNumberArray() {
- Number[] inarray = { Integer.valueOf(1), Long.valueOf(2L), Byte.valueOf((byte) 3) };
+ final Number[] inarray = { Integer.valueOf(1), Long.valueOf(2L), Byte.valueOf((byte) 3) };
assertEquals(3, inarray.length);
Number[] outarray;
outarray = ArrayUtils.removeAll(inarray, 1);
@@ -172,8 +172,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllBooleanArrayRemoveNone() {
- boolean[] array1 = new boolean[] { true, false };
- boolean[] array2 = ArrayUtils.removeAll(array1);
+ final boolean[] array1 = new boolean[] { true, false };
+ final boolean[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(boolean.class, array2.getClass().getComponentType());
@@ -238,8 +238,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllByteArrayRemoveNone() {
- byte[] array1 = new byte[] { 1, 2 };
- byte[] array2 = ArrayUtils.removeAll(array1);
+ final byte[] array1 = new byte[] { 1, 2 };
+ final byte[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(byte.class, array2.getClass().getComponentType());
@@ -304,8 +304,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllCharArrayRemoveNone() {
- char[] array1 = new char[] { 'a', 'b' };
- char[] array2 = ArrayUtils.removeAll(array1);
+ final char[] array1 = new char[] { 'a', 'b' };
+ final char[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(char.class, array2.getClass().getComponentType());
@@ -370,8 +370,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllDoubleArrayRemoveNone() {
- double[] array1 = new double[] { 1, 2 };
- double[] array2 = ArrayUtils.removeAll(array1);
+ final double[] array1 = new double[] { 1, 2 };
+ final double[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(double.class, array2.getClass().getComponentType());
@@ -436,8 +436,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllFloatArrayRemoveNone() {
- float[] array1 = new float[] { 1, 2 };
- float[] array2 = ArrayUtils.removeAll(array1);
+ final float[] array1 = new float[] { 1, 2 };
+ final float[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(float.class, array2.getClass().getComponentType());
@@ -506,8 +506,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllIntArrayRemoveNone() {
- int[] array1 = new int[] { 1, 2 };
- int[] array2 = ArrayUtils.removeAll(array1);
+ final int[] array1 = new int[] { 1, 2 };
+ final int[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(int.class, array2.getClass().getComponentType());
@@ -572,8 +572,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllLongArrayRemoveNone() {
- long[] array1 = new long[] { 1, 2 };
- long[] array2 = ArrayUtils.removeAll(array1);
+ final long[] array1 = new long[] { 1, 2 };
+ final long[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(long.class, array2.getClass().getComponentType());
@@ -638,8 +638,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllShortArrayRemoveNone() {
- short[] array1 = new short[] { 1, 2 };
- short[] array2 = ArrayUtils.removeAll(array1);
+ final short[] array1 = new short[] { 1, 2 };
+ final short[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(short.class, array2.getClass().getComponentType());
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
index f4f789aff..b74c77185 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
@@ -51,20 +51,20 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new Object[] {"a", "b"}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new Object[] {"a", "b"}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((Object[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
public void testRemoveNumberArray(){
- Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
+ final Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
assertEquals(3, inarray.length);
Number[] outarray;
outarray = ArrayUtils.remove(inarray, 1);
@@ -96,15 +96,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new boolean[] {true, false}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new boolean[] {true, false}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((boolean[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -125,15 +125,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new byte[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new byte[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((byte[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -154,15 +154,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new char[] {'a', 'b'}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new char[] {'a', 'b'}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((char[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -183,15 +183,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new double[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new double[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((double[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -212,15 +212,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new float[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new float[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((float[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -241,15 +241,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new int[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new int[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((int[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -270,15 +270,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new long[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new long[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((long[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -299,15 +299,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new short[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new short[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((short[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index deb74e1cc..d93aa2ae6 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -45,7 +45,7 @@ public class ArrayUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ArrayUtils());
- Constructor<?>[] cons = ArrayUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ArrayUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ArrayUtils.class.getModifiers()));
@@ -71,18 +71,18 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testHashCode() {
- long[][] array1 = new long[][] {{2,5}, {4,5}};
- long[][] array2 = new long[][] {{2,5}, {4,6}};
+ final long[][] array1 = new long[][] {{2,5}, {4,5}};
+ final long[][] array2 = new long[][] {{2,5}, {4,6}};
assertTrue(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array1));
assertFalse(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array2));
- Object[] array3 = new Object[] {new String(new char[] {'A', 'B'})};
- Object[] array4 = new Object[] {"AB"};
+ final Object[] array3 = new Object[] {new String(new char[] {'A', 'B'})};
+ final Object[] array4 = new Object[] {"AB"};
assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array3));
assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array4));
- Object[] arrayA = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
- Object[] arrayB = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
+ final Object[] arrayA = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
+ final Object[] arrayB = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
assertTrue(ArrayUtils.hashCode(arrayB) == ArrayUtils.hashCode(arrayA));
}
@@ -101,48 +101,48 @@ public class ArrayUtilsTest {
@Test
public void testIsEquals() {
- long[][] larray1 = new long[][]{{2, 5}, {4, 5}};
- long[][] larray2 = new long[][]{{2, 5}, {4, 6}};
- long[] larray3 = new long[]{2, 5};
+ final long[][] larray1 = new long[][]{{2, 5}, {4, 5}};
+ final long[][] larray2 = new long[][]{{2, 5}, {4, 6}};
+ final long[] larray3 = new long[]{2, 5};
this.assertIsEquals(larray1, larray2, larray3);
- int[][] iarray1 = new int[][]{{2, 5}, {4, 5}};
- int[][] iarray2 = new int[][]{{2, 5}, {4, 6}};
- int[] iarray3 = new int[]{2, 5};
+ final int[][] iarray1 = new int[][]{{2, 5}, {4, 5}};
+ final int[][] iarray2 = new int[][]{{2, 5}, {4, 6}};
+ final int[] iarray3 = new int[]{2, 5};
this.assertIsEquals(iarray1, iarray2, iarray3);
- short[][] sarray1 = new short[][]{{2, 5}, {4, 5}};
- short[][] sarray2 = new short[][]{{2, 5}, {4, 6}};
- short[] sarray3 = new short[]{2, 5};
+ final short[][] sarray1 = new short[][]{{2, 5}, {4, 5}};
+ final short[][] sarray2 = new short[][]{{2, 5}, {4, 6}};
+ final short[] sarray3 = new short[]{2, 5};
this.assertIsEquals(sarray1, sarray2, sarray3);
- float[][] farray1 = new float[][]{{2, 5}, {4, 5}};
- float[][] farray2 = new float[][]{{2, 5}, {4, 6}};
- float[] farray3 = new float[]{2, 5};
+ final float[][] farray1 = new float[][]{{2, 5}, {4, 5}};
+ final float[][] farray2 = new float[][]{{2, 5}, {4, 6}};
+ final float[] farray3 = new float[]{2, 5};
this.assertIsEquals(farray1, farray2, farray3);
- double[][] darray1 = new double[][]{{2, 5}, {4, 5}};
- double[][] darray2 = new double[][]{{2, 5}, {4, 6}};
- double[] darray3 = new double[]{2, 5};
+ final double[][] darray1 = new double[][]{{2, 5}, {4, 5}};
+ final double[][] darray2 = new double[][]{{2, 5}, {4, 6}};
+ final double[] darray3 = new double[]{2, 5};
this.assertIsEquals(darray1, darray2, darray3);
- byte[][] byteArray1 = new byte[][]{{2, 5}, {4, 5}};
- byte[][] byteArray2 = new byte[][]{{2, 5}, {4, 6}};
- byte[] byteArray3 = new byte[]{2, 5};
+ final byte[][] byteArray1 = new byte[][]{{2, 5}, {4, 5}};
+ final byte[][] byteArray2 = new byte[][]{{2, 5}, {4, 6}};
+ final byte[] byteArray3 = new byte[]{2, 5};
this.assertIsEquals(byteArray1, byteArray2, byteArray3);
- char[][] charArray1 = new char[][]{{2, 5}, {4, 5}};
- char[][] charArray2 = new char[][]{{2, 5}, {4, 6}};
- char[] charArray3 = new char[]{2, 5};
+ final char[][] charArray1 = new char[][]{{2, 5}, {4, 5}};
+ final char[][] charArray2 = new char[][]{{2, 5}, {4, 6}};
+ final char[] charArray3 = new char[]{2, 5};
this.assertIsEquals(charArray1, charArray2, charArray3);
- boolean[][] barray1 = new boolean[][]{{true, false}, {true, true}};
- boolean[][] barray2 = new boolean[][]{{true, false}, {true, false}};
- boolean[] barray3 = new boolean[]{false, true};
+ final boolean[][] barray1 = new boolean[][]{{true, false}, {true, true}};
+ final boolean[][] barray2 = new boolean[][]{{true, false}, {true, false}};
+ final boolean[] barray3 = new boolean[]{false, true};
this.assertIsEquals(barray1, barray2, barray3);
- Object[] array3 = new Object[]{new String(new char[]{'A', 'B'})};
- Object[] array4 = new Object[]{"AB"};
+ final Object[] array3 = new Object[]{new String(new char[]{'A', 'B'})};
+ final Object[] array4 = new Object[]{"AB"};
assertTrue(ArrayUtils.isEquals(array3, array3));
assertTrue(ArrayUtils.isEquals(array3, array4));
@@ -234,15 +234,15 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"short"}});
fail("exception expected");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, "illegal type"});
fail("exception expected");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, null});
fail("exception expected");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
map = ArrayUtils.toMap(new Object[] {new Map.Entry<Object, Object>() {
@Override
@@ -278,7 +278,7 @@ public class ArrayUtilsTest {
assertTrue(Arrays.equals(original1, cloned1));
assertTrue(original1 != cloned1);
- StringBuffer buf = new StringBuffer("pick");
+ final StringBuffer buf = new StringBuffer("pick");
original1 = new Object[] {buf, "a", new String[] {"stick"}};
cloned1 = ArrayUtils.clone(original1);
assertTrue(Arrays.equals(original1, cloned1));
@@ -291,8 +291,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneBoolean() {
assertEquals(null, ArrayUtils.clone((boolean[]) null));
- boolean[] original = new boolean[] {true, false};
- boolean[] cloned = ArrayUtils.clone(original);
+ final boolean[] original = new boolean[] {true, false};
+ final boolean[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -300,8 +300,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneLong() {
assertEquals(null, ArrayUtils.clone((long[]) null));
- long[] original = new long[] {0L, 1L};
- long[] cloned = ArrayUtils.clone(original);
+ final long[] original = new long[] {0L, 1L};
+ final long[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -309,8 +309,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneInt() {
assertEquals(null, ArrayUtils.clone((int[]) null));
- int[] original = new int[] {5, 8};
- int[] cloned = ArrayUtils.clone(original);
+ final int[] original = new int[] {5, 8};
+ final int[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -318,8 +318,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneShort() {
assertEquals(null, ArrayUtils.clone((short[]) null));
- short[] original = new short[] {1, 4};
- short[] cloned = ArrayUtils.clone(original);
+ final short[] original = new short[] {1, 4};
+ final short[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -327,8 +327,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneChar() {
assertEquals(null, ArrayUtils.clone((char[]) null));
- char[] original = new char[] {'a', '4'};
- char[] cloned = ArrayUtils.clone(original);
+ final char[] original = new char[] {'a', '4'};
+ final char[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -336,8 +336,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneByte() {
assertEquals(null, ArrayUtils.clone((byte[]) null));
- byte[] original = new byte[] {1, 6};
- byte[] cloned = ArrayUtils.clone(original);
+ final byte[] original = new byte[] {1, 6};
+ final byte[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -345,8 +345,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneDouble() {
assertEquals(null, ArrayUtils.clone((double[]) null));
- double[] original = new double[] {2.4d, 5.7d};
- double[] cloned = ArrayUtils.clone(original);
+ final double[] original = new double[] {2.4d, 5.7d};
+ final double[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -354,8 +354,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneFloat() {
assertEquals(null, ArrayUtils.clone((float[]) null));
- float[] original = new float[] {2.6f, 6.4f};
- float[] cloned = ArrayUtils.clone(original);
+ final float[] original = new float[] {2.6f, 6.4f};
+ final float[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -367,11 +367,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, ArrayUtils.nullToEmpty((boolean[]) null));
// Test valid array handling
- boolean[] original = new boolean[] {true, false};
+ final boolean[] original = new boolean[] {true, false};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- boolean[] empty = new boolean[]{};
- boolean[] result = ArrayUtils.nullToEmpty(empty);
+ final boolean[] empty = new boolean[]{};
+ final boolean[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, result);
assertTrue(empty != result);
}
@@ -381,11 +381,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_LONG_ARRAY, ArrayUtils.nullToEmpty((long[]) null));
// Test valid array handling
- long[] original = new long[] {1L, 2L};
+ final long[] original = new long[] {1L, 2L};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- long[] empty = new long[]{};
- long[] result = ArrayUtils.nullToEmpty(empty);
+ final long[] empty = new long[]{};
+ final long[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_LONG_ARRAY, result);
assertTrue(empty != result);
}
@@ -395,11 +395,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.nullToEmpty((int[]) null));
// Test valid array handling
- int[] original = new int[] {1, 2};
+ final int[] original = new int[] {1, 2};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- int[] empty = new int[]{};
- int[] result = ArrayUtils.nullToEmpty(empty);
+ final int[] empty = new int[]{};
+ final int[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_INT_ARRAY, result);
assertTrue(empty != result);
}
@@ -409,11 +409,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.nullToEmpty((short[]) null));
// Test valid array handling
- short[] original = new short[] {1, 2};
+ final short[] original = new short[] {1, 2};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- short[] empty = new short[]{};
- short[] result = ArrayUtils.nullToEmpty(empty);
+ final short[] empty = new short[]{};
+ final short[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_SHORT_ARRAY, result);
assertTrue(empty != result);
}
@@ -423,11 +423,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.nullToEmpty((char[]) null));
// Test valid array handling
- char[] original = new char[] {'a', 'b'};
+ final char[] original = new char[] {'a', 'b'};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- char[] empty = new char[]{};
- char[] result = ArrayUtils.nullToEmpty(empty);
+ final char[] empty = new char[]{};
+ final char[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, result);
assertTrue(empty != result);
}
@@ -437,11 +437,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.nullToEmpty((byte[]) null));
// Test valid array handling
- byte[] original = new byte[] {0x0F, 0x0E};
+ final byte[] original = new byte[] {0x0F, 0x0E};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- byte[] empty = new byte[]{};
- byte[] result = ArrayUtils.nullToEmpty(empty);
+ final byte[] empty = new byte[]{};
+ final byte[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result);
assertTrue(empty != result);
}
@@ -451,11 +451,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_DOUBLE_ARRAY, ArrayUtils.nullToEmpty((double[]) null));
// Test valid array handling
- double[] original = new double[] {1L, 2L};
+ final double[] original = new double[] {1L, 2L};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- double[] empty = new double[]{};
- double[] result = ArrayUtils.nullToEmpty(empty);
+ final double[] empty = new double[]{};
+ final double[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_DOUBLE_ARRAY, result);
assertTrue(empty != result);
}
@@ -465,11 +465,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.nullToEmpty((float[]) null));
// Test valid array handling
- float[] original = new float[] {2.6f, 3.8f};
+ final float[] original = new float[] {2.6f, 3.8f};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- float[] empty = new float[]{};
- float[] result = ArrayUtils.nullToEmpty(empty);
+ final float[] empty = new float[]{};
+ final float[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, result);
assertTrue(empty != result);
}
@@ -479,11 +479,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Object[]) null));
// Test valid array handling
- Object[] original = new Object[] {Boolean.TRUE, Boolean.FALSE};
+ final Object[] original = new Object[] {Boolean.TRUE, Boolean.FALSE};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Object[] empty = new Object[]{};
- Object[] result = ArrayUtils.nullToEmpty(empty);
+ final Object[] empty = new Object[]{};
+ final Object[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -493,11 +493,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.nullToEmpty((String[]) null));
// Test valid array handling
- String[] original = new String[] {"abc", "def"};
+ final String[] original = new String[] {"abc", "def"};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- String[] empty = new String[]{};
- String[] result = ArrayUtils.nullToEmpty(empty);
+ final String[] empty = new String[]{};
+ final String[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, result);
assertTrue(empty != result);
}
@@ -507,11 +507,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Boolean[]) null));
// Test valid array handling
- Boolean[] original = new Boolean[] {Boolean.TRUE, Boolean.FALSE};
+ final Boolean[] original = new Boolean[] {Boolean.TRUE, Boolean.FALSE};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Boolean[] empty = new Boolean[]{};
- Boolean[] result = ArrayUtils.nullToEmpty(empty);
+ final Boolean[] empty = new Boolean[]{};
+ final Boolean[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -522,11 +522,12 @@ public class ArrayUtilsTest {
assertArrayEquals(ArrayUtils.EMPTY_LONG_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Long[]) null));
// Test valid array handling
@SuppressWarnings("boxing")
+ final
Long[] original = new Long[] {1L, 2L};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Long[] empty = new Long[]{};
- Long[] result = ArrayUtils.nullToEmpty(empty);
+ final Long[] empty = new Long[]{};
+ final Long[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_LONG_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -536,11 +537,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Integer[]) null));
// Test valid array handling
- Integer[] original = new Integer[] {1, 2};
+ final Integer[] original = new Integer[] {1, 2};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Integer[] empty = new Integer[]{};
- Integer[] result = ArrayUtils.nullToEmpty(empty);
+ final Integer[] empty = new Integer[]{};
+ final Integer[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -551,11 +552,12 @@ public class ArrayUtilsTest {
assertArrayEquals(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Short[]) null));
// Test valid array handling
@SuppressWarnings("boxing")
+ final
Short[] original = new Short[] {1, 2};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Short[] empty = new Short[]{};
- Short[] result = ArrayUtils.nullToEmpty(empty);
+ final Short[] empty = new Short[]{};
+ final Short[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -565,11 +567,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Character[]) null));
// Test valid array handling
- Character[] original = new Character[] {'a', 'b'};
+ final Character[] original = new Character[] {'a', 'b'};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Character[] empty = new Character[]{};
- Character[] result = ArrayUtils.nullToEmpty(empty);
+ final Character[] empty = new Character[]{};
+ final Character[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -579,11 +581,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Byte[]) null));
// Test valid array handling
- Byte[] original = new Byte[] {0x0F, 0x0E};
+ final Byte[] original = new Byte[] {0x0F, 0x0E};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Byte[] empty = new Byte[]{};
- Byte[] result = ArrayUtils.nullToEmpty(empty);
+ final Byte[] empty = new Byte[]{};
+ final Byte[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -593,11 +595,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Double[]) null));
// Test valid array handling
- Double[] original = new Double[] {1D, 2D};
+ final Double[] original = new Double[] {1D, 2D};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Double[] empty = new Double[]{};
- Double[] result = ArrayUtils.nullToEmpty(empty);
+ final Double[] empty = new Double[]{};
+ final Double[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -607,11 +609,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Float[]) null));
// Test valid array handling
- Float[] original = new Float[] {2.6f, 3.8f};
+ final Float[] original = new Float[] {2.6f, 3.8f};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Float[] empty = new Float[]{};
- Float[] result = ArrayUtils.nullToEmpty(empty);
+ final Float[] empty = new Float[]{};
+ final Float[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -620,8 +622,8 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayObject() {
- Object[] nullArray = null;
- Object[] objectArray = { "a", "b", "c", "d", "e", "f"};
+ final Object[] nullArray = null;
+ final Object[] objectArray = { "a", "b", "c", "d", "e", "f"};
assertEquals("0 start, mid end", "abcd",
StringUtils.join(ArrayUtils.subarray(objectArray, 0, 4)));
@@ -649,7 +651,7 @@ public class ArrayUtilsTest {
StringUtils.join(ArrayUtils.subarray(objectArray, -2, 12)));
// array type tests
- Date[] dateArray = { new java.sql.Date(new Date().getTime()),
+ final Date[] dateArray = { new java.sql.Date(new Date().getTime()),
new Date(), new Date(), new Date(), new Date() };
assertSame("Object type", Object.class,
@@ -660,18 +662,19 @@ public class ArrayUtilsTest {
ArrayUtils.subarray(dateArray, 1, 4).getClass().getComponentType());
try {
@SuppressWarnings("unused")
+ final
java.sql.Date[] dummy = (java.sql.Date[])ArrayUtils.subarray(dateArray, 1,3);
fail("Invalid downcast");
- } catch (ClassCastException e) {}
+ } catch (final ClassCastException e) {}
}
@Test
public void testSubarrayLong() {
- long[] nullArray = null;
- long[] array = { 999910, 999911, 999912, 999913, 999914, 999915 };
- long[] leftSubarray = { 999910, 999911, 999912, 999913 };
- long[] midSubarray = { 999911, 999912, 999913, 999914 };
- long[] rightSubarray = { 999912, 999913, 999914, 999915 };
+ final long[] nullArray = null;
+ final long[] array = { 999910, 999911, 999912, 999913, 999914, 999915 };
+ final long[] leftSubarray = { 999910, 999911, 999912, 999913 };
+ final long[] midSubarray = { 999911, 999912, 999913, 999914 };
+ final long[] rightSubarray = { 999912, 999913, 999914, 999915 };
assertTrue("0 start, mid end",
ArrayUtils.isEquals(leftSubarray,
@@ -744,11 +747,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayInt() {
- int[] nullArray = null;
- int[] array = { 10, 11, 12, 13, 14, 15 };
- int[] leftSubarray = { 10, 11, 12, 13 };
- int[] midSubarray = { 11, 12, 13, 14 };
- int[] rightSubarray = { 12, 13, 14, 15 };
+ final int[] nullArray = null;
+ final int[] array = { 10, 11, 12, 13, 14, 15 };
+ final int[] leftSubarray = { 10, 11, 12, 13 };
+ final int[] midSubarray = { 11, 12, 13, 14 };
+ final int[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -822,11 +825,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayShort() {
- short[] nullArray = null;
- short[] array = { 10, 11, 12, 13, 14, 15 };
- short[] leftSubarray = { 10, 11, 12, 13 };
- short[] midSubarray = { 11, 12, 13, 14 };
- short[] rightSubarray = { 12, 13, 14, 15 };
+ final short[] nullArray = null;
+ final short[] array = { 10, 11, 12, 13, 14, 15 };
+ final short[] leftSubarray = { 10, 11, 12, 13 };
+ final short[] midSubarray = { 11, 12, 13, 14 };
+ final short[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -900,11 +903,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrChar() {
- char[] nullArray = null;
- char[] array = { 'a', 'b', 'c', 'd', 'e', 'f' };
- char[] leftSubarray = { 'a', 'b', 'c', 'd', };
- char[] midSubarray = { 'b', 'c', 'd', 'e', };
- char[] rightSubarray = { 'c', 'd', 'e', 'f', };
+ final char[] nullArray = null;
+ final char[] array = { 'a', 'b', 'c', 'd', 'e', 'f' };
+ final char[] leftSubarray = { 'a', 'b', 'c', 'd', };
+ final char[] midSubarray = { 'b', 'c', 'd', 'e', };
+ final char[] rightSubarray = { 'c', 'd', 'e', 'f', };
assertTrue("0 start, mid end",
@@ -978,11 +981,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayByte() {
- byte[] nullArray = null;
- byte[] array = { 10, 11, 12, 13, 14, 15 };
- byte[] leftSubarray = { 10, 11, 12, 13 };
- byte[] midSubarray = { 11, 12, 13, 14 };
- byte[] rightSubarray = { 12, 13, 14, 15 };
+ final byte[] nullArray = null;
+ final byte[] array = { 10, 11, 12, 13, 14, 15 };
+ final byte[] leftSubarray = { 10, 11, 12, 13 };
+ final byte[] midSubarray = { 11, 12, 13, 14 };
+ final byte[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -1056,11 +1059,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayDouble() {
- double[] nullArray = null;
- double[] array = { 10.123, 11.234, 12.345, 13.456, 14.567, 15.678 };
- double[] leftSubarray = { 10.123, 11.234, 12.345, 13.456, };
- double[] midSubarray = { 11.234, 12.345, 13.456, 14.567, };
- double[] rightSubarray = { 12.345, 13.456, 14.567, 15.678 };
+ final double[] nullArray = null;
+ final double[] array = { 10.123, 11.234, 12.345, 13.456, 14.567, 15.678 };
+ final double[] leftSubarray = { 10.123, 11.234, 12.345, 13.456, };
+ final double[] midSubarray = { 11.234, 12.345, 13.456, 14.567, };
+ final double[] rightSubarray = { 12.345, 13.456, 14.567, 15.678 };
assertTrue("0 start, mid end",
@@ -1134,11 +1137,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayFloat() {
- float[] nullArray = null;
- float[] array = { 10, 11, 12, 13, 14, 15 };
- float[] leftSubarray = { 10, 11, 12, 13 };
- float[] midSubarray = { 11, 12, 13, 14 };
- float[] rightSubarray = { 12, 13, 14, 15 };
+ final float[] nullArray = null;
+ final float[] array = { 10, 11, 12, 13, 14, 15 };
+ final float[] leftSubarray = { 10, 11, 12, 13 };
+ final float[] midSubarray = { 11, 12, 13, 14 };
+ final float[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -1212,11 +1215,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayBoolean() {
- boolean[] nullArray = null;
- boolean[] array = { true, true, false, true, false, true };
- boolean[] leftSubarray = { true, true, false, true };
- boolean[] midSubarray = { true, false, true, false };
- boolean[] rightSubarray = { false, true, false, true };
+ final boolean[] nullArray = null;
+ final boolean[] array = { true, true, false, true, false, true };
+ final boolean[] leftSubarray = { true, true, false, true };
+ final boolean[] midSubarray = { true, false, true, false };
+ final boolean[] rightSubarray = { false, true, false, true };
assertTrue("0 start, mid end",
@@ -1291,10 +1294,10 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testSameLength() {
- Object[] nullArray = null;
- Object[] emptyArray = new Object[0];
- Object[] oneArray = new Object[] {"pick"};
- Object[] twoArray = new Object[] {"pick", "stick"};
+ final Object[] nullArray = null;
+ final Object[] emptyArray = new Object[0];
+ final Object[] oneArray = new Object[] {"pick"};
+ final Object[] twoArray = new Object[] {"pick", "stick"};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1319,10 +1322,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthBoolean() {
- boolean[] nullArray = null;
- boolean[] emptyArray = new boolean[0];
- boolean[] oneArray = new boolean[] {true};
- boolean[] twoArray = new boolean[] {true, false};
+ final boolean[] nullArray = null;
+ final boolean[] emptyArray = new boolean[0];
+ final boolean[] oneArray = new boolean[] {true};
+ final boolean[] twoArray = new boolean[] {true, false};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1347,10 +1350,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthLong() {
- long[] nullArray = null;
- long[] emptyArray = new long[0];
- long[] oneArray = new long[] {0L};
- long[] twoArray = new long[] {0L, 76L};
+ final long[] nullArray = null;
+ final long[] emptyArray = new long[0];
+ final long[] oneArray = new long[] {0L};
+ final long[] twoArray = new long[] {0L, 76L};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1375,10 +1378,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthInt() {
- int[] nullArray = null;
- int[] emptyArray = new int[0];
- int[] oneArray = new int[] {4};
- int[] twoArray = new int[] {5, 7};
+ final int[] nullArray = null;
+ final int[] emptyArray = new int[0];
+ final int[] oneArray = new int[] {4};
+ final int[] twoArray = new int[] {5, 7};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1403,10 +1406,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthShort() {
- short[] nullArray = null;
- short[] emptyArray = new short[0];
- short[] oneArray = new short[] {4};
- short[] twoArray = new short[] {6, 8};
+ final short[] nullArray = null;
+ final short[] emptyArray = new short[0];
+ final short[] oneArray = new short[] {4};
+ final short[] twoArray = new short[] {6, 8};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1431,10 +1434,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthChar() {
- char[] nullArray = null;
- char[] emptyArray = new char[0];
- char[] oneArray = new char[] {'f'};
- char[] twoArray = new char[] {'d', 't'};
+ final char[] nullArray = null;
+ final char[] emptyArray = new char[0];
+ final char[] oneArray = new char[] {'f'};
+ final char[] twoArray = new char[] {'d', 't'};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1459,10 +1462,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthByte() {
- byte[] nullArray = null;
- byte[] emptyArray = new byte[0];
- byte[] oneArray = new byte[] {3};
- byte[] twoArray = new byte[] {4, 6};
+ final byte[] nullArray = null;
+ final byte[] emptyArray = new byte[0];
+ final byte[] oneArray = new byte[] {3};
+ final byte[] twoArray = new byte[] {4, 6};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1487,10 +1490,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthDouble() {
- double[] nullArray = null;
- double[] emptyArray = new double[0];
- double[] oneArray = new double[] {1.3d};
- double[] twoArray = new double[] {4.5d, 6.3d};
+ final double[] nullArray = null;
+ final double[] emptyArray = new double[0];
+ final double[] oneArray = new double[] {1.3d};
+ final double[] twoArray = new double[] {4.5d, 6.3d};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1515,10 +1518,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthFloat() {
- float[] nullArray = null;
- float[] emptyArray = new float[0];
- float[] oneArray = new float[] {2.5f};
- float[] twoArray = new float[] {6.4f, 5.8f};
+ final float[] nullArray = null;
+ final float[] emptyArray = new float[0];
+ final float[] oneArray = new float[] {2.5f};
+ final float[] twoArray = new float[] {6.4f, 5.8f};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1547,15 +1550,15 @@ public class ArrayUtilsTest {
try {
ArrayUtils.isSameType(null, null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.isSameType(null, new Object[0]);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.isSameType(new Object[0], null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
assertTrue(ArrayUtils.isSameType(new Object[0], new Object[0]));
assertFalse(ArrayUtils.isSameType(new String[0], new Object[0]));
@@ -1567,10 +1570,10 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testReverse() {
- StringBuffer str1 = new StringBuffer("pick");
- String str2 = "a";
- String[] str3 = new String[] {"stick"};
- String str4 = "up";
+ final StringBuffer str1 = new StringBuffer("pick");
+ final String str2 = "a";
+ final String[] str3 = new String[] {"stick"};
+ final String str4 = "up";
Object[] array = new Object[] {str1, str2, str3};
ArrayUtils.reverse(array);
@@ -1697,7 +1700,7 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testIndexOf() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.indexOf(null, null));
assertEquals(-1, ArrayUtils.indexOf(null, "0"));
assertEquals(-1, ArrayUtils.indexOf(new Object[0], "0"));
@@ -1711,7 +1714,7 @@ public class ArrayUtilsTest {
@Test
public void testIndexOfWithStartIndex() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.indexOf(null, null, 2));
assertEquals(-1, ArrayUtils.indexOf(new Object[0], "0", 0));
assertEquals(-1, ArrayUtils.indexOf(null, "0", 2));
@@ -1729,7 +1732,7 @@ public class ArrayUtilsTest {
@Test
public void testLastIndexOf() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.lastIndexOf(null, null));
assertEquals(-1, ArrayUtils.lastIndexOf(null, "0"));
assertEquals(5, ArrayUtils.lastIndexOf(array, "0"));
@@ -1742,7 +1745,7 @@ public class ArrayUtilsTest {
@Test
public void testLastIndexOfWithStartIndex() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.lastIndexOf(null, null, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(null, "0", 2));
assertEquals(0, ArrayUtils.lastIndexOf(array, "0", 2));
@@ -1760,7 +1763,7 @@ public class ArrayUtilsTest {
@Test
public void testContains() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertFalse(ArrayUtils.contains(null, null));
assertFalse(ArrayUtils.contains(null, "1"));
assertTrue(ArrayUtils.contains(array, "0"));
@@ -2414,7 +2417,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Boolean[] {Boolean.TRUE, null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2464,7 +2467,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2523,7 +2526,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2582,7 +2585,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2638,7 +2641,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2660,7 +2663,7 @@ public class ArrayUtilsTest {
@Test
public void testToPrimitive_intNull() {
- Integer[] iArray = null;
+ final Integer[] iArray = null;
assertEquals(null, ArrayUtils.toPrimitive(iArray, Integer.MIN_VALUE));
}
@@ -2702,7 +2705,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2763,7 +2766,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2824,7 +2827,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2872,8 +2875,8 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsEmptyObject() {
- Object[] emptyArray = new Object[] {};
- Object[] notEmptyArray = new Object[] { new String("Value") };
+ final Object[] emptyArray = new Object[] {};
+ final Object[] notEmptyArray = new Object[] { new String("Value") };
assertTrue(ArrayUtils.isEmpty((Object[])null));
assertTrue(ArrayUtils.isEmpty(emptyArray));
assertFalse(ArrayUtils.isEmpty(notEmptyArray));
@@ -2891,50 +2894,50 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsEmptyPrimitives() {
- long[] emptyLongArray = new long[] {};
- long[] notEmptyLongArray = new long[] { 1L };
+ final long[] emptyLongArray = new long[] {};
+ final long[] notEmptyLongArray = new long[] { 1L };
assertTrue(ArrayUtils.isEmpty((long[])null));
assertTrue(ArrayUtils.isEmpty(emptyLongArray));
assertFalse(ArrayUtils.isEmpty(notEmptyLongArray));
- int[] emptyIntArray = new int[] {};
- int[] notEmptyIntArray = new int[] { 1 };
+ final int[] emptyIntArray = new int[] {};
+ final int[] notEmptyIntArray = new int[] { 1 };
assertTrue(ArrayUtils.isEmpty((int[])null));
assertTrue(ArrayUtils.isEmpty(emptyIntArray));
assertFalse(ArrayUtils.isEmpty(notEmptyIntArray));
- short[] emptyShortArray = new short[] {};
- short[] notEmptyShortArray = new short[] { 1 };
+ final short[] emptyShortArray = new short[] {};
+ final short[] notEmptyShortArray = new short[] { 1 };
assertTrue(ArrayUtils.isEmpty((short[])null));
assertTrue(ArrayUtils.isEmpty(emptyShortArray));
assertFalse(ArrayUtils.isEmpty(notEmptyShortArray));
- char[] emptyCharArray = new char[] {};
- char[] notEmptyCharArray = new char[] { 1 };
+ final char[] emptyCharArray = new char[] {};
+ final char[] notEmptyCharArray = new char[] { 1 };
assertTrue(ArrayUtils.isEmpty((char[])null));
assertTrue(ArrayUtils.isEmpty(emptyCharArray));
assertFalse(ArrayUtils.isEmpty(notEmptyCharArray));
- byte[] emptyByteArray = new byte[] {};
- byte[] notEmptyByteArray = new byte[] { 1 };
+ final byte[] emptyByteArray = new byte[] {};
+ final byte[] notEmptyByteArray = new byte[] { 1 };
assertTrue(ArrayUtils.isEmpty((byte[])null));
assertTrue(ArrayUtils.isEmpty(emptyByteArray));
assertFalse(ArrayUtils.isEmpty(notEmptyByteArray));
- double[] emptyDoubleArray = new double[] {};
- double[] notEmptyDoubleArray = new double[] { 1.0 };
+ final double[] emptyDoubleArray = new double[] {};
+ final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertTrue(ArrayUtils.isEmpty((double[])null));
assertTrue(ArrayUtils.isEmpty(emptyDoubleArray));
assertFalse(ArrayUtils.isEmpty(notEmptyDoubleArray));
- float[] emptyFloatArray = new float[] {};
- float[] notEmptyFloatArray = new float[] { 1.0F };
+ final float[] emptyFloatArray = new float[] {};
+ final float[] notEmptyFloatArray = new float[] { 1.0F };
assertTrue(ArrayUtils.isEmpty((float[])null));
assertTrue(ArrayUtils.isEmpty(emptyFloatArray));
assertFalse(ArrayUtils.isEmpty(notEmptyFloatArray));
- boolean[] emptyBooleanArray = new boolean[] {};
- boolean[] notEmptyBooleanArray = new boolean[] { true };
+ final boolean[] emptyBooleanArray = new boolean[] {};
+ final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertTrue(ArrayUtils.isEmpty((boolean[])null));
assertTrue(ArrayUtils.isEmpty(emptyBooleanArray));
assertFalse(ArrayUtils.isEmpty(notEmptyBooleanArray));
@@ -2945,8 +2948,8 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsNotEmptyObject() {
- Object[] emptyArray = new Object[] {};
- Object[] notEmptyArray = new Object[] { new String("Value") };
+ final Object[] emptyArray = new Object[] {};
+ final Object[] notEmptyArray = new Object[] { new String("Value") };
assertFalse(ArrayUtils.isNotEmpty((Object[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyArray));
@@ -2964,50 +2967,50 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsNotEmptyPrimitives() {
- long[] emptyLongArray = new long[] {};
- long[] notEmptyLongArray = new long[] { 1L };
+ final long[] emptyLongArray = new long[] {};
+ final long[] notEmptyLongArray = new long[] { 1L };
assertFalse(ArrayUtils.isNotEmpty((long[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyLongArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyLongArray));
- int[] emptyIntArray = new int[] {};
- int[] notEmptyIntArray = new int[] { 1 };
+ final int[] emptyIntArray = new int[] {};
+ final int[] notEmptyIntArray = new int[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((int[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyIntArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyIntArray));
- short[] emptyShortArray = new short[] {};
- short[] notEmptyShortArray = new short[] { 1 };
+ final short[] emptyShortArray = new short[] {};
+ final short[] notEmptyShortArray = new short[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((short[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyShortArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyShortArray));
- char[] emptyCharArray = new char[] {};
- char[] notEmptyCharArray = new char[] { 1 };
+ final char[] emptyCharArray = new char[] {};
+ final char[] notEmptyCharArray = new char[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((char[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyCharArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyCharArray));
- byte[] emptyByteArray = new byte[] {};
- byte[] notEmptyByteArray = new byte[] { 1 };
+ final byte[] emptyByteArray = new byte[] {};
+ final byte[] notEmptyByteArray = new byte[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((byte[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyByteArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyByteArray));
- double[] emptyDoubleArray = new double[] {};
- double[] notEmptyDoubleArray = new double[] { 1.0 };
+ final double[] emptyDoubleArray = new double[] {};
+ final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertFalse(ArrayUtils.isNotEmpty((double[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyDoubleArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyDoubleArray));
- float[] emptyFloatArray = new float[] {};
- float[] notEmptyFloatArray = new float[] { 1.0F };
+ final float[] emptyFloatArray = new float[] {};
+ final float[] notEmptyFloatArray = new float[] { 1.0F };
assertFalse(ArrayUtils.isNotEmpty((float[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyFloatArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyFloatArray));
- boolean[] emptyBooleanArray = new boolean[] {};
- boolean[] notEmptyBooleanArray = new boolean[] { true };
+ final boolean[] emptyBooleanArray = new boolean[] {};
+ final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertFalse(ArrayUtils.isNotEmpty((boolean[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyBooleanArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyBooleanArray));
@@ -3017,50 +3020,50 @@ public class ArrayUtilsTest {
public void testGetLength() {
assertEquals(0, ArrayUtils.getLength(null));
- Object[] emptyObjectArray = new Object[0];
- Object[] notEmptyObjectArray = new Object[] {"aValue"};
+ final Object[] emptyObjectArray = new Object[0];
+ final Object[] notEmptyObjectArray = new Object[] {"aValue"};
assertEquals(0, ArrayUtils.getLength((Object[]) null));
assertEquals(0, ArrayUtils.getLength(emptyObjectArray));
assertEquals(1, ArrayUtils.getLength(notEmptyObjectArray));
- int[] emptyIntArray = new int[] {};
- int[] notEmptyIntArray = new int[] { 1 };
+ final int[] emptyIntArray = new int[] {};
+ final int[] notEmptyIntArray = new int[] { 1 };
assertEquals(0, ArrayUtils.getLength((int[]) null));
assertEquals(0, ArrayUtils.getLength(emptyIntArray));
assertEquals(1, ArrayUtils.getLength(notEmptyIntArray));
- short[] emptyShortArray = new short[] {};
- short[] notEmptyShortArray = new short[] { 1 };
+ final short[] emptyShortArray = new short[] {};
+ final short[] notEmptyShortArray = new short[] { 1 };
assertEquals(0, ArrayUtils.getLength((short[]) null));
assertEquals(0, ArrayUtils.getLength(emptyShortArray));
assertEquals(1, ArrayUtils.getLength(notEmptyShortArray));
- char[] emptyCharArray = new char[] {};
- char[] notEmptyCharArray = new char[] { 1 };
+ final char[] emptyCharArray = new char[] {};
+ final char[] notEmptyCharArray = new char[] { 1 };
assertEquals(0, ArrayUtils.getLength((char[]) null));
assertEquals(0, ArrayUtils.getLength(emptyCharArray));
assertEquals(1, ArrayUtils.getLength(notEmptyCharArray));
- byte[] emptyByteArray = new byte[] {};
- byte[] notEmptyByteArray = new byte[] { 1 };
+ final byte[] emptyByteArray = new byte[] {};
+ final byte[] notEmptyByteArray = new byte[] { 1 };
assertEquals(0, ArrayUtils.getLength((byte[]) null));
assertEquals(0, ArrayUtils.getLength(emptyByteArray));
assertEquals(1, ArrayUtils.getLength(notEmptyByteArray));
- double[] emptyDoubleArray = new double[] {};
- double[] notEmptyDoubleArray = new double[] { 1.0 };
+ final double[] emptyDoubleArray = new double[] {};
+ final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertEquals(0, ArrayUtils.getLength((double[]) null));
assertEquals(0, ArrayUtils.getLength(emptyDoubleArray));
assertEquals(1, ArrayUtils.getLength(notEmptyDoubleArray));
- float[] emptyFloatArray = new float[] {};
- float[] notEmptyFloatArray = new float[] { 1.0F };
+ final float[] emptyFloatArray = new float[] {};
+ final float[] notEmptyFloatArray = new float[] { 1.0F };
assertEquals(0, ArrayUtils.getLength((float[]) null));
assertEquals(0, ArrayUtils.getLength(emptyFloatArray));
assertEquals(1, ArrayUtils.getLength(notEmptyFloatArray));
- boolean[] emptyBooleanArray = new boolean[] {};
- boolean[] notEmptyBooleanArray = new boolean[] { true };
+ final boolean[] emptyBooleanArray = new boolean[] {};
+ final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertEquals(0, ArrayUtils.getLength((boolean[]) null));
assertEquals(0, ArrayUtils.getLength(emptyBooleanArray));
assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray));
@@ -3068,7 +3071,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.getLength("notAnArray");
fail("IllegalArgumentException should have been thrown");
- } catch (IllegalArgumentException e) {}
+ } catch (final IllegalArgumentException e) {}
}
}
diff --git a/src/test/java/org/apache/commons/lang3/BitFieldTest.java b/src/test/java/org/apache/commons/lang3/BitFieldTest.java
index 3a0de5608..dd71abda9 100644
--- a/src/test/java/org/apache/commons/lang3/BitFieldTest.java
+++ b/src/test/java/org/apache/commons/lang3/BitFieldTest.java
@@ -187,7 +187,7 @@ public class BitFieldTest {
assertEquals(0, new BitField(64).setByteBoolean((byte) 64, false));
assertEquals(0, new BitField(128).setByteBoolean((byte) 128, false));
assertEquals(-2, new BitField(1).setByteBoolean((byte) 255, false));
- byte clearedBit = new BitField(0x40).setByteBoolean((byte) - 63, false);
+ final byte clearedBit = new BitField(0x40).setByteBoolean((byte) - 63, false);
assertFalse(new BitField(0x40).isSet(clearedBit));
}
diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
index f12d97940..4d104a0ee 100644
--- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
@@ -38,7 +38,7 @@ public class BooleanUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new BooleanUtils());
- Constructor<?>[] cons = BooleanUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = BooleanUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
@@ -139,8 +139,8 @@ public class BooleanUtilsTest {
@Test
public void test_toBoolean_Integer_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
assertTrue(BooleanUtils.toBoolean((Integer) null, null, seven));
assertFalse(BooleanUtils.toBoolean((Integer) null, six, null));
@@ -174,9 +174,9 @@ public class BooleanUtilsTest {
@Test
public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
- Integer eight = Integer.valueOf(8);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
+ final Integer eight = Integer.valueOf(8);
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
@@ -233,17 +233,17 @@ public class BooleanUtilsTest {
@Test
public void test_toIntegerObject_boolean_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven));
assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven));
}
@Test
public void test_toIntegerObject_Boolean_Integer_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
- Integer eight = Integer.valueOf(8);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
+ final Integer eight = Integer.valueOf(8);
assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight));
assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight));
assertEquals(eight, BooleanUtils.toIntegerObject((Boolean) null, six, seven, eight));
diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java
index 841049464..301e6f7da 100644
--- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java
@@ -48,7 +48,7 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test
public void testConstructorAccessors_is() {
- CharRange rangea = CharRange.is('a');
+ final CharRange rangea = CharRange.is('a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -57,7 +57,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNot() {
- CharRange rangea = CharRange.isNot('a');
+ final CharRange rangea = CharRange.isNot('a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -66,7 +66,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isIn_Same() {
- CharRange rangea = CharRange.isIn('a', 'a');
+ final CharRange rangea = CharRange.isIn('a', 'a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -75,7 +75,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isIn_Normal() {
- CharRange rangea = CharRange.isIn('a', 'e');
+ final CharRange rangea = CharRange.isIn('a', 'e');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -84,7 +84,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isIn_Reversed() {
- CharRange rangea = CharRange.isIn('e', 'a');
+ final CharRange rangea = CharRange.isIn('e', 'a');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -93,7 +93,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNotIn_Same() {
- CharRange rangea = CharRange.isNotIn('a', 'a');
+ final CharRange rangea = CharRange.isNotIn('a', 'a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -102,7 +102,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNotIn_Normal() {
- CharRange rangea = CharRange.isNotIn('a', 'e');
+ final CharRange rangea = CharRange.isNotIn('a', 'e');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -111,7 +111,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNotIn_Reversed() {
- CharRange rangea = CharRange.isNotIn('e', 'a');
+ final CharRange rangea = CharRange.isNotIn('e', 'a');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -121,9 +121,9 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test
public void testEquals_Object() {
- CharRange rangea = CharRange.is('a');
- CharRange rangeae = CharRange.isIn('a', 'e');
- CharRange rangenotbf = CharRange.isIn('b', 'f');
+ final CharRange rangea = CharRange.is('a');
+ final CharRange rangeae = CharRange.isIn('a', 'e');
+ final CharRange rangenotbf = CharRange.isIn('b', 'f');
assertFalse(rangea.equals(null));
@@ -144,9 +144,9 @@ public class CharRangeTest {
@Test
public void testHashCode() {
- CharRange rangea = CharRange.is('a');
- CharRange rangeae = CharRange.isIn('a', 'e');
- CharRange rangenotbf = CharRange.isIn('b', 'f');
+ final CharRange rangea = CharRange.is('a');
+ final CharRange rangeae = CharRange.isIn('a', 'e');
+ final CharRange rangenotbf = CharRange.isIn('b', 'f');
assertTrue(rangea.hashCode() == rangea.hashCode());
assertTrue(rangea.hashCode() == CharRange.is('a').hashCode());
@@ -196,19 +196,19 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test
public void testContains_Charrange() {
- CharRange a = CharRange.is('a');
- CharRange b = CharRange.is('b');
- CharRange c = CharRange.is('c');
- CharRange c2 = CharRange.is('c');
- CharRange d = CharRange.is('d');
- CharRange e = CharRange.is('e');
- CharRange cd = CharRange.isIn('c', 'd');
- CharRange bd = CharRange.isIn('b', 'd');
- CharRange bc = CharRange.isIn('b', 'c');
- CharRange ab = CharRange.isIn('a', 'b');
- CharRange de = CharRange.isIn('d', 'e');
- CharRange ef = CharRange.isIn('e', 'f');
- CharRange ae = CharRange.isIn('a', 'e');
+ final CharRange a = CharRange.is('a');
+ final CharRange b = CharRange.is('b');
+ final CharRange c = CharRange.is('c');
+ final CharRange c2 = CharRange.is('c');
+ final CharRange d = CharRange.is('d');
+ final CharRange e = CharRange.is('e');
+ final CharRange cd = CharRange.isIn('c', 'd');
+ final CharRange bd = CharRange.isIn('b', 'd');
+ final CharRange bc = CharRange.isIn('b', 'c');
+ final CharRange ab = CharRange.isIn('a', 'b');
+ final CharRange de = CharRange.isIn('d', 'e');
+ final CharRange ef = CharRange.isIn('e', 'f');
+ final CharRange ae = CharRange.isIn('a', 'e');
// normal/normal
assertFalse(c.contains(b));
@@ -234,17 +234,17 @@ public class CharRangeTest {
assertTrue(ae.contains(cd));
assertTrue(ae.contains(de));
- CharRange notb = CharRange.isNot('b');
- CharRange notc = CharRange.isNot('c');
- CharRange notd = CharRange.isNot('d');
- CharRange notab = CharRange.isNotIn('a', 'b');
- CharRange notbc = CharRange.isNotIn('b', 'c');
- CharRange notbd = CharRange.isNotIn('b', 'd');
- CharRange notcd = CharRange.isNotIn('c', 'd');
- CharRange notde = CharRange.isNotIn('d', 'e');
- CharRange notae = CharRange.isNotIn('a', 'e');
- CharRange all = CharRange.isIn((char) 0, Character.MAX_VALUE);
- CharRange allbutfirst = CharRange.isIn((char) 1, Character.MAX_VALUE);
+ final CharRange notb = CharRange.isNot('b');
+ final CharRange notc = CharRange.isNot('c');
+ final CharRange notd = CharRange.isNot('d');
+ final CharRange notab = CharRange.isNotIn('a', 'b');
+ final CharRange notbc = CharRange.isNotIn('b', 'c');
+ final CharRange notbd = CharRange.isNotIn('b', 'd');
+ final CharRange notcd = CharRange.isNotIn('c', 'd');
+ final CharRange notde = CharRange.isNotIn('d', 'e');
+ final CharRange notae = CharRange.isNotIn('a', 'e');
+ final CharRange all = CharRange.isIn((char) 0, Character.MAX_VALUE);
+ final CharRange allbutfirst = CharRange.isIn((char) 1, Character.MAX_VALUE);
// normal/negated
assertFalse(c.contains(notc));
@@ -311,31 +311,32 @@ public class CharRangeTest {
@Test
public void testContainsNullArg() {
- CharRange range = CharRange.is('a');
+ final CharRange range = CharRange.is('a');
try {
@SuppressWarnings("unused")
+ final
boolean contains = range.contains(null);
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("The Range must not be null", e.getMessage());
}
}
@Test
public void testIterator() {
- CharRange a = CharRange.is('a');
- CharRange ad = CharRange.isIn('a', 'd');
- CharRange nota = CharRange.isNot('a');
- CharRange emptySet = CharRange.isNotIn((char) 0, Character.MAX_VALUE);
- CharRange notFirst = CharRange.isNotIn((char) 1, Character.MAX_VALUE);
- CharRange notLast = CharRange.isNotIn((char) 0, (char) (Character.MAX_VALUE - 1));
-
- Iterator<Character> aIt = a.iterator();
+ final CharRange a = CharRange.is('a');
+ final CharRange ad = CharRange.isIn('a', 'd');
+ final CharRange nota = CharRange.isNot('a');
+ final CharRange emptySet = CharRange.isNotIn((char) 0, Character.MAX_VALUE);
+ final CharRange notFirst = CharRange.isNotIn((char) 1, Character.MAX_VALUE);
+ final CharRange notLast = CharRange.isNotIn((char) 0, (char) (Character.MAX_VALUE - 1));
+
+ final Iterator<Character> aIt = a.iterator();
assertNotNull(aIt);
assertTrue(aIt.hasNext());
assertEquals(Character.valueOf('a'), aIt.next());
assertFalse(aIt.hasNext());
- Iterator<Character> adIt = ad.iterator();
+ final Iterator<Character> adIt = ad.iterator();
assertNotNull(adIt);
assertTrue(adIt.hasNext());
assertEquals(Character.valueOf('a'), adIt.next());
@@ -344,25 +345,25 @@ public class CharRangeTest {
assertEquals(Character.valueOf('d'), adIt.next());
assertFalse(adIt.hasNext());
- Iterator<Character> notaIt = nota.iterator();
+ final Iterator<Character> notaIt = nota.iterator();
assertNotNull(notaIt);
assertTrue(notaIt.hasNext());
while (notaIt.hasNext()) {
- Character c = notaIt.next();
+ final Character c = notaIt.next();
assertFalse('a' == c.charValue());
}
- Iterator<Character> emptySetIt = emptySet.iterator();
+ final Iterator<Character> emptySetIt = emptySet.iterator();
assertNotNull(emptySetIt);
assertFalse(emptySetIt.hasNext());
try {
emptySetIt.next();
fail("Should throw NoSuchElementException");
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
assertTrue(true);
}
- Iterator<Character> notFirstIt = notFirst.iterator();
+ final Iterator<Character> notFirstIt = notFirst.iterator();
assertNotNull(notFirstIt);
assertTrue(notFirstIt.hasNext());
assertEquals(Character.valueOf((char) 0), notFirstIt.next());
@@ -370,11 +371,11 @@ public class CharRangeTest {
try {
notFirstIt.next();
fail("Should throw NoSuchElementException");
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
assertTrue(true);
}
- Iterator<Character> notLastIt = notLast.iterator();
+ final Iterator<Character> notLastIt = notLast.iterator();
assertNotNull(notLastIt);
assertTrue(notLastIt.hasNext());
assertEquals(Character.valueOf(Character.MAX_VALUE), notLastIt.next());
@@ -382,7 +383,7 @@ public class CharRangeTest {
try {
notLastIt.next();
fail("Should throw NoSuchElementException");
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
assertTrue(true);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
index 875b69ccb..e68c4068f 100644
--- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
@@ -39,7 +39,7 @@ public class CharSequenceUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new CharSequenceUtils());
- Constructor<?>[] cons = CharSequenceUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = CharSequenceUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(CharSequenceUtils.class.getModifiers()));
@@ -69,13 +69,13 @@ public class CharSequenceUtilsTest {
try {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, -1));
Assert.fail("Expected " + IndexOutOfBoundsException.class.getName());
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// Expected
}
try {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, 1));
Assert.fail("Expected " + IndexOutOfBoundsException.class.getName());
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// Expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/CharSetTest.java b/src/test/java/org/apache/commons/lang3/CharSetTest.java
index 17100073a..014d7b765 100644
--- a/src/test/java/org/apache/commons/lang3/CharSetTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharSetTest.java
@@ -343,12 +343,12 @@ public class CharSetTest {
//-----------------------------------------------------------------------
@Test
public void testEquals_Object() {
- CharSet abc = CharSet.getInstance("abc");
- CharSet abc2 = CharSet.getInstance("abc");
- CharSet atoc = CharSet.getInstance("a-c");
- CharSet atoc2 = CharSet.getInstance("a-c");
- CharSet notatoc = CharSet.getInstance("^a-c");
- CharSet notatoc2 = CharSet.getInstance("^a-c");
+ final CharSet abc = CharSet.getInstance("abc");
+ final CharSet abc2 = CharSet.getInstance("abc");
+ final CharSet atoc = CharSet.getInstance("a-c");
+ final CharSet atoc2 = CharSet.getInstance("a-c");
+ final CharSet notatoc = CharSet.getInstance("^a-c");
+ final CharSet notatoc2 = CharSet.getInstance("^a-c");
assertFalse(abc.equals(null));
@@ -370,12 +370,12 @@ public class CharSetTest {
@Test
public void testHashCode() {
- CharSet abc = CharSet.getInstance("abc");
- CharSet abc2 = CharSet.getInstance("abc");
- CharSet atoc = CharSet.getInstance("a-c");
- CharSet atoc2 = CharSet.getInstance("a-c");
- CharSet notatoc = CharSet.getInstance("^a-c");
- CharSet notatoc2 = CharSet.getInstance("^a-c");
+ final CharSet abc = CharSet.getInstance("abc");
+ final CharSet abc2 = CharSet.getInstance("abc");
+ final CharSet atoc = CharSet.getInstance("a-c");
+ final CharSet atoc2 = CharSet.getInstance("a-c");
+ final CharSet notatoc = CharSet.getInstance("^a-c");
+ final CharSet notatoc2 = CharSet.getInstance("^a-c");
assertEquals(abc.hashCode(), abc.hashCode());
assertEquals(abc.hashCode(), abc2.hashCode());
@@ -388,11 +388,11 @@ public class CharSetTest {
//-----------------------------------------------------------------------
@Test
public void testContains_Char() {
- CharSet btod = CharSet.getInstance("b-d");
- CharSet dtob = CharSet.getInstance("d-b");
- CharSet bcd = CharSet.getInstance("bcd");
- CharSet bd = CharSet.getInstance("bd");
- CharSet notbtod = CharSet.getInstance("^b-d");
+ final CharSet btod = CharSet.getInstance("b-d");
+ final CharSet dtob = CharSet.getInstance("d-b");
+ final CharSet bcd = CharSet.getInstance("bcd");
+ final CharSet bd = CharSet.getInstance("bd");
+ final CharSet notbtod = CharSet.getInstance("^b-d");
assertFalse(btod.contains('a'));
assertTrue(btod.contains('b'));
@@ -424,7 +424,7 @@ public class CharSetTest {
assertTrue(dtob.contains('d'));
assertFalse(dtob.contains('e'));
- CharRange[] array = dtob.getCharRanges();
+ final CharRange[] array = dtob.getCharRanges();
assertEquals("[b-d]", dtob.toString());
assertEquals(1, array.length);
}
diff --git a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
index 1faefd93c..d342a6505 100644
--- a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
@@ -37,7 +37,7 @@ public class CharSetUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new CharSetUtils());
- Constructor<?>[] cons = CharSetUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = CharSetUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(CharSetUtils.class.getModifiers()));
diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
index fc5553ad8..d6b54d992 100644
--- a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
+++ b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
@@ -125,8 +125,8 @@ public class CharUtilsPerfRun {
private int run_CharSet(final int loopCount) {
int t = 0;
for (int i = 0; i < loopCount; i++) {
- for (char ch : CHAR_SAMPLES) {
- boolean b = CharSet.ASCII_NUMERIC.contains(ch);
+ for (final char ch : CHAR_SAMPLES) {
+ final boolean b = CharSet.ASCII_NUMERIC.contains(ch);
t += b ? 1 : 0;
}
}
@@ -136,8 +136,8 @@ public class CharUtilsPerfRun {
private int run_CharUtils_isAsciiNumeric(final int loopCount) {
int t = 0;
for (int i = 0; i < loopCount; i++) {
- for (char ch : CHAR_SAMPLES) {
- boolean b = CharUtils.isAsciiNumeric(ch);
+ for (final char ch : CHAR_SAMPLES) {
+ final boolean b = CharUtils.isAsciiNumeric(ch);
t += b ? 1 : 0;
}
}
@@ -147,8 +147,8 @@ public class CharUtilsPerfRun {
private int run_inlined_CharUtils_isAsciiNumeric(final int loopCount) {
int t = 0;
for (int i = 0; i < loopCount; i++) {
- for (char ch : CHAR_SAMPLES) {
- boolean b = ch >= '0' && ch <= '9';
+ for (final char ch : CHAR_SAMPLES) {
+ final boolean b = ch >= '0' && ch <= '9';
t += b ? 1 : 0;
}
}
@@ -156,7 +156,7 @@ public class CharUtilsPerfRun {
}
private void printlnTotal(final String prefix, final long start) {
- long total = System.currentTimeMillis() - start;
+ final long total = System.currentTimeMillis() - start;
System.out.println(prefix + ": " + NumberFormat.getInstance().format(total) + " milliseconds.");
}
}
diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
index 40ec5fc93..b2adcb36d 100644
--- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
@@ -41,7 +41,7 @@ public class CharUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new CharUtils());
- Constructor<?>[] cons = CharUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = CharUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
@@ -55,14 +55,14 @@ public class CharUtilsTest {
assertSame(CharUtils.toCharacterObject('a'), CharUtils.toCharacterObject('a'));
for (int i = 0; i < 128; i++) {
- Character ch = CharUtils.toCharacterObject((char) i);
- Character ch2 = CharUtils.toCharacterObject((char) i);
+ final Character ch = CharUtils.toCharacterObject((char) i);
+ final Character ch2 = CharUtils.toCharacterObject((char) i);
assertSame(ch, ch2);
assertEquals(i, ch.charValue());
}
for (int i = 128; i < 196; i++) {
- Character ch = CharUtils.toCharacterObject((char) i);
- Character ch2 = CharUtils.toCharacterObject((char) i);
+ final Character ch = CharUtils.toCharacterObject((char) i);
+ final Character ch2 = CharUtils.toCharacterObject((char) i);
assertEquals(ch, ch2);
assertTrue(ch != ch2);
assertEquals(i, ch.charValue());
@@ -86,7 +86,7 @@ public class CharUtilsTest {
assertEquals('B', CharUtils.toChar(CHARACTER_B));
try {
CharUtils.toChar((Character) null);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -102,10 +102,10 @@ public class CharUtilsTest {
assertEquals('B', CharUtils.toChar("BA"));
try {
CharUtils.toChar((String) null);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
CharUtils.toChar("");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -130,7 +130,7 @@ public class CharUtilsTest {
assertEquals(9, CharUtils.toIntValue('9'));
try {
CharUtils.toIntValue('a');
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -146,10 +146,10 @@ public class CharUtilsTest {
assertEquals(3, CharUtils.toIntValue(new Character('3')));
try {
CharUtils.toIntValue(null);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
CharUtils.toIntValue(CHARACTER_A);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -166,15 +166,15 @@ public class CharUtilsTest {
assertSame(CharUtils.toString('a'), CharUtils.toString('a'));
for (int i = 0; i < 128; i++) {
- String str = CharUtils.toString((char) i);
- String str2 = CharUtils.toString((char) i);
+ final String str = CharUtils.toString((char) i);
+ final String str2 = CharUtils.toString((char) i);
assertSame(str, str2);
assertEquals(1, str.length());
assertEquals(i, str.charAt(0));
}
for (int i = 128; i < 196; i++) {
- String str = CharUtils.toString((char) i);
- String str2 = CharUtils.toString((char) i);
+ final String str = CharUtils.toString((char) i);
+ final String str2 = CharUtils.toString((char) i);
assertEquals(str, str2);
assertTrue(str != str2);
assertEquals(1, str.length());
@@ -196,9 +196,9 @@ public class CharUtilsTest {
assertEquals("\\u0041", CharUtils.unicodeEscaped('A'));
for (int i = 0; i < 196; i++) {
- String str = CharUtils.unicodeEscaped((char) i);
+ final String str = CharUtils.unicodeEscaped((char) i);
assertEquals(6, str.length());
- int val = Integer.parseInt(str.substring(2), 16);
+ final int val = Integer.parseInt(str.substring(2), 16);
assertEquals(i, val);
}
assertEquals("\\u0999", CharUtils.unicodeEscaped((char) 0x999));
diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
index 057e57d61..ce6752cdb 100644
--- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
@@ -56,7 +56,7 @@ public class ClassUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ClassUtils());
- Constructor<?>[] cons = ClassUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ClassUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ClassUtils.class.getModifiers()));
@@ -228,7 +228,7 @@ public class ClassUtilsTest {
// -------------------------------------------------------------------------
@Test
public void test_getAllSuperclasses_Class() {
- List<?> list = ClassUtils.getAllSuperclasses(CY.class);
+ final List<?> list = ClassUtils.getAllSuperclasses(CY.class);
assertEquals(2, list.size());
assertEquals(CX.class, list.get(0));
assertEquals(Object.class, list.get(1));
@@ -238,7 +238,7 @@ public class ClassUtilsTest {
@Test
public void test_getAllInterfaces_Class() {
- List<?> list = ClassUtils.getAllInterfaces(CY.class);
+ final List<?> list = ClassUtils.getAllInterfaces(CY.class);
assertEquals(6, list.size());
assertEquals(IB.class, list.get(0));
assertEquals(IC.class, list.get(1));
@@ -270,7 +270,7 @@ public class ClassUtilsTest {
// -------------------------------------------------------------------------
@Test
public void test_convertClassNamesToClasses_List() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
List<Class<?>> result = ClassUtils.convertClassNamesToClasses(list);
assertEquals(0, result.size());
@@ -284,18 +284,19 @@ public class ClassUtilsTest {
assertEquals(Object.class, result.get(2));
@SuppressWarnings("unchecked") // test what happens when non-generic code adds wrong type of element
+ final
List<Object> olist = (List<Object>)(List<?>)list;
olist.add(new Object());
try {
ClassUtils.convertClassNamesToClasses(list);
fail("Should not have been able to convert list");
- } catch (ClassCastException expected) {}
+ } catch (final ClassCastException expected) {}
assertEquals(null, ClassUtils.convertClassNamesToClasses(null));
}
@Test
public void test_convertClassesToClassNames_List() {
- List<Class<?>> list = new ArrayList<Class<?>>();
+ final List<Class<?>> list = new ArrayList<Class<?>>();
List<String> result = ClassUtils.convertClassesToClassNames(list);
assertEquals(0, result.size());
@@ -309,12 +310,13 @@ public class ClassUtilsTest {
assertEquals("java.lang.Object", result.get(2));
@SuppressWarnings("unchecked") // test what happens when non-generic code adds wrong type of element
+ final
List<Object> olist = (List<Object>)(List<?>)list;
olist.add(new Object());
try {
ClassUtils.convertClassesToClassNames(list);
fail("Should not have been able to convert list");
- } catch (ClassCastException expected) {}
+ } catch (final ClassCastException expected) {}
assertEquals(null, ClassUtils.convertClassesToClassNames(null));
}
@@ -333,12 +335,12 @@ public class ClassUtilsTest {
// -------------------------------------------------------------------------
@Test
public void test_isAssignable_ClassArray_ClassArray() throws Exception {
- Class<?>[] array2 = new Class[] {Object.class, Object.class};
- Class<?>[] array1 = new Class[] {Object.class};
- Class<?>[] array1s = new Class[] {String.class};
- Class<?>[] array0 = new Class[] {};
- Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
- Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
+ final Class<?>[] array2 = new Class[] {Object.class, Object.class};
+ final Class<?>[] array1 = new Class[] {Object.class};
+ final Class<?>[] array1s = new Class[] {String.class};
+ final Class<?>[] array0 = new Class[] {};
+ final Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
+ final Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
assertFalse(ClassUtils.isAssignable(array1, array2));
assertFalse(ClassUtils.isAssignable(null, array2));
@@ -352,7 +354,7 @@ public class ClassUtilsTest {
assertTrue(ClassUtils.isAssignable(array1s, array1s));
assertTrue(ClassUtils.isAssignable(array1s, array1));
- boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
+ final boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
assertEquals(autoboxing, ClassUtils.isAssignable(arrayPrimitives, arrayWrappers));
assertEquals(autoboxing, ClassUtils.isAssignable(arrayWrappers, arrayPrimitives));
@@ -364,12 +366,12 @@ public class ClassUtilsTest {
@Test
public void test_isAssignable_ClassArray_ClassArray_Autoboxing() throws Exception {
- Class<?>[] array2 = new Class[] {Object.class, Object.class};
- Class<?>[] array1 = new Class[] {Object.class};
- Class<?>[] array1s = new Class[] {String.class};
- Class<?>[] array0 = new Class[] {};
- Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
- Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
+ final Class<?>[] array2 = new Class[] {Object.class, Object.class};
+ final Class<?>[] array1 = new Class[] {Object.class};
+ final Class<?>[] array1s = new Class[] {String.class};
+ final Class<?>[] array0 = new Class[] {};
+ final Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
+ final Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
assertFalse(ClassUtils.isAssignable(array1, array2, true));
assertFalse(ClassUtils.isAssignable(null, array2, true));
@@ -392,12 +394,12 @@ public class ClassUtilsTest {
@Test
public void test_isAssignable_ClassArray_ClassArray_NoAutoboxing() throws Exception {
- Class<?>[] array2 = new Class[] {Object.class, Object.class};
- Class<?>[] array1 = new Class[] {Object.class};
- Class<?>[] array1s = new Class[] {String.class};
- Class<?>[] array0 = new Class[] {};
- Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
- Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
+ final Class<?>[] array2 = new Class[] {Object.class, Object.class};
+ final Class<?>[] array1 = new Class[] {Object.class};
+ final Class<?>[] array1s = new Class[] {String.class};
+ final Class<?>[] array0 = new Class[] {};
+ final Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
+ final Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
assertFalse(ClassUtils.isAssignable(array1, array2, false));
assertFalse(ClassUtils.isAssignable(null, array2, false));
@@ -430,7 +432,7 @@ public class ClassUtilsTest {
assertTrue(ClassUtils.isAssignable(String.class, String.class));
assertFalse(ClassUtils.isAssignable(Object.class, String.class));
- boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
+ final boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
assertEquals(autoboxing, ClassUtils.isAssignable(Integer.TYPE, Integer.class));
assertEquals(autoboxing, ClassUtils.isAssignable(Integer.TYPE, Object.class));
@@ -579,7 +581,7 @@ public class ClassUtilsTest {
@Test
public void test_isAssignable_DefaultUnboxing_Widening() throws Exception {
- boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
+ final boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
// test byte conversions
assertFalse("byte -> char", ClassUtils.isAssignable(Byte.class, Character.TYPE));
@@ -849,7 +851,7 @@ public class ClassUtilsTest {
assertNull("null -> null", ClassUtils.primitivesToWrappers((Class<?>[]) null)); // equivalent cast to avoid warning
// Other possible casts for null
assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers()));
- Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>)null); // == new Class<?>[]{null}
+ final Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>)null); // == new Class<?>[]{null}
assertTrue("(Class<?>)null -> [null]", Arrays.equals(new Class<?>[]{null}, castNull));
// test empty array is returned unchanged
// TODO this is not documented
@@ -862,12 +864,12 @@ public class ClassUtilsTest {
Integer.TYPE, Long.TYPE, Double.TYPE, Float.TYPE,
String.class, ClassUtils.class
};
- Class<?>[] wrappers= ClassUtils.primitivesToWrappers(primitives);
+ final Class<?>[] wrappers= ClassUtils.primitivesToWrappers(primitives);
for (int i=0; i < primitives.length; i++) {
// test each returned wrapper
- Class<?> primitive = primitives[i];
- Class<?> expectedWrapper = ClassUtils.primitiveToWrapper(primitive);
+ final Class<?> primitive = primitives[i];
+ final Class<?> expectedWrapper = ClassUtils.primitiveToWrapper(primitive);
assertEquals(primitive + " -> " + expectedWrapper, expectedWrapper, wrappers[i]);
}
@@ -887,8 +889,8 @@ public class ClassUtilsTest {
Boolean.TYPE, Byte.TYPE, Character.TYPE, Short.TYPE,
Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE
};
- for (Class<?> primitive : primitives) {
- Class<?> wrapperCls = ClassUtils.primitiveToWrapper(primitive);
+ for (final Class<?> primitive : primitives) {
+ final Class<?> wrapperCls = ClassUtils.primitiveToWrapper(primitive);
assertFalse("Still primitive", wrapperCls.isPrimitive());
assertEquals(wrapperCls + " -> " + primitive, primitive,
ClassUtils.wrapperToPrimitive(wrapperCls));
@@ -914,11 +916,11 @@ public class ClassUtilsTest {
String.class, ClassUtils.class, null
};
- Class<?>[] primitives = ClassUtils.wrappersToPrimitives(classes);
+ final Class<?>[] primitives = ClassUtils.wrappersToPrimitives(classes);
// now test the result
assertEquals("Wrong length of result array", classes.length, primitives.length);
for (int i = 0; i < classes.length; i++) {
- Class<?> expectedPrimitive = ClassUtils.wrapperToPrimitive(classes[i]);
+ final Class<?> expectedPrimitive = ClassUtils.wrapperToPrimitive(classes[i]);
assertEquals(classes[i] + " -> " + expectedPrimitive, expectedPrimitive,
primitives[i]);
}
@@ -930,13 +932,13 @@ public class ClassUtilsTest {
assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives((Class<?>[]) null)); // equivalent cast
// Other possible casts for null
assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.wrappersToPrimitives()));
- Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>)null); // == new Class<?>[]{null}
+ final Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>)null); // == new Class<?>[]{null}
assertTrue("(Class<?>)null -> [null]", Arrays.equals(new Class<?>[]{null}, castNull));
}
@Test
public void testWrappersToPrimitivesEmpty() {
- Class<?>[] empty = new Class[0];
+ final Class<?>[] empty = new Class[0];
assertArrayEquals("Wrong result for empty input", empty, ClassUtils.wrappersToPrimitives(empty));
}
@@ -1051,7 +1053,7 @@ public class ClassUtilsTest {
ClassUtils.getClass( className );
fail( "ClassUtils.getClass() should fail with an exception of type " + exceptionType.getName() + " when given class name \"" + className + "\"." );
}
- catch( Exception e ) {
+ catch( final Exception e ) {
assertTrue( exceptionType.isAssignableFrom( e.getClass() ) );
}
}
@@ -1069,12 +1071,12 @@ public class ClassUtilsTest {
@Test
public void testShowJavaBug() throws Exception {
// Tests with Collections$UnmodifiableSet
- Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
- Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]);
+ final Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
+ final Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]);
try {
isEmptyMethod.invoke(set, new Object[0]);
fail("Failed to throw IllegalAccessException as expected");
- } catch(IllegalAccessException iae) {
+ } catch(final IllegalAccessException iae) {
// expected
}
}
@@ -1082,18 +1084,18 @@ public class ClassUtilsTest {
@Test
public void testGetPublicMethod() throws Exception {
// Tests with Collections$UnmodifiableSet
- Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
- Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]);
+ final Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
+ final Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]);
assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers()));
try {
isEmptyMethod.invoke(set, new Object[0]);
- } catch(java.lang.IllegalAccessException iae) {
+ } catch(final java.lang.IllegalAccessException iae) {
fail("Should not have thrown IllegalAccessException");
}
// Tests with a public Class
- Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString", new Class[0]);
+ final Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString", new Class[0]);
assertEquals(Object.class.getMethod("toString", new Class[0]), toStringMethod);
}
@@ -1104,7 +1106,7 @@ public class ClassUtilsTest {
// Additional varargs tests
assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass()));
- Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null}
+ final Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null}
assertTrue("(Object)null -> [null]", Arrays.equals(new Object[]{null}, castNull));
assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java
index f96a0d897..4cf34d42e 100644
--- a/src/test/java/org/apache/commons/lang3/ConversionTest.java
+++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java
@@ -256,11 +256,11 @@ public class ConversionTest {
*/
@Test
public void testBinaryToHexDigit_2args() {
- boolean[] shortArray = new boolean[]{false, true, true};
+ final boolean[] shortArray = new boolean[]{false, true, true};
assertEquals('6', Conversion.binaryToHexDigit(shortArray, 0));
assertEquals('3', Conversion.binaryToHexDigit(shortArray, 1));
assertEquals('1', Conversion.binaryToHexDigit(shortArray, 2));
- boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
+ final boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
assertEquals('5', Conversion.binaryToHexDigit(longArray, 0));
assertEquals('2', Conversion.binaryToHexDigit(longArray, 1));
assertEquals('9', Conversion.binaryToHexDigit(longArray, 2));
@@ -329,9 +329,9 @@ public class ConversionTest {
// assertEquals('6', Conversion.BinaryToHexDigitMsb0(shortArray,0));
// assertEquals('3', Conversion.BinaryToHexDigitMsb0(shortArray,1));
// assertEquals('1', Conversion.BinaryToHexDigitMsb0(shortArray,2));
- boolean[] shortArray = new boolean[]{true, true, false, true};
+ final boolean[] shortArray = new boolean[]{true, true, false, true};
assertEquals('d', Conversion.binaryToHexDigitMsb0_4bits(shortArray, 0));
- boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
+ final boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
assertEquals('a', Conversion.binaryToHexDigitMsb0_4bits(longArray, 0));
assertEquals('4', Conversion.binaryToHexDigitMsb0_4bits(longArray, 1));
assertEquals('9', Conversion.binaryToHexDigitMsb0_4bits(longArray, 2));
@@ -339,7 +339,7 @@ public class ConversionTest {
// assertEquals('6', Conversion.BinaryToHexDigitMsb0(longArray,4));
// assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray,5));
// assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray,6));
- boolean[] maxLengthArray = new boolean[]{
+ final boolean[] maxLengthArray = new boolean[]{
true, false, true, false, false, true, true, true};
assertEquals('a', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 0));
assertEquals('4', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 1));
@@ -349,7 +349,7 @@ public class ConversionTest {
// assertEquals('7', Conversion.BinaryToHexDigitMsb0(longArray,5));
// assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray,6));
// assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray,7));
- boolean[] javaDocCheck = new boolean[]{
+ final boolean[] javaDocCheck = new boolean[]{
true, false, false, true, true, false, true, false};
assertEquals('d', Conversion.binaryToHexDigitMsb0_4bits(javaDocCheck, 3));
@@ -416,11 +416,11 @@ public class ConversionTest {
true, false, false, false, false, false, false, false, false, false, false,
true, false, true, false, false}, 2));
- boolean[] shortArray = new boolean[]{true, true, false};
+ final boolean[] shortArray = new boolean[]{true, true, false};
assertEquals('6', Conversion.binaryBeMsb0ToHexDigit(shortArray, 0));
assertEquals('3', Conversion.binaryBeMsb0ToHexDigit(shortArray, 1));
assertEquals('1', Conversion.binaryBeMsb0ToHexDigit(shortArray, 2));
- boolean[] shortArray2 = new boolean[]{true, true, true, false, false, true, false, true};
+ final boolean[] shortArray2 = new boolean[]{true, true, true, false, false, true, false, true};
assertEquals('5', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 0));
assertEquals('2', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 1));
assertEquals('9', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 2));
@@ -429,7 +429,7 @@ public class ConversionTest {
assertEquals('7', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 5));
assertEquals('3', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 6));
assertEquals('1', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 7));
- boolean[] multiBytesArray = new boolean[]{
+ final boolean[] multiBytesArray = new boolean[]{
true, true, false, false, true, false, true, false, true, true, true, false, false,
true, false, true};
assertEquals('5', Conversion.binaryBeMsb0ToHexDigit(multiBytesArray, 0));
@@ -511,15 +511,15 @@ public class ConversionTest {
}
static String dbgPrint(final boolean[] src) {
- StringBuilder sb = new StringBuilder();
- for (boolean e : src) {
+ final StringBuilder sb = new StringBuilder();
+ for (final boolean e : src) {
if (e) {
sb.append("1,");
} else {
sb.append("0,");
}
}
- String out = sb.toString();
+ final String out = sb.toString();
return out.substring(0, out.length() - 1);
}
@@ -529,8 +529,8 @@ public class ConversionTest {
for (int i = 0; i < expected.length; i++ ) {
try {
assertEquals(expected[i], actual[i]);
- } catch (Throwable e) {
- String msg = "Mismatch at index "
+ } catch (final Throwable e) {
+ final String msg = "Mismatch at index "
+ i
+ " between:\n"
+ dbgPrint(expected)
@@ -546,7 +546,7 @@ public class ConversionTest {
*/
@Test
public void testIntArrayToLong() {
- int[] src = new int[]{0xCDF1F0C1, 0x0F123456, 0x78000000};
+ final int[] src = new int[]{0xCDF1F0C1, 0x0F123456, 0x78000000};
assertEquals(0x0000000000000000L, Conversion.intArrayToLong(src, 0, 0L, 0, 0));
assertEquals(0x0000000000000000L, Conversion.intArrayToLong(src, 1, 0L, 0, 0));
assertEquals(0x00000000CDF1F0C1L, Conversion.intArrayToLong(src, 0, 0L, 0, 1));
@@ -564,7 +564,7 @@ public class ConversionTest {
*/
@Test
public void testShortArrayToLong() {
- short[] src = new short[]{
+ final short[] src = new short[]{
(short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800};
assertEquals(0x0000000000000000L, Conversion.shortArrayToLong(src, 0, 0L, 0, 0));
assertEquals(0x000000000000CDF1L, Conversion.shortArrayToLong(src, 0, 0L, 0, 1));
@@ -585,7 +585,7 @@ public class ConversionTest {
*/
@Test
public void testByteArrayToLong() {
- byte[] src = new byte[]{
+ final byte[] src = new byte[]{
(byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34,
(byte)0x56, (byte)0x78};
assertEquals(0x0000000000000000L, Conversion.byteArrayToLong(src, 0, 0L, 0, 0));
@@ -605,7 +605,7 @@ public class ConversionTest {
*/
@Test
public void testShortArrayToInt() {
- short[] src = new short[]{
+ final short[] src = new short[]{
(short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800};
assertEquals(0x00000000, Conversion.shortArrayToInt(src, 0, 0, 0, 0));
assertEquals(0x0000CDF1, Conversion.shortArrayToInt(src, 0, 0, 0, 1));
@@ -621,7 +621,7 @@ public class ConversionTest {
*/
@Test
public void testByteArrayToInt() {
- byte[] src = new byte[]{
+ final byte[] src = new byte[]{
(byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34,
(byte)0x56, (byte)0x78};
assertEquals(0x00000000, Conversion.byteArrayToInt(src, 0, 0, 0, 0));
@@ -638,7 +638,7 @@ public class ConversionTest {
*/
@Test
public void testByteArrayToShort() {
- byte[] src = new byte[]{
+ final byte[] src = new byte[]{
(byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34,
(byte)0x56, (byte)0x78};
assertEquals((short)0x0000, Conversion.byteArrayToShort(src, 0, (short)0, 0, 0));
@@ -656,7 +656,7 @@ public class ConversionTest {
*/
@Test
public void testHexToLong() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals(0x0000000000000000L, Conversion.hexToLong(src, 0, 0L, 0, 0));
assertEquals(0x000000000000000CL, Conversion.hexToLong(src, 0, 0L, 0, 1));
assertEquals(0x000000001C0F1FDCL, Conversion.hexToLong(src, 0, 0L, 0, 8));
@@ -672,7 +672,7 @@ public class ConversionTest {
*/
@Test
public void testHexToInt() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals(0x00000000, Conversion.hexToInt(src, 0, 0, 0, 0));
assertEquals(0x0000000C, Conversion.hexToInt(src, 0, 0, 0, 1));
assertEquals(0x1C0F1FDC, Conversion.hexToInt(src, 0, 0, 0, 8));
@@ -686,7 +686,7 @@ public class ConversionTest {
*/
@Test
public void testHexToShort() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals((short)0x0000, Conversion.hexToShort(src, 0, (short)0, 0, 0));
assertEquals((short)0x000C, Conversion.hexToShort(src, 0, (short)0, 0, 1));
assertEquals((short)0x1FDC, Conversion.hexToShort(src, 0, (short)0, 0, 4));
@@ -700,7 +700,7 @@ public class ConversionTest {
*/
@Test
public void testHexToByte() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals((byte)0x00, Conversion.hexToByte(src, 0, (byte)0, 0, 0));
assertEquals((byte)0x0C, Conversion.hexToByte(src, 0, (byte)0, 0, 1));
assertEquals((byte)0xDC, Conversion.hexToByte(src, 0, (byte)0, 0, 2));
@@ -714,7 +714,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToLong() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
@@ -738,7 +738,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToInt() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
@@ -759,7 +759,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToShort() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
@@ -782,7 +782,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToByte() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
index 4d97d49a6..92995e76e 100644
--- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
@@ -45,7 +45,7 @@ public class EnumUtilsTest {
@Test
public void test_getEnumMap() {
- Map<String, Traffic> test = EnumUtils.getEnumMap(Traffic.class);
+ final Map<String, Traffic> test = EnumUtils.getEnumMap(Traffic.class);
assertEquals( "getEnumMap not created correctly", "{RED=RED, AMBER=AMBER, GREEN=GREEN}", test.toString());
assertEquals(3, test.size());
assertTrue(test.containsKey("RED"));
@@ -59,7 +59,7 @@ public class EnumUtilsTest {
@Test
public void test_getEnumList() {
- List<Traffic> test = EnumUtils.getEnumList(Traffic.class);
+ final List<Traffic> test = EnumUtils.getEnumList(Traffic.class);
assertEquals(3, test.size());
assertEquals(Traffic.RED, test.get(0));
assertEquals(Traffic.AMBER, test.get(1));
@@ -168,8 +168,10 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVector_nonEnumClass() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
@SuppressWarnings("rawtypes")
+ final
List rawList = new ArrayList();
EnumUtils.generateBitVector(rawType, rawList);
}
@@ -178,8 +180,10 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVectors_nonEnumClass() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
@SuppressWarnings("rawtypes")
+ final
List rawList = new ArrayList();
EnumUtils.generateBitVectors(rawType, rawList);
}
@@ -188,6 +192,7 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVector_nonEnumClassWithArray() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
EnumUtils.generateBitVector(rawType);
}
@@ -196,6 +201,7 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVectors_nonEnumClassWithArray() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
EnumUtils.generateBitVectors(rawType);
}
diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
index f12a41f07..eb3508940 100644
--- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
+++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
@@ -49,8 +49,8 @@ public class HashSetvBitSetTest {
* @return bitSet - HashSet
*/
private long printTimes(final int count) {
- long hashSet = timeHashSet(count);
- long bitSet = timeBitSet(count);
+ final long hashSet = timeHashSet(count);
+ final long bitSet = timeBitSet(count);
// If percent is less than 100, then bitset is faster
System.out.println("Ratio="+(bitSet*100/hashSet)+"% count="+count+" hash="+hashSet+" bits="+bitSet);
return bitSet - hashSet;
@@ -58,29 +58,29 @@ public class HashSetvBitSetTest {
private static long timeHashSet(final int count) {
int [] result = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < LOOPS; i++) {
result = testHashSet(count);
}
- long elapsed = System.nanoTime() - start;
+ final long elapsed = System.nanoTime() - start;
Assert.assertEquals(count, result.length);
return elapsed;
}
private static long timeBitSet(final int count) {
int [] result = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < LOOPS; i++) {
result = testBitSet(count);
}
- long elapsed = System.nanoTime() - start;
+ final long elapsed = System.nanoTime() - start;
Assert.assertEquals(count, result.length);
return elapsed;
}
@SuppressWarnings("boxing")
private static int[] testHashSet(final int count) {
- HashSet<Integer> toRemove = new HashSet<Integer>();
+ final HashSet<Integer> toRemove = new HashSet<Integer>();
int found = 0;
for (int i = 0; i < count; i++) {
toRemove.add(found++);
@@ -89,7 +89,7 @@ public class HashSetvBitSetTest {
}
private static int[] testBitSet(final int count) {
- BitSet toRemove = new BitSet();
+ final BitSet toRemove = new BitSet();
int found = 0;
for (int i = 0; i < count; i++) {
toRemove.set(found++);
@@ -99,16 +99,16 @@ public class HashSetvBitSetTest {
private static int[] extractIndices(final HashSet<Integer> coll) {
- int[] result = new int[coll.size()];
+ final int[] result = new int[coll.size()];
int i = 0;
- for (Integer index : coll) {
+ for (final Integer index : coll) {
result[i++] = index.intValue();
}
return result;
}
private static int[] extractIndices(final BitSet coll) {
- int[] result = new int[coll.cardinality()];
+ final int[] result = new int[coll.cardinality()];
int i = 0;
int j=0;
while((j=coll.nextSetBit(j)) != -1) {
@@ -136,13 +136,13 @@ public class HashSetvBitSetTest {
}
private long printTimes(final int arraySize, final int bitSetSize) {
- int[] array = new int[arraySize];
- BitSet remove = new BitSet();
+ final int[] array = new int[arraySize];
+ final BitSet remove = new BitSet();
for (int i = 0; i < bitSetSize; i++) {
remove.set(i);
}
- long bitSet = timeBitSetRemoveAll(array, remove );
- long extract = timeExtractRemoveAll(array, remove);
+ final long bitSet = timeBitSetRemoveAll(array, remove );
+ final long extract = timeExtractRemoveAll(array, remove);
// If percent is less than 100, then direct use of bitset is faster
System.out.println("Ratio="+(bitSet*100/extract)+"% array="+array.length+" count="+remove.cardinality()+" extract="+extract+" bitset="+bitSet);
return bitSet - extract;
@@ -150,23 +150,23 @@ public class HashSetvBitSetTest {
private long timeBitSetRemoveAll(final int[] array, final BitSet toRemove) {
int[] output = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for(int i = 0; i < LOOPS2; i++){
output = (int[]) ArrayUtils.removeAll(array, toRemove);
}
- long end = System.nanoTime();
+ final long end = System.nanoTime();
Assert.assertEquals(array.length-toRemove.cardinality(), output.length);
return end - start;
}
private long timeExtractRemoveAll(final int[] array, final BitSet toRemove) {
int[] output = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for(int i = 0; i < LOOPS2; i++){
final int[] extractIndices = extractIndices(toRemove);
output = (int[]) ArrayUtils.removeAll((Object)array, extractIndices);
}
- long end = System.nanoTime();
+ final long end = System.nanoTime();
Assert.assertEquals(array.length-toRemove.cardinality(), output.length);
return end - start;
}
diff --git a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
index 64dd3ead0..f2d47c59d 100644
--- a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
@@ -67,7 +67,7 @@ public class LocaleUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new LocaleUtils());
- Constructor<?>[] cons = LocaleUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = LocaleUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(LocaleUtils.class.getModifiers()));
@@ -81,7 +81,7 @@ public class LocaleUtilsTest {
* @param language the language string
*/
private void assertValidToLocale(final String language) {
- Locale locale = LocaleUtils.toLocale(language);
+ final Locale locale = LocaleUtils.toLocale(language);
assertNotNull("valid locale", locale);
assertEquals(language, locale.getLanguage());
//country and variant are empty
@@ -97,7 +97,7 @@ public class LocaleUtilsTest {
* @param country of the resulting Locale
*/
private void assertValidToLocale(final String localeString, final String language, final String country) {
- Locale locale = LocaleUtils.toLocale(localeString);
+ final Locale locale = LocaleUtils.toLocale(localeString);
assertNotNull("valid locale", locale);
assertEquals(language, locale.getLanguage());
assertEquals(country, locale.getCountry());
@@ -116,7 +116,7 @@ public class LocaleUtilsTest {
private void assertValidToLocale(
final String localeString, final String language,
final String country, final String variant) {
- Locale locale = LocaleUtils.toLocale(localeString);
+ final Locale locale = LocaleUtils.toLocale(localeString);
assertNotNull("valid locale", locale);
assertEquals(language, locale.getLanguage());
assertEquals(country, locale.getCountry());
@@ -141,34 +141,34 @@ public class LocaleUtilsTest {
try {
LocaleUtils.toLocale("Us");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("US");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uS");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("u#");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("u");
fail("Must be 2 chars if less than 5");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uuu");
fail("Must be 2 chars if less than 5");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uu_U");
fail("Must be 2 chars if less than 5");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
}
/**
@@ -183,27 +183,27 @@ public class LocaleUtilsTest {
try {
LocaleUtils.toLocale("us-EN");
fail("Should fail as not underscore");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_En");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_en");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_eN");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uS_EN");
fail("Should fail first part not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_E3");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
}
/**
@@ -225,11 +225,11 @@ public class LocaleUtilsTest {
try {
LocaleUtils.toLocale("us_EN-a");
fail("Should fail as not underscore");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uu_UU_");
fail("Must be 3, 5 or 7+ in length");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
}
//-----------------------------------------------------------------------
@@ -241,7 +241,7 @@ public class LocaleUtilsTest {
* @param expected expected results
*/
private void assertLocaleLookupList(final Locale locale, final Locale defaultLocale, final Locale[] expected) {
- List<Locale> localeList = defaultLocale == null ?
+ final List<Locale> localeList = defaultLocale == null ?
LocaleUtils.localeLookupList(locale) :
LocaleUtils.localeLookupList(locale, defaultLocale);
@@ -331,14 +331,14 @@ public class LocaleUtilsTest {
*/
@Test
public void testAvailableLocaleList() {
- List<Locale> list = LocaleUtils.availableLocaleList();
- List<Locale> list2 = LocaleUtils.availableLocaleList();
+ final List<Locale> list = LocaleUtils.availableLocaleList();
+ final List<Locale> list2 = LocaleUtils.availableLocaleList();
assertNotNull(list);
assertSame(list, list2);
assertUnmodifiableCollection(list);
- Locale[] jdkLocaleArray = Locale.getAvailableLocales();
- List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
+ final Locale[] jdkLocaleArray = Locale.getAvailableLocales();
+ final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
assertEquals(jdkLocaleList, list);
}
@@ -348,15 +348,15 @@ public class LocaleUtilsTest {
*/
@Test
public void testAvailableLocaleSet() {
- Set<Locale> set = LocaleUtils.availableLocaleSet();
- Set<Locale> set2 = LocaleUtils.availableLocaleSet();
+ final Set<Locale> set = LocaleUtils.availableLocaleSet();
+ final Set<Locale> set2 = LocaleUtils.availableLocaleSet();
assertNotNull(set);
assertSame(set, set2);
assertUnmodifiableCollection(set);
- Locale[] jdkLocaleArray = Locale.getAvailableLocales();
- List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
- Set<Locale> jdkLocaleSet = new HashSet<Locale>(jdkLocaleList);
+ final Locale[] jdkLocaleArray = Locale.getAvailableLocales();
+ final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
+ final Set<Locale> jdkLocaleSet = new HashSet<Locale>(jdkLocaleList);
assertEquals(jdkLocaleSet, set);
}
@@ -367,7 +367,7 @@ public class LocaleUtilsTest {
@SuppressWarnings("boxing") // JUnit4 does not support primitive equality testing apart from long
@Test
public void testIsAvailableLocale() {
- Set<Locale> set = LocaleUtils.availableLocaleSet();
+ final Set<Locale> set = LocaleUtils.availableLocaleSet();
assertEquals(set.contains(LOCALE_EN), LocaleUtils.isAvailableLocale(LOCALE_EN));
assertEquals(set.contains(LOCALE_EN_US), LocaleUtils.isAvailableLocale(LOCALE_EN_US));
assertEquals(set.contains(LOCALE_EN_US_ZZZZ), LocaleUtils.isAvailableLocale(LOCALE_EN_US_ZZZZ));
@@ -388,17 +388,17 @@ public class LocaleUtilsTest {
* @param languages array of languages that should be returned
*/
private void assertLanguageByCountry(final String country, final String[] languages) {
- List<Locale> list = LocaleUtils.languagesByCountry(country);
- List<Locale> list2 = LocaleUtils.languagesByCountry(country);
+ final List<Locale> list = LocaleUtils.languagesByCountry(country);
+ final List<Locale> list2 = LocaleUtils.languagesByCountry(country);
assertNotNull(list);
assertSame(list, list2);
//search through langauges
- for (String language : languages) {
- Iterator<Locale> iterator = list.iterator();
+ for (final String language : languages) {
+ final Iterator<Locale> iterator = list.iterator();
boolean found = false;
// see if it was returned by the set
while (iterator.hasNext()) {
- Locale locale = iterator.next();
+ final Locale locale = iterator.next();
// should have an en empty variant
assertTrue(locale.getVariant() == null
|| locale.getVariant().isEmpty());
@@ -439,17 +439,17 @@ public class LocaleUtilsTest {
* @param countries array of countries that should be returned
*/
private void assertCountriesByLanguage(final String language, final String[] countries) {
- List<Locale> list = LocaleUtils.countriesByLanguage(language);
- List<Locale> list2 = LocaleUtils.countriesByLanguage(language);
+ final List<Locale> list = LocaleUtils.countriesByLanguage(language);
+ final List<Locale> list2 = LocaleUtils.countriesByLanguage(language);
assertNotNull(list);
assertSame(list, list2);
//search through langauges
- for (String countrie : countries) {
- Iterator<Locale> iterator = list.iterator();
+ for (final String countrie : countries) {
+ final Iterator<Locale> iterator = list.iterator();
boolean found = false;
// see if it was returned by the set
while (iterator.hasNext()) {
- Locale locale = iterator.next();
+ final Locale locale = iterator.next();
// should have an en empty variant
assertTrue(locale.getVariant() == null
|| locale.getVariant().isEmpty());
@@ -485,7 +485,7 @@ public class LocaleUtilsTest {
try {
coll.add(null);
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
}
/**
diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
index bdd473a24..4809cc947 100644
--- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
@@ -51,7 +51,7 @@ public class ObjectUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ObjectUtils());
- Constructor<?>[] cons = ObjectUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ObjectUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ObjectUtils.class.getModifiers()));
@@ -61,8 +61,8 @@ public class ObjectUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testIsNull() {
- Object o = FOO;
- Object dflt = BAR;
+ final Object o = FOO;
+ final Object dflt = BAR;
assertSame("dflt was not returned when o was null", dflt, ObjectUtils.defaultIfNull(null, dflt));
assertSame("dflt was returned when o was not null", o, ObjectUtils.defaultIfNull(o, dflt));
}
@@ -71,7 +71,7 @@ public class ObjectUtilsTest {
public void testFirstNonNull() {
assertEquals(null, ObjectUtils.firstNonNull(null, null));
assertEquals("", ObjectUtils.firstNonNull(null, ""));
- String firstNonNullGenerics = ObjectUtils.firstNonNull(null, null, "123", "456");
+ final String firstNonNullGenerics = ObjectUtils.firstNonNull(null, null, "123", "456");
assertEquals("123", firstNonNullGenerics);
assertEquals("123", ObjectUtils.firstNonNull("123", null, "456", null));
assertEquals(null, ObjectUtils.firstNonNull());
@@ -112,28 +112,28 @@ public class ObjectUtilsTest {
@Test
public void testHashCodeMulti_multiple_emptyArray() {
- Object[] array = new Object[0];
+ final Object[] array = new Object[0];
assertEquals(1, ObjectUtils.hashCodeMulti(array));
}
@Test
public void testHashCodeMulti_multiple_nullArray() {
- Object[] array = null;
+ final Object[] array = null;
assertEquals(1, ObjectUtils.hashCodeMulti(array));
}
@Test
public void testHashCodeMulti_multiple_likeList() {
- List<Object> list0 = new ArrayList<Object>(Arrays.asList());
+ final List<Object> list0 = new ArrayList<Object>(Arrays.asList());
assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti());
- List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));
+ final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));
assertEquals(list1.hashCode(), ObjectUtils.hashCodeMulti("a"));
- List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b"));
+ final List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b"));
assertEquals(list2.hashCode(), ObjectUtils.hashCodeMulti("a", "b"));
- List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c"));
+ final List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c"));
assertEquals(list3.hashCode(), ObjectUtils.hashCodeMulti("a", "b", "c"));
}
@@ -184,22 +184,22 @@ public class ObjectUtilsTest {
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.identityToString(FOO));
- Integer i = Integer.valueOf(90);
- String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
+ final Integer i = Integer.valueOf(90);
+ final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
assertEquals(expected, ObjectUtils.identityToString(i));
- StringBuffer buffer = new StringBuffer();
+ final StringBuffer buffer = new StringBuffer();
ObjectUtils.identityToString(buffer, i);
assertEquals(expected, buffer.toString());
try {
ObjectUtils.identityToString(null, "tmp");
fail("NullPointerException expected");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
}
try {
ObjectUtils.identityToString(new StringBuffer(), null);
fail("NullPointerException expected");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
}
}
@@ -226,13 +226,13 @@ public class ObjectUtilsTest {
@Test
public void testMax() {
- Calendar calendar = Calendar.getInstance();
- Date nonNullComparable1 = calendar.getTime();
- Date nonNullComparable2 = calendar.getTime();
- String[] nullAray = null;
+ final Calendar calendar = Calendar.getInstance();
+ final Date nonNullComparable1 = calendar.getTime();
+ final Date nonNullComparable2 = calendar.getTime();
+ final String[] nullAray = null;
calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 );
- Date minComparable = calendar.getTime();
+ final Date minComparable = calendar.getTime();
assertNotSame( nonNullComparable1, nonNullComparable2 );
@@ -252,13 +252,13 @@ public class ObjectUtilsTest {
@Test
public void testMin() {
- Calendar calendar = Calendar.getInstance();
- Date nonNullComparable1 = calendar.getTime();
- Date nonNullComparable2 = calendar.getTime();
- String[] nullAray = null;
+ final Calendar calendar = Calendar.getInstance();
+ final Date nonNullComparable1 = calendar.getTime();
+ final Date nonNullComparable2 = calendar.getTime();
+ final String[] nullAray = null;
calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 );
- Date minComparable = calendar.getTime();
+ final Date minComparable = calendar.getTime();
assertNotSame( nonNullComparable1, nonNullComparable2 );
@@ -281,9 +281,9 @@ public class ObjectUtilsTest {
*/
@Test
public void testCompare() {
- Integer one = Integer.valueOf(1);
- Integer two = Integer.valueOf(2);
- Integer nullValue = null;
+ final Integer one = Integer.valueOf(1);
+ final Integer two = Integer.valueOf(2);
+ final Integer nullValue = null;
assertEquals("Null Null false", 0, ObjectUtils.compare(nullValue, nullValue));
assertEquals("Null Null true", 0, ObjectUtils.compare(nullValue, nullValue, true));
@@ -327,12 +327,12 @@ public class ObjectUtilsTest {
@Test
public void testComparatorMedian() {
- CharSequenceComparator cmp = new CharSequenceComparator();
- NonComparableCharSequence foo = new NonComparableCharSequence("foo");
- NonComparableCharSequence bar = new NonComparableCharSequence("bar");
- NonComparableCharSequence baz = new NonComparableCharSequence("baz");
- NonComparableCharSequence blah = new NonComparableCharSequence("blah");
- NonComparableCharSequence wah = new NonComparableCharSequence("wah");
+ final CharSequenceComparator cmp = new CharSequenceComparator();
+ final NonComparableCharSequence foo = new NonComparableCharSequence("foo");
+ final NonComparableCharSequence bar = new NonComparableCharSequence("bar");
+ final NonComparableCharSequence baz = new NonComparableCharSequence("baz");
+ final NonComparableCharSequence blah = new NonComparableCharSequence("blah");
+ final NonComparableCharSequence wah = new NonComparableCharSequence("wah");
assertSame(foo, ObjectUtils.median(cmp, foo));
assertSame(bar, ObjectUtils.median(cmp, foo, bar));
assertSame(baz, ObjectUtils.median(cmp, foo, bar, baz));
@@ -474,18 +474,18 @@ public class ObjectUtilsTest {
// for "Can you screw this up?" The answer is, yes,
// you can even screw this up. (When you == Julius)
// .
- boolean MAGIC_FLAG = ObjectUtils.CONST(true);
- byte MAGIC_BYTE1 = ObjectUtils.CONST((byte) 127);
- byte MAGIC_BYTE2 = ObjectUtils.CONST_BYTE(127);
- char MAGIC_CHAR = ObjectUtils.CONST('a');
- short MAGIC_SHORT1 = ObjectUtils.CONST((short) 123);
- short MAGIC_SHORT2 = ObjectUtils.CONST_SHORT(127);
- int MAGIC_INT = ObjectUtils.CONST(123);
- long MAGIC_LONG1 = ObjectUtils.CONST(123L);
- long MAGIC_LONG2 = ObjectUtils.CONST(3);
- float MAGIC_FLOAT = ObjectUtils.CONST(1.0f);
- double MAGIC_DOUBLE = ObjectUtils.CONST(1.0);
- String MAGIC_STRING = ObjectUtils.CONST("abc");
+ final boolean MAGIC_FLAG = ObjectUtils.CONST(true);
+ final byte MAGIC_BYTE1 = ObjectUtils.CONST((byte) 127);
+ final byte MAGIC_BYTE2 = ObjectUtils.CONST_BYTE(127);
+ final char MAGIC_CHAR = ObjectUtils.CONST('a');
+ final short MAGIC_SHORT1 = ObjectUtils.CONST((short) 123);
+ final short MAGIC_SHORT2 = ObjectUtils.CONST_SHORT(127);
+ final int MAGIC_INT = ObjectUtils.CONST(123);
+ final long MAGIC_LONG1 = ObjectUtils.CONST(123L);
+ final long MAGIC_LONG2 = ObjectUtils.CONST(3);
+ final float MAGIC_FLOAT = ObjectUtils.CONST(1.0f);
+ final double MAGIC_DOUBLE = ObjectUtils.CONST(1.0);
+ final String MAGIC_STRING = ObjectUtils.CONST("abc");
assertTrue(MAGIC_FLAG);
assertEquals(127, MAGIC_BYTE1);
@@ -503,25 +503,25 @@ public class ObjectUtilsTest {
try {
ObjectUtils.CONST_BYTE(-129);
fail("CONST_BYTE(-129): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
try {
ObjectUtils.CONST_BYTE(128);
fail("CONST_BYTE(128): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
try {
ObjectUtils.CONST_SHORT(-32769);
fail("CONST_SHORT(-32769): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
try {
ObjectUtils.CONST_BYTE(32768);
fail("CONST_SHORT(32768): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
diff --git a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
index b00db29d9..420d7bb69 100644
--- a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
@@ -39,7 +39,7 @@ public class RandomStringUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new RandomStringUtils());
- Constructor<?>[] cons = RandomStringUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = RandomStringUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(RandomStringUtils.class.getModifiers()));
@@ -120,7 +120,7 @@ public class RandomStringUtilsTest {
assertEquals("random(50) length", 50, r2.length());
assertTrue("!r1.equals(r2)", !r1.equals(r2));
- long seed = System.currentTimeMillis();
+ final long seed = System.currentTimeMillis();
r1 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed));
r2 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed));
assertEquals("r1.equals(r2)", r1, r2);
@@ -131,7 +131,7 @@ public class RandomStringUtilsTest {
@Test
public void testLANG805() {
- long seed = System.currentTimeMillis();
+ final long seed = System.currentTimeMillis();
assertEquals("aaa", RandomStringUtils.random(3,0,0,false,false,new char[]{'a'},new Random(seed)));
}
@@ -140,7 +140,7 @@ public class RandomStringUtilsTest {
try {
RandomStringUtils.random(3,5,5,false,false);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException ex) { // distinguish from Random#nextInt message
+ } catch (final IllegalArgumentException ex) { // distinguish from Random#nextInt message
final String msg = ex.getMessage();
assertTrue("Message (" + msg + ") must contain 'start'", msg.contains("start"));
assertTrue("Message (" + msg + ") must contain 'end'", msg.contains("end"));
@@ -153,39 +153,39 @@ public class RandomStringUtilsTest {
try {
RandomStringUtils.random(-1);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, true, true);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, DUMMY);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(1, new char[0]); // must not provide empty array => IAE
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, "");
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, (String)null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, 'a', 'z', false, false);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, 'a', 'z', false, false, DUMMY);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, 'a', 'z', false, false, DUMMY, new Random());
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
/**
@@ -194,10 +194,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomAlphaNumeric() {
- char[] testChars = {'a', 'z', 'A', 'Z', '0', '9'};
- boolean[] found = {false, false, false, false, false, false};
+ final char[] testChars = {'a', 'z', 'A', 'Z', '0', '9'};
+ final boolean[] found = {false, false, false, false, false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomAlphanumeric(10);
+ final String randString = RandomStringUtils.randomAlphanumeric(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -218,10 +218,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomNumeric() {
- char[] testChars = {'0','9'};
- boolean[] found = {false, false};
+ final char[] testChars = {'0','9'};
+ final boolean[] found = {false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomNumeric(10);
+ final String randString = RandomStringUtils.randomNumeric(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -242,10 +242,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomAlphabetic() {
- char[] testChars = {'a', 'z', 'A', 'Z'};
- boolean[] found = {false, false, false, false};
+ final char[] testChars = {'a', 'z', 'A', 'Z'};
+ final boolean[] found = {false, false, false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomAlphabetic(10);
+ final String randString = RandomStringUtils.randomAlphabetic(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -266,10 +266,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomAscii() {
- char[] testChars = {(char) 32, (char) 126};
- boolean[] found = {false, false};
+ final char[] testChars = {(char) 32, (char) 126};
+ final boolean[] found = {false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomAscii(10);
+ final String randString = RandomStringUtils.randomAscii(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -293,11 +293,11 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomStringUtilsHomog() {
- String set = "abc";
- char[] chars = set.toCharArray();
+ final String set = "abc";
+ final char[] chars = set.toCharArray();
String gen = "";
- int[] counts = {0,0,0};
- int[] expected = {200,200,200};
+ final int[] counts = {0,0,0};
+ final int[] expected = {200,200,200};
for (int i = 0; i< 100; i++) {
gen = RandomStringUtils.random(6,chars);
for (int j = 0; j < 6; j++) {
@@ -339,16 +339,16 @@ public class RandomStringUtilsTest {
*/
@Test
public void testLang100() throws Exception {
- int size = 5000;
- String encoding = "UTF-8";
- String orig = RandomStringUtils.random(size);
- byte[] bytes = orig.getBytes(encoding);
- String copy = new String(bytes, encoding);
+ final int size = 5000;
+ final String encoding = "UTF-8";
+ final String orig = RandomStringUtils.random(size);
+ final byte[] bytes = orig.getBytes(encoding);
+ final String copy = new String(bytes, encoding);
// for a verbose compare:
for (int i=0; i < orig.length() && i < copy.length(); i++) {
- char o = orig.charAt(i);
- char c = copy.charAt(i);
+ final char o = orig.charAt(i);
+ final char c = copy.charAt(i);
assertEquals("differs at " + i + "(" + Integer.toHexString(new Character(o).hashCode()) + "," +
Integer.toHexString(new Character(c).hashCode()) + ")", o, c);
}
diff --git a/src/test/java/org/apache/commons/lang3/RangeTest.java b/src/test/java/org/apache/commons/lang3/RangeTest.java
index f76ef8e60..16d49e2ad 100644
--- a/src/test/java/org/apache/commons/lang3/RangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/RangeTest.java
@@ -65,22 +65,22 @@ public class RangeTest {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testComparableConstructors() {
- Comparable c =
+ final Comparable c =
new Comparable() {
@Override
public int compareTo(final Object other) {
return 1;
}
};
- Range r1 = Range.is(c);
- Range r2 = Range.between(c, c);
+ final Range r1 = Range.is(c);
+ final Range r2 = Range.between(c, c);
assertEquals(true, r1.isNaturalOrdering());
assertEquals(true, r2.isNaturalOrdering());
}
@Test
public void testIsWithCompare(){
- Comparator<Integer> c = new Comparator<Integer>(){
+ final Comparator<Integer> c = new Comparator<Integer>(){
@Override
public int compare(final Integer o1, final Integer o2) {
return 0; // all integers are equal
@@ -99,7 +99,7 @@ public class RangeTest {
@Test
public void testBetweenWithCompare(){
// TODO add tests with a better comparator
- Comparator<Integer> c = new Comparator<Integer>(){
+ final Comparator<Integer> c = new Comparator<Integer>(){
@Override
public int compare(final Integer o1, final Integer o2) {
return 0; // all integers are equal
@@ -122,7 +122,7 @@ public class RangeTest {
//-----------------------------------------------------------------------
@Test
public void testRangeOfChars() {
- Range<Character> chars = Range.between('a', 'z');
+ final Range<Character> chars = Range.between('a', 'z');
assertTrue(chars.contains('b'));
assertFalse(chars.contains('B'));
}
@@ -154,14 +154,14 @@ public class RangeTest {
public void testToString() {
assertNotNull(byteRange.toString());
- String str = intRange.toString();
+ final String str = intRange.toString();
assertEquals("[10..20]", str);
assertEquals("[-20..-10]", Range.between(-20, -10).toString());
}
@Test
public void testToStringFormat() {
- String str = intRange.toString("From %1$s to %2$s");
+ final String str = intRange.toString("From %1$s to %2$s");
assertEquals("From 10 to 20", str);
}
@@ -242,7 +242,7 @@ public class RangeTest {
try {
intRange.elementCompareTo(null);
fail("NullPointerException should have been thrown");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
// expected
}
diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
index 9df41100b..2bb414199 100644
--- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
@@ -68,7 +68,7 @@ public class SerializationUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new SerializationUtils());
- Constructor<?>[] cons = SerializationUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = SerializationUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(SerializationUtils.class.getModifiers()));
@@ -78,7 +78,7 @@ public class SerializationUtilsTest {
@Test
public void testException() {
SerializationException serEx;
- Exception ex = new Exception();
+ final Exception ex = new Exception();
serEx = new SerializationException();
assertSame(null, serEx.getMessage());
@@ -101,17 +101,17 @@ public class SerializationUtilsTest {
@Test
public void testSerializeStream() throws Exception {
- ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
+ final ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
SerializationUtils.serialize(iMap, streamTest);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- byte[] testBytes = streamTest.toByteArray();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] testBytes = streamTest.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -120,11 +120,11 @@ public class SerializationUtilsTest {
@Test
public void testSerializeStreamUnserializable() throws Exception {
- ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
+ final ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
try {
iMap.put(new Object(), new Object());
SerializationUtils.serialize(iMap, streamTest);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -132,17 +132,17 @@ public class SerializationUtilsTest {
@Test
public void testSerializeStreamNullObj() throws Exception {
- ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
+ final ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
SerializationUtils.serialize(null, streamTest);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- byte[] testBytes = streamTest.toByteArray();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] testBytes = streamTest.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -153,7 +153,7 @@ public class SerializationUtilsTest {
public void testSerializeStreamObjNull() throws Exception {
try {
SerializationUtils.serialize(iMap, null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -163,7 +163,7 @@ public class SerializationUtilsTest {
public void testSerializeStreamNullNull() throws Exception {
try {
SerializationUtils.serialize(null, null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -173,7 +173,7 @@ public class SerializationUtilsTest {
public void testSerializeIOException() throws Exception {
// forces an IOException when the ObjectOutputStream is created, to test not closing the stream
// in the finally block
- OutputStream streamTest = new OutputStream() {
+ final OutputStream streamTest = new OutputStream() {
@Override
public void write(final int arg0) throws IOException {
throw new IOException(SERIALIZE_IO_EXCEPTION_MESSAGE);
@@ -182,7 +182,7 @@ public class SerializationUtilsTest {
try {
SerializationUtils.serialize(iMap, streamTest);
}
- catch(SerializationException e) {
+ catch(final SerializationException e) {
assertEquals("java.io.IOException: " + SERIALIZE_IO_EXCEPTION_MESSAGE, e.getMessage());
}
}
@@ -191,18 +191,18 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeStream() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
- Object test = SerializationUtils.deserialize(inTest);
+ final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(inTest);
assertNotNull(test);
assertTrue(test instanceof HashMap<?, ?>);
assertTrue(test != iMap);
- HashMap<?, ?> testMap = (HashMap<?, ?>) test;
+ final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
assertEquals(iString, testMap.get("FOO"));
assertTrue(iString != testMap.get("FOO"));
assertEquals(iInteger, testMap.get("BAR"));
@@ -213,22 +213,22 @@ public class SerializationUtilsTest {
@Test(expected=ClassCastException.class)
public void testDeserializeClassCastException() {
final String value = "Hello";
- byte[] serialized = SerializationUtils.serialize(value);
+ final byte[] serialized = SerializationUtils.serialize(value);
Assert.assertEquals(value, SerializationUtils.deserialize(serialized));
// Causes ClassCastException in call site, not in SerializationUtils.deserialize
- Integer i = SerializationUtils.deserialize(serialized);
+ final Integer i = SerializationUtils.deserialize(serialized);
}
@Test
public void testDeserializeStreamOfNull() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
- Object test = SerializationUtils.deserialize(inTest);
+ final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(inTest);
assertNull(test);
}
@@ -236,7 +236,7 @@ public class SerializationUtilsTest {
public void testDeserializeStreamNull() throws Exception {
try {
SerializationUtils.deserialize((InputStream) null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -246,7 +246,7 @@ public class SerializationUtilsTest {
public void testDeserializeStreamBadStream() throws Exception {
try {
SerializationUtils.deserialize(new ByteArrayInputStream(new byte[0]));
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -254,17 +254,18 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeStreamClassNotFound() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(new ClassNotFoundSerialization());
oos.flush();
oos.close();
- ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
+ final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
try {
@SuppressWarnings("unused")
+ final
Object test = SerializationUtils.deserialize(inTest);
- } catch(SerializationException se) {
+ } catch(final SerializationException se) {
assertEquals("java.lang.ClassNotFoundException: " + CLASS_NOT_FOUND_MESSAGE, se.getMessage());
}
}
@@ -273,15 +274,15 @@ public class SerializationUtilsTest {
@Test
public void testSerializeBytes() throws Exception {
- byte[] testBytes = SerializationUtils.serialize(iMap);
+ final byte[] testBytes = SerializationUtils.serialize(iMap);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -293,7 +294,7 @@ public class SerializationUtilsTest {
try {
iMap.put(new Object(), new Object());
SerializationUtils.serialize(iMap);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -301,15 +302,15 @@ public class SerializationUtilsTest {
@Test
public void testSerializeBytesNull() throws Exception {
- byte[] testBytes = SerializationUtils.serialize(null);
+ final byte[] testBytes = SerializationUtils.serialize(null);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -320,17 +321,17 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeBytes() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- Object test = SerializationUtils.deserialize(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(streamReal.toByteArray());
assertNotNull(test);
assertTrue(test instanceof HashMap<?, ?>);
assertTrue(test != iMap);
- HashMap<?, ?> testMap = (HashMap<?, ?>) test;
+ final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
assertEquals(iString, testMap.get("FOO"));
assertTrue(iString != testMap.get("FOO"));
assertEquals(iInteger, testMap.get("BAR"));
@@ -340,13 +341,13 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeBytesOfNull() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- Object test = SerializationUtils.deserialize(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(streamReal.toByteArray());
assertNull(test);
}
@@ -354,7 +355,7 @@ public class SerializationUtilsTest {
public void testDeserializeBytesNull() throws Exception {
try {
SerializationUtils.deserialize((byte[]) null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -364,7 +365,7 @@ public class SerializationUtilsTest {
public void testDeserializeBytesBadStream() throws Exception {
try {
SerializationUtils.deserialize(new byte[0]);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -374,11 +375,11 @@ public class SerializationUtilsTest {
@Test
public void testClone() throws Exception {
- Object test = SerializationUtils.clone(iMap);
+ final Object test = SerializationUtils.clone(iMap);
assertNotNull(test);
assertTrue(test instanceof HashMap<?,?>);
assertTrue(test != iMap);
- HashMap<?, ?> testMap = (HashMap<?, ?>) test;
+ final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
assertEquals(iString, testMap.get("FOO"));
assertTrue(iString != testMap.get("FOO"));
assertEquals(iInteger, testMap.get("BAR"));
@@ -388,7 +389,7 @@ public class SerializationUtilsTest {
@Test
public void testCloneNull() throws Exception {
- Object test = SerializationUtils.clone(null);
+ final Object test = SerializationUtils.clone(null);
assertNull(test);
}
@@ -397,7 +398,7 @@ public class SerializationUtilsTest {
try {
iMap.put(new Object(), new Object());
SerializationUtils.clone(iMap);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -405,11 +406,11 @@ public class SerializationUtilsTest {
@Test
public void testPrimitiveTypeClassSerialization() {
- Class<?>[] primitiveTypes = { byte.class, short.class, int.class, long.class, float.class, double.class,
+ final Class<?>[] primitiveTypes = { byte.class, short.class, int.class, long.class, float.class, double.class,
boolean.class, char.class, void.class };
- for (Class<?> primitiveType : primitiveTypes) {
- Class<?> clone = SerializationUtils.clone(primitiveType);
+ for (final Class<?> primitiveType : primitiveTypes) {
+ final Class<?> clone = SerializationUtils.clone(primitiveType);
assertEquals(primitiveType, clone);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
index 1b06bd5cc..f9a172c66 100644
--- a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
@@ -44,7 +44,7 @@ public class StringEscapeUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new StringEscapeUtils());
- Constructor<?>[] cons = StringEscapeUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = StringEscapeUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(StringEscapeUtils.class.getModifiers()));
@@ -57,16 +57,16 @@ public class StringEscapeUtilsTest {
try {
StringEscapeUtils.ESCAPE_JAVA.translate(null, null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.ESCAPE_JAVA.translate("", null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
assertEscapeJava("empty string", "", "");
@@ -111,11 +111,11 @@ public class StringEscapeUtilsTest {
}
private void assertEscapeJava(String message, final String expected, final String original) throws IOException {
- String converted = StringEscapeUtils.escapeJava(original);
+ final String converted = StringEscapeUtils.escapeJava(original);
message = "escapeJava(String) failed" + (message == null ? "" : (": " + message));
assertEquals(message, expected, converted);
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.ESCAPE_JAVA.translate(original, writer);
assertEquals(expected, writer.toString());
}
@@ -126,21 +126,21 @@ public class StringEscapeUtilsTest {
try {
StringEscapeUtils.UNESCAPE_JAVA.translate(null, null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.UNESCAPE_JAVA.translate("", null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.unescapeJava("\\u02-3");
fail();
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
}
assertUnescapeJava("", "");
@@ -160,8 +160,8 @@ public class StringEscapeUtilsTest {
}
private void assertUnescapeJava(final String message, final String unescaped, final String original) throws IOException {
- String expected = unescaped;
- String actual = StringEscapeUtils.unescapeJava(original);
+ final String expected = unescaped;
+ final String actual = StringEscapeUtils.unescapeJava(original);
assertEquals("unescape(String) failed" +
(message == null ? "" : (": " + message)) +
@@ -170,7 +170,7 @@ public class StringEscapeUtilsTest {
"' actual '" + StringEscapeUtils.escapeJava(actual) + "'",
expected, actual);
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.UNESCAPE_JAVA.translate(original, writer);
assertEquals(unescaped, writer.toString());
@@ -182,16 +182,16 @@ public class StringEscapeUtilsTest {
try {
StringEscapeUtils.ESCAPE_ECMASCRIPT.translate(null, null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.ESCAPE_ECMASCRIPT.translate("", null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
assertEquals("He didn\\'t say, \\\"stop!\\\"", StringEscapeUtils.escapeEcmaScript("He didn't say, \"stop!\""));
@@ -220,16 +220,16 @@ public class StringEscapeUtilsTest {
@Test
public void testEscapeHtml() {
for (int i = 0; i < HTML_ESCAPES.length; ++i) {
- String message = HTML_ESCAPES[i][0];
- String expected = HTML_ESCAPES[i][1];
- String original = HTML_ESCAPES[i][2];
+ final String message = HTML_ESCAPES[i][0];
+ final String expected = HTML_ESCAPES[i][1];
+ final String original = HTML_ESCAPES[i][2];
assertEquals(message, expected, StringEscapeUtils.escapeHtml4(original));
- StringWriter sw = new StringWriter();
+ final StringWriter sw = new StringWriter();
try {
StringEscapeUtils.ESCAPE_HTML4.translate(original, sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
- String actual = original == null ? null : sw.toString();
+ final String actual = original == null ? null : sw.toString();
assertEquals(message, expected, actual);
}
}
@@ -237,17 +237,17 @@ public class StringEscapeUtilsTest {
@Test
public void testUnescapeHtml4() {
for (int i = 0; i < HTML_ESCAPES.length; ++i) {
- String message = HTML_ESCAPES[i][0];
- String expected = HTML_ESCAPES[i][2];
- String original = HTML_ESCAPES[i][1];
+ final String message = HTML_ESCAPES[i][0];
+ final String expected = HTML_ESCAPES[i][2];
+ final String original = HTML_ESCAPES[i][1];
assertEquals(message, expected, StringEscapeUtils.unescapeHtml4(original));
- StringWriter sw = new StringWriter();
+ final StringWriter sw = new StringWriter();
try {
StringEscapeUtils.UNESCAPE_HTML4.translate(original, sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
- String actual = original == null ? null : sw.toString();
+ final String actual = original == null ? null : sw.toString();
assertEquals(message, expected, actual);
}
// \u00E7 is a cedilla (c with wiggle under)
@@ -268,11 +268,11 @@ public class StringEscapeUtilsTest {
assertEquals("hex number unescape", "\u0080\u009F", StringEscapeUtils.unescapeHtml4("&#X80;&#X9F;"));
// Test all Character values:
for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
- Character c1 = new Character(i);
- Character c2 = new Character((char)(i+1));
- String expected = c1.toString() + c2.toString();
- String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
- String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
+ final Character c1 = new Character(i);
+ final Character c2 = new Character((char)(i+1));
+ final String expected = c1.toString() + c2.toString();
+ final String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
+ final String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
assertEquals("hex number unescape index " + (int)i, expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2));
}
}
@@ -315,14 +315,14 @@ public class StringEscapeUtilsTest {
StringWriter sw = new StringWriter();
try {
StringEscapeUtils.ESCAPE_XML.translate("<abc>", sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
assertEquals("XML was escaped incorrectly", "&lt;abc&gt;", sw.toString() );
sw = new StringWriter();
try {
StringEscapeUtils.UNESCAPE_XML.translate("&lt;abc&gt;", sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
assertEquals("XML was unescaped incorrectly", "<abc>", sw.toString() );
}
@@ -343,7 +343,7 @@ public class StringEscapeUtilsTest {
*/
@Test
public void testEscapeXmlSupplementaryCharacters() {
- CharSequenceTranslator escapeXml =
+ final CharSequenceTranslator escapeXml =
StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );
assertEquals("Supplementary character must be represented using a single escape", "&#144308;",
@@ -355,7 +355,7 @@ public class StringEscapeUtilsTest {
// http://www.w3.org/TR/xml/#charsets says:
// Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character,
// excluding the surrogate blocks, FFFE, and FFFF. */
- CharSequenceTranslator escapeXml = StringEscapeUtils.ESCAPE_XML
+ final CharSequenceTranslator escapeXml = StringEscapeUtils.ESCAPE_XML
.with(NumericEntityEscaper.below(9), NumericEntityEscaper.between(0xB, 0xC), NumericEntityEscaper.between(0xE, 0x19),
NumericEntityEscaper.between(0xD800, 0xDFFF), NumericEntityEscaper.between(0xFFFE, 0xFFFF), NumericEntityEscaper.above(0x110000));
@@ -418,10 +418,10 @@ public class StringEscapeUtilsTest {
private void checkCsvEscapeWriter(final String expected, final String value) {
try {
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.ESCAPE_CSV.translate(value, writer);
assertEquals(expected, writer.toString());
- } catch (IOException e) {
+ } catch (final IOException e) {
fail("Threw: " + e);
}
}
@@ -454,10 +454,10 @@ public class StringEscapeUtilsTest {
private void checkCsvUnescapeWriter(final String expected, final String value) {
try {
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.UNESCAPE_CSV.translate(value, writer);
assertEquals(expected, writer.toString());
- } catch (IOException e) {
+ } catch (final IOException e) {
fail("Threw: " + e);
}
}
@@ -473,14 +473,14 @@ public class StringEscapeUtilsTest {
// COUNTING ROD UNIT DIGIT THREE
// in Unicode
// codepoint: U+1D362
- byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 };
+ final byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 };
- String original = new String(data, "UTF8");
+ final String original = new String(data, "UTF8");
- String escaped = StringEscapeUtils.escapeHtml4( original );
+ final String escaped = StringEscapeUtils.escapeHtml4( original );
assertEquals( "High Unicode should not have been escaped", original, escaped);
- String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
+ final String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
assertEquals( "High Unicode should have been unchanged", original, unescaped);
// TODO: I think this should hold, needs further investigation
@@ -494,12 +494,12 @@ public class StringEscapeUtilsTest {
@Test
public void testEscapeHiragana() {
// Some random Japanese Unicode characters
- String original = "\u304B\u304C\u3068";
- String escaped = StringEscapeUtils.escapeHtml4(original);
+ final String original = "\u304B\u304C\u3068";
+ final String escaped = StringEscapeUtils.escapeHtml4(original);
assertEquals( "Hiragana character Unicode behaviour should not be being escaped by escapeHtml4",
original, escaped);
- String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
+ final String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
assertEquals( "Hiragana character Unicode behaviour has changed - expected no unescaping", escaped, unescaped);
}
@@ -512,8 +512,8 @@ public class StringEscapeUtilsTest {
*/
@Test
public void testLang708() throws IOException {
- String input = IOUtils.toString(new FileInputStream("src/test/resources/lang-708-input.txt"), "UTF-8");
- String escaped = StringEscapeUtils.escapeEcmaScript(input);
+ final String input = IOUtils.toString(new FileInputStream("src/test/resources/lang-708-input.txt"), "UTF-8");
+ final String escaped = StringEscapeUtils.escapeEcmaScript(input);
// just the end:
assertTrue(escaped, escaped.endsWith("}]"));
// a little more:
@@ -525,8 +525,8 @@ public class StringEscapeUtilsTest {
*/
@Test
public void testLang720() {
- String input = new StringBuilder("\ud842\udfb7").append("A").toString();
- String escaped = StringEscapeUtils.escapeXml(input);
+ final String input = new StringBuilder("\ud842\udfb7").append("A").toString();
+ final String escaped = StringEscapeUtils.escapeXml(input);
assertEquals(input, escaped);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
index 461d7cab1..0bc1e6ed8 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
@@ -216,11 +216,11 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsIgnoreCase_LocaleIndependence() {
- Locale orig = Locale.getDefault();
+ final Locale orig = Locale.getDefault();
- Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() };
+ final Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() };
- String[][] tdata = {
+ final String[][] tdata = {
{ "i", "I" },
{ "I", "i" },
{ "\u03C2", "\u03C3" },
@@ -228,12 +228,12 @@ public class StringUtilsEqualsIndexOfTest {
{ "\u03A3", "\u03C3" },
};
- String[][] fdata = {
+ final String[][] fdata = {
{ "\u00DF", "SS" },
};
try {
- for (Locale locale : locales) {
+ for (final Locale locale : locales) {
Locale.setDefault(locale);
for (int j = 0; j < tdata.length; j++) {
assertTrue(Locale.getDefault() + ": " + j + " " + tdata[j][0] + " " + tdata[j][1], StringUtils
@@ -286,13 +286,13 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsNone_CharArray() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab.";
- char[] chars1= {'b'};
- char[] chars2= {'.'};
- char[] chars3= {'c', 'd'};
- char[] emptyChars = new char[0];
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab.";
+ final char[] chars1= {'b'};
+ final char[] chars2= {'.'};
+ final char[] chars3= {'c', 'd'};
+ final char[] emptyChars = new char[0];
assertTrue(StringUtils.containsNone(null, (char[]) null));
assertTrue(StringUtils.containsNone("", (char[]) null));
assertTrue(StringUtils.containsNone(null, emptyChars));
@@ -344,12 +344,12 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsNone_String() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab.";
- String chars1= "b";
- String chars2= ".";
- String chars3= "cd";
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab.";
+ final String chars1= "b";
+ final String chars2= ".";
+ final String chars3= "cd";
assertTrue(StringUtils.containsNone(null, (String) null));
assertTrue(StringUtils.containsNone("", (String) null));
assertTrue(StringUtils.containsNone(null, ""));
@@ -401,13 +401,13 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsOnly_CharArray() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab";
- char[] chars1= {'b'};
- char[] chars2= {'a'};
- char[] chars3= {'a', 'b'};
- char[] emptyChars = new char[0];
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab";
+ final char[] chars1= {'b'};
+ final char[] chars2= {'a'};
+ final char[] chars3= {'a', 'b'};
+ final char[] emptyChars = new char[0];
assertFalse(StringUtils.containsOnly(null, (char[]) null));
assertFalse(StringUtils.containsOnly("", (char[]) null));
assertFalse(StringUtils.containsOnly(null, emptyChars));
@@ -427,12 +427,12 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsOnly_String() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab";
- String chars1= "b";
- String chars2= "a";
- String chars3= "ab";
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab";
+ final String chars1= "b";
+ final String chars2= "a";
+ final String chars3= "ab";
assertFalse(StringUtils.containsOnly(null, (String) null));
assertFalse(StringUtils.containsOnly("", (String) null));
assertFalse(StringUtils.containsOnly(null, ""));
@@ -492,7 +492,7 @@ public class StringUtilsEqualsIndexOfTest {
if (obj == null || !(obj instanceof CustomCharSequence)) {
return false;
}
- CustomCharSequence other = (CustomCharSequence) obj;
+ final CustomCharSequence other = (CustomCharSequence) obj;
return seq.equals(other.seq);
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index 8740852e5..95cdd58cd 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -111,7 +111,7 @@ public class StringUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new StringUtils());
- Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(StringUtils.class.getModifiers()));
@@ -184,8 +184,8 @@ public class StringUtilsTest {
assertEquals("I AM here 123", StringUtils.swapCase("i am HERE 123") );
assertEquals("i am here 123", StringUtils.swapCase("I AM HERE 123") );
- String test = "This String contains a TitleCase character: \u01C8";
- String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
+ final String test = "This String contains a TitleCase character: \u01C8";
+ final String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
assertEquals(expect, WordUtils.swapCase(test));
}
@@ -423,14 +423,14 @@ public class StringUtilsTest {
}
String[] results;
- String[] expectedResults = {"ab", "de fg"};
+ final String[] expectedResults = {"ab", "de fg"};
results = StringUtils.split("ab de fg", null, 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
assertEquals(expectedResults[i], results[i]);
}
- String[] expectedResults2 = {"ab", "cd:ef"};
+ final String[] expectedResults2 = {"ab", "cd:ef"};
results = StringUtils.split("ab:cd:ef",":", 2);
assertEquals(expectedResults2.length, results.length);
for (int i = 0; i < expectedResults2.length; i++) {
@@ -439,7 +439,7 @@ public class StringUtilsTest {
}
private void innerTestSplit(final char separator, final String sepStr, final char noMatch) {
- String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
+ final String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
"), noMatch hex(" + Integer.toHexString(noMatch) + "), sepStr(" + sepStr + ")";
final String str = "a" + separator + "b" + separator + separator + noMatch + "c";
@@ -484,26 +484,26 @@ public class StringUtilsTest {
assertEquals( 0, StringUtils.splitByWholeSeparator( "", "." ).length ) ;
- String stringToSplitOnNulls = "ab de fg" ;
- String[] splitOnNullExpectedResults = { "ab", "de", "fg" } ;
+ final String stringToSplitOnNulls = "ab de fg" ;
+ final String[] splitOnNullExpectedResults = { "ab", "de", "fg" } ;
- String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null ) ;
+ final String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null ) ;
assertEquals( splitOnNullExpectedResults.length, splitOnNullResults.length ) ;
for ( int i = 0 ; i < splitOnNullExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnNullExpectedResults[i], splitOnNullResults[i] ) ;
}
- String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiously" ;
+ final String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiously" ;
- String[] splitOnStringExpectedResults = { "abstemiously", "abstemiously" } ;
- String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy" ) ;
+ final String[] splitOnStringExpectedResults = { "abstemiously", "abstemiously" } ;
+ final String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy" ) ;
assertEquals( splitOnStringExpectedResults.length, splitOnStringResults.length ) ;
for ( int i = 0 ; i < splitOnStringExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnStringExpectedResults[i], splitOnStringResults[i] ) ;
}
- String[] splitWithMultipleSeparatorExpectedResults = {"ab", "cd", "ef"};
- String[] splitWithMultipleSeparator = StringUtils.splitByWholeSeparator("ab:cd::ef", ":");
+ final String[] splitWithMultipleSeparatorExpectedResults = {"ab", "cd", "ef"};
+ final String[] splitWithMultipleSeparator = StringUtils.splitByWholeSeparator("ab:cd::ef", ":");
assertEquals( splitWithMultipleSeparatorExpectedResults.length, splitWithMultipleSeparator.length );
for( int i = 0; i < splitWithMultipleSeparatorExpectedResults.length ; i++ ) {
assertEquals( splitWithMultipleSeparatorExpectedResults[i], splitWithMultipleSeparator[i] ) ;
@@ -516,21 +516,21 @@ public class StringUtilsTest {
assertEquals( 0, StringUtils.splitByWholeSeparator( "", ".", 3 ).length ) ;
- String stringToSplitOnNulls = "ab de fg" ;
- String[] splitOnNullExpectedResults = { "ab", "de fg" } ;
+ final String stringToSplitOnNulls = "ab de fg" ;
+ final String[] splitOnNullExpectedResults = { "ab", "de fg" } ;
//String[] splitOnNullExpectedResults = { "ab", "de" } ;
- String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null, 2 ) ;
+ final String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null, 2 ) ;
assertEquals( splitOnNullExpectedResults.length, splitOnNullResults.length ) ;
for ( int i = 0 ; i < splitOnNullExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnNullExpectedResults[i], splitOnNullResults[i] ) ;
}
- String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiouslyaeiouyabstemiously" ;
+ final String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiouslyaeiouyabstemiously" ;
- String[] splitOnStringExpectedResults = { "abstemiously", "abstemiouslyaeiouyabstemiously" } ;
+ final String[] splitOnStringExpectedResults = { "abstemiously", "abstemiouslyaeiouyabstemiously" } ;
//String[] splitOnStringExpectedResults = { "abstemiously", "abstemiously" } ;
- String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy", 2 ) ;
+ final String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy", 2 ) ;
assertEquals( splitOnStringExpectedResults.length, splitOnStringResults.length ) ;
for ( int i = 0 ; i < splitOnStringExpectedResults.length ; i++ ) {
assertEquals( splitOnStringExpectedResults[i], splitOnStringResults[i] ) ;
@@ -763,7 +763,7 @@ public class StringUtilsTest {
// Match example in javadoc
{
String[] results;
- String[] expectedResults = {"a", "", "b", "c"};
+ final String[] expectedResults = {"a", "", "b", "c"};
results = StringUtils.splitPreserveAllTokens("a..b.c",'.');
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -792,7 +792,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "de fg"};
+ final String[] expectedResults = {"ab", "de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -802,7 +802,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", " de fg"};
+ final String[] expectedResults = {"ab", " de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -812,7 +812,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "::de:fg"};
+ final String[] expectedResults = {"ab", "::de:fg"};
results = StringUtils.splitPreserveAllTokens("ab:::de:fg", ":", 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -822,7 +822,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", " de fg"};
+ final String[] expectedResults = {"ab", "", " de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 3);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -832,7 +832,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", "", "de fg"};
+ final String[] expectedResults = {"ab", "", "", "de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 4);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -841,7 +841,7 @@ public class StringUtilsTest {
}
{
- String[] expectedResults = {"ab", "cd:ef"};
+ final String[] expectedResults = {"ab", "cd:ef"};
String[] results;
results = StringUtils.splitPreserveAllTokens("ab:cd:ef",":", 2);
assertEquals(expectedResults.length, results.length);
@@ -852,7 +852,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", ":cd:ef"};
+ final String[] expectedResults = {"ab", ":cd:ef"};
results = StringUtils.splitPreserveAllTokens("ab::cd:ef",":", 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -862,7 +862,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", ":cd:ef"};
+ final String[] expectedResults = {"ab", "", ":cd:ef"};
results = StringUtils.splitPreserveAllTokens("ab:::cd:ef",":", 3);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -872,7 +872,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", "", "cd:ef"};
+ final String[] expectedResults = {"ab", "", "", "cd:ef"};
results = StringUtils.splitPreserveAllTokens("ab:::cd:ef",":", 4);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -882,7 +882,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"", "ab", "", "", "cd:ef"};
+ final String[] expectedResults = {"", "ab", "", "", "cd:ef"};
results = StringUtils.splitPreserveAllTokens(":ab:::cd:ef",":", 5);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -892,7 +892,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"", "", "ab", "", "", "cd:ef"};
+ final String[] expectedResults = {"", "", "ab", "", "", "cd:ef"};
results = StringUtils.splitPreserveAllTokens("::ab:::cd:ef",":", 6);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -903,7 +903,7 @@ public class StringUtilsTest {
}
private void innerTestSplitPreserveAllTokens(final char separator, final String sepStr, final char noMatch) {
- String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
+ final String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
"), noMatch hex(" + Integer.toHexString(noMatch) + "), sepStr(" + sepStr + ")";
final String str = "a" + separator + "b" + separator + separator + noMatch + "c";
@@ -1065,7 +1065,7 @@ public class StringUtilsTest {
assertEquals("", StringUtils.replace("", "any", null, 2));
assertEquals("", StringUtils.replace("", "any", "any", 2));
- String str = new String(new char[] {'o', 'o', 'f', 'o', 'o'});
+ final String str = new String(new char[] {'o', 'o', 'f', 'o', 'o'});
assertSame(str, StringUtils.replace(str, "x", "", -1));
assertEquals("f", StringUtils.replace("oofoo", "o", "", -1));
@@ -1155,7 +1155,7 @@ public class StringUtilsTest {
try {
StringUtils.replaceEachRepeatedly("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"});
fail("Should be a circular reference");
- } catch (IllegalStateException e) {}
+ } catch (final IllegalStateException e) {}
//JAVADOC TESTS END
}
@@ -1250,7 +1250,7 @@ public class StringUtilsTest {
assertEquals("aaa", StringUtils.repeat("a", 3));
assertEquals("ababab", StringUtils.repeat("ab", 3));
assertEquals("abcabcabc", StringUtils.repeat("abc", 3));
- String str = StringUtils.repeat("a", 10000); // bigger than pad limit
+ final String str = StringUtils.repeat("a", 10000); // bigger than pad limit
assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[] {'a'}));
}
@@ -1272,7 +1272,7 @@ public class StringUtilsTest {
@Test
public void testChop() {
- String[][] chopCases = {
+ final String[][] chopCases = {
{ FOO_UNCAP + "\r\n", FOO_UNCAP } ,
{ FOO_UNCAP + "\n" , FOO_UNCAP } ,
{ FOO_UNCAP + "\r", FOO_UNCAP },
@@ -1286,9 +1286,9 @@ public class StringUtilsTest {
{ "", "" },
{ "a", "" },
};
- for (String[] chopCase : chopCases) {
- String original = chopCase[0];
- String expectedResult = chopCase[1];
+ for (final String[] chopCase : chopCases) {
+ final String original = chopCase[0];
+ final String expectedResult = chopCase[1];
assertEquals("chop(String) failed",
expectedResult, StringUtils.chop(original));
}
@@ -1298,7 +1298,7 @@ public class StringUtilsTest {
@Test
public void testChomp() {
- String[][] chompCases = {
+ final String[][] chompCases = {
{ FOO_UNCAP + "\r\n", FOO_UNCAP },
{ FOO_UNCAP + "\n" , FOO_UNCAP },
{ FOO_UNCAP + "\r", FOO_UNCAP },
@@ -1316,9 +1316,9 @@ public class StringUtilsTest {
{ null, null },
{ FOO_UNCAP + "\n\r", FOO_UNCAP + "\n"}
};
- for (String[] chompCase : chompCases) {
- String original = chompCase[0];
- String expectedResult = chompCase[1];
+ for (final String[] chompCase : chompCases) {
+ final String original = chompCase[0];
+ final String expectedResult = chompCase[1];
assertEquals("chomp(String) failed",
expectedResult, StringUtils.chomp(original));
}
@@ -1371,7 +1371,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.rightPad("abc", 2, ' '));
assertEquals("abc", StringUtils.rightPad("abc", -1, ' '));
assertEquals("abcxx", StringUtils.rightPad("abc", 5, 'x'));
- String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length
+ final String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length
assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[] {'a'}));
}
@@ -1407,7 +1407,7 @@ public class StringUtilsTest {
assertEquals("xxabc", StringUtils.leftPad("abc", 5, 'x'));
assertEquals("\uffff\uffffabc", StringUtils.leftPad("abc", 5, '\uffff'));
assertEquals("abc", StringUtils.leftPad("abc", 2, ' '));
- String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length
+ final String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length
assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[] {'a'}));
}
@@ -1552,7 +1552,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty("abc", "NULL"));
assertNull(StringUtils.defaultIfEmpty("", null));
// Tests compatibility for the API return type
- String s = StringUtils.defaultIfEmpty("abc", "NULL");
+ final String s = StringUtils.defaultIfEmpty("abc", "NULL");
assertEquals("abc", s);
}
@@ -1564,7 +1564,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank("abc", "NULL"));
assertNull(StringUtils.defaultIfBlank("", null));
// Tests compatibility for the API return type
- String s = StringUtils.defaultIfBlank("abc", "NULL");
+ final String s = StringUtils.defaultIfBlank("abc", "NULL");
assertEquals("abc", s);
}
@@ -1574,7 +1574,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL")).toString());
assertNull(StringUtils.defaultIfEmpty(new StringBuilder(""), null));
// Tests compatibility for the API return type
- StringBuilder s = StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL"));
+ final StringBuilder s = StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL"));
assertEquals("abc", s.toString());
}
@@ -1585,7 +1585,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank(new StringBuilder("abc"), new StringBuilder("NULL")).toString());
assertNull(StringUtils.defaultIfBlank(new StringBuilder(""), null));
// Tests compatibility for the API return type
- StringBuilder s = StringUtils.defaultIfBlank(new StringBuilder("abc"), new StringBuilder("NULL"));
+ final StringBuilder s = StringUtils.defaultIfBlank(new StringBuilder("abc"), new StringBuilder("NULL"));
assertEquals("abc", s.toString());
}
@@ -1595,7 +1595,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL")).toString());
assertNull(StringUtils.defaultIfEmpty(new StringBuffer(""), null));
// Tests compatibility for the API return type
- StringBuffer s = StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL"));
+ final StringBuffer s = StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL"));
assertEquals("abc", s.toString());
}
@@ -1606,7 +1606,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank(new StringBuffer("abc"), new StringBuffer("NULL")).toString());
assertNull(StringUtils.defaultIfBlank(new StringBuffer(""), null));
// Tests compatibility for the API return type
- StringBuffer s = StringUtils.defaultIfBlank(new StringBuffer("abc"), new StringBuffer("NULL"));
+ final StringBuffer s = StringUtils.defaultIfBlank(new StringBuffer("abc"), new StringBuffer("NULL"));
assertEquals("abc", s.toString());
}
@@ -1616,7 +1616,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL")).toString());
assertNull(StringUtils.defaultIfEmpty(CharBuffer.wrap(""), null));
// Tests compatibility for the API return type
- CharBuffer s = StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
+ final CharBuffer s = StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
assertEquals("abc", s.toString());
}
@@ -1627,7 +1627,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL")).toString());
assertNull(StringUtils.defaultIfBlank(CharBuffer.wrap(""), null));
// Tests compatibility for the API return type
- CharBuffer s = StringUtils.defaultIfBlank(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
+ final CharBuffer s = StringUtils.defaultIfBlank(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
assertEquals("abc", s.toString());
}
@@ -1639,7 +1639,7 @@ public class StringUtilsTest {
assertEquals("short", StringUtils.abbreviate("short", 10));
assertEquals("Now is ...", StringUtils.abbreviate("Now is the time for all good men to come to the aid of their party.", 10));
- String raspberry = "raspberry peach";
+ final String raspberry = "raspberry peach";
assertEquals("raspberry p...", StringUtils.abbreviate(raspberry, 14));
assertEquals("raspberry peach", StringUtils.abbreviate("raspberry peach", 15));
assertEquals("raspberry peach", StringUtils.abbreviate("raspberry peach", 16));
@@ -1651,9 +1651,10 @@ public class StringUtilsTest {
try {
@SuppressWarnings("unused")
+ final
String res = StringUtils.abbreviate("abc", 3);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
}
@@ -1666,21 +1667,23 @@ public class StringUtilsTest {
try {
@SuppressWarnings("unused")
+ final
String res = StringUtils.abbreviate("abcdefghij", 0, 3);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
String res = StringUtils.abbreviate("abcdefghij", 5, 6);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
- String raspberry = "raspberry peach";
+ final String raspberry = "raspberry peach";
assertEquals("raspberry peach", StringUtils.abbreviate(raspberry, 11, 15));
assertEquals(null, StringUtils.abbreviate(null, 7, 14));
@@ -1707,9 +1710,9 @@ public class StringUtilsTest {
}
private void assertAbbreviateWithOffset(final String expected, final int offset, final int maxWidth) {
- String abcdefghijklmno = "abcdefghijklmno";
- String message = "abbreviate(String,int,int) failed";
- String actual = StringUtils.abbreviate(abcdefghijklmno, offset, maxWidth);
+ final String abcdefghijklmno = "abcdefghijklmno";
+ final String message = "abbreviate(String,int,int) failed";
+ final String actual = StringUtils.abbreviate(abcdefghijklmno, offset, maxWidth);
if (offset >= 0 && offset < abcdefghijklmno.length()) {
assertTrue(message + " -- should contain offset character",
actual.indexOf((char)('a'+offset)) != -1);
@@ -1736,7 +1739,7 @@ public class StringUtilsTest {
"end to see if the text is complete.", "...", 50) );
// Test a much longer text :)
- String longText = "Start text" + StringUtils.repeat("x", 10000) + "Close text";
+ final String longText = "Start text" + StringUtils.repeat("x", 10000) + "Close text";
assertEquals(
"Start text->Close text",
StringUtils.abbreviateMiddle( longText, "->", 22 ) );
@@ -1803,16 +1806,18 @@ public class StringUtilsTest {
assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo") );
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance("a", null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance(null, "a");
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
}
@@ -1875,24 +1880,27 @@ public class StringUtilsTest {
// exceptions
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance("a", null, 0);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance(null, "a", 0);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance("a", "a", -1);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
}
@@ -2139,21 +2147,21 @@ public class StringUtilsTest {
// This test enforces that this is done.
@Test
public void testStringUtilsCharSequenceContract() {
- Class<StringUtils> c = StringUtils.class;
- Method[] methods = c.getMethods();
- for (Method m : methods) {
+ final Class<StringUtils> c = StringUtils.class;
+ final Method[] methods = c.getMethods();
+ for (final Method m : methods) {
if (m.getReturnType() == String.class || m.getReturnType() == String[].class) {
// Assume this is mutable and ensure the first parameter is not CharSequence.
// It may be String or it may be something else (String[], Object, Object[]) so
// don't actively test for that.
- Class<?>[] params = m.getParameterTypes();
+ final Class<?>[] params = m.getParameterTypes();
if ( params.length > 0 && (params[0] == CharSequence.class || params[0] == CharSequence[].class)) {
fail("The method " + m + " appears to be mutable in spirit and therefore must not accept a CharSequence");
}
} else {
// Assume this is immutable in spirit and ensure the first parameter is not String.
// As above, it may be something other than CharSequence.
- Class<?>[] params = m.getParameterTypes();
+ final Class<?>[] params = m.getParameterTypes();
if ( params.length > 0 && (params[0] == String.class || params[0] == String[].class)) {
fail("The method " + m + " appears to be immutable in spirit and therefore must not accept a String");
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
index a5fc223e3..e020ee59f 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
@@ -241,10 +241,10 @@ public class StringUtilsTrimEmptyTest {
@Test
public void testStripAll() {
// test stripAll method, merely an array version of the above strip
- String[] empty = new String[0];
- String[] fooSpace = new String[] { " "+FOO+" ", " "+FOO, FOO+" " };
- String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
- String[] foo = new String[] { FOO, FOO, FOO };
+ final String[] empty = new String[0];
+ final String[] fooSpace = new String[] { " "+FOO+" ", " "+FOO, FOO+" " };
+ final String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
+ final String[] foo = new String[] { FOO, FOO, FOO };
assertNull(StringUtils.stripAll((String[]) null));
// Additional varargs tests
@@ -261,10 +261,10 @@ public class StringUtilsTrimEmptyTest {
@Test
public void testStripAccents() {
- String cue = "\u00C7\u00FA\u00EA";
+ final String cue = "\u00C7\u00FA\u00EA";
assertEquals( "Failed to strip accents from " + cue, "Cue", StringUtils.stripAccents(cue));
- String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" +
+ final String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" +
"\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D1\u00D2\u00D3" +
"\u00D4\u00D5\u00D6\u00D9\u00DA\u00DB\u00DC\u00DD";
assertEquals( "Failed to strip accents from " + lots,
diff --git a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
index aabea579c..8622edb8c 100644
--- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
@@ -42,7 +42,7 @@ public class SystemUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new SystemUtils());
- Constructor<?>[] cons = SystemUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = SystemUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(SystemUtils.class.getModifiers()));
@@ -54,7 +54,7 @@ public class SystemUtilsTest {
*/
@Test
public void testGetJavaHome() {
- File dir = SystemUtils.getJavaHome();
+ final File dir = SystemUtils.getJavaHome();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@@ -64,7 +64,7 @@ public class SystemUtilsTest {
*/
@Test
public void testGetJavaIoTmpDir() {
- File dir = SystemUtils.getJavaIoTmpDir();
+ final File dir = SystemUtils.getJavaIoTmpDir();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@@ -74,7 +74,7 @@ public class SystemUtilsTest {
*/
@Test
public void testGetUserDir() {
- File dir = SystemUtils.getUserDir();
+ final File dir = SystemUtils.getUserDir();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@@ -84,14 +84,14 @@ public class SystemUtilsTest {
*/
@Test
public void testGetUserHome() {
- File dir = SystemUtils.getUserHome();
+ final File dir = SystemUtils.getUserHome();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@Test
public void testIS_JAVA() {
- String javaVersion = System.getProperty("java.version");
+ final String javaVersion = System.getProperty("java.version");
if (javaVersion == null) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -155,7 +155,7 @@ public class SystemUtilsTest {
@Test
public void testIS_OS() {
- String osName = System.getProperty("os.name");
+ final String osName = System.getProperty("os.name");
if (osName == null) {
assertFalse(SystemUtils.IS_OS_WINDOWS);
assertFalse(SystemUtils.IS_OS_UNIX);
@@ -356,12 +356,12 @@ public class SystemUtilsTest {
@Test
public void testJavaAwtHeadless() {
- boolean atLeastJava14 = SystemUtils.isJavaVersionAtLeast(JAVA_1_4);
- String expectedStringValue = System.getProperty("java.awt.headless");
- String expectedStringValueWithDefault = System.getProperty("java.awt.headless", "false");
+ final boolean atLeastJava14 = SystemUtils.isJavaVersionAtLeast(JAVA_1_4);
+ final String expectedStringValue = System.getProperty("java.awt.headless");
+ final String expectedStringValueWithDefault = System.getProperty("java.awt.headless", "false");
assertNotNull(expectedStringValueWithDefault);
if (atLeastJava14) {
- boolean expectedValue = Boolean.valueOf(expectedStringValue).booleanValue();
+ final boolean expectedValue = Boolean.valueOf(expectedStringValue).booleanValue();
if (expectedStringValue != null) {
assertEquals(expectedStringValue, SystemUtils.JAVA_AWT_HEADLESS);
}
diff --git a/src/test/java/org/apache/commons/lang3/ValidateTest.java b/src/test/java/org/apache/commons/lang3/ValidateTest.java
index fec0eb6e4..a60a591af 100644
--- a/src/test/java/org/apache/commons/lang3/ValidateTest.java
+++ b/src/test/java/org/apache/commons/lang3/ValidateTest.java
@@ -51,7 +51,7 @@ public class ValidateTest {
try {
Validate.isTrue(false);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated expression is false", ex.getMessage());
}
}
@@ -63,7 +63,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -75,7 +75,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG", 6);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -87,7 +87,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG", 7);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -99,7 +99,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG", 7.4d);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -112,12 +112,12 @@ public class ValidateTest {
try {
Validate.notNull(null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notNull(str);
+ final String str = "Hi";
+ final String testStr = Validate.notNull(str);
assertSame(str, testStr);
}
@@ -128,12 +128,12 @@ public class ValidateTest {
try {
Validate.notNull(null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notNull(str, "Message");
+ final String str = "Hi";
+ final String testStr = Validate.notNull(str, "Message");
assertSame(str, testStr);
}
@@ -145,18 +145,18 @@ public class ValidateTest {
try {
Validate.notEmpty((Object[]) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated array is empty", ex.getMessage());
}
try {
Validate.notEmpty(new Object[0]);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated array is empty", ex.getMessage());
}
- String[] array = new String[] {"hi"};
- String[] test = Validate.notEmpty(array);
+ final String[] array = new String[] {"hi"};
+ final String[] test = Validate.notEmpty(array);
assertSame(array, test);
}
@@ -167,18 +167,18 @@ public class ValidateTest {
try {
Validate.notEmpty((Object[]) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty(new Object[0], "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
- String[] array = new String[] {"hi"};
- String[] test = Validate.notEmpty(array, "Message");
+ final String[] array = new String[] {"hi"};
+ final String[] test = Validate.notEmpty(array, "Message");
assertSame(array, test);
}
@@ -186,46 +186,46 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotEmptyCollection1() {
- Collection<Integer> coll = new ArrayList<Integer>();
+ final Collection<Integer> coll = new ArrayList<Integer>();
try {
Validate.notEmpty((Collection<?>) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated collection is empty", ex.getMessage());
}
try {
Validate.notEmpty(coll);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated collection is empty", ex.getMessage());
}
coll.add(Integer.valueOf(8));
Validate.notEmpty(coll);
- Collection<Integer> test = Validate.notEmpty(coll);
+ final Collection<Integer> test = Validate.notEmpty(coll);
assertSame(coll, test);
}
//-----------------------------------------------------------------------
@Test
public void testNotEmptyCollection2() {
- Collection<Integer> coll = new ArrayList<Integer>();
+ final Collection<Integer> coll = new ArrayList<Integer>();
try {
Validate.notEmpty((Collection<?>) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty(coll, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
coll.add(Integer.valueOf(8));
Validate.notEmpty(coll, "MSG");
- Collection<Integer> test = Validate.notEmpty(coll, "Message");
+ final Collection<Integer> test = Validate.notEmpty(coll, "Message");
assertSame(coll, test);
}
@@ -233,46 +233,46 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotEmptyMap1() {
- Map<String, Integer> map = new HashMap<String, Integer>();
+ final Map<String, Integer> map = new HashMap<String, Integer>();
try {
Validate.notEmpty((Map<?, ?>) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated map is empty", ex.getMessage());
}
try {
Validate.notEmpty(map);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated map is empty", ex.getMessage());
}
map.put("ll", Integer.valueOf(8));
Validate.notEmpty(map);
- Map<String, Integer> test = Validate.notEmpty(map);
+ final Map<String, Integer> test = Validate.notEmpty(map);
assertSame(map, test);
}
//-----------------------------------------------------------------------
@Test
public void testNotEmptyMap2() {
- Map<String, Integer> map = new HashMap<String, Integer>();
+ final Map<String, Integer> map = new HashMap<String, Integer>();
try {
Validate.notEmpty((Map<?, ?>) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty(map, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
map.put("ll", Integer.valueOf(8));
Validate.notEmpty(map, "MSG");
- Map<String, Integer> test = Validate.notEmpty(map, "Message");
+ final Map<String, Integer> test = Validate.notEmpty(map, "Message");
assertSame(map, test);
}
@@ -284,18 +284,18 @@ public class ValidateTest {
try {
Validate.notEmpty((String) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated character sequence is empty", ex.getMessage());
}
try {
Validate.notEmpty("");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated character sequence is empty", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notEmpty(str);
+ final String str = "Hi";
+ final String testStr = Validate.notEmpty(str);
assertSame(str, testStr);
}
@@ -306,18 +306,18 @@ public class ValidateTest {
try {
Validate.notEmpty((String) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty("", "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notEmpty(str, "Message");
+ final String str = "Hi";
+ final String testStr = Validate.notEmpty(str, "Message");
assertSame(str, testStr);
}
@@ -326,13 +326,13 @@ public class ValidateTest {
@Test
public void testNotBlankNullStringShouldThrow() {
//given
- String string = null;
+ final String string = null;
try {
//when
Validate.notBlank(string);
fail("Expecting NullPointerException");
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -342,13 +342,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNullStringShouldThrow() {
//given
- String string = null;
+ final String string = null;
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting NullPointerException");
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -358,13 +358,13 @@ public class ValidateTest {
@Test
public void testNotBlankEmptyStringShouldThrow() {
//given
- String string = "";
+ final String string = "";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -374,13 +374,13 @@ public class ValidateTest {
@Test
public void testNotBlankBlankStringWithWhitespacesShouldThrow() {
//given
- String string = " ";
+ final String string = " ";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -390,13 +390,13 @@ public class ValidateTest {
@Test
public void testNotBlankBlankStringWithNewlinesShouldThrow() {
//given
- String string = " \n \t \r \n ";
+ final String string = " \n \t \r \n ";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -406,13 +406,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgBlankStringShouldThrow() {
//given
- String string = " \n \t \r \n ";
+ final String string = " \n \t \r \n ";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -422,13 +422,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgBlankStringWithWhitespacesShouldThrow() {
//given
- String string = " ";
+ final String string = " ";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -438,13 +438,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgEmptyStringShouldThrow() {
//given
- String string = "";
+ final String string = "";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -454,7 +454,7 @@ public class ValidateTest {
@Test
public void testNotBlankNotBlankStringShouldNotThrow() {
//given
- String string = "abc";
+ final String string = "abc";
//when
Validate.notBlank(string);
@@ -466,7 +466,7 @@ public class ValidateTest {
@Test
public void testNotBlankNotBlankStringWithWhitespacesShouldNotThrow() {
//given
- String string = " abc ";
+ final String string = " abc ";
//when
Validate.notBlank(string);
@@ -478,7 +478,7 @@ public class ValidateTest {
@Test
public void testNotBlankNotBlankStringWithNewlinesShouldNotThrow() {
//given
- String string = " \n \t abc \r \n ";
+ final String string = " \n \t abc \r \n ";
//when
Validate.notBlank(string);
@@ -490,7 +490,7 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNotBlankStringShouldNotThrow() {
//given
- String string = "abc";
+ final String string = "abc";
//when
Validate.notBlank(string, "Message");
@@ -502,7 +502,7 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNotBlankStringWithWhitespacesShouldNotThrow() {
//given
- String string = " abc ";
+ final String string = " abc ";
//when
Validate.notBlank(string, "Message");
@@ -514,7 +514,7 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNotBlankStringWithNewlinesShouldNotThrow() {
//given
- String string = " \n \t abc \r \n ";
+ final String string = " \n \t abc \r \n ";
//when
Validate.notBlank(string, "Message");
@@ -525,15 +525,15 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotBlankReturnValues1() {
- String str = "Hi";
- String test = Validate.notBlank(str);
+ final String str = "Hi";
+ final String test = Validate.notBlank(str);
assertSame(str, test);
}
@Test
public void testNotBlankReturnValues2() {
- String str = "Hi";
- String test = Validate.notBlank(str, "Message");
+ final String str = "Hi";
+ final String test = Validate.notBlank(str, "Message");
assertSame(str, test);
}
@@ -546,19 +546,19 @@ public class ValidateTest {
try {
Validate.noNullElements((Object[]) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
array[1] = null;
try {
Validate.noNullElements(array);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated array contains null element at index: 1", ex.getMessage());
}
array = new String[] {"a", "b"};
- String[] test = Validate.noNullElements(array);
+ final String[] test = Validate.noNullElements(array);
assertSame(array, test);
}
@@ -570,19 +570,19 @@ public class ValidateTest {
try {
Validate.noNullElements((Object[]) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
array[1] = null;
try {
Validate.noNullElements(array, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
array = new String[] {"a", "b"};
- String[] test = Validate.noNullElements(array, "Message");
+ final String[] test = Validate.noNullElements(array, "Message");
assertSame(array, test);
}
@@ -590,52 +590,52 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNoNullElementsCollection1() {
- List<String> coll = new ArrayList<String>();
+ final List<String> coll = new ArrayList<String>();
coll.add("a");
coll.add("b");
Validate.noNullElements(coll);
try {
Validate.noNullElements((Collection<?>) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
coll.set(1, null);
try {
Validate.noNullElements(coll);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated collection contains null element at index: 1", ex.getMessage());
}
coll.set(1, "b");
- List<String> test = Validate.noNullElements(coll);
+ final List<String> test = Validate.noNullElements(coll);
assertSame(coll, test);
}
//-----------------------------------------------------------------------
@Test
public void testNoNullElementsCollection2() {
- List<String> coll = new ArrayList<String>();
+ final List<String> coll = new ArrayList<String>();
coll.add("a");
coll.add("b");
Validate.noNullElements(coll, "MSG");
try {
Validate.noNullElements((Collection<?>) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
coll.set(1, null);
try {
Validate.noNullElements(coll, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
coll.set(1, "b");
- List<String> test = Validate.noNullElements(coll, "Message");
+ final List<String> test = Validate.noNullElements(coll, "Message");
assertSame(coll, test);
}
@@ -644,7 +644,7 @@ public class ValidateTest {
@Test
public void testConstructor() {
assertNotNull(new Validate());
- Constructor<?>[] cons = Validate.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = Validate.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(Validate.class.getModifiers()));
@@ -655,47 +655,47 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testValidIndex_withMessage_array() {
- Object[] array = new Object[2];
+ final Object[] array = new Object[2];
Validate.validIndex(array, 0, "Broken: ");
Validate.validIndex(array, 1, "Broken: ");
try {
Validate.validIndex(array, -1, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(array, 2, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
- String[] strArray = new String[] {"Hi"};
- String[] test = Validate.noNullElements(strArray, "Message");
+ final String[] strArray = new String[] {"Hi"};
+ final String[] test = Validate.noNullElements(strArray, "Message");
assertSame(strArray, test);
}
@Test
public void testValidIndex_array() {
- Object[] array = new Object[2];
+ final Object[] array = new Object[2];
Validate.validIndex(array, 0);
Validate.validIndex(array, 1);
try {
Validate.validIndex(array, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated array index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(array, 2);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated array index is invalid: 2", ex.getMessage());
}
- String[] strArray = new String[] {"Hi"};
- String[] test = Validate.noNullElements(strArray);
+ final String[] strArray = new String[] {"Hi"};
+ final String[] test = Validate.noNullElements(strArray);
assertSame(strArray, test);
}
@@ -703,7 +703,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testValidIndex_withMessage_collection() {
- Collection<String> coll = new ArrayList<String>();
+ final Collection<String> coll = new ArrayList<String>();
coll.add(null);
coll.add(null);
Validate.validIndex(coll, 0, "Broken: ");
@@ -711,24 +711,24 @@ public class ValidateTest {
try {
Validate.validIndex(coll, -1, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(coll, 2, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
- List<String> strColl = Arrays.asList(new String[] {"Hi"});
- List<String> test = Validate.validIndex(strColl, 0, "Message");
+ final List<String> strColl = Arrays.asList(new String[] {"Hi"});
+ final List<String> test = Validate.validIndex(strColl, 0, "Message");
assertSame(strColl, test);
}
@Test
public void testValidIndex_collection() {
- Collection<String> coll = new ArrayList<String>();
+ final Collection<String> coll = new ArrayList<String>();
coll.add(null);
coll.add(null);
Validate.validIndex(coll, 0);
@@ -736,18 +736,18 @@ public class ValidateTest {
try {
Validate.validIndex(coll, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated collection index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(coll, 2);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated collection index is invalid: 2", ex.getMessage());
}
- List<String> strColl = Arrays.asList(new String[] {"Hi"});
- List<String> test = Validate.validIndex(strColl, 0);
+ final List<String> strColl = Arrays.asList(new String[] {"Hi"});
+ final List<String> test = Validate.validIndex(strColl, 0);
assertSame(strColl, test);
}
@@ -755,61 +755,61 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testValidIndex_withMessage_charSequence() {
- CharSequence str = "Hi";
+ final CharSequence str = "Hi";
Validate.validIndex(str, 0, "Broken: ");
Validate.validIndex(str, 1, "Broken: ");
try {
Validate.validIndex(str, -1, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(str, 2, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
- String input = "Hi";
- String test = Validate.validIndex(input, 0, "Message");
+ final String input = "Hi";
+ final String test = Validate.validIndex(input, 0, "Message");
assertSame(input, test);
}
@Test
public void testValidIndex_charSequence() {
- CharSequence str = "Hi";
+ final CharSequence str = "Hi";
Validate.validIndex(str, 0);
Validate.validIndex(str, 1);
try {
Validate.validIndex(str, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated character sequence index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(str, 2);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated character sequence index is invalid: 2", ex.getMessage());
}
- String input = "Hi";
- String test = Validate.validIndex(input, 0);
+ final String input = "Hi";
+ final String test = Validate.validIndex(input, 0);
assertSame(input, test);
}
@Test
public void testMatchesPattern()
{
- CharSequence str = "hi";
+ final CharSequence str = "hi";
Validate.matchesPattern(str, "[a-z]*");
try
{
Validate.matchesPattern(str, "[0-9]*");
fail("Expecting IllegalArgumentException");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("The string hi does not match the pattern [0-9]*", e.getMessage());
}
@@ -818,14 +818,14 @@ public class ValidateTest {
@Test
public void testMatchesPattern_withMessage()
{
- CharSequence str = "hi";
+ final CharSequence str = "hi";
Validate.matchesPattern(str, "[a-z]*", "Does not match");
try
{
Validate.matchesPattern(str, "[0-9]*", "Does not match");
fail("Expecting IllegalArgumentException");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Does not match", e.getMessage());
}
@@ -840,7 +840,7 @@ public class ValidateTest {
try {
Validate.inclusiveBetween(0, 5, 6);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("The value 6 is not in the specified inclusive range of 0 to 5", e.getMessage());
}
}
@@ -854,7 +854,7 @@ public class ValidateTest {
try {
Validate.inclusiveBetween(0, 5, 6, "Error");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -867,13 +867,13 @@ public class ValidateTest {
try {
Validate.exclusiveBetween(0, 5, 6);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("The value 6 is not in the specified exclusive range of 0 to 5", e.getMessage());
}
try {
Validate.exclusiveBetween(0, 5, 5);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("The value 5 is not in the specified exclusive range of 0 to 5", e.getMessage());
}
}
@@ -886,13 +886,13 @@ public class ValidateTest {
try {
Validate.exclusiveBetween(0, 5, 6, "Error");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
try {
Validate.exclusiveBetween(0, 5, 5, "Error");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -908,7 +908,7 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi");
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Expected type: java.util.List, actual: java.lang.String", e.getMessage());
}
}
@@ -920,7 +920,7 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi", "Error");
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -936,7 +936,7 @@ public class ValidateTest {
try {
Validate.isAssignableFrom(List.class, String.class);
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Cannot assign a java.lang.String to a java.util.List", e.getMessage());
}
}
@@ -948,7 +948,7 @@ public class ValidateTest {
try {
Validate.isAssignableFrom(List.class, String.class, "Error");
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
index de88ade96..294e50c48 100644
--- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
@@ -45,7 +45,7 @@ public class CompareToBuilderTest {
if (!(o instanceof TestObject)) {
return false;
}
- TestObject rhs = (TestObject) o;
+ final TestObject rhs = (TestObject) o;
return a == rhs.a;
}
@@ -84,7 +84,7 @@ public class CompareToBuilderTest {
if (!(o instanceof TestSubObject)) {
return false;
}
- TestSubObject rhs = (TestSubObject) o;
+ final TestSubObject rhs = (TestSubObject) o;
return super.equals(o) && b == rhs.b;
}
}
@@ -100,8 +100,8 @@ public class CompareToBuilderTest {
@Test
public void testReflectionCompare() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(4);
assertTrue(CompareToBuilder.reflectionCompare(o1, o1) == 0);
assertTrue(CompareToBuilder.reflectionCompare(o1, o2) == 0);
o2.setA(5);
@@ -111,14 +111,14 @@ public class CompareToBuilderTest {
@Test(expected=NullPointerException.class)
public void testReflectionCompareEx1() {
- TestObject o1 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
CompareToBuilder.reflectionCompare(o1, null);
}
@Test(expected=ClassCastException.class)
public void testReflectionCompareEx2() {
- TestObject o1 = new TestObject(4);
- Object o2 = new Object();
+ final TestObject o1 = new TestObject(4);
+ final Object o2 = new Object();
CompareToBuilder.reflectionCompare(o1, o2);
}
@@ -129,7 +129,7 @@ public class CompareToBuilderTest {
@Test
public void testReflectionHierarchyCompareExcludeFields() {
- String[] excludeFields = new String[] { "b" };
+ final String[] excludeFields = new String[] { "b" };
testReflectionHierarchyCompare(true, excludeFields);
TestSubObject x;
@@ -181,12 +181,12 @@ public class CompareToBuilderTest {
}
private void testReflectionHierarchyCompare(final boolean testTransients, final String[] excludeFields) {
- TestObject to1 = new TestObject(1);
- TestObject to2 = new TestObject(2);
- TestObject to3 = new TestObject(3);
- TestSubObject tso1 = new TestSubObject(1, 1);
- TestSubObject tso2 = new TestSubObject(2, 2);
- TestSubObject tso3 = new TestSubObject(3, 3);
+ final TestObject to1 = new TestObject(1);
+ final TestObject to2 = new TestObject(2);
+ final TestObject to3 = new TestObject(3);
+ final TestSubObject tso1 = new TestSubObject(1, 1);
+ final TestSubObject tso2 = new TestSubObject(2, 2);
+ final TestSubObject tso3 = new TestSubObject(3, 3);
assertReflectionCompareContract(to1, to1, to1, false, excludeFields);
assertReflectionCompareContract(to1, to2, to3, false, excludeFields);
@@ -248,8 +248,8 @@ public class CompareToBuilderTest {
@Test
public void testAppendSuper() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().appendSuper(0).append(o2, o1).toComparison() > 0);
@@ -263,8 +263,8 @@ public class CompareToBuilderTest {
@Test
public void testObject() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(4);
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() == 0);
o2.setA(5);
@@ -278,8 +278,8 @@ public class CompareToBuilderTest {
@Test
public void testObjectBuild() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(4);
assertEquals(Integer.valueOf(0), new CompareToBuilder().append(o1, o1).build());
assertEquals(Integer.valueOf(0), new CompareToBuilder().append(o1, o2).build());
o2.setA(5);
@@ -293,14 +293,14 @@ public class CompareToBuilderTest {
@Test(expected=ClassCastException.class)
public void testObjectEx2() {
- TestObject o1 = new TestObject(4);
- Object o2 = new Object();
+ final TestObject o1 = new TestObject(4);
+ final Object o2 = new Object();
new CompareToBuilder().append(o1, o2);
}
@Test
public void testObjectComparator() {
- String o1 = "Fred";
+ final String o1 = "Fred";
String o2 = "Fred";
assertTrue(new CompareToBuilder().append(o1, o1, String.CASE_INSENSITIVE_ORDER).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() == 0);
@@ -318,7 +318,7 @@ public class CompareToBuilderTest {
@Test
public void testObjectComparatorNull() {
- String o1 = "Fred";
+ final String o1 = "Fred";
String o2 = "Fred";
assertTrue(new CompareToBuilder().append(o1, o1, null).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2, null).toComparison() == 0);
@@ -333,8 +333,8 @@ public class CompareToBuilderTest {
@Test
public void testLong() {
- long o1 = 1L;
- long o2 = 2L;
+ final long o1 = 1L;
+ final long o2 = 2L;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -346,8 +346,8 @@ public class CompareToBuilderTest {
@Test
public void testInt() {
- int o1 = 1;
- int o2 = 2;
+ final int o1 = 1;
+ final int o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -359,8 +359,8 @@ public class CompareToBuilderTest {
@Test
public void testShort() {
- short o1 = 1;
- short o2 = 2;
+ final short o1 = 1;
+ final short o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -372,8 +372,8 @@ public class CompareToBuilderTest {
@Test
public void testChar() {
- char o1 = 1;
- char o2 = 2;
+ final char o1 = 1;
+ final char o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -385,8 +385,8 @@ public class CompareToBuilderTest {
@Test
public void testByte() {
- byte o1 = 1;
- byte o2 = 2;
+ final byte o1 = 1;
+ final byte o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -398,8 +398,8 @@ public class CompareToBuilderTest {
@Test
public void testDouble() {
- double o1 = 1;
- double o2 = 2;
+ final double o1 = 1;
+ final double o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -419,8 +419,8 @@ public class CompareToBuilderTest {
@Test
public void testFloat() {
- float o1 = 1;
- float o2 = 2;
+ final float o1 = 1;
+ final float o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -440,8 +440,8 @@ public class CompareToBuilderTest {
@Test
public void testBoolean() {
- boolean o1 = true;
- boolean o2 = false;
+ final boolean o1 = true;
+ final boolean o2 = false;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o2, o2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() > 0);
@@ -450,13 +450,13 @@ public class CompareToBuilderTest {
@Test
public void testObjectArray() {
- TestObject[] obj1 = new TestObject[2];
+ final TestObject[] obj1 = new TestObject[2];
obj1[0] = new TestObject(4);
obj1[1] = new TestObject(5);
- TestObject[] obj2 = new TestObject[2];
+ final TestObject[] obj2 = new TestObject[2];
obj2[0] = new TestObject(4);
obj2[1] = new TestObject(5);
- TestObject[] obj3 = new TestObject[3];
+ final TestObject[] obj3 = new TestObject[3];
obj3[0] = new TestObject(4);
obj3[1] = new TestObject(5);
obj3[2] = new TestObject(6);
@@ -477,13 +477,13 @@ public class CompareToBuilderTest {
@Test
public void testLongArray() {
- long[] obj1 = new long[2];
+ final long[] obj1 = new long[2];
obj1[0] = 5L;
obj1[1] = 6L;
- long[] obj2 = new long[2];
+ final long[] obj2 = new long[2];
obj2[0] = 5L;
obj2[1] = 6L;
- long[] obj3 = new long[3];
+ final long[] obj3 = new long[3];
obj3[0] = 5L;
obj3[1] = 6L;
obj3[2] = 7L;
@@ -504,13 +504,13 @@ public class CompareToBuilderTest {
@Test
public void testIntArray() {
- int[] obj1 = new int[2];
+ final int[] obj1 = new int[2];
obj1[0] = 5;
obj1[1] = 6;
- int[] obj2 = new int[2];
+ final int[] obj2 = new int[2];
obj2[0] = 5;
obj2[1] = 6;
- int[] obj3 = new int[3];
+ final int[] obj3 = new int[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -531,13 +531,13 @@ public class CompareToBuilderTest {
@Test
public void testShortArray() {
- short[] obj1 = new short[2];
+ final short[] obj1 = new short[2];
obj1[0] = 5;
obj1[1] = 6;
- short[] obj2 = new short[2];
+ final short[] obj2 = new short[2];
obj2[0] = 5;
obj2[1] = 6;
- short[] obj3 = new short[3];
+ final short[] obj3 = new short[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -558,13 +558,13 @@ public class CompareToBuilderTest {
@Test
public void testCharArray() {
- char[] obj1 = new char[2];
+ final char[] obj1 = new char[2];
obj1[0] = 5;
obj1[1] = 6;
- char[] obj2 = new char[2];
+ final char[] obj2 = new char[2];
obj2[0] = 5;
obj2[1] = 6;
- char[] obj3 = new char[3];
+ final char[] obj3 = new char[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -585,13 +585,13 @@ public class CompareToBuilderTest {
@Test
public void testByteArray() {
- byte[] obj1 = new byte[2];
+ final byte[] obj1 = new byte[2];
obj1[0] = 5;
obj1[1] = 6;
- byte[] obj2 = new byte[2];
+ final byte[] obj2 = new byte[2];
obj2[0] = 5;
obj2[1] = 6;
- byte[] obj3 = new byte[3];
+ final byte[] obj3 = new byte[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -612,13 +612,13 @@ public class CompareToBuilderTest {
@Test
public void testDoubleArray() {
- double[] obj1 = new double[2];
+ final double[] obj1 = new double[2];
obj1[0] = 5;
obj1[1] = 6;
- double[] obj2 = new double[2];
+ final double[] obj2 = new double[2];
obj2[0] = 5;
obj2[1] = 6;
- double[] obj3 = new double[3];
+ final double[] obj3 = new double[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -639,13 +639,13 @@ public class CompareToBuilderTest {
@Test
public void testFloatArray() {
- float[] obj1 = new float[2];
+ final float[] obj1 = new float[2];
obj1[0] = 5;
obj1[1] = 6;
- float[] obj2 = new float[2];
+ final float[] obj2 = new float[2];
obj2[0] = 5;
obj2[1] = 6;
- float[] obj3 = new float[3];
+ final float[] obj3 = new float[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -666,13 +666,13 @@ public class CompareToBuilderTest {
@Test
public void testBooleanArray() {
- boolean[] obj1 = new boolean[2];
+ final boolean[] obj1 = new boolean[2];
obj1[0] = true;
obj1[1] = false;
- boolean[] obj2 = new boolean[2];
+ final boolean[] obj2 = new boolean[2];
obj2[0] = true;
obj2[1] = false;
- boolean[] obj3 = new boolean[3];
+ final boolean[] obj3 = new boolean[3];
obj3[0] = true;
obj3[1] = false;
obj3[2] = true;
@@ -693,9 +693,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiLongArray() {
- long[][] array1 = new long[2][2];
- long[][] array2 = new long[2][2];
- long[][] array3 = new long[2][3];
+ final long[][] array1 = new long[2][2];
+ final long[][] array2 = new long[2][2];
+ final long[][] array3 = new long[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -717,9 +717,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiIntArray() {
- int[][] array1 = new int[2][2];
- int[][] array2 = new int[2][2];
- int[][] array3 = new int[2][3];
+ final int[][] array1 = new int[2][2];
+ final int[][] array2 = new int[2][2];
+ final int[][] array3 = new int[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -741,9 +741,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiShortArray() {
- short[][] array1 = new short[2][2];
- short[][] array2 = new short[2][2];
- short[][] array3 = new short[2][3];
+ final short[][] array1 = new short[2][2];
+ final short[][] array2 = new short[2][2];
+ final short[][] array3 = new short[2][3];
for (short i = 0; i < array1.length; ++i) {
for (short j = 0; j < array1[0].length; j++) {
array1[i][j] = (short)((i + 1) * (j + 1));
@@ -765,9 +765,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiCharArray() {
- char[][] array1 = new char[2][2];
- char[][] array2 = new char[2][2];
- char[][] array3 = new char[2][3];
+ final char[][] array1 = new char[2][2];
+ final char[][] array2 = new char[2][2];
+ final char[][] array3 = new char[2][3];
for (short i = 0; i < array1.length; ++i) {
for (short j = 0; j < array1[0].length; j++) {
array1[i][j] = (char)((i + 1) * (j + 1));
@@ -789,9 +789,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiByteArray() {
- byte[][] array1 = new byte[2][2];
- byte[][] array2 = new byte[2][2];
- byte[][] array3 = new byte[2][3];
+ final byte[][] array1 = new byte[2][2];
+ final byte[][] array2 = new byte[2][2];
+ final byte[][] array3 = new byte[2][3];
for (byte i = 0; i < array1.length; ++i) {
for (byte j = 0; j < array1[0].length; j++) {
array1[i][j] = (byte)((i + 1) * (j + 1));
@@ -813,9 +813,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiFloatArray() {
- float[][] array1 = new float[2][2];
- float[][] array2 = new float[2][2];
- float[][] array3 = new float[2][3];
+ final float[][] array1 = new float[2][2];
+ final float[][] array2 = new float[2][2];
+ final float[][] array3 = new float[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -837,9 +837,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiDoubleArray() {
- double[][] array1 = new double[2][2];
- double[][] array2 = new double[2][2];
- double[][] array3 = new double[2][3];
+ final double[][] array1 = new double[2][2];
+ final double[][] array2 = new double[2][2];
+ final double[][] array3 = new double[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -861,9 +861,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiBooleanArray() {
- boolean[][] array1 = new boolean[2][2];
- boolean[][] array2 = new boolean[2][2];
- boolean[][] array3 = new boolean[2][3];
+ final boolean[][] array1 = new boolean[2][2];
+ final boolean[][] array2 = new boolean[2][2];
+ final boolean[][] array3 = new boolean[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = i == 1 ^ j == 1;
@@ -885,9 +885,9 @@ public class CompareToBuilderTest {
@Test
public void testRaggedArray() {
- long array1[][] = new long[2][];
- long array2[][] = new long[2][];
- 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];
@@ -913,9 +913,9 @@ public class CompareToBuilderTest {
@Test
public void testMixedArray() {
- Object array1[] = new Object[2];
- Object array2[] = new Object[2];
- 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];
@@ -939,20 +939,20 @@ public class CompareToBuilderTest {
@Test
public void testObjectArrayHiddenByObject() {
- TestObject[] array1 = new TestObject[2];
+ final TestObject[] array1 = new TestObject[2];
array1[0] = new TestObject(4);
array1[1] = new TestObject(5);
- TestObject[] array2 = new TestObject[2];
+ final TestObject[] array2 = new TestObject[2];
array2[0] = new TestObject(4);
array2[1] = new TestObject(5);
- TestObject[] array3 = new TestObject[3];
+ final TestObject[] array3 = new TestObject[3];
array3[0] = new TestObject(4);
array3[1] = new TestObject(5);
array3[2] = new TestObject(6);
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
@@ -966,19 +966,19 @@ public class CompareToBuilderTest {
@Test
public void testLongArrayHiddenByObject() {
- long[] array1 = new long[2];
+ final long[] array1 = new long[2];
array1[0] = 5L;
array1[1] = 6L;
- long[] array2 = new long[2];
+ final long[] array2 = new long[2];
array2[0] = 5L;
array2[1] = 6L;
- long[] array3 = new long[3];
+ final long[] array3 = new long[3];
array3[0] = 5L;
array3[1] = 6L;
array3[2] = 7L;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -991,19 +991,19 @@ public class CompareToBuilderTest {
@Test
public void testIntArrayHiddenByObject() {
- int[] array1 = new int[2];
+ final int[] array1 = new int[2];
array1[0] = 5;
array1[1] = 6;
- int[] array2 = new int[2];
+ final int[] array2 = new int[2];
array2[0] = 5;
array2[1] = 6;
- int[] array3 = new int[3];
+ final int[] array3 = new int[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1016,19 +1016,19 @@ public class CompareToBuilderTest {
@Test
public void testShortArrayHiddenByObject() {
- short[] array1 = new short[2];
+ final short[] array1 = new short[2];
array1[0] = 5;
array1[1] = 6;
- short[] array2 = new short[2];
+ final short[] array2 = new short[2];
array2[0] = 5;
array2[1] = 6;
- short[] array3 = new short[3];
+ final short[] array3 = new short[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1041,19 +1041,19 @@ public class CompareToBuilderTest {
@Test
public void testCharArrayHiddenByObject() {
- char[] array1 = new char[2];
+ final char[] array1 = new char[2];
array1[0] = 5;
array1[1] = 6;
- char[] array2 = new char[2];
+ final char[] array2 = new char[2];
array2[0] = 5;
array2[1] = 6;
- char[] array3 = new char[3];
+ final char[] array3 = new char[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1066,19 +1066,19 @@ public class CompareToBuilderTest {
@Test
public void testByteArrayHiddenByObject() {
- byte[] array1 = new byte[2];
+ final byte[] array1 = new byte[2];
array1[0] = 5;
array1[1] = 6;
- byte[] array2 = new byte[2];
+ final byte[] array2 = new byte[2];
array2[0] = 5;
array2[1] = 6;
- byte[] array3 = new byte[3];
+ final byte[] array3 = new byte[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1091,19 +1091,19 @@ public class CompareToBuilderTest {
@Test
public void testDoubleArrayHiddenByObject() {
- double[] array1 = new double[2];
+ final double[] array1 = new double[2];
array1[0] = 5;
array1[1] = 6;
- double[] array2 = new double[2];
+ final double[] array2 = new double[2];
array2[0] = 5;
array2[1] = 6;
- double[] array3 = new double[3];
+ final double[] array3 = new double[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1116,19 +1116,19 @@ public class CompareToBuilderTest {
@Test
public void testFloatArrayHiddenByObject() {
- float[] array1 = new float[2];
+ final float[] array1 = new float[2];
array1[0] = 5;
array1[1] = 6;
- float[] array2 = new float[2];
+ final float[] array2 = new float[2];
array2[0] = 5;
array2[1] = 6;
- float[] array3 = new float[3];
+ final float[] array3 = new float[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1141,19 +1141,19 @@ public class CompareToBuilderTest {
@Test
public void testBooleanArrayHiddenByObject() {
- boolean[] array1 = new boolean[2];
+ final boolean[] array1 = new boolean[2];
array1[0] = true;
array1[1] = false;
- boolean[] array2 = new boolean[2];
+ final boolean[] array2 = new boolean[2];
array2[0] = true;
array2[1] = false;
- boolean[] array3 = new boolean[3];
+ final boolean[] array3 = new boolean[3];
array3[0] = true;
array3[1] = false;
array3[2] = true;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
diff --git a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
index d1310d6ad..e1511b7b1 100644
--- a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
@@ -65,8 +65,8 @@ public class DefaultToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -83,11 +83,11 @@ public class DefaultToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "John Doe";
p.age = 33;
p.smoker = false;
- String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
+ final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[name=John Doe,age=33,smoker=false]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
index 7c9fb4cde..a708af837 100644
--- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
@@ -49,7 +49,7 @@ public class EqualsBuilderTest {
return false;
}
- TestObject rhs = (TestObject) o;
+ final TestObject rhs = (TestObject) o;
return a == rhs.a;
}
@@ -84,7 +84,7 @@ public class EqualsBuilderTest {
return false;
}
- TestSubObject rhs = (TestSubObject) o;
+ final TestSubObject rhs = (TestSubObject) o;
return super.equals(o) && b == rhs.b;
}
@@ -150,8 +150,8 @@ public class EqualsBuilderTest {
@Test
public void testReflectionEquals() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(EqualsBuilder.reflectionEquals(o1, o1));
assertTrue(!EqualsBuilder.reflectionEquals(o1, o2));
o2.setA(4);
@@ -177,18 +177,18 @@ public class EqualsBuilderTest {
}
private void testReflectionHierarchyEquals(final boolean testTransients) {
- TestObject to1 = new TestObject(4);
- TestObject to1Bis = new TestObject(4);
- TestObject to1Ter = new TestObject(4);
- TestObject to2 = new TestObject(5);
- TestEmptySubObject teso = new TestEmptySubObject(4);
- TestTSubObject ttso = new TestTSubObject(4, 1);
- TestTTSubObject tttso = new TestTTSubObject(4, 1, 2);
- TestTTLeafObject ttlo = new TestTTLeafObject(4, 1, 2, 3);
- TestSubObject tso1 = new TestSubObject(1, 4);
- TestSubObject tso1bis = new TestSubObject(1, 4);
- TestSubObject tso1ter = new TestSubObject(1, 4);
- TestSubObject tso2 = new TestSubObject(2, 5);
+ final TestObject to1 = new TestObject(4);
+ final TestObject to1Bis = new TestObject(4);
+ final TestObject to1Ter = new TestObject(4);
+ final TestObject to2 = new TestObject(5);
+ final TestEmptySubObject teso = new TestEmptySubObject(4);
+ final TestTSubObject ttso = new TestTSubObject(4, 1);
+ final TestTTSubObject tttso = new TestTTSubObject(4, 1, 2);
+ final TestTTLeafObject ttlo = new TestTTLeafObject(4, 1, 2, 3);
+ final TestSubObject tso1 = new TestSubObject(1, 4);
+ final TestSubObject tso1bis = new TestSubObject(1, 4);
+ final TestSubObject tso1ter = new TestSubObject(1, 4);
+ final TestSubObject tso2 = new TestSubObject(2, 5);
testReflectionEqualsEquivalenceRelationship(to1, to1Bis, to1Ter, to2, new TestObject(), testTransients);
testReflectionEqualsEquivalenceRelationship(tso1, tso1bis, tso1ter, tso2, new TestSubObject(), testTransients);
@@ -293,8 +293,8 @@ public class EqualsBuilderTest {
@Test
public void testSuper() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(new EqualsBuilder().appendSuper(true).append(o1, o1).isEquals());
assertFalse(new EqualsBuilder().appendSuper(false).append(o1, o1).isEquals());
assertFalse(new EqualsBuilder().appendSuper(true).append(o1, o2).isEquals());
@@ -303,8 +303,8 @@ public class EqualsBuilderTest {
@Test
public void testObject() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
o2.setA(4);
@@ -319,8 +319,8 @@ public class EqualsBuilderTest {
@Test
public void testObjectBuild() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertEquals(Boolean.TRUE, new EqualsBuilder().append(o1, o1).build());
assertEquals(Boolean.FALSE, new EqualsBuilder().append(o1, o2).build());
o2.setA(4);
@@ -335,48 +335,48 @@ public class EqualsBuilderTest {
@Test
public void testLong() {
- long o1 = 1L;
- long o2 = 2L;
+ final long o1 = 1L;
+ final long o2 = 2L;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testInt() {
- int o1 = 1;
- int o2 = 2;
+ final int o1 = 1;
+ final int o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testShort() {
- short o1 = 1;
- short o2 = 2;
+ final short o1 = 1;
+ final short o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testChar() {
- char o1 = 1;
- char o2 = 2;
+ final char o1 = 1;
+ final char o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testByte() {
- byte o1 = 1;
- byte o2 = 2;
+ final byte o1 = 1;
+ final byte o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testDouble() {
- double o1 = 1;
- double o2 = 2;
+ final double o1 = 1;
+ final double o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
assertTrue(!new EqualsBuilder().append(o1, Double.NaN).isEquals());
@@ -386,8 +386,8 @@ public class EqualsBuilderTest {
@Test
public void testFloat() {
- float o1 = 1;
- float o2 = 2;
+ final float o1 = 1;
+ final float o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
assertTrue(!new EqualsBuilder().append(o1, Float.NaN).isEquals());
@@ -397,7 +397,7 @@ public class EqualsBuilderTest {
@Test
public void testAccessors() {
- EqualsBuilder equalsBuilder = new EqualsBuilder();
+ final EqualsBuilder equalsBuilder = new EqualsBuilder();
assertTrue(equalsBuilder.isEquals());
equalsBuilder.setEquals(true);
assertTrue(equalsBuilder.isEquals());
@@ -407,7 +407,7 @@ public class EqualsBuilderTest {
@Test
public void testReset() {
- EqualsBuilder equalsBuilder = new EqualsBuilder();
+ final EqualsBuilder equalsBuilder = new EqualsBuilder();
assertTrue(equalsBuilder.isEquals());
equalsBuilder.setEquals(false);
assertFalse(equalsBuilder.isEquals());
@@ -417,8 +417,8 @@ public class EqualsBuilderTest {
@Test
public void testBoolean() {
- boolean o1 = true;
- boolean o2 = false;
+ final boolean o1 = true;
+ final boolean o2 = false;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@@ -606,8 +606,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiLongArray() {
- long[][] array1 = new long[2][2];
- long[][] array2 = new long[2][2];
+ final long[][] array1 = new long[2][2];
+ final long[][] array2 = new long[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -622,8 +622,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiIntArray() {
- int[][] array1 = new int[2][2];
- int[][] array2 = new int[2][2];
+ final int[][] array1 = new int[2][2];
+ final int[][] array2 = new int[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -638,8 +638,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiShortArray() {
- short[][] array1 = new short[2][2];
- short[][] array2 = new short[2][2];
+ final short[][] array1 = new short[2][2];
+ final short[][] array2 = new short[2][2];
for (short i = 0; i < array1.length; ++i) {
for (short j = 0; j < array1[0].length; j++) {
array1[i][j] = i;
@@ -654,8 +654,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiCharArray() {
- char[][] array1 = new char[2][2];
- char[][] array2 = new char[2][2];
+ final char[][] array1 = new char[2][2];
+ final char[][] array2 = new char[2][2];
for (char i = 0; i < array1.length; ++i) {
for (char j = 0; j < array1[0].length; j++) {
array1[i][j] = i;
@@ -670,8 +670,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiByteArray() {
- byte[][] array1 = new byte[2][2];
- byte[][] array2 = new byte[2][2];
+ final byte[][] array1 = new byte[2][2];
+ final byte[][] array2 = new byte[2][2];
for (byte i = 0; i < array1.length; ++i) {
for (byte j = 0; j < array1[0].length; j++) {
array1[i][j] = i;
@@ -686,8 +686,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiFloatArray() {
- float[][] array1 = new float[2][2];
- float[][] array2 = new float[2][2];
+ final float[][] array1 = new float[2][2];
+ final float[][] array2 = new float[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -702,8 +702,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiDoubleArray() {
- double[][] array1 = new double[2][2];
- double[][] array2 = new double[2][2];
+ final double[][] array1 = new double[2][2];
+ final double[][] array2 = new double[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -718,8 +718,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiBooleanArray() {
- boolean[][] array1 = new boolean[2][2];
- boolean[][] array2 = new boolean[2][2];
+ final boolean[][] array1 = new boolean[2][2];
+ final boolean[][] array2 = new boolean[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = i == 1 || j == 1;
@@ -732,7 +732,7 @@ public class EqualsBuilderTest {
assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
// compare 1 dim to 2.
- boolean[] array3 = new boolean[]{true, true};
+ final boolean[] array3 = new boolean[]{true, true};
assertFalse(new EqualsBuilder().append(array1, array3).isEquals());
assertFalse(new EqualsBuilder().append(array3, array1).isEquals());
assertFalse(new EqualsBuilder().append(array2, array3).isEquals());
@@ -741,8 +741,8 @@ public class EqualsBuilderTest {
@Test
public void testRaggedArray() {
- long array1[][] = new long[2][];
- 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];
@@ -759,8 +759,8 @@ public class EqualsBuilderTest {
@Test
public void testMixedArray() {
- Object array1[] = new Object[2];
- 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];
@@ -777,14 +777,14 @@ public class EqualsBuilderTest {
@Test
public void testObjectArrayHiddenByObject() {
- TestObject[] array1 = new TestObject[2];
+ final TestObject[] array1 = new TestObject[2];
array1[0] = new TestObject(4);
array1[1] = new TestObject(5);
- TestObject[] array2 = new TestObject[2];
+ final TestObject[] array2 = new TestObject[2];
array2[0] = new TestObject(4);
array2[1] = new TestObject(5);
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -795,14 +795,14 @@ public class EqualsBuilderTest {
@Test
public void testLongArrayHiddenByObject() {
- long[] array1 = new long[2];
+ final long[] array1 = new long[2];
array1[0] = 5L;
array1[1] = 6L;
- long[] array2 = new long[2];
+ final long[] array2 = new long[2];
array2[0] = 5L;
array2[1] = 6L;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -813,14 +813,14 @@ public class EqualsBuilderTest {
@Test
public void testIntArrayHiddenByObject() {
- int[] array1 = new int[2];
+ final int[] array1 = new int[2];
array1[0] = 5;
array1[1] = 6;
- int[] array2 = new int[2];
+ final int[] array2 = new int[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -831,14 +831,14 @@ public class EqualsBuilderTest {
@Test
public void testShortArrayHiddenByObject() {
- short[] array1 = new short[2];
+ final short[] array1 = new short[2];
array1[0] = 5;
array1[1] = 6;
- short[] array2 = new short[2];
+ final short[] array2 = new short[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -849,14 +849,14 @@ public class EqualsBuilderTest {
@Test
public void testCharArrayHiddenByObject() {
- char[] array1 = new char[2];
+ final char[] array1 = new char[2];
array1[0] = 5;
array1[1] = 6;
- char[] array2 = new char[2];
+ final char[] array2 = new char[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -867,14 +867,14 @@ public class EqualsBuilderTest {
@Test
public void testByteArrayHiddenByObject() {
- byte[] array1 = new byte[2];
+ final byte[] array1 = new byte[2];
array1[0] = 5;
array1[1] = 6;
- byte[] array2 = new byte[2];
+ final byte[] array2 = new byte[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -885,14 +885,14 @@ public class EqualsBuilderTest {
@Test
public void testDoubleArrayHiddenByObject() {
- double[] array1 = new double[2];
+ final double[] array1 = new double[2];
array1[0] = 5;
array1[1] = 6;
- double[] array2 = new double[2];
+ final double[] array2 = new double[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -903,14 +903,14 @@ public class EqualsBuilderTest {
@Test
public void testFloatArrayHiddenByObject() {
- float[] array1 = new float[2];
+ final float[] array1 = new float[2];
array1[0] = 5;
array1[1] = 6;
- float[] array2 = new float[2];
+ final float[] array2 = new float[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -921,14 +921,14 @@ public class EqualsBuilderTest {
@Test
public void testBooleanArrayHiddenByObject() {
- boolean[] array1 = new boolean[2];
+ final boolean[] array1 = new boolean[2];
array1[0] = true;
array1[1] = false;
- boolean[] array2 = new boolean[2];
+ final boolean[] array2 = new boolean[2];
array2[0] = true;
array2[1] = false;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -1006,8 +1006,8 @@ public class EqualsBuilderTest {
*/
@Test
public void testUnrelatedClasses() {
- Object[] x = new Object[]{new TestACanEqualB(1)};
- Object[] y = new Object[]{new TestBCanEqualA(1)};
+ final Object[] x = new Object[]{new TestACanEqualB(1)};
+ final Object[] y = new Object[]{new TestBCanEqualA(1)};
// sanity checks:
assertTrue(Arrays.equals(x, x));
@@ -1030,8 +1030,8 @@ public class EqualsBuilderTest {
*/
@Test
public void testNpeForNullElement() {
- Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
- Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
+ final Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
+ final Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
// causes an NPE in 2.0 according to:
// http://issues.apache.org/bugzilla/show_bug.cgi?id=33067
@@ -1040,8 +1040,8 @@ public class EqualsBuilderTest {
@Test
public void testReflectionEqualsExcludeFields() throws Exception {
- TestObjectWithMultipleFields x1 = new TestObjectWithMultipleFields(1, 2, 3);
- TestObjectWithMultipleFields x2 = new TestObjectWithMultipleFields(1, 3, 4);
+ final TestObjectWithMultipleFields x1 = new TestObjectWithMultipleFields(1, 2, 3);
+ final TestObjectWithMultipleFields x2 = new TestObjectWithMultipleFields(1, 3, 4);
// not equal when including all fields
assertTrue(!EqualsBuilder.reflectionEquals(x1, x2));
@@ -1084,18 +1084,18 @@ public class EqualsBuilderTest {
*/
@Test
public void testCyclicalObjectReferences() {
- TestObjectReference refX1 = new TestObjectReference(1);
- TestObjectReference x1 = new TestObjectReference(1);
+ final TestObjectReference refX1 = new TestObjectReference(1);
+ final TestObjectReference x1 = new TestObjectReference(1);
x1.setObjectReference(refX1);
refX1.setObjectReference(x1);
- TestObjectReference refX2 = new TestObjectReference(1);
- TestObjectReference x2 = new TestObjectReference(1);
+ final TestObjectReference refX2 = new TestObjectReference(1);
+ final TestObjectReference x2 = new TestObjectReference(1);
x2.setObjectReference(refX2);
refX2.setObjectReference(x2);
- TestObjectReference refX3 = new TestObjectReference(2);
- TestObjectReference x3 = new TestObjectReference(2);
+ final TestObjectReference refX3 = new TestObjectReference(2);
+ final TestObjectReference x3 = new TestObjectReference(2);
x3.setObjectReference(refX3);
refX3.setObjectReference(x3);
diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
index 9c959f762..1a3959bac 100644
--- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
@@ -32,8 +32,8 @@ public class HashCodeBuilderAndEqualsBuilderTest {
//-----------------------------------------------------------------------
private void testInteger(final boolean testTransients) {
- Integer i1 = Integer.valueOf(12345);
- Integer i2 = Integer.valueOf(12345);
+ final Integer i1 = Integer.valueOf(12345);
+ final Integer i2 = Integer.valueOf(12345);
assertEqualsAndHashCodeContract(i1, i2, testTransients);
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
index fbbf66d3a..9156974a0 100644
--- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
@@ -79,7 +79,7 @@ public class HashCodeBuilderTest {
if (!(o instanceof TestObject)) {
return false;
}
- TestObject rhs = (TestObject) o;
+ final TestObject rhs = (TestObject) o;
return a == rhs.a;
}
@@ -121,7 +121,7 @@ public class HashCodeBuilderTest {
if (!(o instanceof TestSubObject)) {
return false;
}
- TestSubObject rhs = (TestSubObject) o;
+ final TestSubObject rhs = (TestSubObject) o;
return super.equals(o) && b == rhs.b;
}
@@ -175,7 +175,7 @@ public class HashCodeBuilderTest {
@Test
public void testSuper() {
- Object obj = new Object();
+ final Object obj = new Object();
assertEquals(17 * 37 + 19 * 41 + obj.hashCode(), new HashCodeBuilder(17, 37).appendSuper(
new HashCodeBuilder(19, 41).append(obj).toHashCode()).toHashCode());
}
@@ -233,8 +233,8 @@ public class HashCodeBuilderTest {
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
public void testDouble() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double) 0d).toHashCode());
- double d = 1234567.89;
- long l = Double.doubleToLongBits(d);
+ final double d = 1234567.89;
+ final long l = Double.doubleToLongBits(d);
assertEquals(17 * 37 + (int) (l ^ l >> 32), new HashCodeBuilder(17, 37).append(d).toHashCode());
}
@@ -242,8 +242,8 @@ public class HashCodeBuilderTest {
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
public void testFloat() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float) 0f).toHashCode());
- float f = 1234.89f;
- int i = Float.floatToIntBits(f);
+ final float f = 1234.89f;
+ final int i = Float.floatToIntBits(f);
assertEquals(17 * 37 + i, new HashCodeBuilder(17, 37).append(f).toHashCode());
}
@@ -256,7 +256,7 @@ public class HashCodeBuilderTest {
@Test
public void testObjectArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((Object[]) null).toHashCode());
- Object[] obj = new Object[2];
+ final Object[] obj = new Object[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = new Object();
assertEquals((17 * 37 + obj[0].hashCode()) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -267,7 +267,7 @@ public class HashCodeBuilderTest {
@Test
public void testObjectArrayAsObject() {
- Object[] obj = new Object[2];
+ final Object[] obj = new Object[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = new Object();
assertEquals((17 * 37 + obj[0].hashCode()) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -279,32 +279,32 @@ public class HashCodeBuilderTest {
@Test
public void testLongArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long[]) null).toHashCode());
- long[] obj = new long[2];
+ final long[] obj = new long[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5L;
- int h1 = (int) (5L ^ 5L >> 32);
+ final int h1 = (int) (5L ^ 5L >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[1] = 6L;
- int h2 = (int) (6L ^ 6L >> 32);
+ final int h2 = (int) (6L ^ 6L >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
}
@Test
public void testLongArrayAsObject() {
- long[] obj = new long[2];
+ final long[] obj = new long[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5L;
- int h1 = (int) (5L ^ 5L >> 32);
+ final int h1 = (int) (5L ^ 5L >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6L;
- int h2 = (int) (6L ^ 6L >> 32);
+ final int h2 = (int) (6L ^ 6L >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
@Test
public void testIntArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int[]) null).toHashCode());
- int[] obj = new int[2];
+ final int[] obj = new int[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -314,7 +314,7 @@ public class HashCodeBuilderTest {
@Test
public void testIntArrayAsObject() {
- int[] obj = new int[2];
+ final int[] obj = new int[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -325,7 +325,7 @@ public class HashCodeBuilderTest {
@Test
public void testShortArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short[]) null).toHashCode());
- short[] obj = new short[2];
+ final short[] obj = new short[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = (short) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -335,7 +335,7 @@ public class HashCodeBuilderTest {
@Test
public void testShortArrayAsObject() {
- short[] obj = new short[2];
+ final short[] obj = new short[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = (short) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -346,7 +346,7 @@ public class HashCodeBuilderTest {
@Test
public void testCharArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char[]) null).toHashCode());
- char[] obj = new char[2];
+ final char[] obj = new char[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = (char) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -356,7 +356,7 @@ public class HashCodeBuilderTest {
@Test
public void testCharArrayAsObject() {
- char[] obj = new char[2];
+ final char[] obj = new char[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = (char) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -367,7 +367,7 @@ public class HashCodeBuilderTest {
@Test
public void testByteArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte[]) null).toHashCode());
- byte[] obj = new byte[2];
+ final byte[] obj = new byte[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = (byte) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -377,7 +377,7 @@ public class HashCodeBuilderTest {
@Test
public void testByteArrayAsObject() {
- byte[] obj = new byte[2];
+ final byte[] obj = new byte[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = (byte) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -388,61 +388,61 @@ public class HashCodeBuilderTest {
@Test
public void testDoubleArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double[]) null).toHashCode());
- double[] obj = new double[2];
+ final double[] obj = new double[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5.4d;
- long l1 = Double.doubleToLongBits(5.4d);
- int h1 = (int) (l1 ^ l1 >> 32);
+ final long l1 = Double.doubleToLongBits(5.4d);
+ final int h1 = (int) (l1 ^ l1 >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[1] = 6.3d;
- long l2 = Double.doubleToLongBits(6.3d);
- int h2 = (int) (l2 ^ l2 >> 32);
+ final long l2 = Double.doubleToLongBits(6.3d);
+ final int h2 = (int) (l2 ^ l2 >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
}
@Test
public void testDoubleArrayAsObject() {
- double[] obj = new double[2];
+ final double[] obj = new double[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5.4d;
- long l1 = Double.doubleToLongBits(5.4d);
- int h1 = (int) (l1 ^ l1 >> 32);
+ final long l1 = Double.doubleToLongBits(5.4d);
+ final int h1 = (int) (l1 ^ l1 >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6.3d;
- long l2 = Double.doubleToLongBits(6.3d);
- int h2 = (int) (l2 ^ l2 >> 32);
+ final long l2 = Double.doubleToLongBits(6.3d);
+ final int h2 = (int) (l2 ^ l2 >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
@Test
public void testFloatArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float[]) null).toHashCode());
- float[] obj = new float[2];
+ final float[] obj = new float[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5.4f;
- int h1 = Float.floatToIntBits(5.4f);
+ final int h1 = Float.floatToIntBits(5.4f);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[1] = 6.3f;
- int h2 = Float.floatToIntBits(6.3f);
+ final int h2 = Float.floatToIntBits(6.3f);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
}
@Test
public void testFloatArrayAsObject() {
- float[] obj = new float[2];
+ final float[] obj = new float[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5.4f;
- int h1 = Float.floatToIntBits(5.4f);
+ final int h1 = Float.floatToIntBits(5.4f);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6.3f;
- int h2 = Float.floatToIntBits(6.3f);
+ final int h2 = Float.floatToIntBits(6.3f);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
@Test
public void testBooleanArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((boolean[]) null).toHashCode());
- boolean[] obj = new boolean[2];
+ final boolean[] obj = new boolean[2];
assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = true;
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -452,7 +452,7 @@ public class HashCodeBuilderTest {
@Test
public void testBooleanArrayAsObject() {
- boolean[] obj = new boolean[2];
+ final boolean[] obj = new boolean[2];
assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = true;
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -462,7 +462,7 @@ public class HashCodeBuilderTest {
@Test
public void testBooleanMultiArray() {
- boolean[][] obj = new boolean[2][];
+ final boolean[][] obj = new boolean[2][];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = new boolean[0];
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -478,7 +478,7 @@ public class HashCodeBuilderTest {
@Test
public void testReflectionHashCodeExcludeFields() throws Exception {
- TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
+ final TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x));
@@ -517,8 +517,8 @@ public class HashCodeBuilderTest {
*/
@Test
public void testReflectionObjectCycle() {
- ReflectionTestCycleA a = new ReflectionTestCycleA();
- ReflectionTestCycleB b = new ReflectionTestCycleB();
+ final ReflectionTestCycleA a = new ReflectionTestCycleA();
+ final ReflectionTestCycleB b = new ReflectionTestCycleB();
a.b = b;
b.a = a;
@@ -550,7 +550,7 @@ public class HashCodeBuilderTest {
*/
@Test
public void testToHashCodeEqualsHashCode() {
- HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
+ final HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
assertEquals("hashCode() is no longer returning the same value as toHashCode() - see LANG-520",
hcb.toHashCode(), hcb.hashCode());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
index f4bf7d2c6..3a506a077 100644
--- a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
@@ -66,8 +66,8 @@ public class MultiLineToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -84,11 +84,11 @@ public class MultiLineToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Jane Doe";
p.age = 25;
p.smoker = true;
- String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
+ final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[" + SystemUtils.LINE_SEPARATOR + " name=Jane Doe" + SystemUtils.LINE_SEPARATOR + " age=25" + SystemUtils.LINE_SEPARATOR + " smoker=true" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
index d94c8fdc2..7d64e8ff6 100644
--- a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
@@ -65,8 +65,8 @@ public class NoFieldNamesToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -83,11 +83,11 @@ public class NoFieldNamesToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Ron Paul";
p.age = 72;
p.smoker = false;
- String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
+ final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[Ron Paul,72,false]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
index 696cd9a0e..9e589d95a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
@@ -89,18 +89,18 @@ public class ReflectionToStringBuilderConcurrencyTest {
// Create a thread pool with two threads to cause the most contention on the underlying resource.
final ExecutorService threadPool = Executors.newFixedThreadPool(2);
// Consumes toStrings
- Callable<Integer> consumer = new Callable<Integer>() {
+ final Callable<Integer> consumer = new Callable<Integer>() {
@Override
public Integer call() {
for (int i = 0; i < REPEAT; i++) {
- String s = ReflectionToStringBuilder.toString(holder);
+ final String s = ReflectionToStringBuilder.toString(holder);
Assert.assertNotNull(s);
}
return Integer.valueOf(REPEAT);
}
};
// Produces changes in the list
- Callable<Integer> producer = new Callable<Integer>() {
+ final Callable<Integer> producer = new Callable<Integer>() {
@Override
public Integer call() {
for (int i = 0; i < DATA_SIZE; i++) {
@@ -109,11 +109,11 @@ public class ReflectionToStringBuilderConcurrencyTest {
return Integer.valueOf(REPEAT);
}
};
- Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
+ final Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
tasks.add(consumer);
tasks.add(producer);
final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
- for (Future<Integer> future : futures) {
+ for (final Future<Integer> future : futures) {
Assert.assertEquals(REPEAT, future.get().intValue());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
index e563234ac..7b87c25d7 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
@@ -49,74 +49,74 @@ public class ReflectionToStringBuilderExcludeTest {
@Test
public void test_toStringExclude() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD);
this.validateSecretFieldAbsent(toString);
}
@Test
public void test_toStringExcludeArray() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD});
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD});
this.validateSecretFieldAbsent(toString);
}
@Test
public void test_toStringExcludeArrayWithNull() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null});
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null});
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeArrayWithNulls() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null});
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null});
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeCollection() {
- List<String> excludeList = new ArrayList<String>();
+ final List<String> excludeList = new ArrayList<String>();
excludeList.add(SECRET_FIELD);
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldAbsent(toString);
}
@Test
public void test_toStringExcludeCollectionWithNull() {
- List<String> excludeList = new ArrayList<String>();
+ final List<String> excludeList = new ArrayList<String>();
excludeList.add(null);
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeCollectionWithNulls() {
- List<String> excludeList = new ArrayList<String>();
+ final List<String> excludeList = new ArrayList<String>();
excludeList.add(null);
excludeList.add(null);
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeEmptyArray() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), ArrayUtils.EMPTY_STRING_ARRAY);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), ArrayUtils.EMPTY_STRING_ARRAY);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeEmptyCollection() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>());
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>());
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeNullArray() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (String[]) null);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (String[]) null);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeNullCollection() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (Collection<String>) null);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (Collection<String>) null);
this.validateSecretFieldPresent(toString);
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
index 84eb71c53..c4899117e 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
@@ -93,14 +93,14 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
@Test
@Ignore
public void testConcurrency() throws Exception {
- TestFixture testFixture = new TestFixture();
+ final TestFixture testFixture = new TestFixture();
final int numMutators = 10;
final int numIterations = 10;
for (int i = 0; i < numIterations; i++) {
for (int j = 0; j < numMutators; j++) {
- Thread t = new Thread(new MutatingClient(testFixture));
+ final Thread t = new Thread(new MutatingClient(testFixture));
t.start();
- Thread s = new Thread(new InspectingClient(testFixture));
+ final Thread s = new Thread(new InspectingClient(testFixture));
s.start();
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
index 8a782455d..124cb1a1e 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
@@ -65,8 +65,8 @@ public class ShortPrefixToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -83,11 +83,11 @@ public class ShortPrefixToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "John Q. Public";
p.age = 45;
p.smoker = true;
- String pBaseStr = "ToStringStyleTest.Person";
+ final String pBaseStr = "ToStringStyleTest.Person";
assertEquals(pBaseStr + "[name=John Q. Public,age=45,smoker=true]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
index 6bf5a2272..93e0b8505 100644
--- a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
@@ -64,8 +64,8 @@ public class SimpleToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals("<null>", new ToStringBuilder(base).append((Object) null).toString());
assertEquals("3", new ToStringBuilder(base).append(i3).toString());
assertEquals("<null>", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -82,7 +82,7 @@ public class SimpleToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Jane Q. Public";
p.age = 47;
p.smoker = false;
diff --git a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
index 91db43b39..70363951d 100644
--- a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
@@ -80,8 +80,8 @@ public class StandardToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[%NULL%]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=%NULL%]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -98,11 +98,11 @@ public class StandardToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Suzy Queue";
p.age = 19;
p.smoker = false;
- String pBaseStr = "ToStringStyleTest.Person";
+ final String pBaseStr = "ToStringStyleTest.Person";
assertEquals(pBaseStr + "[name=Suzy Queue,age=19,smoker=false]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
index 8c25c2882..ba74ef643 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
@@ -100,7 +100,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionCharacter() {
- Character c = new Character('A');
+ final Character c = new Character('A');
assertEquals(this.toBaseString(c) + "[value=A]", ToStringBuilder.reflectionToString(c));
}
@@ -154,7 +154,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionObjectArray() {
Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{<null>,5,{3,6}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -163,7 +163,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionLongArray() {
long[] array = new long[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -172,7 +172,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionIntArray() {
int[] array = new int[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -181,7 +181,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionShortArray() {
short[] array = new short[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -190,7 +190,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionyteArray() {
byte[] array = new byte[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -199,7 +199,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionCharArray() {
char[] array = new char[] { 'A', '2', '_', 'D' };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{A,2,_,D}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -208,7 +208,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionDoubleArray() {
double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1.0,2.9876,-3.00001,4.3}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -217,7 +217,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionFloatArray() {
float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1.0,2.9876,-3.00001,4.3}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -226,7 +226,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionBooleanArray() {
boolean[] array = new boolean[] { true, false, false };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{true,false,false}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -237,7 +237,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionFloatArrayArray() {
float[][] array = new float[][] { { 1.0f, 2.29686f }, null, { Float.NaN } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1.0,2.29686},<null>,{NaN}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -247,7 +247,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionLongArrayArray() {
long[][] array = new long[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -256,7 +256,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionIntArrayArray() {
int[][] array = new int[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -265,7 +265,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionhortArrayArray() {
short[][] array = new short[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -274,7 +274,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionByteArrayArray() {
byte[][] array = new byte[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -283,7 +283,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionCharArrayArray() {
char[][] array = new char[][] { { 'A', 'B' }, null, { 'p' } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{A,B},<null>,{p}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -292,7 +292,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionDoubleArrayArray() {
double[][] array = new double[][] { { 1.0, 2.29686 }, null, { Double.NaN } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1.0,2.29686},<null>,{NaN}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -301,7 +301,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionBooleanArrayArray() {
boolean[][] array = new boolean[][] { { true, false }, null, { false } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{true,false},<null>,{false}}]", ToStringBuilder.reflectionToString(array));
assertEquals(baseStr + "[{{true,false},<null>,{false}}]", ToStringBuilder.reflectionToString(array));
array = null;
@@ -311,19 +311,19 @@ public class ToStringBuilderTest {
// Reflection hierarchy tests
@Test
public void testReflectionHierarchyArrayList() {
- List<Object> base = new ArrayList<Object>();
- String baseStr = this.toBaseString(base);
+ final List<Object> base = new ArrayList<Object>();
+ final String baseStr = this.toBaseString(base);
// note, the test data depends on the internal representation of the ArrayList, which may differ between JDK versions and vendors
- String expectedWithTransients = baseStr + "[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]";
- String toStringWithTransients = ToStringBuilder.reflectionToString(base, null, true);
+ final String expectedWithTransients = baseStr + "[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]";
+ final String toStringWithTransients = ToStringBuilder.reflectionToString(base, null, true);
if (!expectedWithTransients.equals(toStringWithTransients)) {
// representation different for IBM JDK 1.6.0, LANG-727
if (!("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION))) {
assertEquals(expectedWithTransients, toStringWithTransients);
}
}
- String expectedWithoutTransients = baseStr + "[size=0]";
- String toStringWithoutTransients = ToStringBuilder.reflectionToString(base, null, false);
+ final String expectedWithoutTransients = baseStr + "[size=0]";
+ final String toStringWithoutTransients = ToStringBuilder.reflectionToString(base, null, false);
if (!expectedWithoutTransients.equals(toStringWithoutTransients)) {
// representation different for IBM JDK 1.6.0, LANG-727
if (!("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION))) {
@@ -334,7 +334,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionHierarchy() {
- ReflectionTestFixtureA baseA = new ReflectionTestFixtureA();
+ final ReflectionTestFixtureA baseA = new ReflectionTestFixtureA();
String baseStr = this.toBaseString(baseA);
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA));
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null));
@@ -344,7 +344,7 @@ public class ToStringBuilderTest {
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, Object.class));
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, ReflectionTestFixtureA.class));
- ReflectionTestFixtureB baseB = new ReflectionTestFixtureB();
+ final ReflectionTestFixtureB baseB = new ReflectionTestFixtureB();
baseStr = this.toBaseString(baseB);
assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB));
assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB));
@@ -373,7 +373,7 @@ public class ToStringBuilderTest {
@Test
public void testInnerClassReflection() {
- Outer outer = new Outer();
+ final Outer outer = new Outer();
assertEquals(toBaseString(outer) + "[inner=" + toBaseString(outer.inner) + "[]]", outer.toString());
}
@@ -398,7 +398,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionArrayCycle() throws Exception {
- Object[] objects = new Object[1];
+ final Object[] objects = new Object[1];
objects[0] = objects;
assertEquals(
this.toBaseString(objects) + "[{" + this.toBaseString(objects) + "}]",
@@ -410,8 +410,8 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionArrayCycleLevel2() throws Exception {
- Object[] objects = new Object[1];
- Object[] objectsLevel2 = new Object[1];
+ final Object[] objects = new Object[1];
+ final Object[] objectsLevel2 = new Object[1];
objects[0] = objectsLevel2;
objectsLevel2[0] = objects;
assertEquals(
@@ -424,12 +424,12 @@ public class ToStringBuilderTest {
@Test
public void testReflectionArrayArrayCycle() throws Exception {
- Object[][] objects = new Object[2][2];
+ final Object[][] objects = new Object[2][2];
objects[0][0] = objects;
objects[0][1] = objects;
objects[1][0] = objects;
objects[1][1] = objects;
- String basicToString = this.toBaseString(objects);
+ final String basicToString = this.toBaseString(objects);
assertEquals(
basicToString
+ "[{{"
@@ -528,7 +528,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testSimpleReflectionObjectCycle() throws Exception {
- SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture();
+ final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture();
simple.o = simple;
assertEquals(this.toBaseString(simple) + "[o=" + this.toBaseString(simple) + "]", simple.toString());
}
@@ -540,7 +540,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testSelfInstanceVarReflectionObjectCycle() throws Exception {
- SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture();
+ final SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture();
assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + "]", test.toString());
}
@@ -552,7 +552,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testSelfInstanceTwoVarsReflectionObjectCycle() throws Exception {
- SelfInstanceTwoVarsReflectionTestFixture test = new SelfInstanceTwoVarsReflectionTestFixture();
+ final SelfInstanceTwoVarsReflectionTestFixture test = new SelfInstanceTwoVarsReflectionTestFixture();
assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + ",otherType=" + test.getOtherType().toString() + "]", test.toString());
}
@@ -564,8 +564,8 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionObjectCycle() throws Exception {
- ReflectionTestCycleA a = new ReflectionTestCycleA();
- ReflectionTestCycleB b = new ReflectionTestCycleB();
+ final ReflectionTestCycleA a = new ReflectionTestCycleA();
+ final ReflectionTestCycleB b = new ReflectionTestCycleB();
a.b = b;
b.a = a;
assertEquals(
@@ -581,8 +581,8 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionArrayAndObjectCycle() throws Exception {
- Object[] objects = new Object[1];
- SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(objects);
+ final Object[] objects = new Object[1];
+ final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(objects);
objects[0] = simple;
assertEquals(
this.toBaseString(objects)
@@ -629,8 +629,8 @@ public class ToStringBuilderTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -647,8 +647,8 @@ public class ToStringBuilderTest {
@Test
public void testObjectBuild() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).build());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).build());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).build());
@@ -894,12 +894,12 @@ public class ToStringBuilderTest {
@Test
public void testObjectCycle() {
- ObjectCycle a = new ObjectCycle();
- ObjectCycle b = new ObjectCycle();
+ final ObjectCycle a = new ObjectCycle();
+ final ObjectCycle b = new ObjectCycle();
a.obj = b;
b.obj = a;
- String expected = toBaseString(a) + "[" + toBaseString(b) + "[" + toBaseString(a) + "]]";
+ final String expected = toBaseString(a) + "[" + toBaseString(b) + "[" + toBaseString(a) + "]]";
assertEquals(expected, a.toString());
}
@@ -914,7 +914,7 @@ public class ToStringBuilderTest {
@Test
public void testSimpleReflectionStatics() {
- SimpleReflectionStaticFieldsFixture instance1 = new SimpleReflectionStaticFieldsFixture();
+ final SimpleReflectionStaticFieldsFixture instance1 = new SimpleReflectionStaticFieldsFixture();
assertEquals(
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345]",
ReflectionToStringBuilder.toString(instance1, null, false, true, SimpleReflectionStaticFieldsFixture.class));
@@ -934,7 +934,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionStatics() {
- ReflectionStaticFieldsFixture instance1 = new ReflectionStaticFieldsFixture();
+ final ReflectionStaticFieldsFixture instance1 = new ReflectionStaticFieldsFixture();
assertEquals(
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345,instanceString=instanceString,instanceInt=67890]",
ReflectionToStringBuilder.toString(instance1, null, false, true, ReflectionStaticFieldsFixture.class));
@@ -954,7 +954,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testInheritedReflectionStatics() {
- InheritedReflectionStaticFieldsFixture instance1 = new InheritedReflectionStaticFieldsFixture();
+ final InheritedReflectionStaticFieldsFixture instance1 = new InheritedReflectionStaticFieldsFixture();
assertEquals(
this.toBaseString(instance1) + "[staticString2=staticString2,staticInt2=67890]",
ReflectionToStringBuilder.toString(instance1, null, false, true, InheritedReflectionStaticFieldsFixture.class));
@@ -1003,8 +1003,8 @@ public class ToStringBuilderTest {
*/
@Test
public void test_setUpToClass_valid() {
- Integer val = Integer.valueOf(5);
- ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
+ final Integer val = Integer.valueOf(5);
+ final ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
test.setUpToClass(Number.class);
test.toString();
}
@@ -1014,8 +1014,8 @@ public class ToStringBuilderTest {
*/
@Test(expected=IllegalArgumentException.class)
public void test_setUpToClass_invalid() {
- Integer val = Integer.valueOf(5);
- ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
+ final Integer val = Integer.valueOf(5);
+ final ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
try {
test.setUpToClass(String.class);
} finally {
@@ -1072,8 +1072,8 @@ public class ToStringBuilderTest {
@Test
public void testAppendToStringUsingMultiLineStyle() {
- MultiLineTestObject obj = new MultiLineTestObject();
- ToStringBuilder testBuilder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+ final MultiLineTestObject obj = new MultiLineTestObject();
+ final ToStringBuilder testBuilder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.appendToString(obj.toString());
assertEquals(testBuilder.toString().indexOf("testInt=31337"), -1);
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
index 010a5ae03..16659bfcb 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
@@ -89,7 +89,7 @@ public class ToStringStyleConcurrencyTest {
// Create a thread pool with two threads to cause the most contention on the underlying resource.
final ExecutorService threadPool = Executors.newFixedThreadPool(2);
// Consumes toStrings
- Callable<Integer> consumer = new Callable<Integer>() {
+ final Callable<Integer> consumer = new Callable<Integer>() {
@Override
public Integer call() {
for (int i = 0; i < REPEAT; i++) {
@@ -99,11 +99,11 @@ public class ToStringStyleConcurrencyTest {
return Integer.valueOf(REPEAT);
}
};
- Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
+ final Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
tasks.add(consumer);
tasks.add(consumer);
final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
- for (Future<Integer> future : futures) {
+ for (final Future<Integer> future : futures) {
future.get();
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
index 014860bcb..485e969e2 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
@@ -33,84 +33,84 @@ public class ToStringStyleTest {
//-----------------------------------------------------------------------
@Test
public void testSetArrayStart() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setArrayStart(null);
assertEquals("", style.getArrayStart());
}
@Test
public void testSetArrayEnd() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setArrayEnd(null);
assertEquals("", style.getArrayEnd());
}
@Test
public void testSetArraySeparator() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setArraySeparator(null);
assertEquals("", style.getArraySeparator());
}
@Test
public void testSetContentStart() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setContentStart(null);
assertEquals("", style.getContentStart());
}
@Test
public void testSetContentEnd() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setContentEnd(null);
assertEquals("", style.getContentEnd());
}
@Test
public void testSetFieldNameValueSeparator() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setFieldNameValueSeparator(null);
assertEquals("", style.getFieldNameValueSeparator());
}
@Test
public void testSetFieldSeparator() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setFieldSeparator(null);
assertEquals("", style.getFieldSeparator());
}
@Test
public void testSetNullText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setNullText(null);
assertEquals("", style.getNullText());
}
@Test
public void testSetSizeStartText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSizeStartText(null);
assertEquals("", style.getSizeStartText());
}
@Test
public void testSetSizeEndText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSizeEndText(null);
assertEquals("", style.getSizeEndText());
}
@Test
public void testSetSummaryObjectStartText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSummaryObjectStartText(null);
assertEquals("", style.getSummaryObjectStartText());
}
@Test
public void testSetSummaryObjectEndText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSummaryObjectEndText(null);
assertEquals("", style.getSummaryObjectEndText());
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
index 87135a081..4744e5904 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
@@ -51,8 +51,8 @@ public abstract class AbstractConcurrentInitializerTest {
*/
@Test
public void testGetMultipleTimes() throws ConcurrentException {
- ConcurrentInitializer<Object> initializer = createInitializer();
- Object obj = initializer.get();
+ final ConcurrentInitializer<Object> initializer = createInitializer();
+ final Object obj = initializer.get();
for (int i = 0; i < 10; i++) {
assertEquals("Got different object at " + i, obj, initializer.get());
}
@@ -78,15 +78,15 @@ public abstract class AbstractConcurrentInitializerTest {
startLatch.await();
// access the initializer
object = initializer.get();
- } catch (InterruptedException iex) {
+ } catch (final InterruptedException iex) {
// ignore
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
object = cex;
}
}
}
- GetThread[] threads = new GetThread[threadCount];
+ final GetThread[] threads = new GetThread[threadCount];
for (int i = 0; i < threadCount; i++) {
threads[i] = new GetThread();
threads[i].start();
@@ -94,13 +94,13 @@ public abstract class AbstractConcurrentInitializerTest {
// fire all threads and wait until they are ready
startLatch.countDown();
- for (Thread t : threads) {
+ for (final Thread t : threads) {
t.join();
}
// check results
- Object managedObject = initializer.get();
- for (GetThread t : threads) {
+ final Object managedObject = initializer.get();
+ for (final GetThread t : threads) {
assertEquals("Wrong object", managedObject, t.object);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
index 388729a7e..e8a6e5ed5 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
@@ -33,11 +33,11 @@ public class BackgroundInitializerTest {
*/
private void checkInitialize(final BackgroundInitializerTestImpl init) {
try {
- Integer result = init.get();
+ final Integer result = init.get();
assertEquals("Wrong result", 1, result.intValue());
assertEquals("Wrong number of invocations", 1, init.initializeCalls);
assertNotNull("No future", init.getFuture());
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
fail("Unexpected exception: " + cex);
}
}
@@ -47,7 +47,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testInitialize() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
checkInitialize(init);
}
@@ -58,7 +58,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetActiveExecutorBeforeStart() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertNull("Got an executor", init.getActiveExecutor());
}
@@ -67,9 +67,9 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetActiveExecutorExternal() {
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
try {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
exec);
init.start();
assertSame("Wrong executor", exec, init.getActiveExecutor());
@@ -84,7 +84,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetActiveExecutorTemp() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
assertNotNull("No active executor", init.getActiveExecutor());
checkInitialize(init);
@@ -96,7 +96,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testInitializeTempExecutor() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertTrue("Wrong result of start()", init.start());
checkInitialize(init);
assertTrue("Executor not shutdown", init.getActiveExecutor()
@@ -109,9 +109,9 @@ public class BackgroundInitializerTest {
*/
@Test
public void testSetExternalExecutor() throws Exception {
- ExecutorService exec = Executors.newCachedThreadPool();
+ final ExecutorService exec = Executors.newCachedThreadPool();
try {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.setExternalExecutor(exec);
assertEquals("Wrong executor service", exec, init
.getExternalExecutor());
@@ -129,12 +129,12 @@ public class BackgroundInitializerTest {
*/
@Test
public void testSetExternalExecutorAfterStart() throws ConcurrentException {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
try {
init.setExternalExecutor(Executors.newSingleThreadExecutor());
fail("Could set executor after start()!");
- } catch (IllegalStateException istex) {
+ } catch (final IllegalStateException istex) {
init.get();
}
}
@@ -145,7 +145,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testStartMultipleTimes() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertTrue("Wrong result for start()", init.start());
for (int i = 0; i < 10; i++) {
assertFalse("Could start again", init.start());
@@ -158,7 +158,7 @@ public class BackgroundInitializerTest {
*/
@Test(expected=IllegalStateException.class)
public void testGetBeforeStart() throws ConcurrentException {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.get();
}
@@ -168,14 +168,14 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetRuntimeException() throws Exception {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
- RuntimeException rex = new RuntimeException();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final RuntimeException rex = new RuntimeException();
init.ex = rex;
init.start();
try {
init.get();
fail("Exception not thrown!");
- } catch (Exception ex) {
+ } catch (final Exception ex) {
assertEquals("Runtime exception not thrown", rex, ex);
}
}
@@ -186,14 +186,14 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetCheckedException() throws Exception {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
- Exception ex = new Exception();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final Exception ex = new Exception();
init.ex = ex;
init.start();
try {
init.get();
fail("Exception not thrown!");
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
assertEquals("Exception not thrown", ex, cex.getCause());
}
}
@@ -203,19 +203,19 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetInterruptedException() throws Exception {
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
exec);
final CountDownLatch latch1 = new CountDownLatch(1);
init.shouldSleep = true;
init.start();
final AtomicReference<InterruptedException> iex = new AtomicReference<InterruptedException>();
- Thread getThread = new Thread() {
+ final Thread getThread = new Thread() {
@Override
public void run() {
try {
init.get();
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
if (cex.getCause() instanceof InterruptedException) {
iex.set((InterruptedException) cex.getCause());
}
@@ -238,7 +238,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testIsStartedFalse() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertFalse("Already started", init.isStarted());
}
@@ -247,7 +247,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testIsStartedTrue() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
assertTrue("Not started", init.isStarted());
}
@@ -257,7 +257,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testIsStartedAfterGet() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
checkInitialize(init);
assertTrue("Not started", init.isStarted());
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java b/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
index 764a20a03..3bf8a867a 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
@@ -66,7 +66,7 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testBuildDefaults() {
- BasicThreadFactory factory = builder.build();
+ final BasicThreadFactory factory = builder.build();
checkFactoryDefaults(factory);
}
@@ -99,15 +99,15 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testBuilderReset() {
- ThreadFactory wrappedFactory = EasyMock.createMock(ThreadFactory.class);
- Thread.UncaughtExceptionHandler exHandler = EasyMock
+ final ThreadFactory wrappedFactory = EasyMock.createMock(ThreadFactory.class);
+ final Thread.UncaughtExceptionHandler exHandler = EasyMock
.createMock(Thread.UncaughtExceptionHandler.class);
EasyMock.replay(wrappedFactory, exHandler);
builder.namingPattern(PATTERN).daemon(true).priority(
Thread.MAX_PRIORITY).uncaughtExceptionHandler(exHandler)
.wrappedFactory(wrappedFactory);
builder.reset();
- BasicThreadFactory factory = builder.build();
+ final BasicThreadFactory factory = builder.build();
checkFactoryDefaults(factory);
assertNotSame("Wrapped factory not reset", wrappedFactory, factory
.getWrappedFactory());
@@ -129,17 +129,17 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNamingPattern() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
final int count = 12;
for (int i = 0; i < count; i++) {
EasyMock.expect(wrapped.newThread(r)).andReturn(new Thread());
}
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped)
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped)
.namingPattern(PATTERN).build();
for (int i = 0; i < count; i++) {
- Thread t = factory.newThread(r);
+ final Thread t = factory.newThread(r);
assertEquals("Wrong thread name", String.format(PATTERN, Long
.valueOf(i + 1)), t.getName());
assertEquals("Wrong thread count", i + 1, factory.getThreadCount());
@@ -153,13 +153,13 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoNamingPattern() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
final String name = "unchangedThreadName";
- Thread t = new Thread(name);
+ final Thread t = new Thread(name);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Name was changed", name, t.getName());
EasyMock.verify(wrapped, r);
@@ -171,12 +171,12 @@ public class BasicThreadFactoryTest {
* @param flag the value of the flag
*/
private void checkDaemonFlag(final boolean flag) {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread t = new Thread();
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread t = new Thread();
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).daemon(
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).daemon(
flag).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertTrue("Wrong daemon flag", flag == t.isDaemon());
@@ -205,16 +205,16 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoDaemonFlag() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r1 = EasyMock.createMock(Runnable.class);
- Runnable r2 = EasyMock.createMock(Runnable.class);
- Thread t1 = new Thread();
- Thread t2 = new Thread();
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r1 = EasyMock.createMock(Runnable.class);
+ final Runnable r2 = EasyMock.createMock(Runnable.class);
+ final Thread t1 = new Thread();
+ final Thread t2 = new Thread();
t1.setDaemon(true);
EasyMock.expect(wrapped.newThread(r1)).andReturn(t1);
EasyMock.expect(wrapped.newThread(r2)).andReturn(t2);
EasyMock.replay(wrapped, r1, r2);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread 1", t1, factory.newThread(r1));
assertTrue("No daemon thread", t1.isDaemon());
assertSame("Wrong thread 2", t2, factory.newThread(r2));
@@ -227,13 +227,13 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadPriority() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread t = new Thread();
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread t = new Thread();
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
final int priority = Thread.NORM_PRIORITY + 1;
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).priority(
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).priority(
priority).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong priority", priority, t.getPriority());
@@ -246,14 +246,14 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoPriority() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
final int orgPriority = Thread.NORM_PRIORITY + 1;
- Thread t = new Thread();
+ final Thread t = new Thread();
t.setPriority(orgPriority);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong priority", orgPriority, t.getPriority());
EasyMock.verify(wrapped, r);
@@ -264,14 +264,14 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadExHandler() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread.UncaughtExceptionHandler handler = EasyMock
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread.UncaughtExceptionHandler handler = EasyMock
.createMock(Thread.UncaughtExceptionHandler.class);
- Thread t = new Thread();
+ final Thread t = new Thread();
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r, handler);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped)
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped)
.uncaughtExceptionHandler(handler).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong exception handler", handler, t
@@ -285,15 +285,15 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoExHandler() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread.UncaughtExceptionHandler handler = EasyMock
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread.UncaughtExceptionHandler handler = EasyMock
.createMock(Thread.UncaughtExceptionHandler.class);
- Thread t = new Thread();
+ final Thread t = new Thread();
t.setUncaughtExceptionHandler(handler);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r, handler);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong exception handler", handler, t
.getUncaughtExceptionHandler());
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
index af80f2f93..3e966c273 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
@@ -48,8 +48,8 @@ public class CallableBackgroundInitializerTest {
*/
@Test
public void testInitExecutor() {
- ExecutorService exec = Executors.newSingleThreadExecutor();
- CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
+ final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
new TestCallable(), exec);
assertEquals("Executor not set", exec, init.getExternalExecutor());
}
@@ -60,7 +60,7 @@ public class CallableBackgroundInitializerTest {
*/
@Test(expected=IllegalArgumentException.class)
public void testInitExecutorNullCallable() {
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
new CallableBackgroundInitializer<Integer>(null, exec);
}
@@ -69,8 +69,8 @@ public class CallableBackgroundInitializerTest {
*/
@Test
public void testInitialize() throws Exception {
- TestCallable call = new TestCallable();
- CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
+ final TestCallable call = new TestCallable();
+ final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
call);
assertEquals("Wrong result", RESULT, init.initialize());
assertEquals("Wrong number of invocations", 1, call.callCount);
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java b/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
index d0aff7544..602573128 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
@@ -108,11 +108,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseError() {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.extractCause(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -122,11 +122,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedException() {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.extractCause(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -136,8 +136,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseChecked() {
- Exception ex = new Exception("Test");
- ConcurrentException cex = ConcurrentUtils
+ final Exception ex = new Exception("Test");
+ final ConcurrentException cex = ConcurrentUtils
.extractCause(new ExecutionException(ex));
assertSame("Wrong cause", ex, cex.getCause());
}
@@ -164,11 +164,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedError() {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.extractCauseUnchecked(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -178,11 +178,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedUncheckedException() {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.extractCauseUnchecked(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -192,8 +192,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedChecked() {
- Exception ex = new Exception("Test");
- ConcurrentRuntimeException cex = ConcurrentUtils
+ final Exception ex = new Exception("Test");
+ final ConcurrentRuntimeException cex = ConcurrentUtils
.extractCauseUnchecked(new ExecutionException(ex));
assertSame("Wrong cause", ex, cex.getCause());
}
@@ -203,11 +203,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseError() throws ConcurrentException {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.handleCause(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -217,11 +217,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedException() throws ConcurrentException {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.handleCause(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -231,11 +231,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseChecked() {
- Exception ex = new Exception("Test");
+ final Exception ex = new Exception("Test");
try {
ConcurrentUtils.handleCause(new ExecutionException(ex));
fail("ConcurrentException not thrown!");
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
assertEquals("Wrong cause", ex, cex.getCause());
}
}
@@ -256,11 +256,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedError() {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.handleCauseUnchecked(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -270,11 +270,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedUncheckedException() {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.handleCauseUnchecked(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -284,11 +284,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedChecked() {
- Exception ex = new Exception("Test");
+ final Exception ex = new Exception("Test");
try {
ConcurrentUtils.handleCauseUnchecked(new ExecutionException(ex));
fail("ConcurrentRuntimeException not thrown!");
- } catch (ConcurrentRuntimeException crex) {
+ } catch (final ConcurrentRuntimeException crex) {
assertEquals("Wrong cause", ex, crex.getCause());
}
}
@@ -320,6 +320,7 @@ public class ConcurrentUtilsTest {
@Test
public void testInitialize() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Object result = new Object();
@@ -344,6 +345,7 @@ public class ConcurrentUtilsTest {
@Test
public void testInitializeUnchecked() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Object result = new Object();
@@ -360,6 +362,7 @@ public class ConcurrentUtilsTest {
@Test
public void testInitializeUncheckedEx() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Exception cause = new Exception();
@@ -368,7 +371,7 @@ public class ConcurrentUtilsTest {
try {
ConcurrentUtils.initializeUnchecked(init);
fail("Exception not thrown!");
- } catch (ConcurrentRuntimeException crex) {
+ } catch (final ConcurrentRuntimeException crex) {
assertSame("Wrong cause", cause, crex.getCause());
}
EasyMock.verify(init);
@@ -380,8 +383,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testConstantFuture_Integer() throws Exception {
- Integer value = Integer.valueOf(5);
- Future<Integer> test = ConcurrentUtils.constantFuture(value);
+ final Integer value = Integer.valueOf(5);
+ final Future<Integer> test = ConcurrentUtils.constantFuture(value);
assertTrue(test.isDone());
assertSame(value, test.get());
assertSame(value, test.get(1000, TimeUnit.SECONDS));
@@ -396,8 +399,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testConstantFuture_null() throws Exception {
- Integer value = null;
- Future<Integer> test = ConcurrentUtils.constantFuture(value);
+ final Integer value = null;
+ final Future<Integer> test = ConcurrentUtils.constantFuture(value);
assertTrue(test.isDone());
assertSame(value, test.get());
assertSame(value, test.get(1000, TimeUnit.SECONDS));
@@ -415,7 +418,7 @@ public class ConcurrentUtilsTest {
public void testPutIfAbsentKeyPresent() {
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
map.put(key, value);
assertEquals("Wrong result", value,
ConcurrentUtils.putIfAbsent(map, key, 0));
@@ -429,7 +432,7 @@ public class ConcurrentUtilsTest {
public void testPutIfAbsentKeyNotPresent() {
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
assertEquals("Wrong result", value,
ConcurrentUtils.putIfAbsent(map, key, value));
assertEquals("Wrong value in map", value, map.get(key));
@@ -450,12 +453,13 @@ public class ConcurrentUtilsTest {
@Test
public void testCreateIfAbsentKeyPresent() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
EasyMock.replay(init);
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
map.put(key, value);
assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsent(map, key, init));
@@ -469,13 +473,14 @@ public class ConcurrentUtilsTest {
@Test
public void testCreateIfAbsentKeyNotPresent() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
final String key = "testKey";
final Integer value = 42;
EasyMock.expect(init.get()).andReturn(value);
EasyMock.replay(init);
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsent(map, key, init));
assertEquals("Wrong value in map", value, map.get(key));
@@ -488,6 +493,7 @@ public class ConcurrentUtilsTest {
@Test
public void testCreateIfAbsentNullMap() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
EasyMock.replay(init);
@@ -501,7 +507,7 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testCreateIfAbsentNullInit() throws ConcurrentException {
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
final String key = "testKey";
final Integer value = 42;
map.put(key, value);
@@ -517,7 +523,7 @@ public class ConcurrentUtilsTest {
public void testCreateIfAbsentUncheckedSuccess() {
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsentUnchecked(map, key,
new ConstantInitializer<Integer>(value)));
@@ -531,16 +537,17 @@ public class ConcurrentUtilsTest {
public void testCreateIfAbsentUncheckedException()
throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
- Exception ex = new Exception();
+ final Exception ex = new Exception();
EasyMock.expect(init.get()).andThrow(new ConcurrentException(ex));
EasyMock.replay(init);
try {
ConcurrentUtils.createIfAbsentUnchecked(
new ConcurrentHashMap<String, Integer>(), "test", init);
fail("Exception not thrown!");
- } catch (ConcurrentRuntimeException crex) {
+ } catch (final ConcurrentRuntimeException crex) {
assertEquals("Wrong cause", ex, crex.getCause());
}
EasyMock.verify(init);
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
index 08ca837d2..bfde80e15 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
@@ -115,8 +115,8 @@ public class ConstantInitializerTest {
*/
@Test
public void testToString() {
- String s = init.toString();
- Pattern pattern = Pattern
+ final String s = init.toString();
+ final Pattern pattern = Pattern
.compile("ConstantInitializer@\\d+ \\[ object = " + VALUE
+ " \\]");
assertTrue("Wrong string: " + s, pattern.matcher(s).matches());
@@ -127,7 +127,7 @@ public class ConstantInitializerTest {
*/
@Test
public void testToStringNull() {
- String s = new ConstantInitializer<Object>(null).toString();
+ final String s = new ConstantInitializer<Object>(null).toString();
assertTrue("Object not found: " + s, s.indexOf("object = null") > 0);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
index 6ca12ae29..40009d3ac 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
@@ -58,8 +58,8 @@ public class MultiBackgroundInitializerTest {
*/
private void checkChild(final BackgroundInitializer<?> child,
final ExecutorService expExec) throws ConcurrentException {
- ChildBackgroundInitializer cinit = (ChildBackgroundInitializer) child;
- Integer result = cinit.get();
+ final ChildBackgroundInitializer cinit = (ChildBackgroundInitializer) child;
+ final Integer result = cinit.get();
assertEquals("Wrong result", 1, result.intValue());
assertEquals("Wrong number of executions", 1, cinit.initializeCalls);
if (expExec != null) {
@@ -92,7 +92,7 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeNoChildren() throws ConcurrentException {
assertTrue("Wrong result of start()", initializer.start());
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertTrue("Got child initializers", res.initializerNames().isEmpty());
assertTrue("Executor not shutdown", initializer.getActiveExecutor()
@@ -113,12 +113,12 @@ public class MultiBackgroundInitializerTest {
new ChildBackgroundInitializer());
}
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertEquals("Wrong number of child initializers", count, res
.initializerNames().size());
for (int i = 0; i < count; i++) {
- String key = CHILD_INIT + i;
+ final String key = CHILD_INIT + i;
assertTrue("Name not found: " + key, res.initializerNames()
.contains(key));
assertEquals("Wrong result object", Integer.valueOf(1), res
@@ -145,7 +145,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test
public void testInitializeExternalExec() throws ConcurrentException {
- ExecutorService exec = Executors.newCachedThreadPool();
+ final ExecutorService exec = Executors.newCachedThreadPool();
try {
initializer = new MultiBackgroundInitializer(exec);
checkInitialize();
@@ -164,10 +164,10 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeChildWithExecutor() throws ConcurrentException {
final String initExec = "childInitializerWithExecutor";
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
try {
- ChildBackgroundInitializer c1 = new ChildBackgroundInitializer();
- ChildBackgroundInitializer c2 = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer c1 = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer c2 = new ChildBackgroundInitializer();
c2.setExternalExecutor(exec);
initializer.addInitializer(CHILD_INIT, c1);
initializer.addInitializer(initExec, c2);
@@ -191,7 +191,7 @@ public class MultiBackgroundInitializerTest {
initializer.addInitializer(CHILD_INIT,
new ChildBackgroundInitializer());
fail("Could add initializer after start()!");
- } catch (IllegalStateException istex) {
+ } catch (final IllegalStateException istex) {
initializer.get();
}
}
@@ -202,7 +202,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultGetInitializerUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.getInitializer("unknown");
}
@@ -212,7 +212,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultGetResultObjectUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.getResultObject("unknown");
}
@@ -222,7 +222,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultGetExceptionUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.getException("unknown");
}
@@ -232,7 +232,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultIsExceptionUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.isException("unknown");
}
@@ -242,9 +242,9 @@ public class MultiBackgroundInitializerTest {
@Test(expected = UnsupportedOperationException.class)
public void testResultInitializerNamesModify() throws ConcurrentException {
checkInitialize();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
- Iterator<String> it = res.initializerNames().iterator();
+ final Iterator<String> it = res.initializerNames().iterator();
it.next();
it.remove();
}
@@ -255,14 +255,14 @@ public class MultiBackgroundInitializerTest {
*/
@Test
public void testInitializeRuntimeEx() {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
child.ex = new RuntimeException();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
try {
initializer.get();
fail("Runtime exception not thrown!");
- } catch (Exception ex) {
+ } catch (final Exception ex) {
assertEquals("Wrong exception", child.ex, ex);
}
}
@@ -273,15 +273,15 @@ public class MultiBackgroundInitializerTest {
*/
@Test
public void testInitializeEx() throws ConcurrentException {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
child.ex = new Exception();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertTrue("No exception flag", res.isException(CHILD_INIT));
assertNull("Got a results object", res.getResultObject(CHILD_INIT));
- ConcurrentException cex = res.getException(CHILD_INIT);
+ final ConcurrentException cex = res.getException(CHILD_INIT);
assertEquals("Wrong cause", child.ex, cex.getCause());
}
@@ -292,10 +292,10 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeResultsIsSuccessfulTrue()
throws ConcurrentException {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertTrue("Wrong success flag", res.isSuccessful());
}
@@ -307,11 +307,11 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeResultsIsSuccessfulFalse()
throws ConcurrentException {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
child.ex = new Exception();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertFalse("Wrong success flag", res.isSuccessful());
}
@@ -325,7 +325,7 @@ public class MultiBackgroundInitializerTest {
final String nameMulti = "multiChildInitializer";
initializer
.addInitializer(CHILD_INIT, new ChildBackgroundInitializer());
- MultiBackgroundInitializer mi2 = new MultiBackgroundInitializer();
+ final MultiBackgroundInitializer mi2 = new MultiBackgroundInitializer();
final int count = 3;
for (int i = 0; i < count; i++) {
mi2
@@ -334,11 +334,11 @@ public class MultiBackgroundInitializerTest {
}
initializer.addInitializer(nameMulti, mi2);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
- ExecutorService exec = initializer.getActiveExecutor();
+ final ExecutorService exec = initializer.getActiveExecutor();
checkChild(res.getInitializer(CHILD_INIT), exec);
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res2 = (MultiBackgroundInitializer.MultiBackgroundInitializerResults) res
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res2 = (MultiBackgroundInitializer.MultiBackgroundInitializerResults) res
.getResultObject(nameMulti);
assertEquals("Wrong number of initializers", count, res2
.initializerNames().size());
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
index 36ddcfb2b..c9bd68b62 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
@@ -51,10 +51,10 @@ public class TimedSemaphoreTest {
*/
@Test
public void testInit() {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
EasyMock.replay(service);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
EasyMock.verify(service);
assertEquals("Wrong service", service, semaphore.getExecutorService());
@@ -83,8 +83,8 @@ public class TimedSemaphoreTest {
*/
@Test
public void testInitDefaultService() {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
- ScheduledThreadPoolExecutor exec = (ScheduledThreadPoolExecutor) semaphore
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final ScheduledThreadPoolExecutor exec = (ScheduledThreadPoolExecutor) semaphore
.getExecutorService();
assertFalse("Wrong periodic task policy", exec
.getContinueExistingPeriodicTasksAfterShutdownPolicy());
@@ -99,9 +99,9 @@ public class TimedSemaphoreTest {
*/
@Test
public void testStartTimer() throws InterruptedException {
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(PERIOD,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(PERIOD,
UNIT, LIMIT);
- ScheduledFuture<?> future = semaphore.startTimer();
+ final ScheduledFuture<?> future = semaphore.startTimer();
assertNotNull("No future returned", future);
Thread.sleep(PERIOD);
final int trials = 10;
@@ -121,7 +121,7 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownOwnExecutor() {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
semaphore.shutdown();
assertTrue("Not shutdown", semaphore.isShutdown());
assertTrue("Executor not shutdown", semaphore.getExecutorService()
@@ -134,10 +134,10 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownSharedExecutorNoTask() {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
EasyMock.replay(service);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
semaphore.shutdown();
assertTrue("Not shutdown", semaphore.isShutdown());
@@ -163,13 +163,13 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownSharedExecutorTask() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.expect(Boolean.valueOf(future.cancel(false))).andReturn(Boolean.TRUE);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, LIMIT);
semaphore.acquire();
semaphore.shutdown();
@@ -182,13 +182,13 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownMultipleTimes() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.expect(Boolean.valueOf(future.cancel(false))).andReturn(Boolean.TRUE);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, LIMIT);
semaphore.acquire();
for (int i = 0; i < 10; i++) {
@@ -202,15 +202,15 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireLimit() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
final int count = 10;
- CountDownLatch latch = new CountDownLatch(count - 1);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT, 1);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count,
+ final CountDownLatch latch = new CountDownLatch(count - 1);
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT, 1);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count,
count - 1);
semaphore.setLimit(count - 1);
@@ -239,16 +239,16 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireMultipleThreads() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, 1);
semaphore.latch = new CountDownLatch(1);
final int count = 10;
- SemaphoreThread[] threads = new SemaphoreThread[count];
+ final SemaphoreThread[] threads = new SemaphoreThread[count];
for (int i = 0; i < count; i++) {
threads[i] = new SemaphoreThread(semaphore, null, 1, 0);
threads[i].start();
@@ -274,16 +274,16 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireNoLimit() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, TimedSemaphore.NO_LIMIT);
final int count = 1000;
- CountDownLatch latch = new CountDownLatch(count);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
+ final CountDownLatch latch = new CountDownLatch(count);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
t.start();
latch.await();
EasyMock.verify(service, future);
@@ -294,7 +294,7 @@ public class TimedSemaphoreTest {
*/
@Test(expected = IllegalStateException.class)
public void testPassAfterShutdown() throws InterruptedException {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
semaphore.shutdown();
semaphore.acquire();
}
@@ -308,11 +308,11 @@ public class TimedSemaphoreTest {
@Test
public void testAcquireMultiplePeriods() throws InterruptedException {
final int count = 1000;
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(
PERIOD / 10, TimeUnit.MILLISECONDS, 1);
semaphore.setLimit(count / 4);
- CountDownLatch latch = new CountDownLatch(count);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
+ final CountDownLatch latch = new CountDownLatch(count);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
t.start();
latch.await();
semaphore.shutdown();
@@ -324,12 +324,12 @@ public class TimedSemaphoreTest {
*/
@Test
public void testGetAverageCallsPerPeriod() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
semaphore.acquire();
semaphore.endOfPeriod();
@@ -348,12 +348,12 @@ public class TimedSemaphoreTest {
*/
@Test
public void testGetAvailablePermits() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
for (int i = 0; i < LIMIT; i++) {
assertEquals("Wrong available count at " + i, LIMIT - i, semaphore
@@ -470,7 +470,7 @@ public class TimedSemaphoreTest {
latch.countDown();
}
}
- } catch (InterruptedException iex) {
+ } catch (final InterruptedException iex) {
Thread.currentThread().interrupt();
}
}
diff --git a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
index 1e3b0f095..1685d4895 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
@@ -45,21 +45,21 @@ public class EventListenerSupportTest
@Test(expected=NullPointerException.class)
public void testAddNullListener()
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(null);
}
@Test(expected=NullPointerException.class)
public void testRemoveNullListener()
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.removeListener(null);
}
@Test
public void testEventDispatchOrder() throws PropertyVetoException
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
final List<VetoableChangeListener> calledListeners = new ArrayList<VetoableChangeListener>();
final VetoableChangeListener listener1 = createListener(calledListeners);
@@ -101,17 +101,17 @@ public class EventListenerSupportTest
public void testGetListeners() {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
- VetoableChangeListener[] listeners = listenerSupport.getListeners();
+ final VetoableChangeListener[] listeners = listenerSupport.getListeners();
assertEquals(0, listeners.length);
assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
- VetoableChangeListener[] empty = listeners;
+ final VetoableChangeListener[] empty = listeners;
//for fun, show that the same empty instance is used
assertSame(empty, listenerSupport.getListeners());
- VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class);
listenerSupport.addListener(listener1);
assertEquals(1, listenerSupport.getListeners().length);
- VetoableChangeListener listener2 = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener2 = EasyMock.createNiceMock(VetoableChangeListener.class);
listenerSupport.addListener(listener2);
assertEquals(2, listenerSupport.getListeners().length);
listenerSupport.removeListener(listener1);
@@ -122,7 +122,7 @@ public class EventListenerSupportTest
@Test
public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException {
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(new VetoableChangeListener() {
@Override
@@ -132,25 +132,26 @@ public class EventListenerSupportTest
listenerSupport.addListener(EasyMock.createNiceMock(VetoableChangeListener.class));
//serialize:
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ final ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
objectOutputStream.writeObject(listenerSupport);
objectOutputStream.close();
//deserialize:
@SuppressWarnings("unchecked")
+ final
EventListenerSupport<VetoableChangeListener> deserializedListenerSupport = (EventListenerSupport<VetoableChangeListener>) new ObjectInputStream(
new ByteArrayInputStream(outputStream.toByteArray())).readObject();
//make sure we get a listener array back, of the correct component type, and that it contains only the serializable mock
- VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
+ final VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
assertEquals(1, listeners.length);
//now verify that the mock still receives events; we can infer that the proxy was correctly reconstituted
- VetoableChangeListener listener = listeners[0];
- PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
+ final VetoableChangeListener listener = listeners[0];
+ final PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
listener.vetoableChange(evt);
EasyMock.replay(listener);
deserializedListenerSupport.fire().vetoableChange(evt);
@@ -165,6 +166,7 @@ public class EventListenerSupportTest
public void testSubclassInvocationHandling() throws PropertyVetoException {
@SuppressWarnings("serial")
+ final
EventListenerSupport<VetoableChangeListener> eventListenerSupport = new EventListenerSupport<VetoableChangeListener>(
VetoableChangeListener.class) {
@Override
@@ -184,11 +186,11 @@ public class EventListenerSupportTest
}
};
- VetoableChangeListener listener = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener = EasyMock.createNiceMock(VetoableChangeListener.class);
eventListenerSupport.addListener(listener);
- Object source = new Date();
- PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6);
- PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7);
+ final Object source = new Date();
+ final PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6);
+ final PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7);
listener.vetoableChange(respond);
EasyMock.replay(listener);
eventListenerSupport.fire().vetoableChange(ignore);
diff --git a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
index a7b44e307..2178ea455 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
@@ -48,7 +48,7 @@ public class EventUtilsTest
@Test
public void testConstructor() {
assertNotNull(new EventUtils());
- Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(EventUtils.class.getModifiers()));
@@ -59,8 +59,8 @@ public class EventUtilsTest
public void testAddEventListener()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
assertEquals(0, handler.getEventCount("propertyChange"));
EventUtils.addEventListener(src, PropertyChangeListener.class, listener);
assertEquals(0, handler.getEventCount("propertyChange"));
@@ -72,14 +72,14 @@ public class EventUtilsTest
public void testAddEventListenerWithNoAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
try
{
EventUtils.addEventListener(src, ObjectChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + ObjectChangeListener.class.getSimpleName() + " method which takes a parameter of type " + ObjectChangeListener.class.getName() + ".", e.getMessage());
}
@@ -101,7 +101,7 @@ public class EventUtilsTest
});
fail("Add method should have thrown an exception, so method should fail.");
}
- catch (RuntimeException e)
+ catch (final RuntimeException e)
{
}
@@ -111,14 +111,14 @@ public class EventUtilsTest
public void testAddEventListenerWithPrivateAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
try
{
EventUtils.addEventListener(src, VetoableChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + VetoableChangeListener.class.getSimpleName() + " method which takes a parameter of type " + VetoableChangeListener.class.getName() + ".", e.getMessage());
}
@@ -212,14 +212,14 @@ public class EventUtilsTest
public int getEventCount(final String eventName)
{
- Integer count = eventCounts.get(eventName);
+ final Integer count = eventCounts.get(eventName);
return count == null ? 0 : count.intValue();
}
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
{
- Integer count = eventCounts.get(method.getName());
+ final Integer count = eventCounts.get(method.getName());
if (count == null)
{
eventCounts.put(method.getName(), Integer.valueOf(1));
@@ -258,7 +258,7 @@ public class EventUtilsTest
public void setProperty(final String property)
{
- String oldValue = this.property;
+ final String oldValue = this.property;
this.property = property;
listeners.fire().propertyChange(new PropertyChangeEvent(this, "property", oldValue, property));
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
index 457de710d..cf9035c6b 100644
--- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
@@ -59,7 +59,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
@Test
public void testAddContextValue() {
- String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
+ final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
assertTrue(message.indexOf("test1") >= 0);
assertTrue(message.indexOf("test2") >= 0);
@@ -81,7 +81,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
assertEquals(5, exceptionContext.getContextLabels().size());
assertTrue(exceptionContext.getContextLabels().contains("test2"));
- String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
+ final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
@@ -90,7 +90,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
exceptionContext.addContextValue("test2", "different value");
exceptionContext.setContextValue("test3", "3");
- String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
+ final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
assertTrue(message.indexOf("test Poorly written obj") >= 0);
assertTrue(message.indexOf("Crap") >= 0);
@@ -114,7 +114,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
assertEquals(6, exceptionContext.getContextEntries().size());
assertEquals(6, exceptionContext.getContextLabels().size());
- String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
+ final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
@@ -149,7 +149,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
exceptionContext.addContextValue("test2", "different value");
- Set<String> labels = exceptionContext.getContextLabels();
+ final Set<String> labels = exceptionContext.getContextLabels();
assertEquals(6, exceptionContext.getContextEntries().size());
assertEquals(5, labels.size());
assertTrue(labels.contains("test1"));
@@ -164,7 +164,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
exceptionContext.addContextValue("test2", "different value");
- List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
+ final List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
assertEquals(6, entries.size());
assertEquals("test1", entries.get(0).getKey());
assertEquals("test2", entries.get(1).getKey());
@@ -178,7 +178,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
public void testJavaSerialization() {
exceptionContext.setContextValue("test Poorly written obj", "serializable replacement");
- T clone = SerializationUtils.deserialize(SerializationUtils.serialize(exceptionContext));
+ final T clone = SerializationUtils.deserialize(SerializationUtils.serialize(exceptionContext));
assertEquals(exceptionContext.getFormattedExceptionMessage(null), clone.getFormattedExceptionMessage(null));
}
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
index ac5400059..48703a505 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
@@ -39,8 +39,8 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
@Test
public void testContextedException() {
exceptionContext = new ContextedException();
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(StringUtils.isEmpty(message));
}
@@ -50,15 +50,15 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
exceptionContext = new ContextedException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
@Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedException(new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
@@ -67,8 +67,8 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
@Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -78,8 +78,8 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -95,7 +95,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
- String message = exceptionContext.getMessage();
+ final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
index 24f2ea3b6..7eca04205 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
@@ -41,8 +41,8 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
@Test
public void testContextedException() {
exceptionContext = new ContextedRuntimeException();
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(StringUtils.isEmpty(message));
}
@@ -52,15 +52,15 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
@Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedRuntimeException(new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
@@ -69,8 +69,8 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
@Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -80,8 +80,8 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -97,7 +97,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
- String message = exceptionContext.getMessage();
+ final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index b5d5913a9..15e7e0e92 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -64,8 +64,8 @@ public class ExceptionUtilsTest {
nested = new NestableException(withoutCause);
withCause = new ExceptionWithCause(nested);
jdkNoCause = new NullPointerException();
- ExceptionWithCause a = new ExceptionWithCause(null);
- ExceptionWithCause b = new ExceptionWithCause(a);
+ final ExceptionWithCause a = new ExceptionWithCause(null);
+ final ExceptionWithCause b = new ExceptionWithCause(a);
a.setCause(b);
cyclicCause = new ExceptionWithCause(a);
}
@@ -84,7 +84,7 @@ public class ExceptionUtilsTest {
private Throwable createExceptionWithoutCause() {
try {
throw new ExceptionWithoutCause();
- } catch (Throwable t) {
+ } catch (final Throwable t) {
return t;
}
}
@@ -93,10 +93,10 @@ public class ExceptionUtilsTest {
try {
try {
throw new ExceptionWithCause(createExceptionWithoutCause());
- } catch (Throwable t) {
+ } catch (final Throwable t) {
throw new ExceptionWithCause(t);
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
return t;
}
}
@@ -106,7 +106,7 @@ public class ExceptionUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ExceptionUtils());
- Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers()));
@@ -176,14 +176,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_withoutCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
assertEquals(1, throwables.length);
assertSame(withoutCause, throwables[0]);
}
@Test
public void testGetThrowables_Throwable_nested() {
- Throwable[] throwables = ExceptionUtils.getThrowables(nested);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(nested);
assertEquals(2, throwables.length);
assertSame(nested, throwables[0]);
assertSame(withoutCause, throwables[1]);
@@ -191,7 +191,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_withCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
assertEquals(3, throwables.length);
assertSame(withCause, throwables[0]);
assertSame(nested, throwables[1]);
@@ -200,14 +200,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_jdkNoCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
assertEquals(1, throwables.length);
assertSame(jdkNoCause, throwables[0]);
}
@Test
public void testGetThrowables_Throwable_recursiveCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
assertEquals(3, throwables.length);
assertSame(cyclicCause, throwables[0]);
assertSame(cyclicCause.getCause(), throwables[1]);
@@ -217,20 +217,20 @@ public class ExceptionUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testGetThrowableList_Throwable_null() {
- List<?> throwables = ExceptionUtils.getThrowableList(null);
+ final List<?> throwables = ExceptionUtils.getThrowableList(null);
assertEquals(0, throwables.size());
}
@Test
public void testGetThrowableList_Throwable_withoutCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(withoutCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(withoutCause);
assertEquals(1, throwables.size());
assertSame(withoutCause, throwables.get(0));
}
@Test
public void testGetThrowableList_Throwable_nested() {
- List<?> throwables = ExceptionUtils.getThrowableList(nested);
+ final List<?> throwables = ExceptionUtils.getThrowableList(nested);
assertEquals(2, throwables.size());
assertSame(nested, throwables.get(0));
assertSame(withoutCause, throwables.get(1));
@@ -238,7 +238,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowableList_Throwable_withCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(withCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(withCause);
assertEquals(3, throwables.size());
assertSame(withCause, throwables.get(0));
assertSame(nested, throwables.get(1));
@@ -247,14 +247,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowableList_Throwable_jdkNoCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(jdkNoCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(jdkNoCause);
assertEquals(1, throwables.size());
assertSame(jdkNoCause, throwables.get(0));
}
@Test
public void testGetThrowableList_Throwable_recursiveCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(cyclicCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(cyclicCause);
assertEquals(3, throwables.size());
assertSame(cyclicCause, throwables.get(0));
assertSame(cyclicCause.getCause(), throwables.get(1));
@@ -384,11 +384,11 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
out = new ByteArrayOutputStream(1024);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(withCause, new PrintStream(out));
String stackTrace = out.toString();
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
@@ -410,11 +410,11 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
writer = new StringWriter(1024);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(withCause, new PrintWriter(writer));
String stackTrace = writer.toString();
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
@@ -430,10 +430,10 @@ public class ExceptionUtilsTest {
public void testGetRootCauseStackTrace_Throwable() throws Exception {
assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
String[] stackTrace = ExceptionUtils.getRootCauseStackTrace(withCause);
boolean match = false;
- for (String element : stackTrace) {
+ for (final String element : stackTrace) {
if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) {
match = true;
break;
@@ -443,7 +443,7 @@ public class ExceptionUtilsTest {
stackTrace = ExceptionUtils.getRootCauseStackTrace(withoutCause);
match = false;
- for (String element : stackTrace) {
+ for (final String element : stackTrace) {
if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) {
match = true;
break;
diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
index aa81f65b2..b1bca6819 100644
--- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
@@ -123,27 +123,27 @@ public class FractionTest {
try {
f = Fraction.getFraction(1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// very large: can't represent as unsimplified fraction, although
try {
f = Fraction.getFraction(4, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -172,17 +172,17 @@ public class FractionTest {
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// negative whole
f = Fraction.getFraction(-1, 6, 10);
@@ -192,43 +192,43 @@ public class FractionTest {
try {
f = Fraction.getFraction(-1, -6, 10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, 6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// zero denominator
try {
f = Fraction.getFraction(0, 1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, 2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, -3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// very large
f = Fraction.getFraction(-1, 0, Integer.MAX_VALUE);
@@ -239,15 +239,15 @@ public class FractionTest {
// negative denominators not allowed in this constructor.
f = Fraction.getFraction(0, 4, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, 1, Integer.MAX_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, 2, Integer.MAX_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
public void testReducedFactory_int_int() {
@@ -289,17 +289,17 @@ public class FractionTest {
try {
f = Fraction.getReducedFraction(1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getReducedFraction(2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getReducedFraction(-3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// reduced
f = Fraction.getReducedFraction(0, 2);
@@ -332,7 +332,7 @@ public class FractionTest {
try {
f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE);
fail("Expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// LANG-662
f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2);
@@ -347,22 +347,22 @@ public class FractionTest {
try {
f = Fraction.getFraction(Double.NaN);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Double.POSITIVE_INFINITY);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Double.NEGATIVE_INFINITY);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction((double) Integer.MAX_VALUE + 1);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// zero
f = Fraction.getFraction(0.0d);
@@ -405,7 +405,7 @@ public class FractionTest {
for (int j = 1; j <= i; j++) { // numerator
try {
f = Fraction.getFraction((double) j / (double) i);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
System.err.println(j + " " + i);
throw ex;
}
@@ -419,7 +419,7 @@ public class FractionTest {
for (int j = 1; j <= i; j++) { // numerator
try {
f = Fraction.getFraction((double) j / (double) i);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
System.err.println(j + " " + i);
throw ex;
}
@@ -459,17 +459,17 @@ public class FractionTest {
try {
f = Fraction.getFraction("2.3R");
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2147483648"); // too big
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(".");
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -503,32 +503,32 @@ public class FractionTest {
try {
f = Fraction.getFraction("2 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("a 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2 b/4");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2 ");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(" 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(" ");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -562,22 +562,22 @@ public class FractionTest {
try {
f = Fraction.getFraction("2/d");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2e/3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2/");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("/");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -686,14 +686,14 @@ public class FractionTest {
try {
f = f.invert();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// large values
f = Fraction.getFraction(Integer.MIN_VALUE, 1);
try {
f = f.invert();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f = Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.invert();
@@ -725,7 +725,7 @@ public class FractionTest {
try {
f = f.negate();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -756,7 +756,7 @@ public class FractionTest {
try {
f = f.abs();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -833,11 +833,11 @@ public class FractionTest {
try {
f = f.pow(-1);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = f.pow(Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// one to any power is still one.
f = Fraction.getFraction(1, 1);
@@ -856,20 +856,20 @@ public class FractionTest {
try {
f = f.pow(2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// Numerator growing too negative during the pow operation.
f = Fraction.getFraction(Integer.MIN_VALUE, 1);
try {
f = f.pow(3);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f = Fraction.getFraction(65536, 1);
try {
f = f.pow(2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -936,7 +936,7 @@ public class FractionTest {
try {
f.add(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// if this fraction is added naively, it will overflow.
// check that it doesn't.
@@ -961,7 +961,7 @@ public class FractionTest {
try {
f = f.add(Fraction.ONE); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
@@ -969,26 +969,26 @@ public class FractionTest {
try {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1047,7 +1047,7 @@ public class FractionTest {
try {
f.subtract(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// if this fraction is subtracted naively, it will overflow.
// check that it doesn't.
@@ -1074,7 +1074,7 @@ public class FractionTest {
f2 = Fraction.getFraction(1, Integer.MAX_VALUE - 1);
f = f1.subtract(f2);
fail("expecting ArithmeticException"); //should overflow
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
@@ -1082,26 +1082,26 @@ public class FractionTest {
try {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(Integer.MIN_VALUE, 1);
f = f.subtract(Fraction.ONE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.subtract(Fraction.ONE.negate());
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1158,19 +1158,19 @@ public class FractionTest {
try {
f.multiplyBy(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1190,7 +1190,7 @@ public class FractionTest {
try {
f = f1.divideBy(f2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(2, 7);
@@ -1217,18 +1217,18 @@ public class FractionTest {
try {
f.divideBy(null);
fail("IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1256,7 +1256,7 @@ public class FractionTest {
@Test
public void testHashCode() {
- Fraction f1 = Fraction.getFraction(3, 5);
+ final Fraction f1 = Fraction.getFraction(3, 5);
Fraction f2 = Fraction.getFraction(3, 5);
assertTrue(f1.hashCode() == f2.hashCode());
@@ -1279,7 +1279,7 @@ public class FractionTest {
try {
f1.compareTo(null);
fail("expecting NullPointerException");
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
f2 = Fraction.getFraction(2, 5);
assertTrue(f1.compareTo(f2) > 0);
@@ -1308,7 +1308,7 @@ public class FractionTest {
Fraction f = null;
f = Fraction.getFraction(3, 5);
- String str = f.toString();
+ final String str = f.toString();
assertEquals("3/5", str);
assertSame(str, f.toString());
@@ -1336,7 +1336,7 @@ public class FractionTest {
Fraction f = null;
f = Fraction.getFraction(3, 5);
- String str = f.toProperString();
+ final String str = f.toProperString();
assertEquals("3/5", str);
assertSame(str, f.toProperString());
diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
index 8fbccfac1..c3dc66f24 100644
--- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
@@ -38,19 +38,19 @@ public class IEEE754rUtilsTest {
assertEquals(2.5f, IEEE754rUtils.max(1.2f, 2.5f, Float.NaN), 0.01);
assertTrue(Float.isNaN(IEEE754rUtils.max(Float.NaN, Float.NaN, Float.NaN)));
- double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertEquals(42.0, IEEE754rUtils.max(a), 0.01);
assertEquals(1.2, IEEE754rUtils.min(a), 0.01);
- double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertEquals(42.0, IEEE754rUtils.max(b), 0.01);
assertEquals(1.2, IEEE754rUtils.min(b), 0.01);
- float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertEquals(1.2f, IEEE754rUtils.min(aF), 0.01);
assertEquals(42.0f, IEEE754rUtils.max(aF), 0.01);
- float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertEquals(1.2f, IEEE754rUtils.min(bF), 0.01);
assertEquals(42.0f, IEEE754rUtils.max(bF), 0.01);
}
@@ -60,42 +60,42 @@ public class IEEE754rUtilsTest {
try {
IEEE754rUtils.min( (float[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min(new float[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max( (float[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max(new float[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min( (double[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min(new double[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max( (double[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max(new double[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
}
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 8a11b520e..389cc8af7 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -42,7 +42,7 @@ public class NumberUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new NumberUtils());
- Constructor<?>[] cons = NumberUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = NumberUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(NumberUtils.class.getModifiers()));
@@ -240,7 +240,7 @@ public class NumberUtilsTest {
try {
NumberUtils.createNumber("--1.1E-700F");
fail("Expected NumberFormatException");
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
// expected
}
}
@@ -287,9 +287,9 @@ public class NumberUtilsTest {
protected void testCreateFloatFailure(final String str) {
try {
- Float value = NumberUtils.createFloat(str);
+ final Float value = NumberUtils.createFloat(str);
fail("createFloat(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -307,9 +307,9 @@ public class NumberUtilsTest {
protected void testCreateDoubleFailure(final String str) {
try {
- Double value = NumberUtils.createDouble(str);
+ final Double value = NumberUtils.createDouble(str);
fail("createDouble(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -327,9 +327,9 @@ public class NumberUtilsTest {
protected void testCreateIntegerFailure(final String str) {
try {
- Integer value = NumberUtils.createInteger(str);
+ final Integer value = NumberUtils.createInteger(str);
fail("createInteger(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -347,9 +347,9 @@ public class NumberUtilsTest {
protected void testCreateLongFailure(final String str) {
try {
- Long value = NumberUtils.createLong(str);
+ final Long value = NumberUtils.createLong(str);
fail("createLong(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -379,9 +379,9 @@ public class NumberUtilsTest {
protected void testCreateBigIntegerFailure(final String str) {
try {
- BigInteger value = NumberUtils.createBigInteger(str);
+ final BigInteger value = NumberUtils.createBigInteger(str);
fail("createBigInteger(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -405,9 +405,9 @@ public class NumberUtilsTest {
protected void testCreateBigDecimalFailure(final String str) {
try {
- BigDecimal value = NumberUtils.createBigDecimal(str);
+ final BigDecimal value = NumberUtils.createBigDecimal(str);
fail("createBigDecimal(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -720,12 +720,12 @@ public class NumberUtilsTest {
try {
NumberUtils.max(d);
fail("No exception was thrown for null input.");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
NumberUtils.max(new double[0]);
fail("No exception was thrown for empty input.");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
assertEquals(
"max(double[]) failed for array length 1",
@@ -801,9 +801,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumShort() {
- short low = 1234;
- short mid = 1234 + 1;
- short high = 1234 + 2;
+ final short low = 1234;
+ final short mid = 1234 + 1;
+ final short high = 1234 + 2;
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(low, mid, high));
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, low, high));
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, high, low));
@@ -812,9 +812,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumByte() {
- byte low = 123;
- byte mid = 123 + 1;
- byte high = 123 + 2;
+ final byte low = 123;
+ final byte mid = 123 + 1;
+ final byte high = 123 + 2;
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(low, mid, high));
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, low, high));
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, high, low));
@@ -823,9 +823,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumDouble() {
- double low = 12.3;
- double mid = 12.3 + 1;
- double high = 12.3 + 2;
+ final double low = 12.3;
+ final double mid = 12.3 + 1;
+ final double high = 12.3 + 2;
assertEquals(low, NumberUtils.min(low, mid, high), 0.0001);
assertEquals(low, NumberUtils.min(mid, low, high), 0.0001);
assertEquals(low, NumberUtils.min(mid, high, low), 0.0001);
@@ -835,9 +835,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumFloat() {
- float low = 12.3f;
- float mid = 12.3f + 1;
- float high = 12.3f + 2;
+ final float low = 12.3f;
+ final float mid = 12.3f + 1;
+ final float high = 12.3f + 2;
assertEquals(low, NumberUtils.min(low, mid, high), 0.0001f);
assertEquals(low, NumberUtils.min(mid, low, high), 0.0001f);
assertEquals(low, NumberUtils.min(mid, high, low), 0.0001f);
@@ -865,9 +865,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumShort() {
- short low = 1234;
- short mid = 1234 + 1;
- short high = 1234 + 2;
+ final short low = 1234;
+ final short mid = 1234 + 1;
+ final short high = 1234 + 2;
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(low, mid, high));
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(mid, low, high));
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(mid, high, low));
@@ -876,9 +876,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumByte() {
- byte low = 123;
- byte mid = 123 + 1;
- byte high = 123 + 2;
+ final byte low = 123;
+ final byte mid = 123 + 1;
+ final byte high = 123 + 2;
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(low, mid, high));
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(mid, low, high));
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(mid, high, low));
@@ -887,9 +887,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumDouble() {
- double low = 12.3;
- double mid = 12.3 + 1;
- double high = 12.3 + 2;
+ final double low = 12.3;
+ final double mid = 12.3 + 1;
+ final double high = 12.3 + 2;
assertEquals(high, NumberUtils.max(low, mid, high), 0.0001);
assertEquals(high, NumberUtils.max(mid, low, high), 0.0001);
assertEquals(high, NumberUtils.max(mid, high, low), 0.0001);
@@ -899,9 +899,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumFloat() {
- float low = 12.3f;
- float mid = 12.3f + 1;
- float high = 12.3f + 2;
+ final float low = 12.3f;
+ final float mid = 12.3f + 1;
+ final float high = 12.3f + 2;
assertEquals(high, NumberUtils.max(low, mid, high), 0.0001f);
assertEquals(high, NumberUtils.max(mid, low, high), 0.0001f);
assertEquals(high, NumberUtils.max(mid, high, low), 0.0001f);
@@ -1256,12 +1256,12 @@ public class NumberUtilsTest {
private boolean checkCreateNumber(final String val) {
try {
- Object obj = NumberUtils.createNumber(val);
+ final Object obj = NumberUtils.createNumber(val);
if (obj == null) {
return false;
}
return true;
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return false;
}
}
@@ -1322,18 +1322,18 @@ public class NumberUtilsTest {
assertTrue(Float.isNaN(NumberUtils.min(1.2f, 2.5f, Float.NaN)));
assertTrue(Float.isNaN(NumberUtils.max(1.2f, 2.5f, Float.NaN)));
- double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertTrue(Double.isNaN(NumberUtils.max(a)));
assertTrue(Double.isNaN(NumberUtils.min(a)));
- double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertTrue(Double.isNaN(NumberUtils.max(b)));
assertTrue(Double.isNaN(NumberUtils.min(b)));
- float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertTrue(Float.isNaN(NumberUtils.max(aF)));
- float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertTrue(Float.isNaN(NumberUtils.max(bF)));
}
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
index 069cc3897..12d328330 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
@@ -118,7 +118,7 @@ public class MutableByteTest {
@Test
public void testPrimitiveValues() {
- MutableByte mutNum = new MutableByte( (byte) 1 );
+ final MutableByte mutNum = new MutableByte( (byte) 1 );
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -136,7 +136,7 @@ public class MutableByteTest {
@Test
public void testIncrement() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -145,7 +145,7 @@ public class MutableByteTest {
@Test
public void testDecrement() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -154,7 +154,7 @@ public class MutableByteTest {
@Test
public void testAddValuePrimitive() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add((byte)1);
assertEquals((byte) 2, mutNum.byteValue());
@@ -162,7 +162,7 @@ public class MutableByteTest {
@Test
public void testAddValueObject() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add(Integer.valueOf(1));
assertEquals((byte) 2, mutNum.byteValue());
@@ -170,7 +170,7 @@ public class MutableByteTest {
@Test
public void testSubtractValuePrimitive() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract((byte) 1);
assertEquals((byte) 0, mutNum.byteValue());
@@ -178,7 +178,7 @@ public class MutableByteTest {
@Test
public void testSubtractValueObject() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract(Integer.valueOf(1));
assertEquals((byte) 0, mutNum.byteValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
index 5a2b1213b..1518062c3 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
@@ -130,7 +130,7 @@ public class MutableDoubleTest {
@Test
public void testPrimitiveValues() {
- MutableDouble mutNum = new MutableDouble(1.7);
+ final MutableDouble mutNum = new MutableDouble(1.7);
assertEquals( 1.7F, mutNum.floatValue(), 0 );
assertEquals( 1.7, mutNum.doubleValue(), 0 );
@@ -148,7 +148,7 @@ public class MutableDoubleTest {
@Test
public void testIncrement() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -157,7 +157,7 @@ public class MutableDoubleTest {
@Test
public void testDecrement() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -166,7 +166,7 @@ public class MutableDoubleTest {
@Test
public void testAddValuePrimitive() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(1.1d);
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
@@ -174,7 +174,7 @@ public class MutableDoubleTest {
@Test
public void testAddValueObject() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(Double.valueOf(1.1d));
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
@@ -182,7 +182,7 @@ public class MutableDoubleTest {
@Test
public void testSubtractValuePrimitive() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(0.9d);
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
@@ -190,7 +190,7 @@ public class MutableDoubleTest {
@Test
public void testSubtractValueObject() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(Double.valueOf(0.9d));
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
index 80971ca49..f4663b19d 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
@@ -130,7 +130,7 @@ public class MutableFloatTest {
@Test
public void testPrimitiveValues() {
- MutableFloat mutNum = new MutableFloat(1.7F);
+ final MutableFloat mutNum = new MutableFloat(1.7F);
assertEquals( 1, mutNum.intValue() );
assertEquals( 1.7, mutNum.doubleValue(), 0.00001 );
@@ -148,7 +148,7 @@ public class MutableFloatTest {
@Test
public void testIncrement() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -157,7 +157,7 @@ public class MutableFloatTest {
@Test
public void testDecrement() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -166,7 +166,7 @@ public class MutableFloatTest {
@Test
public void testAddValuePrimitive() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(1.1f);
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
@@ -174,7 +174,7 @@ public class MutableFloatTest {
@Test
public void testAddValueObject() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(Float.valueOf(1.1f));
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
@@ -182,7 +182,7 @@ public class MutableFloatTest {
@Test
public void testSubtractValuePrimitive() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(0.9f);
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
@@ -190,7 +190,7 @@ public class MutableFloatTest {
@Test
public void testSubtractValueObject() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(Float.valueOf(0.9f));
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
index b223c91bd..e68eede87 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
@@ -125,7 +125,7 @@ public class MutableIntTest {
@Test
public void testPrimitiveValues() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
assertEquals( (byte) 1, mutNum.byteValue() );
assertEquals( (short) 1, mutNum.shortValue() );
@@ -142,7 +142,7 @@ public class MutableIntTest {
@Test
public void testIncrement() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -151,7 +151,7 @@ public class MutableIntTest {
@Test
public void testDecrement() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -160,7 +160,7 @@ public class MutableIntTest {
@Test
public void testAddValuePrimitive() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.add(1);
assertEquals(2, mutNum.intValue());
@@ -169,7 +169,7 @@ public class MutableIntTest {
@Test
public void testAddValueObject() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.add(Integer.valueOf(1));
assertEquals(2, mutNum.intValue());
@@ -178,7 +178,7 @@ public class MutableIntTest {
@Test
public void testSubtractValuePrimitive() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.subtract(1);
assertEquals(0, mutNum.intValue());
@@ -187,7 +187,7 @@ public class MutableIntTest {
@Test
public void testSubtractValueObject() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.subtract(Integer.valueOf(1));
assertEquals(0, mutNum.intValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
index 00ada45f6..350c7c055 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
@@ -118,7 +118,7 @@ public class MutableLongTest {
@Test
public void testPrimitiveValues() {
- MutableLong mutNum = new MutableLong(1L);
+ final MutableLong mutNum = new MutableLong(1L);
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -136,7 +136,7 @@ public class MutableLongTest {
@Test
public void testIncrement() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -145,7 +145,7 @@ public class MutableLongTest {
@Test
public void testDecrement() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -154,7 +154,7 @@ public class MutableLongTest {
@Test
public void testAddValuePrimitive() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.add(1);
assertEquals(2, mutNum.intValue());
@@ -163,7 +163,7 @@ public class MutableLongTest {
@Test
public void testAddValueObject() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.add(Long.valueOf(1));
assertEquals(2, mutNum.intValue());
@@ -172,7 +172,7 @@ public class MutableLongTest {
@Test
public void testSubtractValuePrimitive() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.subtract(1);
assertEquals(0, mutNum.intValue());
@@ -181,7 +181,7 @@ public class MutableLongTest {
@Test
public void testSubtractValueObject() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.subtract(Long.valueOf(1));
assertEquals(0, mutNum.intValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
index 4e5a7a116..07c3c1fce 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
@@ -32,7 +32,7 @@ public class MutableObjectTest {
public void testConstructors() {
assertEquals(null, new MutableObject<String>().getValue());
- Integer i = Integer.valueOf(6);
+ final Integer i = Integer.valueOf(6);
assertSame(i, new MutableObject<Integer>(i).getValue());
assertSame("HI", new MutableObject<String>("HI").getValue());
assertSame(null, new MutableObject<Object>(null).getValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
index 051e14db9..8384542fd 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
@@ -42,7 +42,7 @@ public class MutableShortTest {
try {
new MutableShort((Number)null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -65,7 +65,7 @@ public class MutableShortTest {
try {
mutNum.setValue(null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -108,12 +108,12 @@ public class MutableShortTest {
try {
mutNum.compareTo(null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
public void testPrimitiveValues() {
- MutableShort mutNum = new MutableShort( (short) 1 );
+ final MutableShort mutNum = new MutableShort( (short) 1 );
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -131,7 +131,7 @@ public class MutableShortTest {
@Test
public void testIncrement() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -140,7 +140,7 @@ public class MutableShortTest {
@Test
public void testDecrement() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -149,7 +149,7 @@ public class MutableShortTest {
@Test
public void testAddValuePrimitive() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.add((short) 1);
assertEquals((short) 2, mutNum.shortValue());
@@ -157,7 +157,7 @@ public class MutableShortTest {
@Test
public void testAddValueObject() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.add(Short.valueOf((short) 1));
assertEquals((short) 2, mutNum.shortValue());
@@ -165,7 +165,7 @@ public class MutableShortTest {
@Test
public void testSubtractValuePrimitive() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.subtract((short) 1);
assertEquals((short) 0, mutNum.shortValue());
@@ -173,7 +173,7 @@ public class MutableShortTest {
@Test
public void testSubtractValueObject() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.subtract(Short.valueOf((short) 1));
assertEquals((short) 0, mutNum.shortValue());
diff --git a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
index d97edbdce..bfa6f51de 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
@@ -132,19 +132,19 @@ public class ConstructorUtilsTest {
ConstructorUtils.invokeExactConstructor(TestBean.class,
NumberUtils.BYTE_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
ConstructorUtils.invokeExactConstructor(TestBean.class,
NumberUtils.LONG_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
ConstructorUtils.invokeExactConstructor(TestBean.class,
Boolean.TRUE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -214,7 +214,7 @@ public class ConstructorUtilsTest {
private void expectMatchingAccessibleConstructorParameterTypes(final Class<?> cls,
final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
- Constructor<?> c = ConstructorUtils.getMatchingAccessibleConstructor(cls,
+ final Constructor<?> c = ConstructorUtils.getMatchingAccessibleConstructor(cls,
requestTypes);
assertTrue(toString(c.getParameterTypes()) + " not equals "
+ toString(actualTypes), Arrays.equals(actualTypes, c
diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
index a7ab28d81..869a231f0 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
@@ -67,7 +67,7 @@ public class FieldUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new FieldUtils());
- Constructor<?>[] cons = FieldUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = FieldUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(FieldUtils.class.getModifiers()));
@@ -228,7 +228,7 @@ public class FieldUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void testReadStaticFieldIllegalArgumentException2() throws Exception {
assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(Foo.class, "VALUE")));
- Field nonStaticField = FieldUtils.getField(PublicChild.class, "s");
+ final Field nonStaticField = FieldUtils.getField(PublicChild.class, "s");
assumeNotNull(nonStaticField);
FieldUtils.readStaticField(nonStaticField);
}
@@ -246,7 +246,7 @@ public class FieldUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void testReadStaticFieldForceAccessIllegalArgumentException2() throws Exception {
- Field nonStaticField = FieldUtils.getField(PublicChild.class, "s", true);
+ final Field nonStaticField = FieldUtils.getField(PublicChild.class, "s", true);
assumeNotNull(nonStaticField);
FieldUtils.readStaticField(nonStaticField);
}
@@ -261,28 +261,28 @@ public class FieldUtilsTest {
try {
FieldUtils.readStaticField(null, "none");
fail("null class should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, null);
fail("null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, "does_not_exist");
fail("a field that doesn't exist should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(PublicChild.class, "s");
fail("non-static field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -297,28 +297,28 @@ public class FieldUtilsTest {
try {
FieldUtils.readStaticField(null, "none", true);
fail("null class should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, null, true);
fail("null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, "does_not_exist", true);
fail("a field that doesn't exist should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(PublicChild.class, "s", false);
fail("non-static field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -329,19 +329,19 @@ public class FieldUtilsTest {
try {
assertEquals("child", FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -353,32 +353,32 @@ public class FieldUtilsTest {
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@Test
public void testReadField() throws Exception {
- Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
+ final Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
assertEquals("s", FieldUtils.readField(parentS, publicChild));
assertEquals("s", FieldUtils.readField(parentS, publiclyShadowedChild));
assertEquals("s", FieldUtils.readField(parentS, privatelyShadowedChild));
- Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
+ final Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publicChild));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publiclyShadowedChild));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, privatelyShadowedChild));
- Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
+ final Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
assertEquals(I0, FieldUtils.readField(parentI, publicChild));
assertEquals(I0, FieldUtils.readField(parentI, publiclyShadowedChild));
assertEquals(I0, FieldUtils.readField(parentI, privatelyShadowedChild));
- Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
+ final Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
assertEquals(D0, FieldUtils.readField(parentD, publicChild));
assertEquals(D0, FieldUtils.readField(parentD, publiclyShadowedChild));
assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild));
@@ -386,29 +386,29 @@ public class FieldUtilsTest {
try {
FieldUtils.readField((Field)null, publicChild);
fail("a null field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@Test
public void testReadFieldForceAccess() throws Exception {
- Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
+ final Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
parentS.setAccessible(false);
assertEquals("s", FieldUtils.readField(parentS, publicChild, true));
assertEquals("s", FieldUtils.readField(parentS, publiclyShadowedChild, true));
assertEquals("s", FieldUtils.readField(parentS, privatelyShadowedChild, true));
- Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
+ final Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
parentB.setAccessible(false);
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publicChild, true));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publiclyShadowedChild, true));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, privatelyShadowedChild, true));
- Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
+ final Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
parentI.setAccessible(false);
assertEquals(I0, FieldUtils.readField(parentI, publicChild, true));
assertEquals(I0, FieldUtils.readField(parentI, publiclyShadowedChild, true));
assertEquals(I0, FieldUtils.readField(parentI, privatelyShadowedChild, true));
- Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
+ final Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
parentD.setAccessible(false);
assertEquals(D0, FieldUtils.readField(parentD, publicChild, true));
assertEquals(D0, FieldUtils.readField(parentD, publiclyShadowedChild, true));
@@ -417,7 +417,7 @@ public class FieldUtilsTest {
try {
FieldUtils.readField((Field)null, publicChild, true);
fail("a null field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -431,54 +431,54 @@ public class FieldUtilsTest {
try {
FieldUtils.readField(publicChild, null);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readField((Object)null, "none");
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
assertEquals(Boolean.FALSE, FieldUtils.readField(publicChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(Boolean.TRUE, FieldUtils.readField(publiclyShadowedChild, "b"));
try {
assertEquals(Boolean.FALSE, FieldUtils.readField(privatelyShadowedChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(I0, FieldUtils.readField(publicChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(I1, FieldUtils.readField(publiclyShadowedChild, "i"));
try {
assertEquals(I0, FieldUtils.readField(privatelyShadowedChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(D0, FieldUtils.readField(publicChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(D1, FieldUtils.readField(publiclyShadowedChild, "d"));
try {
assertEquals(D0, FieldUtils.readField(privatelyShadowedChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -501,14 +501,14 @@ public class FieldUtilsTest {
try {
FieldUtils.readField(publicChild, null, true);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readField((Object)null, "none", true);
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -518,67 +518,67 @@ public class FieldUtilsTest {
try {
FieldUtils.readDeclaredField(publicChild, null);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readDeclaredField((Object)null, "none");
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
assertEquals("s", FieldUtils.readDeclaredField(publicChild, "s"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals("ss", FieldUtils.readDeclaredField(publiclyShadowedChild, "s"));
try {
assertEquals("s", FieldUtils.readDeclaredField(privatelyShadowedChild, "s"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publicChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(Boolean.TRUE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b"));
try {
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(privatelyShadowedChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(I0, FieldUtils.readDeclaredField(publicChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(I1, FieldUtils.readDeclaredField(publiclyShadowedChild, "i"));
try {
assertEquals(I0, FieldUtils.readDeclaredField(privatelyShadowedChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(D0, FieldUtils.readDeclaredField(publicChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(D1, FieldUtils.readDeclaredField(publiclyShadowedChild, "d"));
try {
assertEquals(D0, FieldUtils.readDeclaredField(privatelyShadowedChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -588,21 +588,21 @@ public class FieldUtilsTest {
try {
FieldUtils.readDeclaredField(publicChild, null, true);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readDeclaredField((Object)null, "none", true);
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
assertEquals("s", FieldUtils.readDeclaredField(publicChild, "s", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals("ss", FieldUtils.readDeclaredField(publiclyShadowedChild, "s", true));
@@ -610,7 +610,7 @@ public class FieldUtilsTest {
try {
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publicChild, "b", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(Boolean.TRUE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b", true));
@@ -618,7 +618,7 @@ public class FieldUtilsTest {
try {
assertEquals(I0, FieldUtils.readDeclaredField(publicChild, "i", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(I1, FieldUtils.readDeclaredField(publiclyShadowedChild, "i", true));
@@ -626,7 +626,7 @@ public class FieldUtilsTest {
try {
assertEquals(D0, FieldUtils.readDeclaredField(publicChild, "d", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(D1, FieldUtils.readDeclaredField(publiclyShadowedChild, "d", true));
@@ -642,49 +642,49 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("mutablePackage");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("mutablePrivate");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PUBLIC");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PROTECTED");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PACKAGE");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -707,28 +707,28 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PROTECTED");
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PACKAGE");
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE");
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -740,43 +740,43 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutableProtected", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePackage", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePrivate", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -794,25 +794,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -824,43 +824,43 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutableProtected", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePackage", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePrivate", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -878,25 +878,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -910,19 +910,19 @@ public class FieldUtilsTest {
try {
FieldUtils.writeField(field, publicChild, Boolean.TRUE);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = parentClass.getDeclaredField("i");
try {
FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = parentClass.getDeclaredField("d");
try {
FieldUtils.writeField(field, publicChild, Double.valueOf(Double.MAX_VALUE));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -950,19 +950,19 @@ public class FieldUtilsTest {
try {
FieldUtils.writeField(publicChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(publicChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(publicChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
@@ -980,19 +980,19 @@ public class FieldUtilsTest {
try {
FieldUtils.writeField(privatelyShadowedChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(privatelyShadowedChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -1032,25 +1032,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredField(publicChild, "s", "S");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
@@ -1066,25 +1066,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "s", "S");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -1094,25 +1094,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredField(publicChild, "s", "S", true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "b", Boolean.TRUE, true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1), true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "d", Double.valueOf(1.0), true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
index 64917e2bb..b603e70b9 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
@@ -185,18 +185,18 @@ public class MethodUtilsTest {
MethodUtils
.invokeExactMethod(testBean, "foo", NumberUtils.BYTE_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils
.invokeExactMethod(testBean, "foo", NumberUtils.LONG_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils.invokeExactMethod(testBean, "foo", Boolean.TRUE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -226,7 +226,7 @@ public class MethodUtilsTest {
try {
MethodUtils.invokeStaticMethod(TestBean.class, "does_not_exist");
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -252,28 +252,28 @@ public class MethodUtilsTest {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
NumberUtils.BYTE_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
NumberUtils.LONG_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
Boolean.TRUE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@Test
public void testGetAccessibleInterfaceMethod() throws Exception {
- Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
- for (Class<?>[] element : p) {
- Method method = TestMutable.class.getMethod("getValue", element);
- Method accessibleMethod = MethodUtils.getAccessibleMethod(method);
+ final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
+ for (final Class<?>[] element : p) {
+ final Method method = TestMutable.class.getMethod("getValue", element);
+ final Method accessibleMethod = MethodUtils.getAccessibleMethod(method);
assertNotSame(accessibleMethod, method);
assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
}
@@ -281,18 +281,18 @@ public class MethodUtilsTest {
@Test
public void testGetAccessibleMethodPrivateInterface() throws Exception {
- Method expected = TestBeanWithInterfaces.class.getMethod("foo");
+ final Method expected = TestBeanWithInterfaces.class.getMethod("foo");
assertNotNull(expected);
- Method actual = MethodUtils.getAccessibleMethod(TestBeanWithInterfaces.class, "foo");
+ final Method actual = MethodUtils.getAccessibleMethod(TestBeanWithInterfaces.class, "foo");
assertNull(actual);
}
@Test
public void testGetAccessibleInterfaceMethodFromDescription()
throws Exception {
- Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
- for (Class<?>[] element : p) {
- Method accessibleMethod = MethodUtils.getAccessibleMethod(
+ final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
+ for (final Class<?>[] element : p) {
+ final Method accessibleMethod = MethodUtils.getAccessibleMethod(
TestMutable.class, "getValue", element);
assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
}
@@ -314,8 +314,8 @@ public class MethodUtilsTest {
@Test
public void testGetAccessibleMethodInaccessible() throws Exception {
- Method expected = TestBean.class.getDeclaredMethod("privateStuff");
- Method actual = MethodUtils.getAccessibleMethod(expected);
+ final Method expected = TestBean.class.getDeclaredMethod("privateStuff");
+ final Method actual = MethodUtils.getAccessibleMethod(expected);
assertNull(actual);
}
@@ -379,7 +379,7 @@ public class MethodUtilsTest {
private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls,
final String methodName, final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
- Method m = MethodUtils.getMatchingAccessibleMethod(cls, methodName,
+ final Method m = MethodUtils.getMatchingAccessibleMethod(cls, methodName,
requestTypes);
assertTrue(toString(m.getParameterTypes()) + " not equals "
+ toString(actualTypes), Arrays.equals(actualTypes, m
diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
index 9aea0bbba..187b11c05 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
@@ -121,11 +121,11 @@ public class TypeUtilsTest<B> {
List<String>[] list11 = null;
List<? extends String>[] list12 = null;
List<? super String>[] list13;
- Class<?> clazz = getClass();
- Method method = clazz.getMethod("dummyMethod", List.class, List.class, List.class,
+ final Class<?> clazz = getClass();
+ final Method method = clazz.getMethod("dummyMethod", List.class, List.class, List.class,
List.class, List.class, List.class, List.class, List[].class, List[].class,
List[].class, List[].class, List[].class, List[].class, List[].class);
- Type[] types = method.getGenericParameterTypes();
+ final Type[] types = method.getGenericParameterTypes();
// list0 = list0;
delegateBooleanAssertion(types, 0, 0, true);
list1 = list0;
@@ -323,17 +323,17 @@ public class TypeUtilsTest<B> {
delegateBooleanAssertion(types, 13, 12, false);
// list13 = list13;
delegateBooleanAssertion(types, 13, 13, true);
- Type disType = getClass().getField("dis").getGenericType();
+ final Type disType = getClass().getField("dis").getGenericType();
// Reporter.log( ( ( ParameterizedType ) disType
// ).getOwnerType().getClass().toString() );
- Type datType = getClass().getField("dat").getGenericType();
- Type daType = getClass().getField("da").getGenericType();
- Type uhderType = getClass().getField("uhder").getGenericType();
- Type dingType = getClass().getField("ding").getGenericType();
- Type testerType = getClass().getField("tester").getGenericType();
- Type tester2Type = getClass().getField("tester2").getGenericType();
- Type dat2Type = getClass().getField("dat2").getGenericType();
- Type dat3Type = getClass().getField("dat3").getGenericType();
+ final Type datType = getClass().getField("dat").getGenericType();
+ final Type daType = getClass().getField("da").getGenericType();
+ final Type uhderType = getClass().getField("uhder").getGenericType();
+ final Type dingType = getClass().getField("ding").getGenericType();
+ final Type testerType = getClass().getField("tester").getGenericType();
+ final Type tester2Type = getClass().getField("tester2").getGenericType();
+ final Type dat2Type = getClass().getField("dat2").getGenericType();
+ final Type dat3Type = getClass().getField("dat3").getGenericType();
dis = dat;
Assert.assertTrue(TypeUtils.isAssignable(datType, disType));
// dis = da;
@@ -353,13 +353,13 @@ public class TypeUtilsTest<B> {
Assert.assertFalse(TypeUtils.isAssignable(datType, dat2Type));
// dat = dat3;
Assert.assertFalse(TypeUtils.isAssignable(dat3Type, datType));
- char ch = 0;
- boolean bo = false;
- byte by = 0;
- short sh = 0;
+ final char ch = 0;
+ final boolean bo = false;
+ final byte by = 0;
+ final short sh = 0;
int in = 0;
long lo = 0;
- float fl = 0;
+ final float fl = 0;
double du = 0;
du = ch;
Assert.assertTrue(TypeUtils.isAssignable(char.class, double.class));
@@ -383,17 +383,17 @@ public class TypeUtilsTest<B> {
Assert.assertFalse(TypeUtils.isAssignable(Integer.class, Long.class));
in = Integer.valueOf(0);
Assert.assertTrue(TypeUtils.isAssignable(Integer.class, int.class));
- Integer inte = in;
+ final Integer inte = in;
Assert.assertTrue(TypeUtils.isAssignable(int.class, Integer.class));
Assert.assertTrue(TypeUtils.isAssignable(int.class, Number.class));
Assert.assertTrue(TypeUtils.isAssignable(int.class, Object.class));
- Type intComparableType = getClass().getField("intComparable").getGenericType();
+ final Type intComparableType = getClass().getField("intComparable").getGenericType();
intComparable = 1;
Assert.assertTrue(TypeUtils.isAssignable(int.class, intComparableType));
Assert.assertTrue(TypeUtils.isAssignable(int.class, Comparable.class));
- Serializable ser = 1;
+ final Serializable ser = 1;
Assert.assertTrue(TypeUtils.isAssignable(int.class, Serializable.class));
- Type longComparableType = getClass().getField("longComparable").getGenericType();
+ final Type longComparableType = getClass().getField("longComparable").getGenericType();
// longComparable = 1;
Assert.assertFalse(TypeUtils.isAssignable(int.class, longComparableType));
// longComparable = Integer.valueOf( 0 );
@@ -401,24 +401,24 @@ public class TypeUtilsTest<B> {
// int[] ia;
// long[] la = ia;
Assert.assertFalse(TypeUtils.isAssignable(int[].class, long[].class));
- Integer[] ia = null;
- Type caType = getClass().getField("intWildcardComparable").getGenericType();
+ final Integer[] ia = null;
+ final Type caType = getClass().getField("intWildcardComparable").getGenericType();
intWildcardComparable = ia;
Assert.assertTrue(TypeUtils.isAssignable(Integer[].class, caType));
// int[] ina = ia;
Assert.assertFalse(TypeUtils.isAssignable(Integer[].class, int[].class));
- int[] ina = null;
+ final int[] ina = null;
Object[] oa;
// oa = ina;
Assert.assertFalse(TypeUtils.isAssignable(int[].class, Object[].class));
oa = new Integer[0];
Assert.assertTrue(TypeUtils.isAssignable(Integer[].class, Object[].class));
- Type bClassType = AClass.class.getField("bClass").getGenericType();
- Type cClassType = AClass.class.getField("cClass").getGenericType();
- Type dClassType = AClass.class.getField("dClass").getGenericType();
- Type eClassType = AClass.class.getField("eClass").getGenericType();
- Type fClassType = AClass.class.getField("fClass").getGenericType();
- AClass aClass = new AClass(new AAClass<String>());
+ final Type bClassType = AClass.class.getField("bClass").getGenericType();
+ final Type cClassType = AClass.class.getField("cClass").getGenericType();
+ final Type dClassType = AClass.class.getField("dClass").getGenericType();
+ final Type eClassType = AClass.class.getField("eClass").getGenericType();
+ final Type fClassType = AClass.class.getField("fClass").getGenericType();
+ final AClass aClass = new AClass(new AAClass<String>());
aClass.bClass = aClass.cClass;
Assert.assertTrue(TypeUtils.isAssignable(cClassType, bClassType));
aClass.bClass = aClass.dClass;
@@ -442,9 +442,9 @@ public class TypeUtilsTest<B> {
}
public void delegateBooleanAssertion(final Type[] types, final int i2, final int i1, final boolean expected) {
- Type type1 = types[i1];
- Type type2 = types[i2];
- boolean isAssignable = TypeUtils.isAssignable(type2, type1);
+ final Type type1 = types[i1];
+ final Type type2 = types[i2];
+ final boolean isAssignable = TypeUtils.isAssignable(type2, type1);
if (expected) {
Assert.assertTrue("[" + i1 + ", " + i2 + "]: From "
@@ -460,8 +460,8 @@ public class TypeUtilsTest<B> {
@SuppressWarnings("boxing") // boxing is deliberate here
@Test
public void testIsInstance() throws SecurityException, NoSuchFieldException {
- Type intComparableType = getClass().getField("intComparable").getGenericType();
- Type uriComparableType = getClass().getField("uriComparable").getGenericType();
+ final Type intComparableType = getClass().getField("intComparable").getGenericType();
+ final Type uriComparableType = getClass().getField("uriComparable").getGenericType();
intComparable = 1;
Assert.assertTrue(TypeUtils.isInstance(1, intComparableType));
// uriComparable = 1;
@@ -490,7 +490,7 @@ public class TypeUtilsTest<B> {
Assert.assertEquals("Type argument of Comparable from int: " + typeArg, Integer.class,
typeVarAssigns.get(treeSetTypeVar));
- Collection<Integer> col = Arrays.asList(new Integer[0]);
+ final Collection<Integer> col = Arrays.asList(new Integer[0]);
typeVarAssigns = TypeUtils.getTypeArguments(List.class, Collection.class);
treeSetTypeVar = Comparable.class.getTypeParameters()[0];
Assert.assertFalse("Type var assigns for Collection from List: " + typeVarAssigns,
@@ -510,8 +510,8 @@ public class TypeUtilsTest<B> {
@Test
public void testTypesSatisfyVariables() throws SecurityException, NoSuchFieldException,
NoSuchMethodException {
- Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<TypeVariable<?>, Type>();
- Integer max = TypeUtilsTest.stub();
+ final Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<TypeVariable<?>, Type>();
+ final Integer max = TypeUtilsTest.stub();
typeVarAssigns.put(getClass().getMethod("stub").getTypeParameters()[0], Integer.class);
Assert.assertTrue(TypeUtils.typesSatisfyVariables(typeVarAssigns));
typeVarAssigns.clear();
@@ -525,11 +525,11 @@ public class TypeUtilsTest<B> {
@Test
public void testDetermineTypeVariableAssignments() throws SecurityException,
NoSuchFieldException, NoSuchMethodException {
- ParameterizedType iterableType = (ParameterizedType) getClass().getField("iterable")
+ final ParameterizedType iterableType = (ParameterizedType) getClass().getField("iterable")
.getGenericType();
- Map<TypeVariable<?>, Type> typeVarAssigns = TypeUtils.determineTypeArguments(TreeSet.class,
+ final Map<TypeVariable<?>, Type> typeVarAssigns = TypeUtils.determineTypeArguments(TreeSet.class,
iterableType);
- TypeVariable<?> treeSetTypeVar = TreeSet.class.getTypeParameters()[0];
+ final TypeVariable<?> treeSetTypeVar = TreeSet.class.getTypeParameters()[0];
Assert.assertTrue(typeVarAssigns.containsKey(treeSetTypeVar));
Assert.assertEquals(iterableType.getActualTypeArguments()[0], typeVarAssigns
.get(treeSetTypeVar));
@@ -537,12 +537,12 @@ public class TypeUtilsTest<B> {
@Test
public void testGetRawType() throws SecurityException, NoSuchFieldException {
- Type stringParentFieldType = GenericTypeHolder.class.getDeclaredField("stringParent")
+ final Type stringParentFieldType = GenericTypeHolder.class.getDeclaredField("stringParent")
.getGenericType();
- Type integerParentFieldType = GenericTypeHolder.class.getDeclaredField("integerParent")
+ final Type integerParentFieldType = GenericTypeHolder.class.getDeclaredField("integerParent")
.getGenericType();
- Type foosFieldType = GenericTypeHolder.class.getDeclaredField("foos").getGenericType();
- Type genericParentT = GenericParent.class.getTypeParameters()[0];
+ final Type foosFieldType = GenericTypeHolder.class.getDeclaredField("foos").getGenericType();
+ final Type genericParentT = GenericParent.class.getTypeParameters()[0];
Assert.assertEquals(GenericParent.class, TypeUtils.getRawType(stringParentFieldType, null));
Assert
.assertEquals(GenericParent.class, TypeUtils.getRawType(integerParentFieldType,
@@ -588,11 +588,11 @@ public class TypeUtilsTest<B> {
@Test
public void testIsArrayGenericTypes() throws Exception {
- Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
+ final Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
List.class, List.class, List.class, List.class, List[].class, List[].class,
List[].class, List[].class, List[].class, List[].class, List[].class);
- Type[] types = method.getGenericParameterTypes();
+ final Type[] types = method.getGenericParameterTypes();
Assert.assertFalse(TypeUtils.isArrayType(types[0]));
Assert.assertFalse(TypeUtils.isArrayType(types[1]));
@@ -633,11 +633,11 @@ public class TypeUtilsTest<B> {
@Test
public void testGetArrayComponentType() throws Exception {
- Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
+ final Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
List.class, List.class, List.class, List.class, List[].class, List[].class,
List[].class, List[].class, List[].class, List[].class, List[].class);
- Type[] types = method.getGenericParameterTypes();
+ final Type[] types = method.getGenericParameterTypes();
Assert.assertNull(TypeUtils.getArrayComponentType(types[0]));
Assert.assertNull(TypeUtils.getArrayComponentType(types[1]));
@@ -657,8 +657,8 @@ public class TypeUtilsTest<B> {
@Test
public void testLang820() throws Exception {
- Type[] typeArray = {String.class, String.class};
- Type[] expectedArray = {String.class};
+ final Type[] typeArray = {String.class, String.class};
+ final Type[] expectedArray = {String.class};
Assert.assertArrayEquals(expectedArray, TypeUtils.normalizeUpperBounds(typeArray));
}
diff --git a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
index b8b13036c..c4329d320 100644
--- a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
@@ -36,7 +36,7 @@ public class CompositeFormatTest {
@Test
public void testCompositeFormat() {
- Format parser = new Format() {
+ final Format parser = new Format() {
@Override
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
throw new UnsupportedOperationException("Not implemented");
@@ -48,7 +48,7 @@ public class CompositeFormatTest {
}
};
- Format formatter = new Format() {
+ final Format formatter = new Format() {
@Override
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
return null; // do nothing
@@ -60,7 +60,7 @@ public class CompositeFormatTest {
}
};
- CompositeFormat composite = new CompositeFormat(parser, formatter);
+ final CompositeFormat composite = new CompositeFormat(parser, formatter);
composite.parseObject("", null);
composite.format(new Object(), new StringBuffer(), null);
@@ -70,10 +70,10 @@ public class CompositeFormatTest {
@Test
public void testUsage() throws Exception {
- Format f1 = new SimpleDateFormat("MMddyyyy", Locale.ENGLISH);
- Format f2 = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
- CompositeFormat c = new CompositeFormat(f1, f2);
- String testString = "January 3, 2005";
+ final Format f1 = new SimpleDateFormat("MMddyyyy", Locale.ENGLISH);
+ final Format f2 = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
+ final CompositeFormat c = new CompositeFormat(f1, f2);
+ final String testString = "January 3, 2005";
assertEquals(testString, c.format(c.parseObject("01032005")));
assertEquals(testString, c.reformat("01032005"));
}
diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
index 5b519767b..aa9845a75 100644
--- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
@@ -59,8 +59,8 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testExtendedFormats() {
- String pattern = "Lower: {0,lower} Upper: {1,upper}";
- ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
+ final String pattern = "Lower: {0,lower} Upper: {1,upper}";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
assertPatternsEqual("TOPATTERN", pattern, emf.toPattern());
assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"foo", "bar"}));
assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"Foo", "Bar"}));
@@ -74,8 +74,8 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testEscapedQuote_LANG_477() {
- String pattern = "it''s a {0,lower} 'test'!";
- ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
+ final String pattern = "it''s a {0,lower} 'test'!";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
assertEquals("it's a dummy test!", emf.format(new Object[] {"DUMMY"}));
}
@@ -84,21 +84,21 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testExtendedAndBuiltInFormats() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23, 18, 33, 05);
- Object[] args = new Object[] {"John Doe", cal.getTime(), Double.valueOf("12345.67")};
- String builtinsPattern = "DOB: {1,date,short} Salary: {2,number,currency}";
- String extendedPattern = "Name: {0,upper} ";
- String pattern = extendedPattern + builtinsPattern;
+ final Object[] args = new Object[] {"John Doe", cal.getTime(), Double.valueOf("12345.67")};
+ final String builtinsPattern = "DOB: {1,date,short} Salary: {2,number,currency}";
+ final String extendedPattern = "Name: {0,upper} ";
+ final String pattern = extendedPattern + builtinsPattern;
- HashSet<Locale> testLocales = new HashSet<Locale>();
+ final HashSet<Locale> testLocales = new HashSet<Locale>();
testLocales.addAll(Arrays.asList(DateFormat.getAvailableLocales()));
testLocales.retainAll(Arrays.asList(NumberFormat.getAvailableLocales()));
testLocales.add(null);
- for (Locale locale : testLocales) {
- MessageFormat builtins = createMessageFormat(builtinsPattern, locale);
- String expectedPattern = extendedPattern + builtins.toPattern();
+ for (final Locale locale : testLocales) {
+ final MessageFormat builtins = createMessageFormat(builtinsPattern, locale);
+ final String expectedPattern = extendedPattern + builtins.toPattern();
DateFormat df = null;
NumberFormat nf = null;
ExtendedMessageFormat emf = null;
@@ -111,7 +111,7 @@ public class ExtendedMessageFormatTest {
nf = NumberFormat.getCurrencyInstance(locale);
emf = new ExtendedMessageFormat(pattern, locale, registry);
}
- StringBuilder expected = new StringBuilder();
+ final StringBuilder expected = new StringBuilder();
expected.append("Name: ");
expected.append(args[0].toString().toUpperCase());
expected.append(" DOB: ");
@@ -183,17 +183,17 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testBuiltInChoiceFormat() {
- Object[] values = new Number[] {Integer.valueOf(1), Double.valueOf("2.2"), Double.valueOf("1234.5")};
+ final Object[] values = new Number[] {Integer.valueOf(1), Double.valueOf("2.2"), Double.valueOf("1234.5")};
String choicePattern = null;
- Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
+ final Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
choicePattern = "{0,choice,1#One|2#Two|3#Many {0,number}}";
- for (Object value : values) {
+ for (final Object value : values) {
checkBuiltInFormat(value + ": " + choicePattern, new Object[] {value}, availableLocales);
}
choicePattern = "{0,choice,1#''One''|2#\"Two\"|3#''{Many}'' {0,number}}";
- for (Object value : values) {
+ for (final Object value : values) {
checkBuiltInFormat(value + ": " + choicePattern, new Object[] {value}, availableLocales);
}
}
@@ -203,10 +203,10 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testBuiltInDateTimeFormat() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23, 18, 33, 05);
- Object[] args = new Object[] {cal.getTime()};
- Locale[] availableLocales = DateFormat.getAvailableLocales();
+ final Object[] args = new Object[] {cal.getTime()};
+ final Locale[] availableLocales = DateFormat.getAvailableLocales();
checkBuiltInFormat("1: {0,date,short}", args, availableLocales);
checkBuiltInFormat("2: {0,date,medium}", args, availableLocales);
@@ -224,11 +224,11 @@ public class ExtendedMessageFormatTest {
@Test
public void testOverriddenBuiltinFormat() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23);
- Object[] args = new Object[] {cal.getTime()};
- Locale[] availableLocales = DateFormat.getAvailableLocales();
- Map<String, ? extends FormatFactory> registry = Collections.singletonMap("date", new OverrideShortDateFormatFactory());
+ final Object[] args = new Object[] {cal.getTime()};
+ final Locale[] availableLocales = DateFormat.getAvailableLocales();
+ final Map<String, ? extends FormatFactory> registry = Collections.singletonMap("date", new OverrideShortDateFormatFactory());
//check the non-overridden builtins:
checkBuiltInFormat("1: {0,date}", registry, args, availableLocales);
@@ -239,10 +239,10 @@ public class ExtendedMessageFormatTest {
//check the overridden format:
for (int i = -1; i < availableLocales.length; i++) {
- Locale locale = i < 0 ? null : availableLocales[i];
- MessageFormat dateDefault = createMessageFormat("{0,date}", locale);
- String pattern = "{0,date,short}";
- ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, registry);
+ final Locale locale = i < 0 ? null : availableLocales[i];
+ final MessageFormat dateDefault = createMessageFormat("{0,date}", locale);
+ final String pattern = "{0,date,short}";
+ final ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, registry);
assertEquals("overridden date,short format", dateDefault.format(args), dateShort.format(args));
assertEquals("overridden date,short pattern", pattern, dateShort.toPattern());
}
@@ -253,8 +253,8 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testBuiltInNumberFormat() {
- Object[] args = new Object[] {Double.valueOf("6543.21")};
- Locale[] availableLocales = NumberFormat.getAvailableLocales();
+ final Object[] args = new Object[] {Double.valueOf("6543.21")};
+ final Locale[] availableLocales = NumberFormat.getAvailableLocales();
checkBuiltInFormat("1: {0,number}", args, availableLocales);
checkBuiltInFormat("2: {0,number,integer}", args, availableLocales);
checkBuiltInFormat("3: {0,number,currency}", args, availableLocales);
@@ -267,11 +267,11 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testEqualsHashcode() {
- Map<String, ? extends FormatFactory> registry = Collections.singletonMap("testfmt", new LowerCaseFormatFactory());
- Map<String, ? extends FormatFactory> otherRegitry = Collections.singletonMap("testfmt", new UpperCaseFormatFactory());
+ final Map<String, ? extends FormatFactory> registry = Collections.singletonMap("testfmt", new LowerCaseFormatFactory());
+ final Map<String, ? extends FormatFactory> otherRegitry = Collections.singletonMap("testfmt", new UpperCaseFormatFactory());
- String pattern = "Pattern: {0,testfmt}";
- ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, Locale.US, registry);
+ final String pattern = "Pattern: {0,testfmt}";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, Locale.US, registry);
ExtendedMessageFormat other = null;
@@ -324,7 +324,7 @@ public class ExtendedMessageFormatTest {
*/
private void checkBuiltInFormat(final String pattern, final Map<String, ?> registry, final Object[] args, final Locale[] locales) {
checkBuiltInFormat(pattern, registry, args, (Locale) null);
- for (Locale locale : locales) {
+ for (final Locale locale : locales) {
checkBuiltInFormat(pattern, registry, args, locale);
}
}
@@ -338,13 +338,13 @@ public class ExtendedMessageFormatTest {
* @param locale Locale
*/
private void checkBuiltInFormat(final String pattern, final Map<String, ?> registry, final Object[] args, final Locale locale) {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
buffer.append("Pattern=[");
buffer.append(pattern);
buffer.append("], locale=[");
buffer.append(locale);
buffer.append("]");
- MessageFormat mf = createMessageFormat(pattern, locale);
+ final MessageFormat mf = createMessageFormat(pattern, locale);
// System.out.println(buffer + ", result=[" + mf.format(args) +"]");
ExtendedMessageFormat emf = null;
if (locale == null) {
@@ -370,7 +370,7 @@ public class ExtendedMessageFormatTest {
* @return MessageFormat
*/
private MessageFormat createMessageFormat(final String pattern, final Locale locale) {
- MessageFormat result = new MessageFormat(pattern);
+ final MessageFormat result = new MessageFormat(pattern);
if (locale != null) {
result.setLocale(locale);
result.applyPattern(pattern);
diff --git a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
index 94919cc2e..bb847427a 100644
--- a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
@@ -46,7 +46,7 @@ public class FormattableUtilsTest {
@Test
public void testAlternatePadCharacter() {
- char pad='_';
+ final char pad='_';
assertEquals("foo", FormattableUtils.append("foo", new Formatter(), 0, -1, -1, pad).toString());
assertEquals("fo", FormattableUtils.append("foo", new Formatter(), 0, -1, 2, pad).toString());
assertEquals("_foo", FormattableUtils.append("foo", new Formatter(), 0, 4, -1, pad).toString());
diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
index d1162a623..37f452bf5 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
@@ -59,7 +59,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.setNullText("NULL");
assertEquals("", sb.toString());
@@ -91,7 +91,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppend_Object() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendNull();
assertEquals("", sb.toString());
@@ -167,42 +167,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append("bar", -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -230,42 +230,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new StringBuilder("bar"), -1, 1);
fail("append(StringBuilder, -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 3, 1);
fail("append(StringBuilder, 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 1, -1);
fail("append(StringBuilder,, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 1, 3);
fail("append(StringBuilder, 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), -1, 3);
fail("append(StringBuilder, -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 4, 0);
fail("append(StringBuilder, 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -311,42 +311,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new StringBuffer("bar"), -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -389,42 +389,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new StrBuilder("bar"), -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -464,42 +464,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new char[]{'b', 'a', 'r'}, -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -513,7 +513,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppend_Boolean() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append(true);
assertEquals("true", sb.toString());
@@ -527,7 +527,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppend_PrimitiveNumber() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append(0);
assertEquals("0", sb.toString());
@@ -545,7 +545,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_FormattedString() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final String str) {
count[0]++;
@@ -566,7 +566,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendln_Object() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendln((Object) null);
assertEquals("" + SEP, sb.toString());
@@ -581,7 +581,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_String() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final String str) {
count[0]++;
@@ -603,7 +603,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_String_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final String str, final int startIndex, final int length) {
count[0]++;
@@ -625,7 +625,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuffer() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuffer str) {
count[0]++;
@@ -647,7 +647,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuilder() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuilder str) {
count[0]++;
@@ -669,7 +669,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuffer_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuffer str, final int startIndex, final int length) {
count[0]++;
@@ -691,7 +691,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuilder_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuilder str, final int startIndex, final int length) {
count[0]++;
@@ -713,7 +713,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StrBuilder() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StrBuilder str) {
count[0]++;
@@ -735,7 +735,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StrBuilder_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StrBuilder str, final int startIndex, final int length) {
count[0]++;
@@ -757,7 +757,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_CharArray() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final char[] str) {
count[0]++;
@@ -779,7 +779,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_CharArray_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final char[] str, final int startIndex, final int length) {
count[0]++;
@@ -800,7 +800,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendln_Boolean() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendln(true);
assertEquals("true" + SEP, sb.toString());
@@ -812,7 +812,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendln_PrimitiveNumber() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendln(0);
assertEquals("0" + SEP, sb.toString());
@@ -832,7 +832,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendPadding() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("foo");
assertEquals("foo", sb.toString());
@@ -854,7 +854,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadLeft() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadLeft("foo", -1, '-');
assertEquals("", sb.toString());
@@ -893,7 +893,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadLeft_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadLeft(123, -1, '-');
assertEquals("", sb.toString());
@@ -927,7 +927,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadRight() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadRight("foo", -1, '-');
assertEquals("", sb.toString());
@@ -966,7 +966,7 @@ public class StrBuilderAppendInsertTest {
// See: http://issues.apache.org/jira/browse/LANG-299
@Test
public void testLang299() {
- StrBuilder sb = new StrBuilder(1);
+ final StrBuilder sb = new StrBuilder(1);
sb.appendFixedWidthPadRight("foo", 1, '-');
assertEquals("f", sb.toString());
}
@@ -974,7 +974,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadRight_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadRight(123, -1, '-');
assertEquals("", sb.toString());
@@ -1030,7 +1030,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendAll_Array() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendAll((Object[]) null);
assertEquals("", sb.toString());
@@ -1050,7 +1050,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendAll_Collection() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendAll((Collection<?>) null);
assertEquals("", sb.toString());
@@ -1066,7 +1066,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendAll_Iterator() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendAll((Iterator<?>) null);
assertEquals("", sb.toString());
@@ -1082,7 +1082,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparators_Array() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendWithSeparators((Object[]) null, ",");
assertEquals("", sb.toString());
@@ -1106,7 +1106,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparators_Collection() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendWithSeparators((Collection<?>) null, ",");
assertEquals("", sb.toString());
@@ -1130,7 +1130,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparators_Iterator() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendWithSeparators((Iterator<?>) null, ",");
assertEquals("", sb.toString());
@@ -1154,7 +1154,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparatorsWithNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.setNullText("null");
sb.appendWithSeparators(new Object[]{"foo", null, "baz"}, ",");
assertEquals("foo,null,baz", sb.toString());
@@ -1167,7 +1167,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_String() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(","); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1179,7 +1179,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_String_String() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
final String startSeparator = "order by ";
final String standardSeparator = ",";
final String foo = "foo";
@@ -1202,7 +1202,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_char() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(','); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1212,7 +1212,7 @@ public class StrBuilderAppendInsertTest {
}
@Test
public void testAppendSeparator_char_char() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
final char startSeparator = ':';
final char standardSeparator = ',';
final String foo = "foo";
@@ -1227,7 +1227,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_String_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(",", 0); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1242,7 +1242,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_char_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(',', 0); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1258,21 +1258,21 @@ public class StrBuilderAppendInsertTest {
@Test
public void testInsert() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("barbaz");
assertEquals("barbaz", sb.toString());
try {
sb.insert(-1, FOO);
fail("insert(-1, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, FOO);
fail("insert(7, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1289,14 +1289,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, "foo");
fail("insert(-1, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, "foo");
fail("insert(7, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1313,14 +1313,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, new char[]{'f', 'o', 'o'});
fail("insert(-1, char[]) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, new char[]{'f', 'o', 'o'});
fail("insert(7, char[]) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1340,14 +1340,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 3, 3);
fail("insert(-1, char[], 3, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 3, 3);
fail("insert(7, char[], 3, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1360,28 +1360,28 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, -1, 3);
fail("insert(0, char[], -1, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 10, 3);
fail("insert(0, char[], 10, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 0, -1);
fail("insert(0, char[], 0, -1) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 0, 10);
fail("insert(0, char[], 0, 10) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1398,14 +1398,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, true);
fail("insert(-1, boolean) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, true);
fail("insert(7, boolean) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1422,14 +1422,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, '!');
fail("insert(-1, char) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, '!');
fail("insert(7, char) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1443,14 +1443,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 0);
fail("insert(-1, int) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 0);
fail("insert(7, int) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1464,14 +1464,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 1L);
fail("insert(-1, long) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 1L);
fail("insert(7, long) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1485,14 +1485,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 2.3F);
fail("insert(-1, float) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 2.3F);
fail("insert(7, float) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1506,14 +1506,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 4.5D);
fail("insert(-1, double) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 4.5D);
fail("insert(7, double) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1524,7 +1524,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testInsertWithNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.setNullText("null");
sb.append("barbaz");
assertEquals("barbaz", sb.toString());
@@ -1532,14 +1532,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, FOO);
fail("insert(-1, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, FOO);
fail("insert(7, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1556,14 +1556,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, "foo");
fail("insert(-1, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, "foo");
fail("insert(7, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
index 64fdfb0f8..c5fdfdc11 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
@@ -35,42 +35,42 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testConstructors() {
- StrBuilder sb0 = new StrBuilder();
+ final StrBuilder sb0 = new StrBuilder();
assertEquals(32, sb0.capacity());
assertEquals(0, sb0.length());
assertEquals(0, sb0.size());
- StrBuilder sb1 = new StrBuilder(32);
+ final StrBuilder sb1 = new StrBuilder(32);
assertEquals(32, sb1.capacity());
assertEquals(0, sb1.length());
assertEquals(0, sb1.size());
- StrBuilder sb2 = new StrBuilder(0);
+ final StrBuilder sb2 = new StrBuilder(0);
assertEquals(32, sb2.capacity());
assertEquals(0, sb2.length());
assertEquals(0, sb2.size());
- StrBuilder sb3 = new StrBuilder(-1);
+ final StrBuilder sb3 = new StrBuilder(-1);
assertEquals(32, sb3.capacity());
assertEquals(0, sb3.length());
assertEquals(0, sb3.size());
- StrBuilder sb4 = new StrBuilder(1);
+ final StrBuilder sb4 = new StrBuilder(1);
assertEquals(1, sb4.capacity());
assertEquals(0, sb4.length());
assertEquals(0, sb4.size());
- StrBuilder sb5 = new StrBuilder((String) null);
+ final StrBuilder sb5 = new StrBuilder((String) null);
assertEquals(32, sb5.capacity());
assertEquals(0, sb5.length());
assertEquals(0, sb5.size());
- StrBuilder sb6 = new StrBuilder("");
+ final StrBuilder sb6 = new StrBuilder("");
assertEquals(32, sb6.capacity());
assertEquals(0, sb6.length());
assertEquals(0, sb6.size());
- StrBuilder sb7 = new StrBuilder("foo");
+ final StrBuilder sb7 = new StrBuilder("foo");
assertEquals(35, sb7.capacity());
assertEquals(3, sb7.length());
assertEquals(3, sb7.size());
@@ -79,7 +79,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testChaining() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertSame(sb, sb.setNewLineText(null));
assertSame(sb, sb.setNullText(null));
assertSame(sb, sb.setLength(1));
@@ -94,7 +94,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testGetSetNewLineText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(null, sb.getNewLineText());
sb.setNewLineText("#");
@@ -110,7 +110,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testGetSetNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(null, sb.getNullText());
sb.setNullText("null");
@@ -129,7 +129,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testCapacityAndLength() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(32, sb.capacity());
assertEquals(0, sb.length());
assertEquals(0, sb.size());
@@ -180,7 +180,7 @@ public class StrBuilderTest {
try {
sb.setLength(-1);
fail("setLength(-1) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -214,7 +214,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLength() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(0, sb.length());
sb.append("Hello");
@@ -223,7 +223,7 @@ public class StrBuilderTest {
@Test
public void testSetLength() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("Hello");
sb.setLength(2); // shorten
assertEquals("He", sb.toString());
@@ -235,7 +235,7 @@ public class StrBuilderTest {
try {
sb.setLength(-1);
fail("setLength(-1) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
}
@@ -243,7 +243,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testCapacity() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(sb.buffer.length, sb.capacity());
sb.append("HelloWorldHelloWorldHelloWorldHelloWorld");
@@ -252,7 +252,7 @@ public class StrBuilderTest {
@Test
public void testEnsureCapacity() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.ensureCapacity(2);
assertTrue(sb.capacity() >= 2);
@@ -266,7 +266,7 @@ public class StrBuilderTest {
@Test
public void testMinimizeCapacity() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.minimizeCapacity();
assertEquals(0, sb.capacity());
@@ -278,7 +278,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testSize() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(0, sb.size());
sb.append("Hello");
@@ -287,7 +287,7 @@ public class StrBuilderTest {
@Test
public void testIsEmpty() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertTrue(sb.isEmpty());
sb.append("Hello");
@@ -299,7 +299,7 @@ public class StrBuilderTest {
@Test
public void testClear() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("Hello");
sb.clear();
assertEquals(0, sb.length());
@@ -309,17 +309,17 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testCharAt() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
try {
sb.charAt(0);
fail("charAt(0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.charAt(-1);
fail("charAt(-1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
sb.append("foo");
@@ -329,13 +329,13 @@ public class StrBuilderTest {
try {
sb.charAt(-1);
fail("charAt(-1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.charAt(3);
fail("charAt(3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
}
@@ -343,17 +343,17 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testSetCharAt() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
try {
sb.setCharAt(0, 'f');
fail("setCharAt(0,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.setCharAt(-1, 'f');
fail("setCharAt(-1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
sb.append("foo");
@@ -363,7 +363,7 @@ public class StrBuilderTest {
try {
sb.setCharAt(3, '!');
fail("setCharAt(3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
assertEquals("bar", sb.toString());
@@ -372,20 +372,20 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testDeleteCharAt() {
- StrBuilder sb = new StrBuilder("abc");
+ final StrBuilder sb = new StrBuilder("abc");
sb.deleteCharAt(0);
assertEquals("bc", sb.toString());
try {
sb.deleteCharAt(1000);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
//-----------------------------------------------------------------------
@Test
public void testToCharArray() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, sb.toCharArray());
char[] a = sb.toCharArray();
@@ -400,7 +400,7 @@ public class StrBuilderTest {
@Test
public void testToCharArrayIntInt() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, sb.toCharArray(0, 0));
sb.append("junit");
@@ -422,19 +422,19 @@ public class StrBuilderTest {
try {
sb.toCharArray(-1, 5);
fail("no string index out of bound on -1");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
try {
sb.toCharArray(6, 5);
fail("no string index out of bound on -1");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
}
@Test
public void testGetChars ( ) {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
char[] input = new char[10];
char[] a = sb.getChars(input);
@@ -462,7 +462,7 @@ public class StrBuilderTest {
@Test
public void testGetCharsIntIntCharArrayInt( ) {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("junit");
char[] a = new char[5];
@@ -477,28 +477,28 @@ public class StrBuilderTest {
sb.getChars(-1,0,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(0,-1,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(0,20,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(4,2,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
}
@@ -518,17 +518,17 @@ public class StrBuilderTest {
try {
sb.delete(1, 2);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.delete(-1, 1);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
sb = new StrBuilder("anything");
try {
sb.delete(2, 1);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
//-----------------------------------------------------------------------
@@ -677,23 +677,23 @@ public class StrBuilderTest {
try {
sb.replace(2, 1, "anything");
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
sb = new StrBuilder();
try {
sb.replace(1, 2, "anything");
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.replace(-1, 1, "anything");
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
//-----------------------------------------------------------------------
@Test
public void testReplaceAll_char_char() {
- StrBuilder sb = new StrBuilder("abcbccba");
+ final StrBuilder sb = new StrBuilder("abcbccba");
sb.replaceAll('x', 'y');
assertEquals("abcbccba", sb.toString());
sb.replaceAll('a', 'd');
@@ -709,7 +709,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testReplaceFirst_char_char() {
- StrBuilder sb = new StrBuilder("abcbccba");
+ final StrBuilder sb = new StrBuilder("abcbccba");
sb.replaceFirst('x', 'y');
assertEquals("abcbccba", sb.toString());
sb.replaceFirst('a', 'd');
@@ -947,14 +947,14 @@ public class StrBuilderTest {
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb.length(), -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals("aaxaaaayaa", sb.toString());
sb = new StrBuilder("aaxaaaayaa");
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb.length(), -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals("aaxaaaayaa", sb.toString());
}
@@ -1008,7 +1008,7 @@ public class StrBuilderTest {
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals("aaxaaaayaa", sb.toString());
}
@@ -1046,7 +1046,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testReverse() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals("", sb.reverse().toString());
sb.clear().append(true);
@@ -1057,7 +1057,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testTrim() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals("", sb.reverse().toString());
sb.clear().append(" \u0000 ");
@@ -1079,7 +1079,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testStartsWith() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertFalse(sb.startsWith("a"));
assertFalse(sb.startsWith(null));
assertTrue(sb.startsWith(""));
@@ -1092,7 +1092,7 @@ public class StrBuilderTest {
@Test
public void testEndsWith() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertFalse(sb.endsWith("a"));
assertFalse(sb.endsWith("c"));
assertTrue(sb.endsWith(""));
@@ -1110,30 +1110,30 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testSubSequenceIntInt() {
- StrBuilder sb = new StrBuilder ("hello goodbye");
+ final StrBuilder sb = new StrBuilder ("hello goodbye");
// Start index is negative
try {
sb.subSequence(-1, 5);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// End index is negative
try {
sb.subSequence(2, -1);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// End index greater than length()
try {
sb.subSequence(2, sb.length() + 1);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// Start index greater then end index
try {
sb.subSequence(3, 2);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// Normal cases
assertEquals ("hello", sb.subSequence(0, 5));
@@ -1144,7 +1144,7 @@ public class StrBuilderTest {
@Test
public void testSubstringInt() {
- StrBuilder sb = new StrBuilder ("hello goodbye");
+ final StrBuilder sb = new StrBuilder ("hello goodbye");
assertEquals ("goodbye", sb.substring(6));
assertEquals ("hello goodbye".substring(6), sb.substring(6));
assertEquals ("hello goodbye", sb.substring(0));
@@ -1152,18 +1152,18 @@ public class StrBuilderTest {
try {
sb.substring(-1);
fail ();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.substring(15);
fail ();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
public void testSubstringIntInt() {
- StrBuilder sb = new StrBuilder ("hello goodbye");
+ final StrBuilder sb = new StrBuilder ("hello goodbye");
assertEquals ("hello", sb.substring(0, 5));
assertEquals ("hello goodbye".substring(0, 6), sb.substring(0, 6));
@@ -1175,18 +1175,18 @@ public class StrBuilderTest {
try {
sb.substring(-1, 5);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.substring(15, 20);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
// -----------------------------------------------------------------------
@Test
public void testMidString() {
- StrBuilder sb = new StrBuilder("hello goodbye hello");
+ final StrBuilder sb = new StrBuilder("hello goodbye hello");
assertEquals("goodbye", sb.midString(6, 7));
assertEquals("hello", sb.midString(0, 5));
assertEquals("hello", sb.midString(-5, 5));
@@ -1197,7 +1197,7 @@ public class StrBuilderTest {
@Test
public void testRightString() {
- StrBuilder sb = new StrBuilder("left right");
+ final StrBuilder sb = new StrBuilder("left right");
assertEquals("right", sb.rightString(5));
assertEquals("", sb.rightString(0));
assertEquals("", sb.rightString(-5));
@@ -1206,7 +1206,7 @@ public class StrBuilderTest {
@Test
public void testLeftString() {
- StrBuilder sb = new StrBuilder("left right");
+ final StrBuilder sb = new StrBuilder("left right");
assertEquals("left", sb.leftString(4));
assertEquals("", sb.leftString(0));
assertEquals("", sb.leftString(-5));
@@ -1216,7 +1216,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testContains_char() {
- StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
+ final StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
assertTrue(sb.contains('a'));
assertTrue(sb.contains('o'));
assertTrue(sb.contains('z'));
@@ -1225,7 +1225,7 @@ public class StrBuilderTest {
@Test
public void testContains_String() {
- StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
+ final StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
assertTrue(sb.contains("a"));
assertTrue(sb.contains("pq"));
assertTrue(sb.contains("z"));
@@ -1251,7 +1251,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testIndexOf_char() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals(0, sb.indexOf('a'));
// should work like String#indexOf
@@ -1287,7 +1287,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_char() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals (2, sb.lastIndexOf('a'));
//should work like String#lastIndexOf
@@ -1322,7 +1322,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testIndexOf_String() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals(0, sb.indexOf("a"));
//should work like String#indexOf
@@ -1382,7 +1382,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_String() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals(2, sb.lastIndexOf("a"));
//should work like String#lastIndexOf
@@ -1443,7 +1443,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testIndexOf_StrMatcher() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.indexOf((StrMatcher) null));
assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a')));
@@ -1461,7 +1461,7 @@ public class StrBuilderTest {
@Test
public void testIndexOf_StrMatcher_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.indexOf((StrMatcher) null, 2));
assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 2));
assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 0));
@@ -1501,7 +1501,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_StrMatcher() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.lastIndexOf((StrMatcher) null));
assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a')));
@@ -1519,7 +1519,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_StrMatcher_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.lastIndexOf((StrMatcher) null, 2));
assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 2));
assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 0));
@@ -1575,18 +1575,18 @@ public class StrBuilderTest {
@Test
public void testAsTokenizer() throws Exception {
// from Javadoc
- StrBuilder b = new StrBuilder();
+ final StrBuilder b = new StrBuilder();
b.append("a b ");
- StrTokenizer t = b.asTokenizer();
+ final StrTokenizer t = b.asTokenizer();
- String[] tokens1 = t.getTokenArray();
+ final String[] tokens1 = t.getTokenArray();
assertEquals(2, tokens1.length);
assertEquals("a", tokens1[0]);
assertEquals("b", tokens1[1]);
assertEquals(2, t.size());
b.append("c d ");
- String[] tokens2 = t.getTokenArray();
+ final String[] tokens2 = t.getTokenArray();
assertEquals(2, tokens2.length);
assertEquals("a", tokens2[0]);
assertEquals("b", tokens2[1]);
@@ -1595,7 +1595,7 @@ public class StrBuilderTest {
assertEquals("b", t.next());
t.reset();
- String[] tokens3 = t.getTokenArray();
+ final String[] tokens3 = t.getTokenArray();
assertEquals(4, tokens3.length);
assertEquals("a", tokens3[0]);
assertEquals("b", tokens3[1]);
@@ -1613,10 +1613,10 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testAsReader() throws Exception {
- StrBuilder sb = new StrBuilder("some text");
+ final StrBuilder sb = new StrBuilder("some text");
Reader reader = sb.asReader();
assertTrue(reader.ready());
- char[] buf = new char[40];
+ final char[] buf = new char[40];
assertEquals(9, reader.read(buf));
assertEquals("some text", new String(buf, 0, 9));
@@ -1651,23 +1651,23 @@ public class StrBuilderTest {
try {
reader.read(array, -1, 0);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, 0, -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, 100, 1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, 0, 100);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, Integer.MAX_VALUE, Integer.MAX_VALUE);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals(0, reader.read(array, 0, 0));
assertEquals(0, array[0]);
@@ -1685,8 +1685,8 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testAsWriter() throws Exception {
- StrBuilder sb = new StrBuilder("base");
- Writer writer = sb.asWriter();
+ final StrBuilder sb = new StrBuilder("base");
+ final Writer writer = sb.asWriter();
writer.write('l');
assertEquals("basel", sb.toString());
@@ -1720,8 +1720,8 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testEqualsIgnoreCase() {
- StrBuilder sb1 = new StrBuilder();
- StrBuilder sb2 = new StrBuilder();
+ final StrBuilder sb1 = new StrBuilder();
+ final StrBuilder sb2 = new StrBuilder();
assertTrue(sb1.equalsIgnoreCase(sb1));
assertTrue(sb1.equalsIgnoreCase(sb2));
assertTrue(sb2.equalsIgnoreCase(sb2));
@@ -1744,8 +1744,8 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testEquals() {
- StrBuilder sb1 = new StrBuilder();
- StrBuilder sb2 = new StrBuilder();
+ final StrBuilder sb1 = new StrBuilder();
+ final StrBuilder sb2 = new StrBuilder();
assertTrue(sb1.equals(sb2));
assertTrue(sb1.equals(sb1));
assertTrue(sb2.equals(sb2));
@@ -1770,15 +1770,15 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testHashCode() {
- StrBuilder sb = new StrBuilder();
- int hc1a = sb.hashCode();
- int hc1b = sb.hashCode();
+ final StrBuilder sb = new StrBuilder();
+ final int hc1a = sb.hashCode();
+ final int hc1b = sb.hashCode();
assertEquals(0, hc1a);
assertEquals(hc1a, hc1b);
sb.append("abc");
- int hc2a = sb.hashCode();
- int hc2b = sb.hashCode();
+ final int hc2a = sb.hashCode();
+ final int hc2b = sb.hashCode();
assertTrue(hc2a != 0);
assertEquals(hc2a, hc2b);
}
@@ -1786,14 +1786,14 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testToString() {
- StrBuilder sb = new StrBuilder("abc");
+ final StrBuilder sb = new StrBuilder("abc");
assertEquals("abc", sb.toString());
}
//-----------------------------------------------------------------------
@Test
public void testToStringBuffer() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(new StringBuffer().toString(), sb.toStringBuffer().toString());
sb.append("junit");
@@ -1803,7 +1803,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testToStringBuilder() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(new StringBuilder().toString(), sb.toStringBuilder().toString());
sb.append("junit");
@@ -1813,14 +1813,14 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLang294() {
- StrBuilder sb = new StrBuilder("\n%BLAH%\nDo more stuff\neven more stuff\n%BLAH%\n");
+ final StrBuilder sb = new StrBuilder("\n%BLAH%\nDo more stuff\neven more stuff\n%BLAH%\n");
sb.deleteAll("\n%BLAH%");
assertEquals("\nDo more stuff\neven more stuff\n", sb.toString());
}
@Test
public void testIndexOfLang294() {
- StrBuilder sb = new StrBuilder("onetwothree");
+ final StrBuilder sb = new StrBuilder("onetwothree");
sb.deleteFirst("three");
assertEquals(-1, sb.indexOf("three"));
}
@@ -1828,7 +1828,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLang295() {
- StrBuilder sb = new StrBuilder("onetwothree");
+ final StrBuilder sb = new StrBuilder("onetwothree");
sb.deleteFirst("three");
assertFalse( "The contains(char) method is looking beyond the end of the string", sb.contains('h'));
assertEquals( "The indexOf(char) method is looking beyond the end of the string", -1, sb.indexOf('h'));
@@ -1837,21 +1837,21 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLang412Right() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadRight(null, 10, '*');
assertEquals( "Failed to invoke appendFixedWidthPadRight correctly", "**********", sb.toString());
}
@Test
public void testLang412Left() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadLeft(null, 10, '*');
assertEquals( "Failed to invoke appendFixedWidthPadLeft correctly", "**********", sb.toString());
}
@Test
public void testAsBuilder() {
- StrBuilder sb = new StrBuilder().appendAll("Lorem", " ", "ipsum", " ", "dolor");
+ final StrBuilder sb = new StrBuilder().appendAll("Lorem", " ", "ipsum", " ", "dolor");
assertEquals(sb.toString(), sb.build());
}
diff --git a/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java b/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
index 592e6a9b9..e45a324c8 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
@@ -48,14 +48,14 @@ public class StrLookupTest {
try {
StrLookup.systemPropertiesLookup().lookup(null);
fail();
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
// expected
}
}
@Test
public void testMapLookup() {
- Map<String, Object> map = new HashMap<String, Object>();
+ final Map<String, Object> map = new HashMap<String, Object>();
map.put("key", "value");
map.put("number", Integer.valueOf(2));
assertEquals("value", StrLookup.mapLookup(map).lookup("key"));
@@ -67,7 +67,7 @@ public class StrLookupTest {
@Test
public void testMapLookup_nullMap() {
- Map<String, ?> map = null;
+ final Map<String, ?> map = null;
assertEquals(null, StrLookup.mapLookup(map).lookup(null));
assertEquals(null, StrLookup.mapLookup(map).lookup(""));
assertEquals(null, StrLookup.mapLookup(map).lookup("any"));
diff --git a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
index 0d576dcab..89bc3a741 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
@@ -38,7 +38,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCommaMatcher() {
- StrMatcher matcher = StrMatcher.commaMatcher();
+ final StrMatcher matcher = StrMatcher.commaMatcher();
assertSame(matcher, StrMatcher.commaMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 0));
assertEquals(1, matcher.isMatch(BUFFER1, 1));
@@ -48,7 +48,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testTabMatcher() {
- StrMatcher matcher = StrMatcher.tabMatcher();
+ final StrMatcher matcher = StrMatcher.tabMatcher();
assertSame(matcher, StrMatcher.tabMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 2));
assertEquals(1, matcher.isMatch(BUFFER1, 3));
@@ -58,7 +58,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testSpaceMatcher() {
- StrMatcher matcher = StrMatcher.spaceMatcher();
+ final StrMatcher matcher = StrMatcher.spaceMatcher();
assertSame(matcher, StrMatcher.spaceMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 4));
assertEquals(1, matcher.isMatch(BUFFER1, 5));
@@ -68,7 +68,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testSplitMatcher() {
- StrMatcher matcher = StrMatcher.splitMatcher();
+ final StrMatcher matcher = StrMatcher.splitMatcher();
assertSame(matcher, StrMatcher.splitMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 2));
assertEquals(1, matcher.isMatch(BUFFER1, 3));
@@ -84,7 +84,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testTrimMatcher() {
- StrMatcher matcher = StrMatcher.trimMatcher();
+ final StrMatcher matcher = StrMatcher.trimMatcher();
assertSame(matcher, StrMatcher.trimMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 2));
assertEquals(1, matcher.isMatch(BUFFER1, 3));
@@ -100,7 +100,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testSingleQuoteMatcher() {
- StrMatcher matcher = StrMatcher.singleQuoteMatcher();
+ final StrMatcher matcher = StrMatcher.singleQuoteMatcher();
assertSame(matcher, StrMatcher.singleQuoteMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 10));
assertEquals(1, matcher.isMatch(BUFFER1, 11));
@@ -110,7 +110,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testDoubleQuoteMatcher() {
- StrMatcher matcher = StrMatcher.doubleQuoteMatcher();
+ final StrMatcher matcher = StrMatcher.doubleQuoteMatcher();
assertSame(matcher, StrMatcher.doubleQuoteMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 11));
assertEquals(1, matcher.isMatch(BUFFER1, 12));
@@ -119,7 +119,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testQuoteMatcher() {
- StrMatcher matcher = StrMatcher.quoteMatcher();
+ final StrMatcher matcher = StrMatcher.quoteMatcher();
assertSame(matcher, StrMatcher.quoteMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 10));
assertEquals(1, matcher.isMatch(BUFFER1, 11));
@@ -129,7 +129,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testNoneMatcher() {
- StrMatcher matcher = StrMatcher.noneMatcher();
+ final StrMatcher matcher = StrMatcher.noneMatcher();
assertSame(matcher, StrMatcher.noneMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 0));
assertEquals(0, matcher.isMatch(BUFFER1, 1));
@@ -149,7 +149,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCharMatcher_char() {
- StrMatcher matcher = StrMatcher.charMatcher('c');
+ final StrMatcher matcher = StrMatcher.charMatcher('c');
assertEquals(0, matcher.isMatch(BUFFER2, 0));
assertEquals(0, matcher.isMatch(BUFFER2, 1));
assertEquals(1, matcher.isMatch(BUFFER2, 2));
@@ -161,7 +161,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCharSetMatcher_String() {
- StrMatcher matcher = StrMatcher.charSetMatcher("ace");
+ final StrMatcher matcher = StrMatcher.charSetMatcher("ace");
assertEquals(1, matcher.isMatch(BUFFER2, 0));
assertEquals(0, matcher.isMatch(BUFFER2, 1));
assertEquals(1, matcher.isMatch(BUFFER2, 2));
@@ -176,7 +176,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCharSetMatcher_charArray() {
- StrMatcher matcher = StrMatcher.charSetMatcher("ace".toCharArray());
+ final StrMatcher matcher = StrMatcher.charSetMatcher("ace".toCharArray());
assertEquals(1, matcher.isMatch(BUFFER2, 0));
assertEquals(0, matcher.isMatch(BUFFER2, 1));
assertEquals(1, matcher.isMatch(BUFFER2, 2));
@@ -191,7 +191,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testStringMatcher_String() {
- StrMatcher matcher = StrMatcher.stringMatcher("bc");
+ final StrMatcher matcher = StrMatcher.stringMatcher("bc");
assertEquals(0, matcher.isMatch(BUFFER2, 0));
assertEquals(2, matcher.isMatch(BUFFER2, 1));
assertEquals(0, matcher.isMatch(BUFFER2, 2));
@@ -208,7 +208,7 @@ public class StrMatcherTest {
// remember that the API contract is tight for the isMatch() method
// all the onus is on the caller, so invalid inputs are not
// the concern of StrMatcher, and are not bugs
- StrMatcher matcher = StrMatcher.stringMatcher("bc");
+ final StrMatcher matcher = StrMatcher.stringMatcher("bc");
assertEquals(2, matcher.isMatch(BUFFER2, 1, 1, BUFFER2.length));
assertEquals(2, matcher.isMatch(BUFFER2, 1, 0, 3));
assertEquals(0, matcher.isMatch(BUFFER2, 1, 0, 2));
diff --git a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
index ee2612160..013cc83c6 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
@@ -94,7 +94,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testReplaceChangedMap() {
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
values.put("target", "moon");
assertEquals("The quick brown fox jumps over the moon.", sub.replace("The ${animal} jumps over the ${target}."));
}
@@ -114,7 +114,7 @@ public class StrSubstitutorTest {
public void testReplaceAdjacentAtStart() {
values.put("code", "GBP");
values.put("amount", "12.50");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
assertEquals("GBP12.50 charged", sub.replace("${code}${amount} charged"));
}
@@ -125,7 +125,7 @@ public class StrSubstitutorTest {
public void testReplaceAdjacentAtEnd() {
values.put("code", "GBP");
values.put("amount", "12.50");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
assertEquals("Amount is GBP12.50", sub.replace("Amount is ${code}${amount}"));
}
@@ -225,7 +225,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testCyclicReplacement() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("animal", "${critter}");
map.put("target", "${pet}");
map.put("pet", "${petCharacteristic} dog");
@@ -234,11 +234,11 @@ public class StrSubstitutorTest {
map.put("critterSpeed", "quick");
map.put("critterColor", "brown");
map.put("critterType", "${animal}");
- StrSubstitutor sub = new StrSubstitutor(map);
+ final StrSubstitutor sub = new StrSubstitutor(map);
try {
sub.replace("The ${animal} jumps over the ${target}.");
fail("Cyclic replacement was not detected!");
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
// expected
}
}
@@ -272,7 +272,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testReplacePartialString_noReplace() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertEquals("${animal} jumps", sub.replace("The ${animal} jumps over the ${target}.", 4, 15));
}
@@ -284,7 +284,7 @@ public class StrSubstitutorTest {
values.put("animal.1", "fox");
values.put("animal.2", "mouse");
values.put("species", "2");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
sub.setEnableSubstitutionInVariables(true);
assertEquals(
"Wrong result (1)",
@@ -305,7 +305,7 @@ public class StrSubstitutorTest {
values.put("animal.1", "fox");
values.put("animal.2", "mouse");
values.put("species", "2");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
assertEquals(
"Wrong result",
"The ${animal.${species}} jumps over the lazy dog.",
@@ -322,7 +322,7 @@ public class StrSubstitutorTest {
values.put("color", "white");
values.put("species.white", "1");
values.put("species.brown", "2");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
sub.setEnableSubstitutionInVariables(true);
assertEquals(
"Wrong result",
@@ -337,9 +337,9 @@ public class StrSubstitutorTest {
@Test
public void testResolveVariable() {
final StrBuilder builder = new StrBuilder("Hi ${name}!");
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
- StrSubstitutor sub = new StrSubstitutor(map) {
+ final StrSubstitutor sub = new StrSubstitutor(map) {
@Override
protected String resolveVariable(final String variableName, final StrBuilder buf, final int startPos, final int endPos) {
assertEquals("name", variableName);
@@ -359,7 +359,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testConstructorNoArgs() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertEquals("Hi ${name}", sub.replace("Hi ${name}"));
}
@@ -368,9 +368,9 @@ public class StrSubstitutorTest {
*/
@Test
public void testConstructorMapPrefixSuffix() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
- StrSubstitutor sub = new StrSubstitutor(map, "<", ">");
+ final StrSubstitutor sub = new StrSubstitutor(map, "<", ">");
assertEquals("Hi < commons", sub.replace("Hi $< <name>"));
}
@@ -379,9 +379,9 @@ public class StrSubstitutorTest {
*/
@Test
public void testConstructorMapFull() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
- StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!');
+ final StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!');
assertEquals("Hi < commons", sub.replace("Hi !< <name>"));
}
@@ -391,7 +391,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testGetSetEscape() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertEquals('$', sub.getEscapeChar());
sub.setEscapeChar('<');
assertEquals('<', sub.getEscapeChar());
@@ -402,7 +402,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testGetSetPrefix() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher);
sub.setVariablePrefix('<');
assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.CharMatcher);
@@ -412,18 +412,18 @@ public class StrSubstitutorTest {
try {
sub.setVariablePrefix((String) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher);
- StrMatcher matcher = StrMatcher.commaMatcher();
+ final StrMatcher matcher = StrMatcher.commaMatcher();
sub.setVariablePrefixMatcher(matcher);
assertSame(matcher, sub.getVariablePrefixMatcher());
try {
sub.setVariablePrefixMatcher((StrMatcher) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertSame(matcher, sub.getVariablePrefixMatcher());
@@ -434,7 +434,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testGetSetSuffix() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertTrue(sub.getVariableSuffixMatcher() instanceof StrMatcher.StringMatcher);
sub.setVariableSuffix('<');
assertTrue(sub.getVariableSuffixMatcher() instanceof StrMatcher.CharMatcher);
@@ -444,18 +444,18 @@ public class StrSubstitutorTest {
try {
sub.setVariableSuffix((String) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertTrue(sub.getVariableSuffixMatcher() instanceof StrMatcher.StringMatcher);
- StrMatcher matcher = StrMatcher.commaMatcher();
+ final StrMatcher matcher = StrMatcher.commaMatcher();
sub.setVariableSuffixMatcher(matcher);
assertSame(matcher, sub.getVariableSuffixMatcher());
try {
sub.setVariableSuffixMatcher((StrMatcher) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertSame(matcher, sub.getVariableSuffixMatcher());
@@ -467,7 +467,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testStaticReplace() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
assertEquals("Hi commons!", StrSubstitutor.replace("Hi ${name}!", map));
}
@@ -477,7 +477,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testStaticReplacePrefixSuffix() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
assertEquals("Hi commons!", StrSubstitutor.replace("Hi <name>!", map, "<", ">"));
}
@@ -487,7 +487,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testStaticReplaceSystemProperties() {
- StrBuilder buf = new StrBuilder();
+ final StrBuilder buf = new StrBuilder();
buf.append("Hi ").append(System.getProperty("user.name"));
buf.append(", you are working with ");
buf.append(System.getProperty("os.name"));
@@ -503,18 +503,18 @@ public class StrSubstitutorTest {
*/
@Test
public void testSubstituteDefaultProperties(){
- String org = "${doesnotwork}";
+ final String org = "${doesnotwork}";
System.setProperty("doesnotwork", "It works!");
// create a new Properties object with the System.getProperties as default
- Properties props = new Properties(System.getProperties());
+ final Properties props = new Properties(System.getProperties());
assertEquals("It works!", StrSubstitutor.replace(org, props));
}
@Test
public void testSamePrefixAndSuffix() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("greeting", "Hello");
map.put(" there ", "XXX");
map.put("name", "commons");
@@ -524,8 +524,8 @@ public class StrSubstitutorTest {
//-----------------------------------------------------------------------
private void doTestReplace(final String expectedResult, final String replaceTemplate, final boolean substring) {
- String expectedShortResult = expectedResult.substring(1, expectedResult.length() - 1);
- StrSubstitutor sub = new StrSubstitutor(values);
+ final String expectedShortResult = expectedResult.substring(1, expectedResult.length() - 1);
+ final StrSubstitutor sub = new StrSubstitutor(values);
// replace using String
assertEquals(expectedResult, sub.replace(replaceTemplate));
@@ -534,7 +534,7 @@ public class StrSubstitutorTest {
}
// replace using char[]
- char[] chars = replaceTemplate.toCharArray();
+ final char[] chars = replaceTemplate.toCharArray();
assertEquals(expectedResult, sub.replace(chars));
if (substring) {
assertEquals(expectedShortResult, sub.replace(chars, 1, chars.length - 2));
@@ -555,7 +555,7 @@ public class StrSubstitutorTest {
}
// replace using object
- MutableObject<String> obj = new MutableObject<String>(replaceTemplate); // toString returns template
+ final MutableObject<String> obj = new MutableObject<String>(replaceTemplate); // toString returns template
assertEquals(expectedResult, sub.replace(obj));
// replace in StringBuffer
@@ -580,7 +580,7 @@ public class StrSubstitutorTest {
}
private void doTestNoReplace(final String replaceTemplate) {
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
if (replaceTemplate == null) {
assertEquals(null, sub.replace((String) null));
@@ -598,7 +598,7 @@ public class StrSubstitutorTest {
assertFalse(sub.replaceIn((StrBuilder) null, 0, 100));
} else {
assertEquals(replaceTemplate, sub.replace(replaceTemplate));
- StrBuilder bld = new StrBuilder(replaceTemplate);
+ final StrBuilder bld = new StrBuilder(replaceTemplate);
assertFalse(sub.replaceIn(bld));
assertEquals(replaceTemplate, bld.toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
index 969c2337b..8bf434bf3 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
@@ -46,15 +46,15 @@ public class StrTokenizerTest {
@Test
public void test1() {
- String input = "a;b;c;\"d;\"\"e\";f; ; ; ";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b;c;\"d;\"\"e\";f; ; ; ";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",};
+ final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -67,15 +67,15 @@ public class StrTokenizerTest {
@Test
public void test2() {
- String input = "a;b;c ;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b;c ;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",};
+ final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -88,15 +88,15 @@ public class StrTokenizerTest {
@Test
public void test3() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",};
+ final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -109,15 +109,15 @@ public class StrTokenizerTest {
@Test
public void test4() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",};
+ final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -130,16 +130,16 @@ public class StrTokenizerTest {
@Test
public void test5() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- 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(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -152,16 +152,16 @@ public class StrTokenizerTest {
@Test
public void test6() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
// tok.setTreatingEmptyAsNull(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- 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()) {
@@ -188,15 +188,15 @@ public class StrTokenizerTest {
@Test
public void test7() {
- String input = "a b c \"d e\" f ";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c \"d e\" f ";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterMatcher(StrMatcher.spaceMatcher());
tok.setQuoteMatcher(StrMatcher.doubleQuoteMatcher());
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",};
+ final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -209,15 +209,15 @@ public class StrTokenizerTest {
@Test
public void test8() {
- String input = "a b c \"d e\" f ";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c \"d e\" f ";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterMatcher(StrMatcher.spaceMatcher());
tok.setQuoteMatcher(StrMatcher.doubleQuoteMatcher());
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d e", "f",};
+ final String expected[] = new String[]{"a", "b", "c", "d e", "f",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -229,8 +229,8 @@ public class StrTokenizerTest {
@Test
public void testBasic1() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -239,8 +239,8 @@ public class StrTokenizerTest {
@Test
public void testBasic2() {
- String input = "a \nb\fc";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a \nb\fc";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -249,8 +249,8 @@ public class StrTokenizerTest {
@Test
public void testBasic3() {
- String input = "a \nb\u0001\fc";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a \nb\u0001\fc";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("b\u0001", tok.next());
assertEquals("c", tok.next());
@@ -259,8 +259,8 @@ public class StrTokenizerTest {
@Test
public void testBasic4() {
- String input = "a \"b\" c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a \"b\" c";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("\"b\"", tok.next());
assertEquals("c", tok.next());
@@ -269,8 +269,8 @@ public class StrTokenizerTest {
@Test
public void testBasic5() {
- String input = "a:b':c";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a:b':c";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
assertEquals("a", tok.next());
assertEquals("b'", tok.next());
assertEquals("c", tok.next());
@@ -279,8 +279,8 @@ public class StrTokenizerTest {
@Test
public void testBasicDelim1() {
- String input = "a:b:c";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a:b:c";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -289,16 +289,16 @@ public class StrTokenizerTest {
@Test
public void testBasicDelim2() {
- String input = "a:b:c";
- StrTokenizer tok = new StrTokenizer(input, ',');
+ final String input = "a:b:c";
+ final StrTokenizer tok = new StrTokenizer(input, ',');
assertEquals("a:b:c", tok.next());
assertFalse(tok.hasNext());
}
@Test
public void testBasicEmpty1() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setIgnoreEmptyTokens(false);
assertEquals("a", tok.next());
assertEquals("", tok.next());
@@ -309,8 +309,8 @@ public class StrTokenizerTest {
@Test
public void testBasicEmpty2() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
assertEquals("a", tok.next());
@@ -322,8 +322,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted1() {
- String input = "a 'b' c";
- StrTokenizer tok = new StrTokenizer(input, ' ', '\'');
+ final String input = "a 'b' c";
+ final StrTokenizer tok = new StrTokenizer(input, ' ', '\'');
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -332,8 +332,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted2() {
- String input = "a:'b':";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a:'b':";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
assertEquals("a", tok.next());
@@ -344,8 +344,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted3() {
- String input = "a:'b''c'";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a:'b''c'";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
assertEquals("a", tok.next());
@@ -355,8 +355,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted4() {
- String input = "a: 'b' 'c' :d";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a: 'b' 'c' :d";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -368,8 +368,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted5() {
- String input = "a: 'b'x'c' :d";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a: 'b'x'c' :d";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -381,8 +381,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted6() {
- String input = "a:'b'\"c':d";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a:'b'\"c':d";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setQuoteMatcher(StrMatcher.quoteMatcher());
assertEquals("a", tok.next());
assertEquals("b\"c:d", tok.next());
@@ -391,8 +391,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted7() {
- String input = "a:\"There's a reason here\":b";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a:\"There's a reason here\":b";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setQuoteMatcher(StrMatcher.quoteMatcher());
assertEquals("a", tok.next());
assertEquals("There's a reason here", tok.next());
@@ -402,8 +402,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuotedTrimmed1() {
- String input = "a: 'b' :";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a: 'b' :";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -415,8 +415,8 @@ public class StrTokenizerTest {
@Test
public void testBasicTrimmed1() {
- String input = "a: b : ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a: b : ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -428,8 +428,8 @@ public class StrTokenizerTest {
@Test
public void testBasicTrimmed2() {
- String input = "a: b :";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a: b :";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setTrimmerMatcher(StrMatcher.stringMatcher(" "));
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -441,8 +441,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed1() {
- String input = "a: bIGNOREc : ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a: bIGNOREc : ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
@@ -455,8 +455,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed2() {
- String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
@@ -469,8 +469,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed3() {
- String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -482,8 +482,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed4() {
- String input = "IGNOREaIGNORE: IGNORE 'bIGNOREc'IGNORE'd' IGNORE : IGNORE ";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "IGNOREaIGNORE: IGNORE 'bIGNOREc'IGNORE'd' IGNORE : IGNORE ";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
@@ -497,10 +497,10 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testListArray() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
- String[] array = tok.getTokenArray();
- List<?> list = tok.getTokenList();
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
+ final String[] array = tok.getTokenArray();
+ final List<?> list = tok.getTokenList();
assertEquals(Arrays.asList(array), list);
assertEquals(3, list.size());
@@ -539,12 +539,12 @@ public class StrTokenizerTest {
try {
tokenizer.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
}
@Test
public void testGetContent() {
- String input = "a b c \"d e\" f ";
+ final String input = "a b c \"d e\" f ";
StrTokenizer tok = new StrTokenizer(input);
assertEquals(input, tok.getContent());
@@ -558,7 +558,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testChaining() {
- StrTokenizer tok = new StrTokenizer();
+ final StrTokenizer tok = new StrTokenizer();
assertEquals(tok, tok.reset());
assertEquals(tok, tok.reset(""));
assertEquals(tok, tok.reset(new char[0]));
@@ -580,7 +580,7 @@ public class StrTokenizerTest {
*/
@Test
public void testCloneNotSupportedException() {
- Object notCloned = new StrTokenizer() {
+ final Object notCloned = new StrTokenizer() {
@Override
Object cloneReset() throws CloneNotSupportedException {
throw new CloneNotSupportedException("test");
@@ -591,13 +591,13 @@ public class StrTokenizerTest {
@Test
public void testCloneNull() {
- StrTokenizer tokenizer = new StrTokenizer((char[]) null);
+ final StrTokenizer tokenizer = new StrTokenizer((char[]) null);
// Start sanity check
assertEquals(null, tokenizer.nextToken());
tokenizer.reset();
assertEquals(null, tokenizer.nextToken());
// End sanity check
- StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
+ final StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
tokenizer.reset();
assertEquals(null, tokenizer.nextToken());
assertEquals(null, clonedTokenizer.nextToken());
@@ -605,14 +605,14 @@ public class StrTokenizerTest {
@Test
public void testCloneReset() {
- char[] input = new char[]{'a'};
- StrTokenizer tokenizer = new StrTokenizer(input);
+ final char[] input = new char[]{'a'};
+ final StrTokenizer tokenizer = new StrTokenizer(input);
// Start sanity check
assertEquals("a", tokenizer.nextToken());
tokenizer.reset(input);
assertEquals("a", tokenizer.nextToken());
// End sanity check
- StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
+ final StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
input[0] = 'b';
tokenizer.reset(input);
assertEquals("b", tokenizer.nextToken());
@@ -718,7 +718,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testReset() {
- StrTokenizer tok = new StrTokenizer("a b c");
+ final StrTokenizer tok = new StrTokenizer("a b c");
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -734,7 +734,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testReset_String() {
- StrTokenizer tok = new StrTokenizer("x x x");
+ final StrTokenizer tok = new StrTokenizer("x x x");
tok.reset("d e");
assertEquals("d", tok.next());
assertEquals("e", tok.next());
@@ -747,9 +747,9 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testReset_charArray() {
- StrTokenizer tok = new StrTokenizer("x x x");
+ final StrTokenizer tok = new StrTokenizer("x x x");
- char[] array = new char[] {'a', 'b', 'c'};
+ final char[] array = new char[] {'a', 'b', 'c'};
tok.reset(array);
assertEquals("abc", tok.next());
assertFalse(tok.hasNext());
@@ -798,27 +798,27 @@ public class StrTokenizerTest {
@Test
public void testIteration() {
- StrTokenizer tkn = new StrTokenizer("a b c");
+ final StrTokenizer tkn = new StrTokenizer("a b c");
assertFalse(tkn.hasPrevious());
try {
tkn.previous();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
assertTrue(tkn.hasNext());
assertEquals("a", tkn.next());
try {
tkn.remove();
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
try {
tkn.set("x");
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
try {
tkn.add("y");
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
assertTrue(tkn.hasPrevious());
assertTrue(tkn.hasNext());
@@ -833,7 +833,7 @@ public class StrTokenizerTest {
try {
tkn.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
assertTrue(tkn.hasPrevious());
assertFalse(tkn.hasNext());
}
@@ -841,7 +841,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testTokenizeSubclassInputChange() {
- StrTokenizer tkn = new StrTokenizer("a b c d e") {
+ final StrTokenizer tkn = new StrTokenizer("a b c d e") {
@Override
protected List<String> tokenize(final char[] chars, final int offset, final int count) {
return super.tokenize("w x y z".toCharArray(), 2, 5);
@@ -854,10 +854,10 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testTokenizeSubclassOutputChange() {
- StrTokenizer tkn = new StrTokenizer("a b c") {
+ final StrTokenizer tkn = new StrTokenizer("a b c") {
@Override
protected List<String> tokenize(final char[] chars, final int offset, final int count) {
- List<String> list = super.tokenize(chars, offset, count);
+ final List<String> list = super.tokenize(chars, offset, count);
Collections.reverse(list);
return list;
}
@@ -870,7 +870,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testToString() {
- StrTokenizer tkn = new StrTokenizer("a b c d e");
+ final StrTokenizer tkn = new StrTokenizer("a b c d e");
assertEquals("StrTokenizer[not tokenized yet]", tkn.toString());
tkn.next();
assertEquals("StrTokenizer[a, b, c, d, e]", tkn.toString());
diff --git a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
index 35806ef46..786f42133 100644
--- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
@@ -37,7 +37,7 @@ public class WordUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new WordUtils());
- Constructor<?>[] cons = WordUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = WordUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(WordUtils.class.getModifiers()));
@@ -54,7 +54,7 @@ public class WordUtilsTest {
assertEquals("", WordUtils.wrap("", -1));
// normal
- String systemNewLine = System.getProperty("line.separator");
+ final String systemNewLine = System.getProperty("line.separator");
String input = "Here is one line of text that is going to be wrapped after 20 columns.";
String expected = "Here is one line of" + systemNewLine + "text that is going"
+ systemNewLine + "to be wrapped after" + systemNewLine + "20 columns.";
@@ -110,7 +110,7 @@ public class WordUtilsTest {
assertEquals(expected, WordUtils.wrap(input, -1, "\n", false));
// system newline char
- String systemNewLine = System.getProperty("line.separator");
+ final String systemNewLine = System.getProperty("line.separator");
input = "Here is one line of text that is going to be wrapped after 20 columns.";
expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine
+ "to be wrapped after" + systemNewLine + "20 columns.";
@@ -360,8 +360,8 @@ public class WordUtilsTest {
assertEquals("I AM here 123", WordUtils.swapCase("i am HERE 123") );
assertEquals("i am here 123", WordUtils.swapCase("I AM HERE 123") );
- String test = "This String contains a TitleCase character: \u01C8";
- String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
+ final String test = "This String contains a TitleCase character: \u01C8";
+ final String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
assertEquals(expect, WordUtils.swapCase(test));
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
index 71c369268..8d3b3fc3c 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
@@ -38,9 +38,9 @@ public class EntityArraysTest {
// LANG-659 - check arrays for duplicate entries
@Test
public void testHTML40_EXTENDED_ESCAPE(){
- Set<String> col0 = new HashSet<String>();
- Set<String> col1 = new HashSet<String>();
- String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
+ final Set<String> col0 = new HashSet<String>();
+ final Set<String> col1 = new HashSet<String>();
+ final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
for(int i =0; i <sa.length; i++){
assertTrue("Already added entry 0: "+i+" "+sa[i][0],col0.add(sa[i][0]));
assertTrue("Already added entry 1: "+i+" "+sa[i][1],col1.add(sa[i][1]));
@@ -50,13 +50,13 @@ public class EntityArraysTest {
// LANG-658 - check arrays for duplicate entries
@Test
public void testISO8859_1_ESCAPE(){
- Set<String> col0 = new HashSet<String>();
- Set<String> col1 = new HashSet<String>();
- String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
+ final Set<String> col0 = new HashSet<String>();
+ final Set<String> col1 = new HashSet<String>();
+ final String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
boolean success = true;
for(int i =0; i <sa.length; i++){
- boolean add0 = col0.add(sa[i][0]);
- boolean add1 = col1.add(sa[i][1]);
+ final boolean add0 = col0.add(sa[i][0]);
+ final boolean add1 = col1.add(sa[i][1]);
if (!add0) {
success = false;
System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]);
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
index 8efb009e2..af4d6843b 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
@@ -32,9 +32,9 @@ public class LookupTranslatorTest {
@Test
public void testBasicLookup() throws IOException {
- LookupTranslator lt = new LookupTranslator(new CharSequence[][] { { "one", "two" } });
- StringWriter out = new StringWriter();
- int result = lt.translate("one", 0, out);
+ final LookupTranslator lt = new LookupTranslator(new CharSequence[][] { { "one", "two" } });
+ final StringWriter out = new StringWriter();
+ final int result = lt.translate("one", 0, out);
assertEquals("Incorrect codepoint consumption", 3, result);
assertEquals("Incorrect value", "two", out.toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
index f3c6dff79..816d8a8d2 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
@@ -29,39 +29,39 @@ public class NumericEntityEscaperTest {
@Test
public void testBelow() {
- NumericEntityEscaper nee = NumericEntityEscaper.below('F');
+ final NumericEntityEscaper nee = NumericEntityEscaper.below('F');
- String input = "ADFGZ";
- String result = nee.translate(input);
+ final String input = "ADFGZ";
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities via the below method", "&#65;&#68;FGZ", result);
}
@Test
public void testBetween() {
- NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L');
+ final NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L');
- String input = "ADFGZ";
- String result = nee.translate(input);
+ final String input = "ADFGZ";
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities via the between method", "AD&#70;&#71;Z", result);
}
@Test
public void testAbove() {
- NumericEntityEscaper nee = NumericEntityEscaper.above('F');
+ final NumericEntityEscaper nee = NumericEntityEscaper.above('F');
- String input = "ADFGZ";
- String result = nee.translate(input);
+ final String input = "ADFGZ";
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities via the above method", "ADF&#71;&#90;", result);
}
// See LANG-617
@Test
public void testSupplementary() {
- NumericEntityEscaper nee = new NumericEntityEscaper();
- String input = "\uD803\uDC22";
- String expected = "&#68642;";
+ final NumericEntityEscaper nee = new NumericEntityEscaper();
+ final String input = "\uD803\uDC22";
+ final String expected = "&#68642;";
- String result = nee.translate(input);
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities supplementary characters", expected, result);
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
index cb80ef67b..4087cb9ed 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
@@ -30,17 +30,17 @@ public class NumericEntityUnescaperTest {
@Test
public void testSupplementaryUnescaping() {
- NumericEntityUnescaper neu = new NumericEntityUnescaper();
- String input = "&#68642;";
- String expected = "\uD803\uDC22";
+ final NumericEntityUnescaper neu = new NumericEntityUnescaper();
+ final String input = "&#68642;";
+ final String expected = "\uD803\uDC22";
- String result = neu.translate(input);
+ final String result = neu.translate(input);
assertEquals("Failed to unescape numeric entities supplementary characters", expected, result);
}
@Test
public void testOutOfBounds() {
- NumericEntityUnescaper neu = new NumericEntityUnescaper();
+ final NumericEntityUnescaper neu = new NumericEntityUnescaper();
assertEquals("Failed to ignore when last character is &", "Test &", neu.translate("Test &"));
assertEquals("Failed to ignore when last character is &", "Test &#", neu.translate("Test &#"));
@@ -73,7 +73,7 @@ public class NumericEntityUnescaperTest {
try {
result = neu.translate(input);
fail("IllegalArgumentException expected");
- } catch(IllegalArgumentException iae) {
+ } catch(final IllegalArgumentException iae) {
// expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
index 91c6479de..7cbe60ce3 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
@@ -28,7 +28,7 @@ public class OctalUnescaperTest {
@Test
public void testBetween() {
- OctalUnescaper oue = new OctalUnescaper(); //.between("1", "377");
+ final OctalUnescaper oue = new OctalUnescaper(); //.between("1", "377");
String input = "\\45";
String result = oue.translate(input);
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
index 7dfe322c9..61f2a0cc6 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
@@ -29,28 +29,28 @@ public class UnicodeEscaperTest {
@Test
public void testBelow() {
- UnicodeEscaper ue = UnicodeEscaper.below('F');
+ final UnicodeEscaper ue = UnicodeEscaper.below('F');
- String input = "ADFGZ";
- String result = ue.translate(input);
+ final String input = "ADFGZ";
+ final String result = ue.translate(input);
assertEquals("Failed to escape Unicode characters via the below method", "\\u0041\\u0044FGZ", result);
}
@Test
public void testBetween() {
- UnicodeEscaper ue = UnicodeEscaper.between('F', 'L');
+ final UnicodeEscaper ue = UnicodeEscaper.between('F', 'L');
- String input = "ADFGZ";
- String result = ue.translate(input);
+ final String input = "ADFGZ";
+ final String result = ue.translate(input);
assertEquals("Failed to escape Unicode characters via the between method", "AD\\u0046\\u0047Z", result);
}
@Test
public void testAbove() {
- UnicodeEscaper ue = UnicodeEscaper.above('F');
+ final UnicodeEscaper ue = UnicodeEscaper.above('F');
- String input = "ADFGZ";
- String result = ue.translate(input);
+ final String input = "ADFGZ";
+ final String result = ue.translate(input);
assertEquals("Failed to escape Unicode characters via the above method", "ADF\\u0047\\u005A", result);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
index ed882aa26..f003011f3 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
@@ -31,30 +31,30 @@ public class UnicodeUnescaperTest {
// Requested in LANG-507
@Test
public void testUPlus() {
- UnicodeUnescaper uu = new UnicodeUnescaper();
+ final UnicodeUnescaper uu = new UnicodeUnescaper();
- String input = "\\u+0047";
+ final String input = "\\u+0047";
assertEquals("Failed to unescape Unicode characters with 'u+' notation", "G", uu.translate(input));
}
@Test
public void testUuuuu() {
- UnicodeUnescaper uu = new UnicodeUnescaper();
+ final UnicodeUnescaper uu = new UnicodeUnescaper();
- String input = "\\uuuuuuuu0047";
- String result = uu.translate(input);
+ final String input = "\\uuuuuuuu0047";
+ final String result = uu.translate(input);
assertEquals("Failed to unescape Unicode characters with many 'u' characters", "G", result);
}
@Test
public void testLessThanFour() {
- UnicodeUnescaper uu = new UnicodeUnescaper();
+ final UnicodeUnescaper uu = new UnicodeUnescaper();
- String input = "\\0047\\u006";
+ final String input = "\\0047\\u006";
try {
uu.translate(input);
fail("A lack of digits in a Unicode escape sequence failed to throw an exception");
- } catch(IllegalArgumentException iae) {
+ } catch(final IllegalArgumentException iae) {
// expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
index 6f3299fa0..2d8984218 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
@@ -34,7 +34,7 @@ public class DateFormatUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new DateFormatUtils());
- Constructor<?>[] cons = DateFormatUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = DateFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DateFormatUtils.class.getModifiers()));
@@ -44,14 +44,14 @@ public class DateFormatUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testFormat() {
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005,0,1,12,0,0);
c.setTimeZone(TimeZone.getDefault());
- StringBuilder buffer = new StringBuilder ();
- int year = c.get(Calendar.YEAR);
- int month = c.get(Calendar.MONTH) + 1;
- int day = c.get(Calendar.DAY_OF_MONTH);
- int hour = c.get(Calendar.HOUR_OF_DAY);
+ final StringBuilder buffer = new StringBuilder ();
+ final int year = c.get(Calendar.YEAR);
+ final int month = c.get(Calendar.MONTH) + 1;
+ final int day = c.get(Calendar.DAY_OF_MONTH);
+ final int hour = c.get(Calendar.HOUR_OF_DAY);
buffer.append (year);
buffer.append(month);
buffer.append(day);
@@ -68,14 +68,14 @@ public class DateFormatUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testFormatCalendar() {
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005,0,1,12,0,0);
c.setTimeZone(TimeZone.getDefault());
- StringBuilder buffer = new StringBuilder ();
- int year = c.get(Calendar.YEAR);
- int month = c.get(Calendar.MONTH) + 1;
- int day = c.get(Calendar.DAY_OF_MONTH);
- int hour = c.get(Calendar.HOUR_OF_DAY);
+ final StringBuilder buffer = new StringBuilder ();
+ final int year = c.get(Calendar.YEAR);
+ final int month = c.get(Calendar.MONTH) + 1;
+ final int day = c.get(Calendar.DAY_OF_MONTH);
+ final int hour = c.get(Calendar.HOUR_OF_DAY);
buffer.append (year);
buffer.append(month);
buffer.append(day);
@@ -91,7 +91,7 @@ public class DateFormatUtilsTest {
@Test
public void testFormatUTC() {
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005,0,1,12,0,0);
assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()));
@@ -104,8 +104,8 @@ public class DateFormatUtilsTest {
@Test
public void testDateTimeISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,9,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), timeZone);
@@ -128,8 +128,8 @@ public class DateFormatUtilsTest {
@Test
public void testDateISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_DATE_FORMAT.getPattern(), timeZone);
@@ -152,8 +152,8 @@ public class DateFormatUtilsTest {
@Test
public void testTimeISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_TIME_FORMAT.getPattern(), timeZone);
@@ -176,8 +176,8 @@ public class DateFormatUtilsTest {
@Test
public void testTimeNoTISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_TIME_NO_T_FORMAT.getPattern(), timeZone);
@@ -200,8 +200,8 @@ public class DateFormatUtilsTest {
@Test
public void testSMTP(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2003,5,8,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern(), timeZone,
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
index 6b05aafdd..ff9cf3369 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
@@ -48,27 +48,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -76,27 +76,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -104,27 +104,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -132,27 +132,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -239,13 +239,13 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfSecondWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND);
assertEquals(millis, testResult);
}
@Test
public void testMillisecondsOfSecondWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.SECOND);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.SECOND);
assertEquals(millis, testResult);
assertEquals(aCalendar.get(Calendar.MILLISECOND), testResult);
}
@@ -254,25 +254,25 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfMinuteWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MINUTE);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND), testResult);
}
@Test
public void testMillisecondsOfMinuteWithCalender() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MINUTE);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND), testResult);
}
@Test
public void testSecondsofMinuteWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MINUTE);
assertEquals(seconds, testResult);
}
@Test
public void testSecondsofMinuteWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MINUTE);
assertEquals(seconds, testResult);
assertEquals(aCalendar.get(Calendar.SECOND), testResult);
}
@@ -281,19 +281,19 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfHourWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
}
@Test
public void testMillisecondsOfHourWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
}
@Test
public void testSecondsofHourWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(
seconds
+ (minutes
@@ -303,7 +303,7 @@ public class DateUtilsFragmentTest {
@Test
public void testSecondsofHourWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(
seconds
+ (minutes
@@ -313,13 +313,13 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfHourWithDate() {
- long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.HOUR_OF_DAY);
assertEquals(minutes, testResult);
}
@Test
public void testMinutesOfHourWithCalendar() {
- long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(minutes, testResult);
}
@@ -327,7 +327,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DATE);
- long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
+ final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -336,7 +336,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DATE);
- long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
+ final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -345,7 +345,7 @@ public class DateUtilsFragmentTest {
@Test
public void testSecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInSeconds(aDate, Calendar.DATE);
- long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
+ final long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInSeconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -354,7 +354,7 @@ public class DateUtilsFragmentTest {
@Test
public void testSecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.DATE);
- long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
+ final long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -363,7 +363,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfDayWithDate() {
long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE);
- long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
+ final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue,testResult);
testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue,testResult);
@@ -372,7 +372,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DATE);
- long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
+ final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
@@ -381,7 +381,7 @@ public class DateUtilsFragmentTest {
@Test
public void testHoursOfDayWithDate() {
long testResult = DateUtils.getFragmentInHours(aDate, Calendar.DATE);
- long expectedValue = hours;
+ final long expectedValue = hours;
assertEquals(expectedValue,testResult);
testResult = DateUtils.getFragmentInHours(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue,testResult);
@@ -390,7 +390,7 @@ public class DateUtilsFragmentTest {
@Test
public void testHoursOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DATE);
- long expectedValue = hours;
+ final long expectedValue = hours;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
@@ -400,7 +400,7 @@ public class DateUtilsFragmentTest {
//Calendar.MONTH as useful fragment
@Test
public void testMillisecondsOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MONTH);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY),
testResult);
@@ -408,7 +408,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MONTH);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY),
testResult);
@@ -416,7 +416,7 @@ testResult);
@Test
public void testSecondsOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
@@ -427,7 +427,7 @@ testResult);
@Test
public void testSecondsOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MONTH);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
@@ -438,7 +438,7 @@ testResult);
@Test
public void testMinutesOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.MONTH);
assertEquals(minutes
+ ((hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_MINUTE,
@@ -447,7 +447,7 @@ testResult);
@Test
public void testMinutesOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.MONTH);
assertEquals( minutes +((hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
@@ -455,7 +455,7 @@ testResult);
@Test
public void testHoursOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInHours(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInHours(aDate, Calendar.MONTH);
assertEquals(hours + ((days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
testResult);
@@ -463,7 +463,7 @@ testResult);
@Test
public void testHoursOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.MONTH);
assertEquals( hours +((days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
testResult);
@@ -472,8 +472,8 @@ testResult);
//Calendar.YEAR as useful fragment
@Test
public void testMillisecondsOfYearWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (cal.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY),
@@ -482,7 +482,7 @@ testResult);
@Test
public void testMillisecondsOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.YEAR);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (aCalendar.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY),
testResult);
@@ -490,8 +490,8 @@ testResult);
@Test
public void testSecondsOfYearWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(
seconds
@@ -503,7 +503,7 @@ testResult);
@Test
public void testSecondsOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.YEAR);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
@@ -514,8 +514,8 @@ testResult);
@Test
public void testMinutesOfYearWithDate() {
- long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(minutes
+ ((hours * DateUtils.MILLIS_PER_HOUR) + (cal.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
@@ -525,7 +525,7 @@ testResult);
@Test
public void testMinutesOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.YEAR);
assertEquals( minutes +((hours * DateUtils.MILLIS_PER_HOUR) + (aCalendar.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
@@ -533,8 +533,8 @@ testResult);
@Test
public void testHoursOfYearWithDate() {
- long testResult = DateUtils.getFragmentInHours(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInHours(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(hours + ((cal.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
@@ -543,7 +543,7 @@ testResult);
@Test
public void testHoursOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.YEAR);
assertEquals( hours +((aCalendar.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
testResult);
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
index 19af40cc7..2a3b29d5b 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
@@ -84,9 +84,9 @@ public class DateUtilsRoundingTest {
@Test
public void testRoundYear() throws Exception {
final int calendarField = Calendar.YEAR;
- Date roundedUpDate = dateTimeParser.parse("January 1, 2008 0:00:00.000");
- Date roundedDownDate = targetYearDate;
- Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999");
+ final Date roundedUpDate = dateTimeParser.parse("January 1, 2008 0:00:00.000");
+ final Date roundedDownDate = targetYearDate;
+ final Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
}
@@ -416,7 +416,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateYear() throws Exception {
final int calendarField = Calendar.YEAR;
- Date lastTruncateDate = dateTimeParser.parse("December 31, 2007 23:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("December 31, 2007 23:59:59.999");
baseTruncateTest(targetYearDate, lastTruncateDate, calendarField);
}
@@ -429,8 +429,8 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateMonth() throws Exception {
final int calendarField = Calendar.MONTH;
- Date truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000");
- Date lastTruncateDate = dateTimeParser.parse("March 31, 2008 23:59:59.999");
+ final Date truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000");
+ final Date lastTruncateDate = dateTimeParser.parse("March 31, 2008 23:59:59.999");
baseTruncateTest(truncatedDate, lastTruncateDate, calendarField);
}
@@ -497,7 +497,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateDate() throws Exception {
final int calendarField = Calendar.DATE;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetDateDate, lastTruncateDate, calendarField);
}
@@ -510,7 +510,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateDayOfMonth() throws Exception {
final int calendarField = Calendar.DAY_OF_MONTH;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetDayOfMonthDate, lastTruncateDate, calendarField);
}
@@ -543,7 +543,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateHour() throws Exception {
final int calendarField = Calendar.HOUR;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
baseTruncateTest(targetHourDate, lastTruncateDate, calendarField);
}
@@ -556,7 +556,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateHourOfDay() throws Exception {
final int calendarField = Calendar.HOUR_OF_DAY;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
baseTruncateTest(targetHourOfDayDate, lastTruncateDate, calendarField);
}
@@ -569,7 +569,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateMinute() throws Exception {
final int calendarField = Calendar.MINUTE;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999");
baseTruncateTest(targetMinuteDate, lastTruncateDate, calendarField);
}
@@ -582,7 +582,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateSecond() throws Exception {
final int calendarField = Calendar.SECOND;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999");
baseTruncateTest(targetSecondDate, lastTruncateDate, calendarField);
}
@@ -611,7 +611,7 @@ public class DateUtilsRoundingTest {
* @since 3.0
*/
protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) {
- Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1);
+ final Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1);
//Date-comparison
assertEquals(roundedDownDate, DateUtils.round(roundedDownDate, calendarField));
@@ -659,7 +659,7 @@ public class DateUtilsRoundingTest {
* @since 3.0
*/
protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncateDate, final int calendarField) {
- Date nextTruncateDate = DateUtils.addMilliseconds(lastTruncateDate, 1);
+ final Date nextTruncateDate = DateUtils.addMilliseconds(lastTruncateDate, 1);
//Date-comparison
assertEquals("Truncating "+ fdf.format(truncatedDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", truncatedDate, DateUtils.truncate(truncatedDate, calendarField));
@@ -704,22 +704,22 @@ public class DateUtilsRoundingTest {
assertEquals(januaryOneDate, DateUtils.round(minDate, calendarField));
assertEquals(januaryOneDate, DateUtils.round(maxDate, calendarField));
- Calendar minCalendar = Calendar.getInstance();
+ final Calendar minCalendar = Calendar.getInstance();
minCalendar.setTime(minDate);
- Calendar maxCalendar = Calendar.getInstance();
+ final Calendar maxCalendar = Calendar.getInstance();
maxCalendar.setTime(maxDate);
assertEquals("Rounding "+ fdf.format(januaryOneCalendar) +" as Date with CalendarField-value "+ calendarField +" must return itself", januaryOneCalendar, DateUtils.round(januaryOneCalendar, calendarField));
assertEquals(januaryOneCalendar, DateUtils.round(minCalendar, calendarField));
assertEquals(januaryOneCalendar, DateUtils.round(maxCalendar, calendarField));
- Date toPrevRoundDate = DateUtils.addMilliseconds(minDate, -1);
- Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1);
+ final Date toPrevRoundDate = DateUtils.addMilliseconds(minDate, -1);
+ final Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1);
assertFalse(fdf.format(minDate) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)));
assertFalse(fdf.format(maxDate) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)));
- Calendar toPrevRoundCalendar = Calendar.getInstance();
+ final Calendar toPrevRoundCalendar = Calendar.getInstance();
toPrevRoundCalendar.setTime(toPrevRoundDate);
- Calendar toNextRoundCalendar = Calendar.getInstance();
+ final Calendar toNextRoundCalendar = Calendar.getInstance();
toNextRoundCalendar.setTime(toNextRoundDate);
assertFalse(fdf.format(minCalendar) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)));
assertFalse(fdf.format(maxCalendar) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)));
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
index acc0cce0f..48cc3ea15 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -53,7 +53,7 @@ public class DateUtilsTest {
private static final long MILLIS_TEST;
static {
- GregorianCalendar cal = new GregorianCalendar(2000, 6, 5, 4, 3, 2);
+ final GregorianCalendar cal = new GregorianCalendar(2000, 6, 5, 4, 3, 2);
cal.set(Calendar.MILLISECOND, 1);
MILLIS_TEST = cal.getTime().getTime();
System.out.println("DateUtilsTest: Default Locale="+Locale.getDefault());
@@ -149,7 +149,7 @@ public class DateUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new DateUtils());
- Constructor<?>[] cons = DateUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = DateUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DateUtils.class.getModifiers()));
@@ -171,14 +171,14 @@ public class DateUtilsTest {
try {
DateUtils.isSameDay((Date) null, (Date) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testIsSameDay_Cal() {
- GregorianCalendar cal1 = new GregorianCalendar(2004, 6, 9, 13, 45);
- GregorianCalendar cal2 = new GregorianCalendar(2004, 6, 9, 13, 45);
+ final GregorianCalendar cal1 = new GregorianCalendar(2004, 6, 9, 13, 45);
+ final GregorianCalendar cal2 = new GregorianCalendar(2004, 6, 9, 13, 45);
assertTrue(DateUtils.isSameDay(cal1, cal2));
cal2.add(Calendar.DAY_OF_YEAR, 1);
assertFalse(DateUtils.isSameDay(cal1, cal2));
@@ -189,7 +189,7 @@ public class DateUtilsTest {
try {
DateUtils.isSameDay((Calendar) null, (Calendar) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@@ -207,14 +207,14 @@ public class DateUtilsTest {
try {
DateUtils.isSameInstant((Date) null, (Date) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testIsSameInstant_Cal() {
- GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
- GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
+ final GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
+ final GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
cal1.set(2004, 6, 9, 13, 45, 0);
cal1.set(Calendar.MILLISECOND, 0);
cal2.set(2004, 6, 9, 13, 45, 0);
@@ -226,22 +226,22 @@ public class DateUtilsTest {
try {
DateUtils.isSameInstant((Calendar) null, (Calendar) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testIsSameLocalTime_Cal() {
- GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
- GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
+ final GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
+ final GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
cal1.set(2004, 6, 9, 13, 45, 0);
cal1.set(Calendar.MILLISECOND, 0);
cal2.set(2004, 6, 9, 13, 45, 0);
cal2.set(Calendar.MILLISECOND, 0);
assertTrue(DateUtils.isSameLocalTime(cal1, cal2));
- Calendar cal3 = Calendar.getInstance();
- Calendar cal4 = Calendar.getInstance();
+ final Calendar cal3 = Calendar.getInstance();
+ final Calendar cal4 = Calendar.getInstance();
cal3.set(2004, 6, 9, 4, 0, 0);
cal4.set(2004, 6, 9, 16, 0, 0);
cal3.set(Calendar.MILLISECOND, 0);
@@ -253,15 +253,15 @@ public class DateUtilsTest {
try {
DateUtils.isSameLocalTime((Calendar) null, (Calendar) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testParseDate() throws Exception {
- GregorianCalendar cal = new GregorianCalendar(1972, 11, 3);
+ final GregorianCalendar cal = new GregorianCalendar(1972, 11, 3);
String dateStr = "1972-12-03";
- String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"};
+ final String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"};
Date date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
@@ -276,30 +276,30 @@ public class DateUtilsTest {
try {
DateUtils.parseDate("PURPLE", parsers);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
try {
DateUtils.parseDate("197212AB", parsers);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
try {
DateUtils.parseDate(null, parsers);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.parseDate(dateStr, (String[]) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.parseDate(dateStr, new String[0]);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
}
// LANG-486
@Test
public void testParseDateWithLeniency() throws Exception {
- GregorianCalendar cal = new GregorianCalendar(1998, 6, 30);
- String dateStr = "02 942, 1996";
- String[] parsers = new String[] {"MM DDD, yyyy"};
+ final GregorianCalendar cal = new GregorianCalendar(1998, 6, 30);
+ final String dateStr = "02 942, 1996";
+ final String[] parsers = new String[] {"MM DDD, yyyy"};
Date date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
@@ -307,13 +307,13 @@ public class DateUtilsTest {
try {
date = DateUtils.parseDateStrictly(dateStr, parsers);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testAddYears() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addYears(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -333,7 +333,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddMonths() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addMonths(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -353,7 +353,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddWeeks() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addWeeks(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -373,7 +373,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddDays() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addDays(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -393,7 +393,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddHours() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addHours(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -413,7 +413,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddMinutes() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addMinutes(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -433,7 +433,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddSeconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addSeconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -453,7 +453,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddMilliseconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addMilliseconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -473,7 +473,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetYears() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setYears(base, 2000);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -493,7 +493,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetMonths() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setMonths(base, 5);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -507,7 +507,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setMonths(base, 12);
fail("DateUtils.setMonths did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -515,7 +515,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetDays() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setDays(base, 1);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -529,7 +529,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setDays(base, 32);
fail("DateUtils.setDays did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -537,7 +537,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetHours() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setHours(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -551,7 +551,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setHours(base, 24);
fail("DateUtils.setHours did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -559,7 +559,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetMinutes() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setMinutes(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -573,7 +573,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setMinutes(base, 60);
fail("DateUtils.setMinutes did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -581,7 +581,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetSeconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setSeconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -595,7 +595,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setSeconds(base, 60);
fail("DateUtils.setSeconds did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -603,7 +603,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetMilliseconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setMilliseconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -617,14 +617,14 @@ public class DateUtilsTest {
try {
result = DateUtils.setMilliseconds(base, 1000);
fail("DateUtils.setMilliseconds did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
//-----------------------------------------------------------------------
private void assertDate(final Date date, final int year, final int month, final int day, final int hour, final int min, final int sec, final int mil) throws Exception {
- GregorianCalendar cal = new GregorianCalendar();
+ final GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
assertEquals(year, cal.get(Calendar.YEAR));
assertEquals(month, cal.get(Calendar.MONTH));
@@ -642,7 +642,7 @@ public class DateUtilsTest {
try {
DateUtils.toCalendar(null);
fail("Expected NullPointerException to be thrown");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
// expected
}
}
@@ -779,23 +779,23 @@ public class DateUtilsTest {
try {
DateUtils.round((Date) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.round((Calendar) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.round((Object) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.round("", Calendar.SECOND);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
try {
DateUtils.round(date1, -9999);
fail();
- } catch(IllegalArgumentException ex) {}
+ } catch(final IllegalArgumentException ex) {}
assertEquals("round ampm-1 failed",
dateTimeParser.parse("February 3, 2002 00:00:00.000"),
@@ -880,7 +880,7 @@ public class DateUtilsTest {
{
TimeZone.setDefault(defaultZone);
dateTimeParser.setTimeZone(defaultZone);
- Calendar testCalendar = Calendar.getInstance();
+ final Calendar testCalendar = Calendar.getInstance();
testCalendar.set(2007, 6, 2, 8, 8, 50);
Date date = testCalendar.getTime();
assertEquals("Minute Round Up Failed",
@@ -1075,19 +1075,19 @@ public class DateUtilsTest {
try {
DateUtils.truncate((Date) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.truncate((Calendar) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.truncate((Object) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.truncate("", Calendar.SECOND);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
// Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560
// Test truncate across beginning of daylight saving time
@@ -1110,20 +1110,20 @@ public class DateUtilsTest {
dateTimeParser.setTimeZone(defaultZone);
// Bug 31395, large dates
- Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
- GregorianCalendar endCal = new GregorianCalendar();
+ final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
+ final GregorianCalendar endCal = new GregorianCalendar();
endCal.setTime(endOfTime);
try {
DateUtils.truncate(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000001);
try {
DateUtils.truncate(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000000);
- Calendar cal = DateUtils.truncate(endCal, Calendar.DATE);
+ final Calendar cal = DateUtils.truncate(endCal, Calendar.DATE);
assertEquals(0, cal.get(Calendar.HOUR));
}
@@ -1140,17 +1140,17 @@ public class DateUtilsTest {
}
// Set TimeZone to Mountain Time
- TimeZone MST_MDT = TimeZone.getTimeZone("MST7MDT");
+ final TimeZone MST_MDT = TimeZone.getTimeZone("MST7MDT");
TimeZone.setDefault(MST_MDT);
- DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
+ final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
format.setTimeZone(MST_MDT);
- Date oct31_01MDT = new Date(1099206000000L);
+ final Date oct31_01MDT = new Date(1099206000000L);
- Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
- Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
- Date oct31_01_02_03MDT = new Date(oct31_01_02MDT.getTime() + 3000L); // + 3 seconds
- Date oct31_01_02_03_04MDT = new Date(oct31_01_02_03MDT.getTime() + 4L); // + 4 milliseconds
+ final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
+ final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
+ final Date oct31_01_02_03MDT = new Date(oct31_01_02MDT.getTime() + 3000L); // + 3 seconds
+ final Date oct31_01_02_03_04MDT = new Date(oct31_01_02_03MDT.getTime() + 4L); // + 4 milliseconds
assertEquals("Check 00:00:00.000", "2004-10-31 00:00:00.000 MDT", format.format(oct31MDT));
assertEquals("Check 01:00:00.000", "2004-10-31 01:00:00.000 MDT", format.format(oct31_01MDT));
@@ -1159,7 +1159,7 @@ public class DateUtilsTest {
assertEquals("Check 01:02:03.004", "2004-10-31 01:02:03.004 MDT", format.format(oct31_01_02_03_04MDT));
// ------- Demonstrate Problem -------
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(new Date(oct31_01MDT.getTime()));
gval.set(Calendar.MINUTE, gval.get(Calendar.MINUTE)); // set minutes to the same value
assertEquals("Demonstrate Problem", gval.getTime().getTime(), oct31_01MDT.getTime() + 3600000L);
@@ -1210,9 +1210,9 @@ public class DateUtilsTest {
// http://issues.apache.org/jira/browse/LANG-530
@Test
public void testLang530() throws ParseException {
- Date d = new Date();
- String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d);
- Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
+ final Date d = new Date();
+ final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d);
+ final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
// the format loses milliseconds so have to reintroduce them
assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000);
}
@@ -1369,23 +1369,23 @@ public class DateUtilsTest {
try {
DateUtils.ceiling((Date) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.ceiling((Calendar) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.ceiling((Object) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.ceiling("", Calendar.SECOND);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
try {
DateUtils.ceiling(date1, -9999);
fail();
- } catch(IllegalArgumentException ex) {}
+ } catch(final IllegalArgumentException ex) {}
// Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560
@@ -1450,20 +1450,20 @@ public class DateUtilsTest {
dateTimeParser.setTimeZone(defaultZone);
// Bug 31395, large dates
- Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
- GregorianCalendar endCal = new GregorianCalendar();
+ final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
+ final GregorianCalendar endCal = new GregorianCalendar();
endCal.setTime(endOfTime);
try {
DateUtils.ceiling(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000001);
try {
DateUtils.ceiling(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000000);
- Calendar cal = DateUtils.ceiling(endCal, Calendar.DATE);
+ final Calendar cal = DateUtils.ceiling(endCal, Calendar.DATE);
assertEquals(0, cal.get(Calendar.HOUR));
}
@@ -1474,23 +1474,23 @@ public class DateUtilsTest {
public void testIteratorEx() throws Exception {
try {
DateUtils.iterator(Calendar.getInstance(), -9999);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator((Calendar) null, DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator((Object) null, DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator("", DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
}
/**
@@ -1498,19 +1498,19 @@ public class DateUtilsTest {
*/
@Test
public void testWeekIterator() throws Exception {
- Calendar now = Calendar.getInstance();
+ final Calendar now = Calendar.getInstance();
for (int i = 0; i< 7; i++) {
- Calendar today = DateUtils.truncate(now, Calendar.DATE);
- Calendar sunday = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar today = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar sunday = DateUtils.truncate(now, Calendar.DATE);
sunday.add(Calendar.DATE, 1 - sunday.get(Calendar.DAY_OF_WEEK));
- Calendar monday = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar monday = DateUtils.truncate(now, Calendar.DATE);
if (monday.get(Calendar.DAY_OF_WEEK) == 1) {
//This is sunday... roll back 6 days
monday.add(Calendar.DATE, -6);
} else {
monday.add(Calendar.DATE, 2 - monday.get(Calendar.DAY_OF_WEEK));
}
- Calendar centered = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar centered = DateUtils.truncate(now, Calendar.DATE);
centered.add(Calendar.DATE, -3);
Iterator<?> it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY);
@@ -1529,12 +1529,12 @@ public class DateUtilsTest {
try {
it.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER);
it.next();
try {
it.remove();
- } catch( UnsupportedOperationException ex) {}
+ } catch( final UnsupportedOperationException ex) {}
now.add(Calendar.DATE,1);
}
@@ -1568,7 +1568,7 @@ public class DateUtilsTest {
@Test
public void testLANG799_EN_OK() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1581,7 +1581,7 @@ public class DateUtilsTest {
// Parse German date with English Locale
@Test(expected=ParseException.class)
public void testLANG799_EN_FAIL() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1592,7 +1592,7 @@ public class DateUtilsTest {
@Test
public void testLANG799_DE_OK() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.GERMAN);
try {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1605,7 +1605,7 @@ public class DateUtilsTest {
// Parse English date with German Locale
@Test(expected=ParseException.class)
public void testLANG799_DE_FAIL() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.GERMAN);
try {
DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1617,7 +1617,7 @@ public class DateUtilsTest {
// Parse German date with English Locale, specifying German Locale override
@Test
public void testLANG799_EN_WITH_DE_LOCALE() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", Locale.GERMAN, "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1631,7 +1631,7 @@ public class DateUtilsTest {
* that are dates (no time), and exactly 1 day spaced after each other.
*/
private static void assertWeekIterator(final Iterator<?> it, final Calendar start) {
- Calendar end = (Calendar) start.clone();
+ final Calendar end = (Calendar) start.clone();
end.add(Calendar.DATE, 6);
assertWeekIterator(it, start, end);
@@ -1641,9 +1641,9 @@ public class DateUtilsTest {
* Convenience method for when working with Date objects
*/
private static void assertWeekIterator(final Iterator<?> it, final Date start, final Date end) {
- Calendar calStart = Calendar.getInstance();
+ final Calendar calStart = Calendar.getInstance();
calStart.setTime(start);
- Calendar calEnd = Calendar.getInstance();
+ final Calendar calEnd = Calendar.getInstance();
calEnd.setTime(end);
assertWeekIterator(it, calStart, calEnd);
diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
index 0e2efd9ce..c7f050b02 100644
--- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
@@ -34,7 +34,7 @@ public class DurationFormatUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new DurationFormatUtils());
- Constructor<?>[] cons = DurationFormatUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = DurationFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DurationFormatUtils.class.getModifiers()));
@@ -132,10 +132,10 @@ public class DurationFormatUtilsTest {
*/
@Test
public void testFormatDurationPluralWords() {
- long oneSecond = 1000;
- long oneMinute = oneSecond * 60;
- long oneHour = oneMinute * 60;
- long oneDay = oneHour * 24;
+ final long oneSecond = 1000;
+ final long oneMinute = oneSecond * 60;
+ final long oneHour = oneMinute * 60;
+ final long oneDay = oneHour * 24;
String text = null;
text = DurationFormatUtils.formatDurationWords(oneSecond, false, false);
@@ -236,28 +236,28 @@ public class DurationFormatUtilsTest {
assertEquals("60000", DurationFormatUtils.formatDuration(duration, "S"));
assertEquals("01:00", DurationFormatUtils.formatDuration(duration, "mm:ss"));
- Calendar base = Calendar.getInstance();
+ final Calendar base = Calendar.getInstance();
base.set(2000, 0, 1, 0, 0, 0);
base.set(Calendar.MILLISECOND, 0);
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2003, 1, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
duration = cal.getTime().getTime() - base.getTime().getTime(); // duration from 2000-01-01 to cal
// don't use 1970 in test as time zones were less reliable in 1970 than now
// remember that duration formatting ignores time zones, working on strict hour lengths
- int days = 366 + 365 + 365 + 31;
+ final int days = 366 + 365 + 365 + 31;
assertEquals("0 0 " + days, DurationFormatUtils.formatDuration(duration, "y M d"));
}
@Test
public void testFormatPeriodISO() {
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar base = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar base = Calendar.getInstance(timeZone);
base.set(1970, 0, 1, 0, 0, 0);
base.set(Calendar.MILLISECOND, 0);
- Calendar cal = Calendar.getInstance(timeZone);
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002, 1, 23, 9, 11, 12);
cal.set(Calendar.MILLISECOND, 1);
String text;
@@ -280,10 +280,10 @@ public class DurationFormatUtilsTest {
@Test
public void testFormatPeriod() {
- Calendar cal1970 = Calendar.getInstance();
+ final Calendar cal1970 = Calendar.getInstance();
cal1970.set(1970, 0, 1, 0, 0, 0);
cal1970.set(Calendar.MILLISECOND, 0);
- long time1970 = cal1970.getTime().getTime();
+ final long time1970 = cal1970.getTime().getTime();
assertEquals("0", DurationFormatUtils.formatPeriod(time1970, time1970, "y"));
assertEquals("0", DurationFormatUtils.formatPeriod(time1970, time1970, "M"));
@@ -306,7 +306,7 @@ public class DurationFormatUtilsTest {
assertEquals("60000", DurationFormatUtils.formatPeriod(time1970, time, "S"));
assertEquals("01:00", DurationFormatUtils.formatPeriod(time1970, time, "mm:ss"));
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(1973, 6, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
time = cal.getTime().getTime();
@@ -374,13 +374,13 @@ public class DurationFormatUtilsTest {
.lexx(DurationFormatUtils.ISO_EXTENDED_FORMAT_PATTERN));
// test failures in equals
- DurationFormatUtils.Token token = new DurationFormatUtils.Token(DurationFormatUtils.y, 4);
+ final DurationFormatUtils.Token token = new DurationFormatUtils.Token(DurationFormatUtils.y, 4);
assertFalse("Token equal to non-Token class. ", token.equals(new Object()));
assertFalse("Token equal to Token with wrong value class. ", token.equals(new DurationFormatUtils.Token(
new Object())));
assertFalse("Token equal to Token with different count. ", token.equals(new DurationFormatUtils.Token(
DurationFormatUtils.y, 1)));
- DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4);
+ final DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4);
assertTrue("Token with Number value not equal to itself. ", numToken.equals(numToken));
}
@@ -401,12 +401,12 @@ public class DurationFormatUtilsTest {
@Test
public void testLANG815() {
- Calendar calendar = Calendar.getInstance();
+ final Calendar calendar = Calendar.getInstance();
calendar.set(2012, 6, 30, 0, 0, 0);
- long startMillis = calendar.getTimeInMillis();
+ final long startMillis = calendar.getTimeInMillis();
calendar.set(2012, 8, 8);
- long endMillis = calendar.getTimeInMillis();
+ final long endMillis = calendar.getTimeInMillis();
assertEquals("1 9", DurationFormatUtils.formatPeriod(startMillis, endMillis, "M d"));
}
@@ -543,16 +543,16 @@ public class DurationFormatUtilsTest {
// }
private void bruteForce(final int year, final int month, final int day, final String format, final int calendarType) {
- String msg = year + "-" + month + "-" + day + " to ";
- Calendar c = Calendar.getInstance();
+ final String msg = year + "-" + month + "-" + day + " to ";
+ final Calendar c = Calendar.getInstance();
c.set(year, month, day, 0, 0, 0);
- int[] array1 = new int[] { year, month, day, 0, 0, 0 };
- int[] array2 = new int[] { year, month, day, 0, 0, 0 };
+ final int[] array1 = new int[] { year, month, day, 0, 0, 0 };
+ final int[] array2 = new int[] { year, month, day, 0, 0, 0 };
for (int i=0; i < FOUR_YEARS; i++) {
array2[0] = c.get(Calendar.YEAR);
array2[1] = c.get(Calendar.MONTH);
array2[2] = c.get(Calendar.DAY_OF_MONTH);
- String tmpMsg = msg + array2[0] + "-" + array2[1] + "-" + array2[2] + " at ";
+ final String tmpMsg = msg + array2[0] + "-" + array2[1] + "-" + array2[2] + " at ";
assertEqualDuration( tmpMsg + i, Integer.toString(i), array1, array2, format );
c.add(calendarType, 1);
}
@@ -562,15 +562,15 @@ public class DurationFormatUtilsTest {
assertEqualDuration(null, expected, start, end, format);
}
private void assertEqualDuration(final String message, final String expected, final int[] start, final int[] end, final String format) {
- Calendar cal1 = Calendar.getInstance();
+ final Calendar cal1 = Calendar.getInstance();
cal1.set(start[0], start[1], start[2], start[3], start[4], start[5]);
cal1.set(Calendar.MILLISECOND, 0);
- Calendar cal2 = Calendar.getInstance();
+ final Calendar cal2 = Calendar.getInstance();
cal2.set(end[0], end[1], end[2], end[3], end[4], end[5]);
cal2.set(Calendar.MILLISECOND, 0);
- long milli1 = cal1.getTime().getTime();
- long milli2 = cal2.getTime().getTime();
- String result = DurationFormatUtils.formatPeriod(milli1, milli2, format);
+ final long milli1 = cal1.getTime().getTime();
+ final long milli2 = cal2.getTime().getTime();
+ final String result = DurationFormatUtils.formatPeriod(milli1, milli2, format);
if (message == null) {
assertEquals(expected, result);
} else {
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
index b0867b915..eaf62febb 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
@@ -51,16 +51,16 @@ public class FastDateFormatTest {
*/
@Test
public void test_getInstance() {
- FastDateFormat format1 = FastDateFormat.getInstance();
- FastDateFormat format2 = FastDateFormat.getInstance();
+ final FastDateFormat format1 = FastDateFormat.getInstance();
+ final FastDateFormat format2 = FastDateFormat.getInstance();
assertSame(format1, format2);
}
@Test
public void test_getInstance_String() {
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy");
- FastDateFormat format2 = FastDateFormat.getInstance("MM-DD-yyyy");
- FastDateFormat format3 = FastDateFormat.getInstance("MM-DD-yyyy");
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy");
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM-DD-yyyy");
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM-DD-yyyy");
assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2);
assertSame(format2, format3);
@@ -71,19 +71,19 @@ public class FastDateFormatTest {
@Test
public void test_getInstance_String_TimeZone() {
- Locale realDefaultLocale = Locale.getDefault();
- TimeZone realDefaultZone = TimeZone.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
+ final TimeZone realDefaultZone = TimeZone.getDefault();
try {
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
TimeZone.getTimeZone("Atlantic/Reykjavik"));
- FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
- FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
- FastDateFormat format4 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
- FastDateFormat format5 = FastDateFormat.getInstance("MM-DD-yyyy", TimeZone.getDefault());
- FastDateFormat format6 = FastDateFormat.getInstance("MM-DD-yyyy");
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
+ final FastDateFormat format4 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
+ final FastDateFormat format5 = FastDateFormat.getInstance("MM-DD-yyyy", TimeZone.getDefault());
+ final FastDateFormat format6 = FastDateFormat.getInstance("MM-DD-yyyy");
assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2);
assertEquals(TimeZone.getTimeZone("Atlantic/Reykjavik"), format1.getTimeZone());
@@ -100,12 +100,12 @@ public class FastDateFormatTest {
@Test
public void test_getInstance_String_Locale() {
- Locale realDefaultLocale = Locale.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.US);
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
- FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2);
assertSame(format1, format3);
@@ -118,13 +118,13 @@ public class FastDateFormatTest {
@Test
public void test_changeDefault_Locale_DateInstance() {
- Locale realDefaultLocale = Locale.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.US);
- FastDateFormat format1 = FastDateFormat.getDateInstance(FastDateFormat.FULL, Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
+ final FastDateFormat format1 = FastDateFormat.getDateInstance(FastDateFormat.FULL, Locale.GERMANY);
+ final FastDateFormat format2 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
Locale.setDefault(Locale.GERMANY);
- FastDateFormat format3 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
+ final FastDateFormat format3 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
assertSame(Locale.GERMANY, format1.getLocale());
assertSame(Locale.US, format2.getLocale());
@@ -139,13 +139,13 @@ public class FastDateFormatTest {
@Test
public void test_changeDefault_Locale_DateTimeInstance() {
- Locale realDefaultLocale = Locale.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.US);
- FastDateFormat format1 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
+ final FastDateFormat format1 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, Locale.GERMANY);
+ final FastDateFormat format2 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
Locale.setDefault(Locale.GERMANY);
- FastDateFormat format3 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
+ final FastDateFormat format3 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
assertSame(Locale.GERMANY, format1.getLocale());
assertSame(Locale.US, format2.getLocale());
@@ -160,16 +160,16 @@ public class FastDateFormatTest {
@Test
public void test_getInstance_String_TimeZone_Locale() {
- Locale realDefaultLocale = Locale.getDefault();
- TimeZone realDefaultZone = TimeZone.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
+ final TimeZone realDefaultZone = TimeZone.getDefault();
try {
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
TimeZone.getTimeZone("Atlantic/Reykjavik"), Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
- FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy",
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy",
TimeZone.getDefault(), Locale.GERMANY);
assertTrue(format1 != format2); // -- junit 3.8 version -- assertNotSame(format1, format2);
@@ -188,11 +188,11 @@ public class FastDateFormatTest {
@Test
public void testCheckDefaults() {
- FastDateFormat format = FastDateFormat.getInstance();
- FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT);
+ final FastDateFormat format = FastDateFormat.getInstance();
+ final FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT);
assertEquals(medium, format);
- SimpleDateFormat sdf = new SimpleDateFormat();
+ final SimpleDateFormat sdf = new SimpleDateFormat();
assertEquals(sdf.toPattern(), format.getPattern());
assertEquals(Locale.getDefault(), format.getLocale());
@@ -201,10 +201,10 @@ public class FastDateFormatTest {
@Test
public void testCheckDifferingStyles() {
- FastDateFormat shortShort = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT, Locale.US);
- FastDateFormat shortLong = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.LONG, Locale.US);
- FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US);
- FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US);
+ final FastDateFormat shortShort = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT, Locale.US);
+ final FastDateFormat shortLong = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.LONG, Locale.US);
+ final FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US);
+ final FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US);
assertFalse(shortShort.equals(shortLong));
assertFalse(shortShort.equals(longShort));
@@ -255,7 +255,7 @@ public class FastDateFormatTest {
final String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS Z";
final FastDateFormat formatter= FastDateFormat.getInstance(pattern);
- long sdfTime= measureTime(formatter, new SimpleDateFormat(pattern) {
+ final long sdfTime= measureTime(formatter, new SimpleDateFormat(pattern) {
private static final long serialVersionUID = 1L; // because SimpleDateFormat is serializable
@Override
@@ -266,9 +266,9 @@ public class FastDateFormatTest {
}
});
- long fdfTime= measureTime(formatter, FastDateFormat.getInstance(pattern));
+ final long fdfTime= measureTime(formatter, FastDateFormat.getInstance(pattern));
- String times= ">>FastDateFormatTest: FastDateParser:"+fdfTime+" SimpleDateFormat:"+sdfTime;
+ final String times= ">>FastDateFormatTest: FastDateParser:"+fdfTime+" SimpleDateFormat:"+sdfTime;
System.out.println(times);
}
@@ -286,15 +286,15 @@ public class FastDateFormatTest {
public void run() {
for(int i= 0; i<NROUNDS; ++i) {
try {
- Date date= new Date();
- String formattedDate= formatter.format(date);
- long start= System.currentTimeMillis();
- Object pd= parser.parseObject(formattedDate);
+ final Date date= new Date();
+ final String formattedDate= formatter.format(date);
+ final long start= System.currentTimeMillis();
+ final Object pd= parser.parseObject(formattedDate);
totalElapsed.addAndGet(System.currentTimeMillis()-start);
if(!date.equals(pd)) {
failures.incrementAndGet();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
failures.incrementAndGet();
e.printStackTrace();
}
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
index 130503483..dc64eec1f 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
@@ -83,7 +83,7 @@ public class FastDateParserTest {
@Test
public void test_Equality_Hash() {
- DateParser[] parsers= {
+ final DateParser[] parsers= {
getInstance(yMdHmsSZ, NEW_YORK, Locale.US),
getInstance(DMY_DOT, NEW_YORK, Locale.US),
getInstance(YMD_SLASH, NEW_YORK, Locale.US),
@@ -93,25 +93,25 @@ public class FastDateParserTest {
getInstance(MDY_SLASH, REYKJAVIK, SWEDEN)
};
- Map<DateParser,Integer> map= new HashMap<DateParser,Integer>();
+ final Map<DateParser,Integer> map= new HashMap<DateParser,Integer>();
int i= 0;
- for(DateParser parser:parsers) {
+ for(final DateParser parser:parsers) {
map.put(parser, Integer.valueOf(i++));
}
i= 0;
- for(DateParser parser:parsers) {
+ for(final DateParser parser:parsers) {
assertEquals(i++, map.get(parser).intValue());
}
}
@Test
public void testParseZone() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 6, 10, 16, 33, 20);
- DateParser fdf = getInstance(yMdHmsSZ, NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance(yMdHmsSZ, NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("2003-07-10T15:33:20.000 -0500"));
assertEquals(cal.getTime(), fdf.parse("2003-07-10T15:33:20.000 GMT-05:00"));
@@ -131,7 +131,7 @@ public class FastDateParserTest {
@Test
public void testParseLongShort() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
@@ -142,7 +142,7 @@ public class FastDateParserTest {
assertEquals(cal.getTime(), fdf.parse("2003 AD February 0010 PM Monday 0015 0033 0020 0989 GMT-05:00"));
cal.set(Calendar.ERA, GregorianCalendar.BC);
- Date parse = fdf.parse("2003 BC February 0010 PM Saturday 0015 0033 0020 0989 GMT-05:00");
+ final Date parse = fdf.parse("2003 BC February 0010 PM Saturday 0015 0033 0020 0989 GMT-05:00");
assertEquals(cal.getTime(), parse);
fdf = getInstance("y G M d a E H m s S Z", NEW_YORK, Locale.US);
@@ -154,13 +154,13 @@ public class FastDateParserTest {
@Test
public void testAmPm() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
- DateParser h = getInstance("yyyy-MM-dd hh a mm:ss", NEW_YORK, Locale.US);
- DateParser K = getInstance("yyyy-MM-dd KK a mm:ss", NEW_YORK, Locale.US);
- DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US);
- DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US);
+ final DateParser h = getInstance("yyyy-MM-dd hh a mm:ss", NEW_YORK, Locale.US);
+ final DateParser K = getInstance("yyyy-MM-dd KK a mm:ss", NEW_YORK, Locale.US);
+ final DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US);
+ final DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US);
cal.set(2010, 7, 1, 0, 33, 20);
assertEquals(cal.getTime(), h.parse("2010-08-01 12 AM 33:20"));
@@ -190,10 +190,10 @@ public class FastDateParserTest {
@Test
// Check that all Locales can parse the formats we use
public void testParses() throws Exception {
- for(Locale locale : Locale.getAvailableLocales()) {
- for(TimeZone tz : new TimeZone[]{NEW_YORK, GMT}) {
- Calendar cal = Calendar.getInstance(tz);
- for(int year : new int[]{2003, 1940, 1868, 1867, 0, -1940}) {
+ for(final Locale locale : Locale.getAvailableLocales()) {
+ for(final TimeZone tz : new TimeZone[]{NEW_YORK, GMT}) {
+ final Calendar cal = Calendar.getInstance(tz);
+ for(final int year : new int[]{2003, 1940, 1868, 1867, 0, -1940}) {
// http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html
if (year < 1868 && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) {
continue; // Japanese imperial calendar does not support eras before 1868
@@ -205,20 +205,20 @@ public class FastDateParserTest {
} else {
cal.set(year, 1, 10);
}
- Date in = cal.getTime();
- for(String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) {
- SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
+ final Date in = cal.getTime();
+ for(final String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) {
+ final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
if (format.equals(SHORT_FORMAT)) {
if (year < 1930) {
sdf.set2DigitYearStart(cal.getTime());
}
}
- String fmt = sdf.format(in);
+ final String fmt = sdf.format(in);
try {
- Date out = sdf.parse(fmt);
+ final Date out = sdf.parse(fmt);
assertEquals(locale.toString()+" "+year+" "+ format+ " "+tz.getID(), in, out);
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
System.out.println(fmt+" "+locale.toString()+" "+year+" "+ format+ " "+tz.getID());
throw pe;
}
@@ -270,23 +270,23 @@ public class FastDateParserTest {
private void testLocales(final String format, final boolean eraBC) throws Exception {
- Calendar cal= Calendar.getInstance(GMT);
+ final Calendar cal= Calendar.getInstance(GMT);
cal.clear();
cal.set(2003, 1, 10);
if (eraBC) {
cal.set(Calendar.ERA, GregorianCalendar.BC);
}
- for(Locale locale : Locale.getAvailableLocales()) {
+ for(final Locale locale : Locale.getAvailableLocales()) {
// ja_JP_JP cannot handle dates before 1868 properly
if (eraBC && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) {
continue;
}
- SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
- DateParser fdf = getInstance(format, locale);
+ final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
+ final DateParser fdf = getInstance(format, locale);
try {
checkParse(locale, cal, sdf, fdf);
- } catch(ParseException ex) {
+ } catch(final ParseException ex) {
Assert.fail("Locale "+locale+ " failed with "+format+" era "+(eraBC?"BC":"AD")+"\n" + trimMessage(ex.toString()));
}
}
@@ -296,7 +296,7 @@ public class FastDateParserTest {
if (msg.length() < 100) {
return msg;
}
- int gmt = msg.indexOf("(GMT");
+ final int gmt = msg.indexOf("(GMT");
if (gmt > 0) {
return msg.substring(0, gmt+4)+"...)";
}
@@ -304,32 +304,32 @@ public class FastDateParserTest {
}
private void checkParse(final Locale locale, final Calendar cal, final SimpleDateFormat sdf, final DateParser fdf) throws ParseException {
- String formattedDate= sdf.format(cal.getTime());
- Date expectedTime = sdf.parse(formattedDate);
- Date actualTime = fdf.parse(formattedDate);
+ final String formattedDate= sdf.format(cal.getTime());
+ final Date expectedTime = sdf.parse(formattedDate);
+ final Date actualTime = fdf.parse(formattedDate);
assertEquals(locale.toString()+" "+formattedDate
+"\n",expectedTime, actualTime);
}
@Test
public void testParseNumerics() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
- DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("20030210153320989"));
}
@Test
public void testQuotes() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
- DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("'20030210A'B153320989'"));
}
@@ -364,13 +364,13 @@ public class FastDateParserTest {
Throwable s = null;
try {
- SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
+ final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
sdf.setTimeZone(NEW_YORK);
dsdf = sdf.parse(date);
if (shouldFail) {
Assert.fail("Expected SDF failure, but got " + dsdf + " for ["+format+","+date+"]");
}
- } catch (Exception e) {
+ } catch (final Exception e) {
s = e;
if (!shouldFail) {
throw e;
@@ -381,12 +381,12 @@ public class FastDateParserTest {
}
try {
- DateParser fdp = getInstance(format, NEW_YORK, Locale.US);
+ final DateParser fdp = getInstance(format, NEW_YORK, Locale.US);
dfdp = fdp.parse(date);
if (shouldFail) {
Assert.fail("Expected FDF failure, but got " + dfdp + " for ["+format+","+date+"] using "+((FastDateParser)fdp).getParsePattern());
}
- } catch (Exception e) {
+ } catch (final Exception e) {
f = e;
if (!shouldFail) {
throw e;
@@ -405,11 +405,11 @@ public class FastDateParserTest {
@Test
public void testDayOf() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10);
- DateParser fdf = getInstance("W w F D y", NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance("W w F D y", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("3 7 2 41 03"));
}
@@ -420,7 +420,7 @@ public class FastDateParserTest {
@Test
public void testShortDateStyleWithLocales() throws ParseException {
DateParser fdf = getDateInstance(FastDateFormat.SHORT, Locale.US);
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2004, 1, 3);
@@ -436,8 +436,8 @@ public class FastDateParserTest {
*/
@Test
public void testLowYearPadding() throws ParseException {
- DateParser parser = getInstance(YMD_SLASH);
- Calendar cal = Calendar.getInstance();
+ final DateParser parser = getInstance(YMD_SLASH);
+ final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(1,0,1);
@@ -455,8 +455,8 @@ public class FastDateParserTest {
*/
@Test
public void testMilleniumBug() throws ParseException {
- DateParser parser = getInstance(DMY_DOT);
- Calendar cal = Calendar.getInstance();
+ final DateParser parser = getInstance(DMY_DOT);
+ final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(1000,0,1);
@@ -466,10 +466,10 @@ public class FastDateParserTest {
@Test
public void testLang303() throws ParseException {
DateParser parser = getInstance(YMD_SLASH);
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2004, 11, 31);
- Date date = parser.parse("2004/11/31");
+ final Date date = parser.parse("2004/11/31");
parser = SerializationUtils.deserialize(SerializationUtils.serialize((Serializable) parser));
assertEquals(date, parser.parse("2004/11/31"));
@@ -477,9 +477,9 @@ public class FastDateParserTest {
@Test
public void testLang538() throws ParseException {
- DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT);
+ final DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT);
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));
+ final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));
cal.clear();
cal.set(2009, 9, 16, 8, 42, 16);
@@ -488,8 +488,8 @@ public class FastDateParserTest {
@Test
public void testEquals() {
- DateParser parser1= getInstance(YMD_SLASH);
- DateParser parser2= getInstance(YMD_SLASH);
+ final DateParser parser1= getInstance(YMD_SLASH);
+ final DateParser parser2= getInstance(YMD_SLASH);
assertEquals(parser1, parser2);
assertEquals(parser1.hashCode(), parser2.hashCode());
@@ -499,25 +499,25 @@ public class FastDateParserTest {
@Test
public void testToStringContainsName() {
- DateParser parser= getInstance(YMD_SLASH);
+ final DateParser parser= getInstance(YMD_SLASH);
assertTrue(parser.toString().startsWith("FastDate"));
}
@Test
public void testPatternMatches() {
- DateParser parser= getInstance(yMdHmsSZ);
+ final DateParser parser= getInstance(yMdHmsSZ);
assertEquals(yMdHmsSZ, parser.getPattern());
}
@Test
public void testLocaleMatches() {
- DateParser parser= getInstance(yMdHmsSZ, SWEDEN);
+ final DateParser parser= getInstance(yMdHmsSZ, SWEDEN);
assertEquals(SWEDEN, parser.getLocale());
}
@Test
public void testTimeZoneMatches() {
- DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK);
+ final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK);
assertEquals(REYKJAVIK, parser.getTimeZone());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
index a6540caa9..ea0793ce3 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
@@ -72,18 +72,18 @@ public class FastDatePrinterTest {
@Test
public void testFormat() {
- Locale realDefaultLocale = Locale.getDefault();
- TimeZone realDefaultZone = TimeZone.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
+ final TimeZone realDefaultZone = TimeZone.getDefault();
try {
Locale.setDefault(Locale.US);
TimeZone.setDefault(NEW_YORK);
- GregorianCalendar cal1 = new GregorianCalendar(2003, 0, 10, 15, 33, 20);
- GregorianCalendar cal2 = new GregorianCalendar(2003, 6, 10, 9, 00, 00);
- Date date1 = cal1.getTime();
- Date date2 = cal2.getTime();
- long millis1 = date1.getTime();
- long millis2 = date2.getTime();
+ final GregorianCalendar cal1 = new GregorianCalendar(2003, 0, 10, 15, 33, 20);
+ final GregorianCalendar cal2 = new GregorianCalendar(2003, 6, 10, 9, 00, 00);
+ final Date date1 = cal1.getTime();
+ final Date date2 = cal2.getTime();
+ final long millis1 = date1.getTime();
+ final long millis2 = date2.getTime();
DatePrinter fdf = getInstance("yyyy-MM-dd'T'HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
@@ -113,7 +113,7 @@ public class FastDatePrinterTest {
assertEquals("-04:00", fdf.format(cal2));
assertEquals("-04:00", fdf.format(millis2));
- String pattern = "GGGG GGG GG G yyyy yyy yy y MMMM MMM MM M" +
+ final String pattern = "GGGG GGG GG G yyyy yyy yy y MMMM MMM MM M" +
" dddd ddd dd d DDDD DDD DD D EEEE EEE EE E aaaa aaa aa a zzzz zzz zz z";
fdf = getInstance(pattern);
sdf = new SimpleDateFormat(pattern);
@@ -131,9 +131,9 @@ public class FastDatePrinterTest {
*/
@Test
public void testShortDateStyleWithLocales() {
- Locale usLocale = Locale.US;
- Locale swedishLocale = new Locale("sv", "SE");
- Calendar cal = Calendar.getInstance();
+ final Locale usLocale = Locale.US;
+ final Locale swedishLocale = new Locale("sv", "SE");
+ final Calendar cal = Calendar.getInstance();
cal.set(2004, 1, 3);
DatePrinter fdf = getDateInstance(FastDateFormat.SHORT, usLocale);
assertEquals("2/3/04", fdf.format(cal));
@@ -148,8 +148,8 @@ public class FastDatePrinterTest {
*/
@Test
public void testLowYearPadding() {
- Calendar cal = Calendar.getInstance();
- DatePrinter format = getInstance(YYYY_MM_DD);
+ final Calendar cal = Calendar.getInstance();
+ final DatePrinter format = getInstance(YYYY_MM_DD);
cal.set(1,0,1);
assertEquals("0001/01/01", format.format(cal));
@@ -165,8 +165,8 @@ public class FastDatePrinterTest {
*/
@Test
public void testMilleniumBug() {
- Calendar cal = Calendar.getInstance();
- DatePrinter format = getInstance("dd.MM.yyyy");
+ final Calendar cal = Calendar.getInstance();
+ final DatePrinter format = getInstance("dd.MM.yyyy");
cal.set(1000,0,1);
assertEquals("01.01.1000", format.format(cal));
@@ -178,8 +178,8 @@ public class FastDatePrinterTest {
*/
@Test
public void testSimpleDate() {
- Calendar cal = Calendar.getInstance();
- DatePrinter format = getInstance(YYYY_MM_DD);
+ final Calendar cal = Calendar.getInstance();
+ final DatePrinter format = getInstance(YYYY_MM_DD);
cal.set(2004,11,31);
assertEquals("2004/12/31", format.format(cal));
@@ -191,11 +191,11 @@ public class FastDatePrinterTest {
@Test
public void testLang303() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2004, 11, 31);
DatePrinter format = getInstance(YYYY_MM_DD);
- String output = format.format(cal);
+ final String output = format.format(cal);
format = SerializationUtils.deserialize(SerializationUtils.serialize((Serializable) format));
assertEquals(output, format.format(cal));
@@ -205,32 +205,32 @@ public class FastDatePrinterTest {
public void testLang538() {
// more commonly constructed with: cal = new GregorianCalendar(2009, 9, 16, 8, 42, 16)
// for the unit test to work in any time zone, constructing with GMT-8 rather than default locale time zone
- GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT-8"));
+ final GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT-8"));
cal.clear();
cal.set(2009, 9, 16, 8, 42, 16);
- DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT"));
+ final DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT"));
assertEquals("dateTime", "2009-10-16T16:42:16.000Z", format.format(cal.getTime()));
assertEquals("dateTime", "2009-10-16T08:42:16.000Z", format.format(cal));
}
@Test
public void testLang645() {
- Locale locale = new Locale("sv", "SE");
+ final Locale locale = new Locale("sv", "SE");
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2010, 0, 1, 12, 0, 0);
- Date d = cal.getTime();
+ final Date d = cal.getTime();
- DatePrinter fdf = getInstance("EEEE', week 'ww", locale);
+ final DatePrinter fdf = getInstance("EEEE', week 'ww", locale);
assertEquals("fredag, week 53", fdf.format(d));
}
@Test
public void testEquals() {
- DatePrinter printer1= getInstance(YYYY_MM_DD);
- DatePrinter printer2= getInstance(YYYY_MM_DD);
+ final DatePrinter printer1= getInstance(YYYY_MM_DD);
+ final DatePrinter printer2= getInstance(YYYY_MM_DD);
assertEquals(printer1, printer2);
assertEquals(printer1.hashCode(), printer2.hashCode());
@@ -240,35 +240,35 @@ public class FastDatePrinterTest {
@Test
public void testToStringContainsName() {
- DatePrinter printer= getInstance(YYYY_MM_DD);
+ final DatePrinter printer= getInstance(YYYY_MM_DD);
assertTrue(printer.toString().startsWith("FastDate"));
}
@Test
public void testPatternMatches() {
- DatePrinter printer= getInstance(YYYY_MM_DD);
+ final DatePrinter printer= getInstance(YYYY_MM_DD);
assertEquals(YYYY_MM_DD, printer.getPattern());
}
@Test
public void testLocaleMatches() {
- DatePrinter printer= getInstance(YYYY_MM_DD, SWEDEN);
+ final DatePrinter printer= getInstance(YYYY_MM_DD, SWEDEN);
assertEquals(SWEDEN, printer.getLocale());
}
@Test
public void testTimeZoneMatches() {
- DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK);
+ final DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK);
assertEquals(NEW_YORK, printer.getTimeZone());
}
@Test
public void testCalendarTimezoneRespected() {
- String[] availableZones = TimeZone.getAvailableIDs();
- TimeZone currentZone = TimeZone.getDefault();
+ final String[] availableZones = TimeZone.getAvailableIDs();
+ final TimeZone currentZone = TimeZone.getDefault();
TimeZone anotherZone = null;
- for (String zone : availableZones) {
+ for (final String zone : availableZones) {
if (!zone.equals(currentZone.getID())) {
anotherZone = TimeZone.getTimeZone(zone);
}
@@ -279,10 +279,10 @@ public class FastDatePrinterTest {
final String pattern = "h:mma z";
final Calendar cal = Calendar.getInstance(anotherZone);
- SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+ final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
sdf.setTimeZone(anotherZone);
- String expectedValue = sdf.format(cal.getTime());
- String actualValue = FastDateFormat.getInstance(pattern).format(cal);
+ final String expectedValue = sdf.format(cal.getTime());
+ final String actualValue = FastDateFormat.getInstance(pattern).format(cal);
assertEquals(expectedValue, actualValue);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
index bec23b943..ad2857907 100644
--- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
@@ -33,11 +33,11 @@ public class StopWatchTest {
//-----------------------------------------------------------------------
@Test
public void testStopWatchSimple(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.stop();
- long time = watch.getTime();
+ final long time = watch.getTime();
assertEquals(time, watch.getTime());
assertTrue(time >= 500);
@@ -49,28 +49,28 @@ public class StopWatchTest {
@Test
public void testStopWatchSimpleGet(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
assertEquals(0, watch.getTime());
assertEquals("0:00:00.000", watch.toString());
watch.start();
- try {Thread.sleep(500);} catch (InterruptedException ex) {}
+ try {Thread.sleep(500);} catch (final InterruptedException ex) {}
assertTrue(watch.getTime() < 2000);
}
@Test
public void testStopWatchSplit(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.split();
- long splitTime = watch.getSplitTime();
- String splitStr = watch.toSplitString();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ final long splitTime = watch.getSplitTime();
+ final String splitStr = watch.toSplitString();
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.unsplit();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.stop();
- long totalTime = watch.getTime();
+ final long totalTime = watch.getTime();
assertEquals("Formatted split string not the correct length",
splitStr.length(), 11);
@@ -82,16 +82,16 @@ public class StopWatchTest {
@Test
public void testStopWatchSuspend(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.suspend();
- long suspendTime = watch.getTime();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ final long suspendTime = watch.getTime();
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.resume();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.stop();
- long totalTime = watch.getTime();
+ final long totalTime = watch.getTime();
assertTrue(suspendTime >= 500);
assertTrue(suspendTime < 700);
@@ -101,60 +101,60 @@ public class StopWatchTest {
@Test
public void testLang315() {
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(200);} catch (InterruptedException ex) {}
+ try {Thread.sleep(200);} catch (final InterruptedException ex) {}
watch.suspend();
- long suspendTime = watch.getTime();
- try {Thread.sleep(200);} catch (InterruptedException ex) {}
+ final long suspendTime = watch.getTime();
+ try {Thread.sleep(200);} catch (final InterruptedException ex) {}
watch.stop();
- long totalTime = watch.getTime();
+ final long totalTime = watch.getTime();
assertTrue( suspendTime == totalTime );
}
// test bad states
@Test
public void testBadStates() {
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
try {
watch.stop();
fail("Calling stop on an unstarted StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.stop();
fail("Calling stop on an unstarted StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.suspend();
fail("Calling suspend on an unstarted StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.split();
fail("Calling split on a non-running StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.resume();
fail("Calling resume on an unsuspended StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
@@ -163,28 +163,28 @@ public class StopWatchTest {
try {
watch.start();
fail("Calling start on a started StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.getSplitTime();
fail("Calling getSplitTime on an unsplit StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.resume();
fail("Calling resume on an unsuspended StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
@@ -193,33 +193,33 @@ public class StopWatchTest {
try {
watch.start();
fail("Calling start on a stopped StopWatch should throw an exception as it needs to be reset. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
}
@Test
public void testGetStartTime() {
- long beforeStopWatch = System.currentTimeMillis();
- StopWatch watch = new StopWatch();
+ final long beforeStopWatch = System.currentTimeMillis();
+ final StopWatch watch = new StopWatch();
try {
watch.getStartTime();
fail("Calling getStartTime on an unstarted StopWatch should throw an exception");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
// expected
}
watch.start();
try {
watch.getStartTime();
Assert.assertTrue(watch.getStartTime() >= beforeStopWatch);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
fail("Start time should be available: " + ex.getMessage());
}
watch.reset();
try {
watch.getStartTime();
fail("Calling getStartTime on a reset, but unstarted StopWatch should throw an exception");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
// expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
index 42ba48880..01661042e 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
@@ -36,12 +36,12 @@ public class ImmutablePairTest {
@Test
public void testBasic() throws Exception {
- ImmutablePair<Integer, String> pair = new ImmutablePair<Integer, String>(0, "foo");
+ final ImmutablePair<Integer, String> pair = new ImmutablePair<Integer, String>(0, "foo");
assertEquals(0, pair.left.intValue());
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.right);
assertEquals("foo", pair.getRight());
- ImmutablePair<Object, String> pair2 = new ImmutablePair<Object, String>(null, "bar");
+ final ImmutablePair<Object, String> pair2 = new ImmutablePair<Object, String>(null, "bar");
assertNull(pair2.left);
assertNull(pair2.getLeft());
assertEquals("bar", pair2.right);
@@ -50,12 +50,12 @@ public class ImmutablePairTest {
@Test
public void testPairOf() throws Exception {
- ImmutablePair<Integer, String> pair = ImmutablePair.of(0, "foo");
+ final ImmutablePair<Integer, String> pair = ImmutablePair.of(0, "foo");
assertEquals(0, pair.left.intValue());
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.right);
assertEquals("foo", pair.getRight());
- ImmutablePair<Object, String> pair2 = ImmutablePair.of(null, "bar");
+ final ImmutablePair<Object, String> pair2 = ImmutablePair.of(null, "bar");
assertNull(pair2.left);
assertNull(pair2.getLeft());
assertEquals("bar", pair2.right);
@@ -68,7 +68,7 @@ public class ImmutablePairTest {
assertFalse(ImmutablePair.of("foo", 0).equals(ImmutablePair.of("foo", null)));
assertFalse(ImmutablePair.of("foo", "bar").equals(ImmutablePair.of("xyz", "bar")));
- ImmutablePair<String, String> p = ImmutablePair.of("foo", "bar");
+ final ImmutablePair<String, String> p = ImmutablePair.of("foo", "bar");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -89,11 +89,11 @@ public class ImmutablePairTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- ImmutablePair<Integer, String> origPair = ImmutablePair.of(0, "foo");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final ImmutablePair<Integer, String> origPair = ImmutablePair.of(0, "foo");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origPair);
- ImmutablePair<Integer, String> deserializedPair = (ImmutablePair<Integer, String>) new ObjectInputStream(
+ final ImmutablePair<Integer, String> deserializedPair = (ImmutablePair<Integer, String>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origPair, deserializedPair);
assertEquals(origPair.hashCode(), deserializedPair.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
index 8d9d8452a..a6e7cf330 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
@@ -36,14 +36,14 @@ public class ImmutableTripleTest {
@Test
public void testBasic() throws Exception {
- ImmutableTriple<Integer, String, Boolean> triple = new ImmutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
+ final ImmutableTriple<Integer, String, Boolean> triple = new ImmutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
assertEquals(0, triple.left.intValue());
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.middle);
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.TRUE, triple.right);
assertEquals(Boolean.TRUE, triple.getRight());
- ImmutableTriple<Object, String, Integer> triple2 = new ImmutableTriple<Object, String, Integer>(null, "bar", 42);
+ final ImmutableTriple<Object, String, Integer> triple2 = new ImmutableTriple<Object, String, Integer>(null, "bar", 42);
assertNull(triple2.left);
assertNull(triple2.getLeft());
assertEquals("bar", triple2.middle);
@@ -54,14 +54,14 @@ public class ImmutableTripleTest {
@Test
public void testTripleOf() throws Exception {
- ImmutableTriple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.FALSE);
+ final ImmutableTriple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.FALSE);
assertEquals(0, triple.left.intValue());
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.middle);
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.FALSE, triple.right);
assertEquals(Boolean.FALSE, triple.getRight());
- ImmutableTriple<Object, String, Boolean> triple2 = ImmutableTriple.of(null, "bar", Boolean.TRUE);
+ final ImmutableTriple<Object, String, Boolean> triple2 = ImmutableTriple.of(null, "bar", Boolean.TRUE);
assertNull(triple2.left);
assertNull(triple2.getLeft());
assertEquals("bar", triple2.middle);
@@ -76,7 +76,7 @@ public class ImmutableTripleTest {
assertFalse(ImmutableTriple.of("foo", 0, Boolean.TRUE).equals(ImmutableTriple.of("foo", null, null)));
assertFalse(ImmutableTriple.of("foo", "bar", "baz").equals(ImmutableTriple.of("xyz", "bar", "blo")));
- ImmutableTriple<String, String, String> p = ImmutableTriple.of("foo", "bar", "baz");
+ final ImmutableTriple<String, String, String> p = ImmutableTriple.of("foo", "bar", "baz");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -100,11 +100,11 @@ public class ImmutableTripleTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- ImmutableTriple<Integer, String, Boolean> origTriple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final ImmutableTriple<Integer, String, Boolean> origTriple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origTriple);
- ImmutableTriple<Integer, String, Boolean> deserializedTriple = (ImmutableTriple<Integer, String, Boolean>) new ObjectInputStream(
+ final ImmutableTriple<Integer, String, Boolean> deserializedTriple = (ImmutableTriple<Integer, String, Boolean>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origTriple, deserializedTriple);
assertEquals(origTriple.hashCode(), deserializedTriple.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
index ef1f72c15..0b64004a5 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
@@ -36,24 +36,24 @@ public class MutablePairTest {
@Test
public void testBasic() throws Exception {
- MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
+ final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.getRight());
- MutablePair<Object, String> pair2 = new MutablePair<Object, String>(null, "bar");
+ final MutablePair<Object, String> pair2 = new MutablePair<Object, String>(null, "bar");
assertNull(pair2.getLeft());
assertEquals("bar", pair2.getRight());
}
@Test
public void testDefault() throws Exception {
- MutablePair<Integer, String> pair = new MutablePair<Integer, String>();
+ final MutablePair<Integer, String> pair = new MutablePair<Integer, String>();
assertNull(pair.getLeft());
assertNull(pair.getRight());
}
@Test
public void testMutate() throws Exception {
- MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
+ final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
pair.setLeft(42);
pair.setRight("bar");
assertEquals(42, pair.getLeft().intValue());
@@ -62,10 +62,10 @@ public class MutablePairTest {
@Test
public void testPairOf() throws Exception {
- MutablePair<Integer, String> pair = MutablePair.of(0, "foo");
+ final MutablePair<Integer, String> pair = MutablePair.of(0, "foo");
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.getRight());
- MutablePair<Object, String> pair2 = MutablePair.of(null, "bar");
+ final MutablePair<Object, String> pair2 = MutablePair.of(null, "bar");
assertNull(pair2.getLeft());
assertEquals("bar", pair2.getRight());
}
@@ -76,7 +76,7 @@ public class MutablePairTest {
assertFalse(MutablePair.of("foo", 0).equals(MutablePair.of("foo", null)));
assertFalse(MutablePair.of("foo", "bar").equals(MutablePair.of("xyz", "bar")));
- MutablePair<String, String> p = MutablePair.of("foo", "bar");
+ final MutablePair<String, String> p = MutablePair.of("foo", "bar");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -97,11 +97,11 @@ public class MutablePairTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- MutablePair<Integer, String> origPair = MutablePair.of(0, "foo");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final MutablePair<Integer, String> origPair = MutablePair.of(0, "foo");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origPair);
- MutablePair<Integer, String> deserializedPair = (MutablePair<Integer, String>) new ObjectInputStream(
+ final MutablePair<Integer, String> deserializedPair = (MutablePair<Integer, String>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origPair, deserializedPair);
assertEquals(origPair.hashCode(), deserializedPair.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
index 2106f37cb..210a95549 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
@@ -36,11 +36,11 @@ public class MutableTripleTest {
@Test
public void testBasic() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.FALSE);
+ final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.FALSE);
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.FALSE, triple.getRight());
- MutableTriple<Object, String, String> triple2 = new MutableTriple<Object, String, String>(null, "bar", "hello");
+ final MutableTriple<Object, String, String> triple2 = new MutableTriple<Object, String, String>(null, "bar", "hello");
assertNull(triple2.getLeft());
assertEquals("bar", triple2.getMiddle());
assertEquals("hello", triple2.getRight());
@@ -48,7 +48,7 @@ public class MutableTripleTest {
@Test
public void testDefault() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>();
+ final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>();
assertNull(triple.getLeft());
assertNull(triple.getMiddle());
assertNull(triple.getRight());
@@ -56,7 +56,7 @@ public class MutableTripleTest {
@Test
public void testMutate() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
+ final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
triple.setLeft(42);
triple.setMiddle("bar");
triple.setRight(Boolean.FALSE);
@@ -67,11 +67,11 @@ public class MutableTripleTest {
@Test
public void testTripleOf() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = MutableTriple.of(0, "foo", Boolean.TRUE);
+ final MutableTriple<Integer, String, Boolean> triple = MutableTriple.of(0, "foo", Boolean.TRUE);
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.TRUE, triple.getRight());
- MutableTriple<Object, String, String> triple2 = MutableTriple.of(null, "bar", "hello");
+ final MutableTriple<Object, String, String> triple2 = MutableTriple.of(null, "bar", "hello");
assertNull(triple2.getLeft());
assertEquals("bar", triple2.getMiddle());
assertEquals("hello", triple2.getRight());
@@ -84,7 +84,7 @@ public class MutableTripleTest {
assertFalse(MutableTriple.of("foo", "bar", "baz").equals(MutableTriple.of("xyz", "bar", "baz")));
assertFalse(MutableTriple.of("foo", "bar", "baz").equals(MutableTriple.of("foo", "bar", "blo")));
- MutableTriple<String, String, String> p = MutableTriple.of("foo", "bar", "baz");
+ final MutableTriple<String, String, String> p = MutableTriple.of("foo", "bar", "baz");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -108,11 +108,11 @@ public class MutableTripleTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- MutableTriple<Integer, String, Boolean> origTriple = MutableTriple.of(0, "foo", Boolean.TRUE);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final MutableTriple<Integer, String, Boolean> origTriple = MutableTriple.of(0, "foo", Boolean.TRUE);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origTriple);
- MutableTriple<Integer, String, Boolean> deserializedTriple = (MutableTriple<Integer, String, Boolean>) new ObjectInputStream(
+ final MutableTriple<Integer, String, Boolean> deserializedTriple = (MutableTriple<Integer, String, Boolean>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origTriple, deserializedTriple);
assertEquals(origTriple.hashCode(), deserializedTriple.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
index 9054d6110..365f2abe3 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
@@ -37,11 +37,11 @@ public class PairTest {
@Test
public void testPairOf() throws Exception {
- Pair<Integer, String> pair = Pair.of(0, "foo");
+ final Pair<Integer, String> pair = Pair.of(0, "foo");
assertTrue(pair instanceof ImmutablePair<?, ?>);
assertEquals(0, ((ImmutablePair<Integer, String>) pair).left.intValue());
assertEquals("foo", ((ImmutablePair<Integer, String>) pair).right);
- Pair<Object, String> pair2 = Pair.of(null, "bar");
+ final Pair<Object, String> pair2 = Pair.of(null, "bar");
assertTrue(pair2 instanceof ImmutablePair<?, ?>);
assertNull(((ImmutablePair<Object, String>) pair2).left);
assertEquals("bar", ((ImmutablePair<Object, String>) pair2).right);
@@ -49,11 +49,11 @@ public class PairTest {
@Test
public void testCompatibilityBetweenPairs() throws Exception {
- Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
- Pair<Integer, String> pair2 = MutablePair.of(0, "foo");
+ final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
+ final Pair<Integer, String> pair2 = MutablePair.of(0, "foo");
assertEquals(pair, pair2);
assertEquals(pair.hashCode(), pair2.hashCode());
- HashSet<Pair<Integer, String>> set = new HashSet<Pair<Integer, String>>();
+ final HashSet<Pair<Integer, String>> set = new HashSet<Pair<Integer, String>>();
set.add(pair);
assertTrue(set.contains(pair2));
@@ -64,18 +64,18 @@ public class PairTest {
@Test
public void testMapEntry() throws Exception {
- Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
- HashMap<Integer, String> map = new HashMap<Integer, String>();
+ final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
+ final HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put(0, "foo");
- Entry<Integer, String> entry = map.entrySet().iterator().next();
+ final Entry<Integer, String> entry = map.entrySet().iterator().next();
assertEquals(pair, entry);
assertEquals(pair.hashCode(), entry.hashCode());
}
@Test
public void testComparable1() throws Exception {
- Pair<String, String> pair1 = Pair.of("A", "D");
- Pair<String, String> pair2 = Pair.of("B", "C");
+ final Pair<String, String> pair1 = Pair.of("A", "D");
+ final Pair<String, String> pair2 = Pair.of("B", "C");
assertTrue(pair1.compareTo(pair1) == 0);
assertTrue(pair1.compareTo(pair2) < 0);
assertTrue(pair2.compareTo(pair2) == 0);
@@ -84,8 +84,8 @@ public class PairTest {
@Test
public void testComparable2() throws Exception {
- Pair<String, String> pair1 = Pair.of("A", "C");
- Pair<String, String> pair2 = Pair.of("A", "D");
+ final Pair<String, String> pair1 = Pair.of("A", "C");
+ final Pair<String, String> pair2 = Pair.of("A", "D");
assertTrue(pair1.compareTo(pair1) == 0);
assertTrue(pair1.compareTo(pair2) < 0);
assertTrue(pair2.compareTo(pair2) == 0);
@@ -94,27 +94,27 @@ public class PairTest {
@Test
public void testToString() throws Exception {
- Pair<String, String> pair = Pair.of("Key", "Value");
+ final Pair<String, String> pair = Pair.of("Key", "Value");
assertEquals("(Key,Value)", pair.toString());
}
@Test
public void testToStringCustom() throws Exception {
- Calendar date = Calendar.getInstance();
+ final Calendar date = Calendar.getInstance();
date.set(2011, Calendar.APRIL, 25);
- Pair<String, Calendar> pair = Pair.of("DOB", date);
+ final Pair<String, Calendar> pair = Pair.of("DOB", date);
assertEquals("Test created on " + "04-25-2011", pair.toString("Test created on %2$tm-%2$td-%2$tY"));
}
@Test
public void testFormattable_simple() throws Exception {
- Pair<String, String> pair = Pair.of("Key", "Value");
+ final Pair<String, String> pair = Pair.of("Key", "Value");
assertEquals("(Key,Value)", String.format("%1$s", pair));
}
@Test
public void testFormattable_padded() throws Exception {
- Pair<String, String> pair = Pair.of("Key", "Value");
+ final Pair<String, String> pair = Pair.of("Key", "Value");
assertEquals(" (Key,Value)", String.format("%1$20s", pair));
}
diff --git a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
index 630776f75..d9cff33cd 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
@@ -34,12 +34,12 @@ public class TripleTest {
@Test
public void testTripleOf() throws Exception {
- Triple<Integer, String, Boolean> triple = Triple.of(0, "foo", Boolean.TRUE);
+ final Triple<Integer, String, Boolean> triple = Triple.of(0, "foo", Boolean.TRUE);
assertTrue(triple instanceof ImmutableTriple<?, ?, ?>);
assertEquals(0, ((ImmutableTriple<Integer, String, Boolean>) triple).left.intValue());
assertEquals("foo", ((ImmutableTriple<Integer, String, Boolean>) triple).middle);
assertEquals(Boolean.TRUE, ((ImmutableTriple<Integer, String, Boolean>) triple).right);
- Triple<Object, String, Long> triple2 = Triple.of(null, "bar", Long.valueOf(200L));
+ final Triple<Object, String, Long> triple2 = Triple.of(null, "bar", Long.valueOf(200L));
assertTrue(triple2 instanceof ImmutableTriple<?, ?, ?>);
assertNull(((ImmutableTriple<Object, String, Long>) triple2).left);
assertEquals("bar", ((ImmutableTriple<Object, String, Long>) triple2).middle);
@@ -48,19 +48,19 @@ public class TripleTest {
@Test
public void testCompatibilityBetweenTriples() throws Exception {
- Triple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
- Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
+ final Triple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
+ final Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
assertEquals(triple, triple2);
assertEquals(triple.hashCode(), triple2.hashCode());
- HashSet<Triple<Integer, String, Boolean>> set = new HashSet<Triple<Integer, String, Boolean>>();
+ final HashSet<Triple<Integer, String, Boolean>> set = new HashSet<Triple<Integer, String, Boolean>>();
set.add(triple);
assertTrue(set.contains(triple2));
}
@Test
public void testComparable1() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("A", "D", "A");
- Triple<String, String, String> triple2 = Triple.of("B", "C", "A");
+ final Triple<String, String, String> triple1 = Triple.of("A", "D", "A");
+ final Triple<String, String, String> triple2 = Triple.of("B", "C", "A");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -69,8 +69,8 @@ public class TripleTest {
@Test
public void testComparable2() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("A", "C", "B");
- Triple<String, String, String> triple2 = Triple.of("A", "D", "B");
+ final Triple<String, String, String> triple1 = Triple.of("A", "C", "B");
+ final Triple<String, String, String> triple2 = Triple.of("A", "D", "B");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -79,8 +79,8 @@ public class TripleTest {
@Test
public void testComparable3() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("A", "A", "D");
- Triple<String, String, String> triple2 = Triple.of("A", "B", "C");
+ final Triple<String, String, String> triple1 = Triple.of("A", "A", "D");
+ final Triple<String, String, String> triple2 = Triple.of("A", "B", "C");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -89,8 +89,8 @@ public class TripleTest {
@Test
public void testComparable4() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("B", "A", "C");
- Triple<String, String, String> triple2 = Triple.of("B", "A", "D");
+ final Triple<String, String, String> triple1 = Triple.of("B", "A", "C");
+ final Triple<String, String, String> triple2 = Triple.of("B", "A", "D");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -99,27 +99,27 @@ public class TripleTest {
@Test
public void testToString() throws Exception {
- Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
+ final Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
assertEquals("(Key,Something,Value)", triple.toString());
}
@Test
public void testToStringCustom() throws Exception {
- Calendar date = Calendar.getInstance();
+ final Calendar date = Calendar.getInstance();
date.set(2011, Calendar.APRIL, 25);
- Triple<String, String, Calendar> triple = Triple.of("DOB", "string", date);
+ final Triple<String, String, Calendar> triple = Triple.of("DOB", "string", date);
assertEquals("Test created on " + "04-25-2011", triple.toString("Test created on %3$tm-%3$td-%3$tY"));
}
@Test
public void testFormattable_simple() throws Exception {
- Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
+ final Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
assertEquals("(Key,Something,Value)", String.format("%1$s", triple));
}
@Test
public void testFormattable_padded() throws Exception {
- Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
+ final Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
assertEquals(" (Key,Something,Value)", String.format("%1$30s", triple));
}