You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/22 08:09:49 UTC
svn commit: r1436770 [1/16] - in /commons/proper/lang/trunk/src:
main/java/org/apache/commons/lang3/
main/java/org/apache/commons/lang3/builder/
main/java/org/apache/commons/lang3/concurrent/
main/java/org/apache/commons/lang3/event/ main/java/org/apac...
Author: ggregory
Date: Tue Jan 22 07:09:45 2013
New Revision: 1436770
URL: http://svn.apache.org/viewvc?rev=1436770&view=rev
Log:
Add final modifier to local variables.
Modified:
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharEncoding.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharRange.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSet.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSetUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/EnumUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/LocaleUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ObjectUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SystemUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Validate.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/IDKey.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/Fraction.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/StrLookup.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/StrMatcher.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/WordUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Triple.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BitFieldTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharRangeTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSetTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ConversionTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RangeTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ValidateTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/FractionTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java Tue Jan 22 07:09:45 2013
@@ -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);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java Tue Jan 22 07:09:45 2013
@@ -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;
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java Tue Jan 22 07:09:45 2013
@@ -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");
}
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharEncoding.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharEncoding.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharEncoding.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharEncoding.java Tue Jan 22 07:09:45 2013
@@ -97,7 +97,7 @@ public class CharEncoding {
}
try {
return Charset.isSupported(name);
- } catch (IllegalCharsetNameException ex) {
+ } catch (final IllegalCharsetNameException ex) {
return false;
}
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharRange.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharRange.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharRange.java Tue Jan 22 07:09:45 2013
@@ -67,7 +67,7 @@ final class CharRange implements Iterabl
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 Iterabl
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 Iterabl
@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 Iterabl
if (hasNext == false) {
throw new NoSuchElementException();
}
- char cur = current;
+ final char cur = current;
prepareNext();
return Character.valueOf(cur);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java Tue Jan 22 07:09:45 2013
@@ -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);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSet.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSet.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSet.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSet.java Tue Jan 22 07:09:45 2013
@@ -140,7 +140,7 @@ public class CharSet implements Serializ
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 Serializ
*/
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 Serializ
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 Serializ
* @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 Serializ
if (obj instanceof CharSet == false) {
return false;
}
- CharSet other = (CharSet) obj;
+ final CharSet other = (CharSet) obj;
return set.equals(other.set);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSetUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSetUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSetUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSetUtils.java Tue Jan 22 07:09:45 2013
@@ -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;
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java Tue Jan 22 07:09:45 2013
@@ -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("[]");
}