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 [3/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...
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java Tue Jan 22 07:09:45 2013
@@ -322,8 +322,8 @@ public class ReflectionToStringBuilder e
* @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 e
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 e
*/
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");
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java Tue Jan 22 07:09:45 2013
@@ -169,7 +169,7 @@ public abstract class ToStringStyle impl
* 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 impl
*/
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 impl
*/
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 impl
*/
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 impl
* @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 impl
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 impl
*/
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);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java Tue Jan 22 07:09:45 2013
@@ -210,10 +210,10 @@ public abstract class BackgroundInitiali
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);
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java Tue Jan 22 07:09:45 2013
@@ -202,7 +202,7 @@ public class BasicThreadFactory implemen
*/
@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 implemen
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 implemen
*/
@Override
public BasicThreadFactory build() {
- BasicThreadFactory factory = new BasicThreadFactory(this);
+ final BasicThreadFactory factory = new BasicThreadFactory(this);
reset();
return factory;
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java Tue Jan 22 07:09:45 2013
@@ -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());
}
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConstantInitializer.java Tue Jan 22 07:09:45 2013
@@ -110,7 +110,7 @@ public class ConstantInitializer<T> impl
return false;
}
- ConstantInitializer<?> c = (ConstantInitializer<?>) obj;
+ final ConstantInitializer<?> c = (ConstantInitializer<?>) obj;
return ObjectUtils.equals(getObject(), c.getObject());
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java Tue Jan 22 07:09:45 2013
@@ -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);
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java Tue Jan 22 07:09:45 2013
@@ -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);
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java Tue Jan 22 07:09:45 2013
@@ -218,15 +218,15 @@ public class EventListenerSupport<L> imp
* @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> imp
*/
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> imp
*/
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> imp
*/
@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;
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java Tue Jan 22 07:09:45 2013
@@ -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());
}
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java Tue Jan 22 07:09:45 2013
@@ -125,7 +125,7 @@ public class DefaultExceptionContext imp
*/
@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 imp
String valueStr;
try {
valueStr = value.toString();
- } catch (Exception e) {
+ } catch (final Exception e) {
valueStr = "Exception thrown on toString(): " + ExceptionUtils.getStackTrace(e);
}
buffer.append(valueStr);
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java Tue Jan 22 07:09:45 2013
@@ -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);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/Fraction.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/Fraction.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/Fraction.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/Fraction.java Tue Jan 22 07:09:45 2013
@@ -226,7 +226,7 @@ public final class Fraction extends Numb
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 Numb
* @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 Numb
// 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 Numb
// 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 Numb
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 Numb
}
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 Numb
* 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 Numb
*/
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 Numb
* 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 Numb
* 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 Numb
}
// 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 Numb
// 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 Numb
}
// 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 Numb
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 Numb
}
// 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 Numb
// 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 {
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java Tue Jan 22 07:09:45 2013
@@ -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) {
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java Tue Jan 22 07:09:45 2013
@@ -178,7 +178,7 @@ public class MutableBoolean implements M
*/
@Override
public int compareTo(final MutableBoolean other) {
- boolean anotherVal = other.value;
+ final boolean anotherVal = other.value;
return value == anotherVal ? 0 : (value ? 1 : -1);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java Tue Jan 22 07:09:45 2013
@@ -268,7 +268,7 @@ public class MutableByte extends Number
*/
@Override
public int compareTo(final MutableByte other) {
- byte anotherVal = other.value;
+ final byte anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java Tue Jan 22 07:09:45 2013
@@ -284,7 +284,7 @@ public class MutableDouble extends Numbe
*/
@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 Numbe
*/
@Override
public int compareTo(final MutableDouble other) {
- double anotherVal = other.value;
+ final double anotherVal = other.value;
return Double.compare(value, anotherVal);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java Tue Jan 22 07:09:45 2013
@@ -298,7 +298,7 @@ public class MutableFloat extends Number
*/
@Override
public int compareTo(final MutableFloat other) {
- float anotherVal = other.value;
+ final float anotherVal = other.value;
return Float.compare(value, anotherVal);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java Tue Jan 22 07:09:45 2013
@@ -258,7 +258,7 @@ public class MutableInt extends Number i
*/
@Override
public int compareTo(final MutableInt other) {
- int anotherVal = other.value;
+ final int anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java Tue Jan 22 07:09:45 2013
@@ -258,7 +258,7 @@ public class MutableLong extends Number
*/
@Override
public int compareTo(final MutableLong other) {
- long anotherVal = other.value;
+ final long anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java Tue Jan 22 07:09:45 2013
@@ -97,7 +97,7 @@ public class MutableObject<T> implements
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;
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java Tue Jan 22 07:09:45 2013
@@ -268,7 +268,7 @@ public class MutableShort extends Number
*/
@Override
public int compareTo(final MutableShort other) {
- short anotherVal = other.value;
+ final short anotherVal = other.value;
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java Tue Jan 22 07:09:45 2013
@@ -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;
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java Tue Jan 22 07:09:45 2013
@@ -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);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java Tue Jan 22 07:09:45 2013
@@ -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;
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java Tue Jan 22 07:09:45 2013
@@ -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(),