This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new 764b9bb Use final. 764b9bb is described below commit 764b9bba528487fb575b84766998086c24bb1f48 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Nov 20 22:12:25 2020 -0500 Use final. --- src/main/java/org/apache/commons/lang3/ArrayUtils.java | 4 ++-- .../java/org/apache/commons/lang3/RandomUtils.java | 2 +- .../lang3/concurrent/locks/LockingVisitors.java | 12 ++++++------ .../org/apache/commons/lang3/function/TriFunction.java | 4 ++-- .../java/org/apache/commons/lang3/ArrayUtilsTest.java | 8 ++++---- .../apache/commons/lang3/CharSequenceUtilsTest.java | 4 ++-- .../apache/commons/lang3/reflect/FieldUtilsTest.java | 2 +- .../apache/commons/lang3/reflect/TypeUtilsTest.java | 18 +++++++++--------- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index c36c2ac..8fe8915 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -7869,7 +7869,7 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd * @see Arrays#sort(Object[]) * @since 3.12 */ - public static <T> T[] sort(T[] array) { + public static <T> T[] sort(final T[] array) { Arrays.sort(array); return array; } @@ -7885,7 +7885,7 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd * @see Arrays#sort(Object[]) * @since 3.12 */ - public static <T> T[] sort(T[] array, Comparator<? super T> comparator) { + public static <T> T[] sort(final T[] array, final Comparator<? super T> comparator) { Arrays.sort(array, comparator); return array; } diff --git a/src/main/java/org/apache/commons/lang3/RandomUtils.java b/src/main/java/org/apache/commons/lang3/RandomUtils.java index 777d177..6f963d1 100644 --- a/src/main/java/org/apache/commons/lang3/RandomUtils.java +++ b/src/main/java/org/apache/commons/lang3/RandomUtils.java @@ -166,7 +166,7 @@ public class RandomUtils { * @return a random {@code long} value between 0 (inclusive) and {@code n} * (exclusive). */ - private static long nextLong(long n) { + private static long nextLong(final long n) { // Extracted from o.a.c.rng.core.BaseProvider.nextLong(long) long bits; long val; diff --git a/src/main/java/org/apache/commons/lang3/concurrent/locks/LockingVisitors.java b/src/main/java/org/apache/commons/lang3/concurrent/locks/LockingVisitors.java index 24755e5..0c43a6b 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/locks/LockingVisitors.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/locks/LockingVisitors.java @@ -118,7 +118,7 @@ public class LockingVisitors { * @param readLockSupplier Supplies the read lock, usually from the lock object. * @param writeLockSupplier Supplies the write lock, usually from the lock object. */ - protected LockVisitor(final O object, L lock, Supplier<Lock> readLockSupplier, Supplier<Lock> writeLockSupplier) { + protected LockVisitor(final O object, final L lock, final Supplier<Lock> readLockSupplier, final Supplier<Lock> writeLockSupplier) { this.object = Objects.requireNonNull(object, "object"); this.lock = Objects.requireNonNull(lock, "lock"); this.readLockSupplier = Objects.requireNonNull(readLockSupplier, "readLockSupplier"); @@ -143,7 +143,7 @@ public class LockingVisitors { * @see #acceptWriteLocked(FailableConsumer) * @see #applyReadLocked(FailableFunction) */ - public void acceptReadLocked(FailableConsumer<O, ?> consumer) { + public void acceptReadLocked(final FailableConsumer<O, ?> consumer) { lockAcceptUnlock(readLockSupplier, consumer); } @@ -205,7 +205,7 @@ public class LockingVisitors { * @see #acceptReadLocked(FailableConsumer) * @see #applyWriteLocked(FailableFunction) */ - public <T> T applyReadLocked(FailableFunction<O, T, ?> function) { + public <T> T applyReadLocked(final FailableFunction<O, T, ?> function) { return lockApplyUnlock(readLockSupplier, function); } @@ -271,7 +271,7 @@ public class LockingVisitors { lock.lock(); try { consumer.accept(object); - } catch (Throwable t) { + } catch (final Throwable t) { throw Failable.rethrow(t); } finally { lock.unlock(); @@ -298,7 +298,7 @@ public class LockingVisitors { lock.lock(); try { return function.apply(object); - } catch (Throwable t) { + } catch (final Throwable t) { throw Failable.rethrow(t); } finally { lock.unlock(); @@ -348,7 +348,7 @@ public class LockingVisitors { * @param object The locked (hidden) object. The caller is supposed to drop all references to the locked object. * @param stampedLock the lock to use. */ - protected StampedLockVisitor(final O object, StampedLock stampedLock) { + protected StampedLockVisitor(final O object, final StampedLock stampedLock) { super(object, stampedLock, stampedLock::asReadLock, stampedLock::asWriteLock); } } diff --git a/src/main/java/org/apache/commons/lang3/function/TriFunction.java b/src/main/java/org/apache/commons/lang3/function/TriFunction.java index 6e5af2d..7d8b81c 100644 --- a/src/main/java/org/apache/commons/lang3/function/TriFunction.java +++ b/src/main/java/org/apache/commons/lang3/function/TriFunction.java @@ -59,8 +59,8 @@ public interface TriFunction<T, U, V, R> { * @return a composed function that first applies this function and then applies the {@code after} function * @throws NullPointerException if after is null */ - default <W> TriFunction<T, U, V, W> andThen(Function<? super R, ? extends W> after) { + default <W> TriFunction<T, U, V, W> andThen(final Function<? super R, ? extends W> after) { Objects.requireNonNull(after); - return (T t, U u, V v) -> after.apply(apply(t, u, v)); + return (final T t, final U u, final V v) -> after.apply(apply(t, u, v)); } } diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index 38a5f9f..f9b74d9 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -278,7 +278,7 @@ public class ArrayUtilsTest { @Test public void testContainsDoubleNaN() { - double[] a = new double[] { Double.NEGATIVE_INFINITY, Double.NaN, Double.POSITIVE_INFINITY }; + final double[] a = new double[] { Double.NEGATIVE_INFINITY, Double.NaN, Double.POSITIVE_INFINITY }; assertTrue(ArrayUtils.contains(a, Double.POSITIVE_INFINITY)); assertTrue(ArrayUtils.contains(a, Double.NEGATIVE_INFINITY)); assertTrue(ArrayUtils.contains(a, Double.NaN)); @@ -311,7 +311,7 @@ public class ArrayUtilsTest { @Test public void testContainsFloatNaN() { - float[] array = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, Float.POSITIVE_INFINITY }; + final float[] array = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, Float.POSITIVE_INFINITY }; assertTrue(ArrayUtils.contains(array, Float.POSITIVE_INFINITY)); assertTrue(ArrayUtils.contains(array, Float.NEGATIVE_INFINITY)); assertTrue(ArrayUtils.contains(array, Float.NaN)); @@ -1062,7 +1062,7 @@ public class ArrayUtilsTest { @Test public void testIndexOfDoubleNaN() { - double[] array = new double[] { Double.NEGATIVE_INFINITY, Double.NaN, Double.POSITIVE_INFINITY, Double.NaN }; + final double[] array = new double[] { Double.NEGATIVE_INFINITY, Double.NaN, Double.POSITIVE_INFINITY, Double.NaN }; assertEquals(0, ArrayUtils.indexOf(array, Double.NEGATIVE_INFINITY)); assertEquals(1, ArrayUtils.indexOf(array, Double.NaN)); assertEquals(2, ArrayUtils.indexOf(array, Double.POSITIVE_INFINITY)); @@ -1134,7 +1134,7 @@ public class ArrayUtilsTest { @Test public void testIndexOfFloatNaN() { - float[] array = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, Float.POSITIVE_INFINITY, Float.NaN }; + final float[] array = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, Float.POSITIVE_INFINITY, Float.NaN }; assertEquals(0, ArrayUtils.indexOf(array, Float.NEGATIVE_INFINITY)); assertEquals(1, ArrayUtils.indexOf(array, Float.NaN)); assertEquals(2, ArrayUtils.indexOf(array, Float.POSITIVE_INFINITY)); diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java index 3353f7a..214724f 100644 --- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java @@ -268,8 +268,8 @@ public class CharSequenceUtilsTest { @ParameterizedTest @MethodSource("lastIndexWithStandardCharSequence") - public void testLastIndexOfWithDifferentCharSequences(CharSequence cs, CharSequence search, int start, - int expected) { + public void testLastIndexOfWithDifferentCharSequences(final CharSequence cs, final CharSequence search, final int start, + final int expected) { assertEquals(expected, CharSequenceUtils.lastIndexOf(cs, search, start)); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java index 0bcacea..a1bb83d 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java @@ -181,7 +181,7 @@ public class FieldUtilsTest { assertEquals(expected, allFields.length, Arrays.toString(allFields)); } - private Field[] sort(Field[] fields) { + private Field[] sort(final Field[] fields) { // Field does not implement Comparable, so we use a KISS solution here. return ArrayUtils.sort(fields, ObjectToStringComparator.INSTANCE); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java index 8cdce0b..3570a9a 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java @@ -739,18 +739,18 @@ public class TypeUtilsTest<B> { assertTrue(TypeUtils.isAssignable(fClassType, eClassType)); } - private void testIsAssignable(Class testUnassignableClass) { + private void testIsAssignable(final Class testUnassignableClass) { final Class<Constructor> rawClass = Constructor.class; final Class<Insets> typeArgClass = Insets.class; // Builds a ParameterizedType for Constructor<Insets> - ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); + final ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); assertEquals(rawClass, paramType.getRawType()); assertEquals(typeArgClass, paramType.getActualTypeArguments()[0]); assertFalse(testUnassignableClass.isAssignableFrom(paramType.getClass())); assertFalse(paramType.getClass().isAssignableFrom(testUnassignableClass)); - GenericArrayType arrayType = TypeUtils.genericArrayType(paramType); + final GenericArrayType arrayType = TypeUtils.genericArrayType(paramType); assertFalse(TypeUtils.isAssignable(arrayType, paramType), () -> String.format("TypeUtils.isAssignable(%s, %s)", arrayType, paramType)); assertFalse(TypeUtils.isAssignable(paramType, arrayType), @@ -762,14 +762,14 @@ public class TypeUtilsTest<B> { final Class<Constructor> rawClass = Constructor.class; final Class<Insets> typeArgClass = Insets.class; // Builds a ParameterizedType for Constructor<Insets> - ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); + final ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); assertEquals(rawClass, paramType.getRawType()); assertEquals(typeArgClass, paramType.getActualTypeArguments()[0]); assertFalse(GenericArrayType.class.isAssignableFrom(paramType.getClass())); assertFalse(paramType.getClass().isAssignableFrom(GenericArrayType.class)); - GenericArrayType testType = TypeUtils.genericArrayType(paramType); + final GenericArrayType testType = TypeUtils.genericArrayType(paramType); assertFalse(TypeUtils.isAssignable(paramType, testType), () -> String.format("TypeUtils.isAssignable(%s, %s)", paramType, testType)); assertFalse(TypeUtils.isAssignable(testType, paramType), @@ -782,14 +782,14 @@ public class TypeUtilsTest<B> { final Class<Constructor> rawClass = Constructor.class; final Class<Insets> typeArgClass = Insets.class; // Builds a ParameterizedType for Constructor<Insets> - ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); + final ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); assertEquals(rawClass, paramType.getRawType()); assertEquals(typeArgClass, paramType.getActualTypeArguments()[0]); assertFalse(WildcardType.class.isAssignableFrom(paramType.getClass())); assertFalse(paramType.getClass().isAssignableFrom(WildcardType.class)); - WildcardType testType = TypeUtils.WILDCARD_ALL; + final WildcardType testType = TypeUtils.WILDCARD_ALL; // TODO This test returns true unlike the test above. // Is this a bug in this test or in the main code? assertFalse(TypeUtils.isAssignable(paramType, testType), @@ -803,14 +803,14 @@ public class TypeUtilsTest<B> { final Class<Constructor> rawClass = Constructor.class; final Class<Insets> typeArgClass = Insets.class; // Builds a ParameterizedType for Constructor<Insets> - ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); + final ParameterizedType paramType = TypeUtils.parameterize(rawClass, typeArgClass); assertEquals(rawClass, paramType.getRawType()); assertEquals(typeArgClass, paramType.getActualTypeArguments()[0]); assertTrue(Object.class.isAssignableFrom(paramType.getClass())); assertFalse(paramType.getClass().isAssignableFrom(Object.class)); - Type testType = Object.class; + final Type testType = Object.class; assertTrue(TypeUtils.isAssignable(paramType, testType), () -> String.format("TypeUtils.isAssignable(%s, %s)", paramType, testType)); assertFalse(TypeUtils.isAssignable(testType, paramType),