From bb99f201b174a64a0eaeb3a5b115ac8a1a2e38d1 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 10 Oct 2023 16:14:05 -0400 Subject: [PATCH] Make private static classes final --- .../java/org/apache/commons/collections4/CollectionUtils.java | 4 ++-- src/main/java/org/apache/commons/collections4/ListUtils.java | 2 +- .../java/org/apache/commons/collections4/SplitMapUtils.java | 4 ++-- .../org/apache/commons/collections4/map/MultiValueMap.java | 2 +- .../commons/collections4/multiset/AbstractMapMultiSet.java | 2 +- .../commons/collections4/multiset/AbstractMultiSet.java | 2 +- .../commons/collections4/properties/PropertiesFactory.java | 2 +- .../commons/collections4/sequence/SequencesComparator.java | 2 +- .../commons/collections4/trie/AbstractPatriciaTrie.java | 2 +- .../java/org/apache/commons/collections4/MapPerformance.java | 2 +- .../commons/collections4/bidimap/DualTreeBidiMap2Test.java | 2 +- .../bloomfilter/IndexProducerFromBitmapProducerTest.java | 2 +- .../commons/collections4/bloomfilter/IndexProducerTest.java | 2 +- .../collection/PredicatedCollectionBuilderTest.java | 2 +- .../collections4/collection/TransformedCollectionTest.java | 4 ++-- .../collections4/functors/ComparatorPredicateTest.java | 2 +- .../apache/commons/collections4/map/LazySortedMapTest.java | 2 +- .../commons/collections4/map/PassiveExpiringMapTest.java | 2 +- .../org/apache/commons/collections4/map/ReferenceMapTest.java | 2 +- .../collections4/sequence/SequencesComparatorTest.java | 2 +- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 28b5f3a67d..caf178164b 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -161,7 +161,7 @@ private int getFreq(final Object obj, final Map freqMap) { * Helper class for set-related operations, e.g. union, subtract, intersection. * @param the element type */ - private static class SetOperationCardinalityHelper extends CardinalityHelper implements Iterable { + private static final class SetOperationCardinalityHelper extends CardinalityHelper implements Iterable { /** Contains the unique elements of the two collections. */ private final Set elements; @@ -712,7 +712,7 @@ public static int hashCode(final Collection collection, * @param the element type * @since 4.0 */ - private static class EquatorWrapper { + private static final class EquatorWrapper { private final Equator equator; private final O object; diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java index 4dccc16a79..054c070a26 100644 --- a/src/main/java/org/apache/commons/collections4/ListUtils.java +++ b/src/main/java/org/apache/commons/collections4/ListUtils.java @@ -98,7 +98,7 @@ public void visitKeepCommand(final E object) { * Provides a partition view on a {@link List}. * @since 4.0 */ - private static class Partition extends AbstractList> { + private static final class Partition extends AbstractList> { private final List list; private final int size; diff --git a/src/main/java/org/apache/commons/collections4/SplitMapUtils.java b/src/main/java/org/apache/commons/collections4/SplitMapUtils.java index fbd1364dd8..0fe2ffc045 100644 --- a/src/main/java/org/apache/commons/collections4/SplitMapUtils.java +++ b/src/main/java/org/apache/commons/collections4/SplitMapUtils.java @@ -44,7 +44,7 @@ public class SplitMapUtils { private SplitMapUtils() {} - private static class WrappedGet implements IterableMap, Unmodifiable { + private static final class WrappedGet implements IterableMap, Unmodifiable { private final Get get; private WrappedGet(final Get get) { @@ -136,7 +136,7 @@ public MapIterator mapIterator() { } } - private static class WrappedPut implements Map, Put { + private static final class WrappedPut implements Map, Put { private final Put put; private WrappedPut(final Put put) { diff --git a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java index 796f1b39be..ed2474ae8f 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java @@ -541,7 +541,7 @@ public V next() { /** * Inner class that provides a simple reflection factory. */ - private static class ReflectionFactory> implements Factory, Serializable { + private static final class ReflectionFactory> implements Factory, Serializable { /** Serialization version */ private static final long serialVersionUID = 2986114157496788874L; diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java index 4f1cdfd02c..05b1ddef01 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java @@ -147,7 +147,7 @@ public Iterator iterator() { /** * Inner class iterator for the MultiSet. */ - private static class MapBasedMultiSetIterator implements Iterator { + private static final class MapBasedMultiSetIterator implements Iterator { private final AbstractMapMultiSet parent; private final Iterator> entryIterator; private Map.Entry current; diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java index 312ae2b117..fe2b0793d0 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java @@ -122,7 +122,7 @@ public Iterator iterator() { /** * Inner class iterator for the MultiSet. */ - private static class MultiSetIterator implements Iterator { + private static final class MultiSetIterator implements Iterator { private final AbstractMultiSet parent; private final Iterator> entryIterator; private Entry current; diff --git a/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java b/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java index 57045254c0..ef6eef6bf8 100644 --- a/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java +++ b/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java @@ -43,7 +43,7 @@ */ public class PropertiesFactory extends AbstractPropertiesFactory { - private static class EmptyProperties extends Properties { + private static final class EmptyProperties extends Properties { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java b/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java index 2121948775..89d940d99e 100644 --- a/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java +++ b/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java @@ -292,7 +292,7 @@ private void buildScript(final int start1, final int end1, final int start2, fin * This class is a simple placeholder to hold the end part of a path * under construction in a {@link SequencesComparator SequencesComparator}. */ - private static class Snake { + private static final class Snake { /** Start index. */ private final int start; diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java index 166618c5ee..35ab7fb984 100644 --- a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java @@ -1257,7 +1257,7 @@ static boolean isValidUplink(final TrieEntry next, final TrieEntry f * wise there's no difference (except for the need to load the * {@link Reference} Class but that happens only once). */ - private static class Reference { + private static final class Reference { private E item; diff --git a/src/test/java/org/apache/commons/collections4/MapPerformance.java b/src/test/java/org/apache/commons/collections4/MapPerformance.java index ba0cf0d14a..e2dcff61f0 100644 --- a/src/test/java/org/apache/commons/collections4/MapPerformance.java +++ b/src/test/java/org/apache/commons/collections4/MapPerformance.java @@ -127,7 +127,7 @@ private static void test(final Map map, final String name) { System.out.println(name + (endMillis - startMillis)); } - private static class DummyMap implements Map { + private static final class DummyMap implements Map { @Override public void clear() { } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java index 008f27a807..fd7516d205 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java @@ -97,7 +97,7 @@ public void testSerializeDeserializeCheckComparator() throws Exception { } } - private static class IntegerComparator implements Comparator, Serializable{ + private static final class IntegerComparator implements Comparator, Serializable{ private static final long serialVersionUID = 1L; @Override public int compare(final Integer o1, final Integer o2) { diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerFromBitmapProducerTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerFromBitmapProducerTest.java index f048ba35ca..a823e39f07 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerFromBitmapProducerTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerFromBitmapProducerTest.java @@ -84,7 +84,7 @@ public final void testFromBitMapProducerTest() { } } - private static class TestingBitMapProducer implements BitMapProducer { + private static final class TestingBitMapProducer implements BitMapProducer { long[] values; TestingBitMapProducer(final long[] values) { diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerTest.java index 9cf4bcc37f..7aa96e5b32 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/IndexProducerTest.java @@ -54,7 +54,7 @@ public void fromBitMapProducerTest() { } } - private static class TestingBitMapProducer implements BitMapProducer { + private static final class TestingBitMapProducer implements BitMapProducer { long[] values; TestingBitMapProducer(final long[] values) { diff --git a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java index 484189fd5f..8c25f77763 100644 --- a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java @@ -129,7 +129,7 @@ private void checkPredicatedCollection2(final Collection collection) { assertEquals(3, collection.size()); } - private static class OddPredicate implements Predicate { + private static final class OddPredicate implements Predicate { @Override public boolean evaluate(final Integer value) { return value % 2 == 1; diff --git a/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java index d5e0b951fd..28f52ad3ee 100644 --- a/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java @@ -38,14 +38,14 @@ */ public class TransformedCollectionTest extends AbstractCollectionTest { - private static class StringToInteger implements Transformer { + private static final class StringToInteger implements Transformer { @Override public Object transform(final Object input) { return Integer.valueOf((String) input); } } - private static class ToLowerCase implements Transformer { + private static final class ToLowerCase implements Transformer { @Override public Object transform(final Object input) { return ((String) input).toLowerCase(); diff --git a/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java index 49603dd478..c3a92a867e 100644 --- a/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java @@ -26,7 +26,7 @@ public class ComparatorPredicateTest extends AbstractPredicateTest { - private static class TestComparator> implements Comparator { + private static final class TestComparator> implements Comparator { @Override public int compare(final T first, final T second) { return first.compareTo(second); diff --git a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java index bc21d916a2..39429c955f 100644 --- a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java @@ -45,7 +45,7 @@ @SuppressWarnings("boxing") public class LazySortedMapTest extends AbstractSortedMapTest { - private static class ReverseStringComparator implements Comparator { + private static final class ReverseStringComparator implements Comparator { @Override public int compare(final String arg0, final String arg1) { diff --git a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java index 39a4bb22e4..2efba94134 100644 --- a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java @@ -40,7 +40,7 @@ */ public class PassiveExpiringMapTest extends AbstractMapTest { - private static class TestExpirationPolicy + private static final class TestExpirationPolicy implements ExpirationPolicy { private static final long serialVersionUID = 1L; diff --git a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java index aa48b36ba5..342530a9ac 100644 --- a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java @@ -346,7 +346,7 @@ private static void gc() { } } - private static class AccessibleEntry extends ReferenceEntry { + private static final class AccessibleEntry extends ReferenceEntry { final AbstractReferenceMap parent; final Consumer consumer; diff --git a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java index 97c8143ef7..6ec1a79848 100644 --- a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java @@ -154,7 +154,7 @@ private List sequence(final String string) { return list; } - private static class ExecutionVisitor implements CommandVisitor { + private static final class ExecutionVisitor implements CommandVisitor { private List v; private int index;