Use final.
This commit is contained in:
parent
d5196e7fe4
commit
764b9bba52
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue