Navigation Menu

Skip to content

Commit

Permalink
Use final.
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jan 3, 2018
1 parent 9e62a0e commit 059c468
Show file tree
Hide file tree
Showing 82 changed files with 592 additions and 588 deletions.
Expand Up @@ -951,7 +951,7 @@ public static <O, R extends Collection<? super O>> R select(final Iterable<? ext
* @since 4.1
*/
public static <O, R extends Collection<? super O>> R select(final Iterable<? extends O> inputCollection,
final Predicate<? super O> predicate, R outputCollection, R rejectedCollection) {
final Predicate<? super O> predicate, final R outputCollection, final R rejectedCollection) {

if (inputCollection != null && predicate != null) {
for (final O element : inputCollection) {
Expand Down Expand Up @@ -1273,7 +1273,7 @@ public static <T> T get(final Iterable<T> iterable, final int index) {
* @throws IllegalArgumentException if the object type is invalid
*/
public static Object get(final Object object, final int index) {
int i = index;
final int i = index;
if (i < 0) {
throw new IndexOutOfBoundsException("Index cannot be negative: " + i);
}
Expand Down Expand Up @@ -1534,8 +1534,8 @@ public static int maxSize(final Collection<? extends Object> coll) {
* @throws NullPointerException if either collection is null
* @since 4.0
*/
public static <O extends Comparable<? super O>> List<O> collate(Iterable<? extends O> a,
Iterable<? extends O> b) {
public static <O extends Comparable<? super O>> List<O> collate(final Iterable<? extends O> a,
final Iterable<? extends O> b) {
return collate(a, b, ComparatorUtils.<O>naturalComparator(), true);
}

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

final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
@Override
public EquatorWrapper<E> transform(E input) {
public EquatorWrapper<E> transform(final E input) {
return new EquatorWrapper<>(equator, input);
}
};
Expand Down Expand Up @@ -1791,7 +1791,7 @@ public static <E> Collection<E> removeAll(final Iterable<E> collection,

final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
@Override
public EquatorWrapper<E> transform(E input) {
public EquatorWrapper<E> transform(final E input) {
return new EquatorWrapper<>(equator, input);
}
};
Expand Down
Expand Up @@ -172,7 +172,7 @@ public static <E> Iterable<E> chainedIterable(final Iterable<? extends E>... ite
public Iterator<E> iterator() {
return new LazyIteratorChain<E>() {
@Override
protected Iterator<? extends E> nextIterator(int count) {
protected Iterator<? extends E> nextIterator(final int count) {
if (count > iterables.length) {
return null;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ public static <E> Iterable<E> loopingIterable(final Iterable<E> iterable) {
public Iterator<E> iterator() {
return new LazyIteratorChain<E>() {
@Override
protected Iterator<? extends E> nextIterator(int count) {
protected Iterator<? extends E> nextIterator(final int count) {
if (IterableUtils.isEmpty(iterable)) {
return null;
}
Expand Down Expand Up @@ -546,6 +546,7 @@ public static <E> Iterable<E> zippingIterable(final Iterable<? extends E> first,
@Override
public Iterator<E> iterator() {
@SuppressWarnings("unchecked") // safe
final
Iterator<? extends E>[] iterators = new Iterator[others.length + 1];
iterators[0] = first.iterator();
for (int i = 0; i < others.length; i++) {
Expand Down Expand Up @@ -915,7 +916,7 @@ public static <O, R extends Collection<O>> List<R> partition(final Iterable<? ex
throw new NullPointerException("Predicates must not be null.");
}

for (Predicate<?> p : predicates) {
for (final Predicate<?> p : predicates) {
if (p == null) {
throw new NullPointerException("Predicate must not be null.");
}
Expand Down
Expand Up @@ -433,7 +433,7 @@ public static <E> ResettableListIterator<E> arrayListIterator(final Object array
* @throws IllegalArgumentException if max is negative
* @since 4.1
*/
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator, long max) {
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator, final long max) {
return boundedIterator(iterator, 0, max);
}

Expand All @@ -455,7 +455,7 @@ public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E>
* @since 4.1
*/
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator,
long offset, long max) {
final long offset, final long max) {
return new BoundedIterator<>(iterator, offset, max);
}

Expand Down Expand Up @@ -890,7 +890,7 @@ public static <E> Iterator<E> pushbackIterator(final Iterator<? extends E> itera
* @throws IllegalArgumentException if offset is negative
* @since 4.1
*/
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, long offset) {
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, final long offset) {
return new SkippingIterator<>(iterator, offset);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/commons/collections4/ListUtils.java
Expand Up @@ -570,7 +570,7 @@ public static String longestCommonSubsequence(final CharSequence a, final CharSe
}
final List<Character> lcs = longestCommonSubsequence(new CharSequenceAsList( a ), new CharSequenceAsList( b ));
final StringBuilder sb = new StringBuilder();
for ( Character ch : lcs ) {
for ( final Character ch : lcs ) {
sb.append(ch);
}
return sb.toString();
Expand Down Expand Up @@ -614,7 +614,7 @@ public CharSequenceAsList(final CharSequence sequence) {
}

@Override
public Character get( int index ) {
public Character get( final int index ) {
return Character.valueOf(sequence.charAt( index ));
}

Expand Down
Expand Up @@ -1798,7 +1798,7 @@ public static <K, V> IterableSortedMap<K, V> iterableSortedMap(final SortedMap<K
* @param map a Map or null
* @return the given map size or 0 if the map is null
*/
public static int size(Map<?, ?> map) {
public static int size(final Map<?, ?> map) {
return map == null ? 0 : map.size();
}

Expand Down
Expand Up @@ -127,7 +127,7 @@ public static <K, V> Collection<V> getCollection(final MultiValuedMap<K, V> map,
*/
public static <K, V> List<V> getValuesAsList(final MultiValuedMap<K, V> map, final K key) {
if (map != null) {
Collection<V> col = map.get(key);
final Collection<V> col = map.get(key);
if (col instanceof List) {
return (List<V>) col;
}
Expand All @@ -147,7 +147,7 @@ public static <K, V> List<V> getValuesAsList(final MultiValuedMap<K, V> map, fin
*/
public static <K, V> Set<V> getValuesAsSet(final MultiValuedMap<K, V> map, final K key) {
if (map != null) {
Collection<V> col = map.get(key);
final Collection<V> col = map.get(key);
if (col instanceof Set) {
return (Set<V>) col;
}
Expand All @@ -167,7 +167,7 @@ public static <K, V> Set<V> getValuesAsSet(final MultiValuedMap<K, V> map, final
*/
public static <K, V> Bag<V> getValuesAsBag(final MultiValuedMap<K, V> map, final K key) {
if (map != null) {
Collection<V> col = map.get(key);
final Collection<V> col = map.get(key);
if (col instanceof Bag) {
return (Bag<V>) col;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/apache/commons/collections4/SetUtils.java
Expand Up @@ -446,7 +446,7 @@ public static <E> SetView<E> union(final Set<? extends E> a, final Set<? extends

return new SetView<E>() {
@Override
public boolean contains(Object o) {
public boolean contains(final Object o) {
return a.contains(o) || b.contains(o);
}

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

final Predicate<E> notContainedInB = new Predicate<E>() {
@Override
public boolean evaluate(E object) {
public boolean evaluate(final E object) {
return !b.contains(object);
}
};

return new SetView<E>() {
@Override
public boolean contains(Object o) {
public boolean contains(final Object o) {
return a.contains(o) && !b.contains(o);
}

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

final Predicate<E> containedInB = new Predicate<E>() {
@Override
public boolean evaluate(E object) {
public boolean evaluate(final E object) {
return b.contains(object);
}
};

return new SetView<E>() {
@Override
public boolean contains(Object o) {
public boolean contains(final Object o) {
return a.contains(o) && b.contains(o);
}

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

return new SetView<E>() {
@Override
public boolean contains(Object o) {
public boolean contains(final Object o) {
return a.contains(o) ^ b.contains(o);
}

Expand Down
Expand Up @@ -1441,10 +1441,10 @@ private String doToString(final DataElement dataElement) {
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{
stream.defaultReadObject();
rootNode = new Node[2];
int size = stream.readInt();
final int size = stream.readInt();
for(int i = 0; i < size; i++){
K k =(K) stream.readObject();
V v =(V) stream.readObject();
final K k =(K) stream.readObject();
final V v =(V) stream.readObject();
put(k, v);
}
}
Expand Down
Expand Up @@ -256,7 +256,7 @@ public Builder<E> add(final E item) {
*/
public Builder<E> addAll(final Collection<? extends E> items) {
if (items != null) {
for (E item : items) {
for (final E item : items) {
add(item);
}
}
Expand Down
Expand Up @@ -82,7 +82,7 @@ public PermutationIterator(final Collection<? extends E> coll) {
Arrays.fill(direction, false);
int value = 1;
objectMap = new HashMap<>();
for (E e : coll) {
for (final E e : coll) {
objectMap.put(Integer.valueOf(value), e);
keys[value - 1] = value;
value++;
Expand Down Expand Up @@ -123,7 +123,7 @@ public List<E> next() {
}
}
if (largestKey == -1) {
List<E> toReturn = nextPermutation;
final List<E> toReturn = nextPermutation;
nextPermutation = null;
return toReturn;
}
Expand All @@ -133,7 +133,7 @@ public List<E> next() {
final int tmpKey = keys[indexOfLargestMobileInteger];
keys[indexOfLargestMobileInteger] = keys[indexOfLargestMobileInteger + offset];
keys[indexOfLargestMobileInteger + offset] = tmpKey;
boolean tmpDirection = direction[indexOfLargestMobileInteger];
final boolean tmpDirection = direction[indexOfLargestMobileInteger];
direction[indexOfLargestMobileInteger] = direction[indexOfLargestMobileInteger + offset];
direction[indexOfLargestMobileInteger + offset] = tmpDirection;

Expand Down
Expand Up @@ -53,7 +53,7 @@ public K getKey() {
return key;
}

protected K setKey(K key) {
protected K setKey(final K key) {
final K old = this.key;
this.key = key;
return old;
Expand All @@ -69,7 +69,7 @@ public V getValue() {
return value;
}

protected V setValue(V value) {
protected V setValue(final V value) {
final V old = this.value;
this.value = value;
return old;
Expand Down
Expand Up @@ -261,7 +261,7 @@ public boolean removeAll(final Collection<?> coll) {
*/
@Override
public boolean retainAll(final Collection<?> coll) {
boolean result = set.retainAll(coll);
final boolean result = set.retainAll(coll);
if (result == false) {
return false;
}
Expand Down
Expand Up @@ -1062,7 +1062,7 @@ protected void doReadObject(final ObjectInputStream in) throws IOException, Clas
* @param type the type to check against.
* @return true if keyType has the specified type
*/
protected boolean isKeyType(ReferenceStrength type) {
protected boolean isKeyType(final ReferenceStrength type) {
return this.keyType == type;
}
}
Expand Up @@ -429,7 +429,7 @@ public Iterator<Entry<K, V>> iterator() {

return new LazyIteratorChain<Entry<K, V>>() {
@Override
protected Iterator<? extends Entry<K, V>> nextIterator(int count) {
protected Iterator<? extends Entry<K, V>> nextIterator(final int count) {
if ( ! keyIterator.hasNext() ) {
return null;
}
Expand All @@ -447,7 +447,7 @@ public V getValue() {
return input;
}
@Override
public V setValue(V value) {
public V setValue(final V value) {
throw new UnsupportedOperationException();
}
};
Expand Down Expand Up @@ -566,7 +566,7 @@ public T create() {
}
}

private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
private void readObject(final ObjectInputStream is) throws IOException, ClassNotFoundException {
is.defaultReadObject();
// ensure that the de-serialized class is a Collection, COLLECTIONS-580
if (clazz != null && !Collection.class.isAssignableFrom(clazz)) {
Expand Down

0 comments on commit 059c468

Please sign in to comment.