Skip to content

Commit 059c468

Browse files
committed
Use final.
1 parent 9e62a0e commit 059c468

82 files changed

Lines changed: 592 additions & 588 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/org/apache/commons/collections4/CollectionUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ public static <O, R extends Collection<? super O>> R select(final Iterable<? ext
951951
* @since 4.1
952952
*/
953953
public static <O, R extends Collection<? super O>> R select(final Iterable<? extends O> inputCollection,
954-
final Predicate<? super O> predicate, R outputCollection, R rejectedCollection) {
954+
final Predicate<? super O> predicate, final R outputCollection, final R rejectedCollection) {
955955

956956
if (inputCollection != null && predicate != null) {
957957
for (final O element : inputCollection) {
@@ -1273,7 +1273,7 @@ public static <T> T get(final Iterable<T> iterable, final int index) {
12731273
* @throws IllegalArgumentException if the object type is invalid
12741274
*/
12751275
public static Object get(final Object object, final int index) {
1276-
int i = index;
1276+
final int i = index;
12771277
if (i < 0) {
12781278
throw new IndexOutOfBoundsException("Index cannot be negative: " + i);
12791279
}
@@ -1534,8 +1534,8 @@ public static int maxSize(final Collection<? extends Object> coll) {
15341534
* @throws NullPointerException if either collection is null
15351535
* @since 4.0
15361536
*/
1537-
public static <O extends Comparable<? super O>> List<O> collate(Iterable<? extends O> a,
1538-
Iterable<? extends O> b) {
1537+
public static <O extends Comparable<? super O>> List<O> collate(final Iterable<? extends O> a,
1538+
final Iterable<? extends O> b) {
15391539
return collate(a, b, ComparatorUtils.<O>naturalComparator(), true);
15401540
}
15411541

@@ -1715,7 +1715,7 @@ public static <E> Collection<E> retainAll(final Iterable<E> collection,
17151715

17161716
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
17171717
@Override
1718-
public EquatorWrapper<E> transform(E input) {
1718+
public EquatorWrapper<E> transform(final E input) {
17191719
return new EquatorWrapper<>(equator, input);
17201720
}
17211721
};
@@ -1791,7 +1791,7 @@ public static <E> Collection<E> removeAll(final Iterable<E> collection,
17911791

17921792
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
17931793
@Override
1794-
public EquatorWrapper<E> transform(E input) {
1794+
public EquatorWrapper<E> transform(final E input) {
17951795
return new EquatorWrapper<>(equator, input);
17961796
}
17971797
};

src/main/java/org/apache/commons/collections4/IterableUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static <E> Iterable<E> chainedIterable(final Iterable<? extends E>... ite
172172
public Iterator<E> iterator() {
173173
return new LazyIteratorChain<E>() {
174174
@Override
175-
protected Iterator<? extends E> nextIterator(int count) {
175+
protected Iterator<? extends E> nextIterator(final int count) {
176176
if (count > iterables.length) {
177177
return null;
178178
}
@@ -324,7 +324,7 @@ public static <E> Iterable<E> loopingIterable(final Iterable<E> iterable) {
324324
public Iterator<E> iterator() {
325325
return new LazyIteratorChain<E>() {
326326
@Override
327-
protected Iterator<? extends E> nextIterator(int count) {
327+
protected Iterator<? extends E> nextIterator(final int count) {
328328
if (IterableUtils.isEmpty(iterable)) {
329329
return null;
330330
}
@@ -546,6 +546,7 @@ public static <E> Iterable<E> zippingIterable(final Iterable<? extends E> first,
546546
@Override
547547
public Iterator<E> iterator() {
548548
@SuppressWarnings("unchecked") // safe
549+
final
549550
Iterator<? extends E>[] iterators = new Iterator[others.length + 1];
550551
iterators[0] = first.iterator();
551552
for (int i = 0; i < others.length; i++) {
@@ -915,7 +916,7 @@ public static <O, R extends Collection<O>> List<R> partition(final Iterable<? ex
915916
throw new NullPointerException("Predicates must not be null.");
916917
}
917918

918-
for (Predicate<?> p : predicates) {
919+
for (final Predicate<?> p : predicates) {
919920
if (p == null) {
920921
throw new NullPointerException("Predicate must not be null.");
921922
}

src/main/java/org/apache/commons/collections4/IteratorUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public static <E> ResettableListIterator<E> arrayListIterator(final Object array
433433
* @throws IllegalArgumentException if max is negative
434434
* @since 4.1
435435
*/
436-
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator, long max) {
436+
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator, final long max) {
437437
return boundedIterator(iterator, 0, max);
438438
}
439439

@@ -455,7 +455,7 @@ public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E>
455455
* @since 4.1
456456
*/
457457
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator,
458-
long offset, long max) {
458+
final long offset, final long max) {
459459
return new BoundedIterator<>(iterator, offset, max);
460460
}
461461

@@ -890,7 +890,7 @@ public static <E> Iterator<E> pushbackIterator(final Iterator<? extends E> itera
890890
* @throws IllegalArgumentException if offset is negative
891891
* @since 4.1
892892
*/
893-
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, long offset) {
893+
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, final long offset) {
894894
return new SkippingIterator<>(iterator, offset);
895895
}
896896

src/main/java/org/apache/commons/collections4/ListUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public static String longestCommonSubsequence(final CharSequence a, final CharSe
570570
}
571571
final List<Character> lcs = longestCommonSubsequence(new CharSequenceAsList( a ), new CharSequenceAsList( b ));
572572
final StringBuilder sb = new StringBuilder();
573-
for ( Character ch : lcs ) {
573+
for ( final Character ch : lcs ) {
574574
sb.append(ch);
575575
}
576576
return sb.toString();
@@ -614,7 +614,7 @@ public CharSequenceAsList(final CharSequence sequence) {
614614
}
615615

616616
@Override
617-
public Character get( int index ) {
617+
public Character get( final int index ) {
618618
return Character.valueOf(sequence.charAt( index ));
619619
}
620620

src/main/java/org/apache/commons/collections4/MapUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ public static <K, V> IterableSortedMap<K, V> iterableSortedMap(final SortedMap<K
17981798
* @param map a Map or null
17991799
* @return the given map size or 0 if the map is null
18001800
*/
1801-
public static int size(Map<?, ?> map) {
1801+
public static int size(final Map<?, ?> map) {
18021802
return map == null ? 0 : map.size();
18031803
}
18041804

src/main/java/org/apache/commons/collections4/MultiMapUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static <K, V> Collection<V> getCollection(final MultiValuedMap<K, V> map,
127127
*/
128128
public static <K, V> List<V> getValuesAsList(final MultiValuedMap<K, V> map, final K key) {
129129
if (map != null) {
130-
Collection<V> col = map.get(key);
130+
final Collection<V> col = map.get(key);
131131
if (col instanceof List) {
132132
return (List<V>) col;
133133
}
@@ -147,7 +147,7 @@ public static <K, V> List<V> getValuesAsList(final MultiValuedMap<K, V> map, fin
147147
*/
148148
public static <K, V> Set<V> getValuesAsSet(final MultiValuedMap<K, V> map, final K key) {
149149
if (map != null) {
150-
Collection<V> col = map.get(key);
150+
final Collection<V> col = map.get(key);
151151
if (col instanceof Set) {
152152
return (Set<V>) col;
153153
}
@@ -167,7 +167,7 @@ public static <K, V> Set<V> getValuesAsSet(final MultiValuedMap<K, V> map, final
167167
*/
168168
public static <K, V> Bag<V> getValuesAsBag(final MultiValuedMap<K, V> map, final K key) {
169169
if (map != null) {
170-
Collection<V> col = map.get(key);
170+
final Collection<V> col = map.get(key);
171171
if (col instanceof Bag) {
172172
return (Bag<V>) col;
173173
}

src/main/java/org/apache/commons/collections4/SetUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public static <E> SetView<E> union(final Set<? extends E> a, final Set<? extends
446446

447447
return new SetView<E>() {
448448
@Override
449-
public boolean contains(Object o) {
449+
public boolean contains(final Object o) {
450450
return a.contains(o) || b.contains(o);
451451
}
452452

@@ -488,14 +488,14 @@ public static <E> SetView<E> difference(final Set<? extends E> a, final Set<? ex
488488

489489
final Predicate<E> notContainedInB = new Predicate<E>() {
490490
@Override
491-
public boolean evaluate(E object) {
491+
public boolean evaluate(final E object) {
492492
return !b.contains(object);
493493
}
494494
};
495495

496496
return new SetView<E>() {
497497
@Override
498-
public boolean contains(Object o) {
498+
public boolean contains(final Object o) {
499499
return a.contains(o) && !b.contains(o);
500500
}
501501

@@ -526,14 +526,14 @@ public static <E> SetView<E> intersection(final Set<? extends E> a, final Set<?
526526

527527
final Predicate<E> containedInB = new Predicate<E>() {
528528
@Override
529-
public boolean evaluate(E object) {
529+
public boolean evaluate(final E object) {
530530
return b.contains(object);
531531
}
532532
};
533533

534534
return new SetView<E>() {
535535
@Override
536-
public boolean contains(Object o) {
536+
public boolean contains(final Object o) {
537537
return a.contains(o) && b.contains(o);
538538
}
539539

@@ -570,7 +570,7 @@ public static <E> SetView<E> disjunction(final Set<? extends E> a, final Set<? e
570570

571571
return new SetView<E>() {
572572
@Override
573-
public boolean contains(Object o) {
573+
public boolean contains(final Object o) {
574574
return a.contains(o) ^ b.contains(o);
575575
}
576576

src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,10 +1441,10 @@ private String doToString(final DataElement dataElement) {
14411441
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{
14421442
stream.defaultReadObject();
14431443
rootNode = new Node[2];
1444-
int size = stream.readInt();
1444+
final int size = stream.readInt();
14451445
for(int i = 0; i < size; i++){
1446-
K k =(K) stream.readObject();
1447-
V v =(V) stream.readObject();
1446+
final K k =(K) stream.readObject();
1447+
final V v =(V) stream.readObject();
14481448
put(k, v);
14491449
}
14501450
}

src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public Builder<E> add(final E item) {
256256
*/
257257
public Builder<E> addAll(final Collection<? extends E> items) {
258258
if (items != null) {
259-
for (E item : items) {
259+
for (final E item : items) {
260260
add(item);
261261
}
262262
}

src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public PermutationIterator(final Collection<? extends E> coll) {
8282
Arrays.fill(direction, false);
8383
int value = 1;
8484
objectMap = new HashMap<>();
85-
for (E e : coll) {
85+
for (final E e : coll) {
8686
objectMap.put(Integer.valueOf(value), e);
8787
keys[value - 1] = value;
8888
value++;
@@ -123,7 +123,7 @@ public List<E> next() {
123123
}
124124
}
125125
if (largestKey == -1) {
126-
List<E> toReturn = nextPermutation;
126+
final List<E> toReturn = nextPermutation;
127127
nextPermutation = null;
128128
return toReturn;
129129
}
@@ -133,7 +133,7 @@ public List<E> next() {
133133
final int tmpKey = keys[indexOfLargestMobileInteger];
134134
keys[indexOfLargestMobileInteger] = keys[indexOfLargestMobileInteger + offset];
135135
keys[indexOfLargestMobileInteger + offset] = tmpKey;
136-
boolean tmpDirection = direction[indexOfLargestMobileInteger];
136+
final boolean tmpDirection = direction[indexOfLargestMobileInteger];
137137
direction[indexOfLargestMobileInteger] = direction[indexOfLargestMobileInteger + offset];
138138
direction[indexOfLargestMobileInteger + offset] = tmpDirection;
139139

0 commit comments

Comments
 (0)