Skip to content
Permalink
Browse files
Use final.
  • Loading branch information
garydgregory committed Mar 4, 2022
1 parent 2a2a534 commit 505722c303e78e4f6bdd36f55940cd4659d3219c
Showing 9 changed files with 18 additions and 18 deletions.
@@ -185,7 +185,7 @@ public static <E> List<E> fixedSizeList(final List<E> list) {
* @see List#get(int)
* @since 4.5
*/
public static <T> T getFirst(List<T> list) {
public static <T> T getFirst(final List<T> list) {
return Objects.requireNonNull(list, "list").get(0);
}

@@ -200,7 +200,7 @@ public static <T> T getFirst(List<T> list) {
* @see List#get(int)
* @since 4.5
*/
public static <T> T getLast(List<T> list) {
public static <T> T getLast(final List<T> list) {
return Objects.requireNonNull(list, "list").get(list.size() - 1);
}

@@ -50,7 +50,7 @@ public void getFromEnumeration() throws Exception {
assertEquals("one", EnumerationUtils.get(en, 1));

// Enumerator, non-existent entry
Enumeration<String> finalEn = en;
final Enumeration<String> finalEn = en;
assertThrows(IndexOutOfBoundsException.class, () -> EnumerationUtils.get(finalEn, 3));

assertFalse(en.hasMoreElements());
@@ -185,7 +185,7 @@ public void testChainedTransformer() {
assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null));
assertEquals("B", TransformerUtils.chainedTransformer(a, b).transform(null));
assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null));
Collection<Transformer<Object, Object>> coll = new ArrayList<>();
final Collection<Transformer<Object, Object>> coll = new ArrayList<>();
coll.add(b);
coll.add(a);
assertEquals("A", TransformerUtils.chainedTransformer(coll).transform(null));
@@ -203,7 +203,7 @@ public void testChainedTransformer() {
() -> assertThrows(NullPointerException.class, () -> TransformerUtils.chainedTransformer(null, null)),

() -> assertThrows(NullPointerException.class, () -> {
Collection<Transformer<Object, Object>> coll1 = new ArrayList<>();
final Collection<Transformer<Object, Object>> coll1 = new ArrayList<>();
coll1.add(null);
coll1.add(null);
TransformerUtils.chainedTransformer(coll1);
@@ -400,7 +400,7 @@ public void testInstantiateTransformerNull() {

Transformer<Class<?>, Object> trans = TransformerUtils.instantiateTransformer(new Class[] { Long.class }, new Object[] { null });

Transformer<Class<?>, Object> finalTrans = trans;
final Transformer<Class<?>, Object> finalTrans = trans;
assertThrows(FunctorException.class, () -> finalTrans.transform(String.class));

trans = TransformerUtils.instantiateTransformer();
@@ -46,7 +46,7 @@ public void testFirstKey() {
resetEmpty();
OrderedBidiMap<K, V> bidi = getMap();

OrderedBidiMap<K, V> finalBidi = bidi;
final OrderedBidiMap<K, V> finalBidi = bidi;
assertThrows(NoSuchElementException.class, () -> finalBidi.firstKey());

resetFull();
@@ -59,7 +59,7 @@ public void testLastKey() {
resetEmpty();
OrderedBidiMap<K, V> bidi = getMap();

OrderedBidiMap<K, V> finalBidi = bidi;
final OrderedBidiMap<K, V> finalBidi = bidi;
assertThrows(NoSuchElementException.class, () -> finalBidi.lastKey());

resetFull();
@@ -95,7 +95,7 @@ public void testNextKey() {
assertNull(bidi.nextKey(confirmedLast));

if (!isAllowNullKey()) {
OrderedBidiMap<K, V> finalBidi = bidi;
final OrderedBidiMap<K, V> finalBidi = bidi;
assertThrows(NullPointerException.class, () -> finalBidi.nextKey(null));

} else {
@@ -129,7 +129,7 @@ public void testPreviousKey() {
assertNull(bidi.previousKey(confirmedLast));

if (!isAllowNullKey()) {
OrderedBidiMap<K, V> finalBidi = bidi;
final OrderedBidiMap<K, V> finalBidi = bidi;
assertThrows(NullPointerException.class, () -> finalBidi.previousKey(null));

} else {
@@ -156,7 +156,7 @@ public void testLock() {
public void testUnknownObjectBehavior() {
FixedOrderComparator<String> comparator = new FixedOrderComparator<>(topCities);

FixedOrderComparator<String> finalComparator = comparator;
final FixedOrderComparator<String> finalComparator = comparator;
assertThrows(IllegalArgumentException.class, () -> finalComparator.compare("New York", "Minneapolis"),
"Should have thrown a IllegalArgumentException");

@@ -71,18 +71,18 @@ public Collection<DynamicTest> testThrowingClosure() {
return Arrays.asList(

dynamicTest("Closure NoException", () -> {
Closure<Integer> closure = generateNoExceptionClosure();
final Closure<Integer> closure = generateNoExceptionClosure();
closure.execute(Integer.valueOf(0));
}),

dynamicTest("Closure IOException", () -> {
Closure<Integer> closure = generateIOExceptionClosure();
final Closure<Integer> closure = generateIOExceptionClosure();
final FunctorException thrown = assertThrows(FunctorException.class, () -> closure.execute(Integer.valueOf(0)));
assertTrue(thrown.getCause() instanceof IOException);
}),

dynamicTest("Closure NullPointerException", () -> {
Closure<Integer> closure = generateNullPointerExceptionClosure();
final Closure<Integer> closure = generateNullPointerExceptionClosure();
assertThrows(NullPointerException.class, () -> closure.execute(Integer.valueOf(0)));
})

@@ -105,7 +105,7 @@ public void testListIteratorSet() {
// a call to set() before a call to next() or previous() should throw an IllegalStateException
iter = makeArrayListIterator(testArray);

ListIterator<E> finalIter = iter;
final ListIterator<E> finalIter = iter;
assertThrows(IllegalStateException.class, () -> finalIter.set((E) "should fail"), "ListIterator#set should fail if next() or previous() have not yet been called.");
}

@@ -102,7 +102,7 @@ public void testListIteratorSet() {
// a call to set() before a call to next() or previous() should throw an IllegalStateException
iter = makeArrayListIterator((E[]) testArray);

ListIterator<E> finalIter = iter;
final ListIterator<E> finalIter = iter;
assertThrows(IllegalStateException.class, () -> finalIter.set((E) "should fail"), "ListIterator#set should fail if next() or previous() have not yet been called.");
}

@@ -394,13 +394,13 @@ public void testRemove_KeyItem() {
public void testUnsafeDeSerialization() throws Exception {
final MultiValueMap map1 = MultiValueMap.multiValueMap(new HashMap(), ArrayList.class);
byte[] bytes = serialize(map1);
Object result = deserialize(bytes);
final Object result = deserialize(bytes);
assertEquals(map1, result);

final MultiValueMap map2 = MultiValueMap.multiValueMap(new HashMap(), (Class) String.class);
bytes = serialize(map2);

byte[] finalBytes = bytes;
final byte[] finalBytes = bytes;
assertThrows(UnsupportedOperationException.class, () -> deserialize(finalBytes));
}

0 comments on commit 505722c

Please sign in to comment.