diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 1176477da..c12e94a40 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -1568,10 +1568,10 @@ public class CollectionUtils { return ((Object[]) object).length == 0; } if (object instanceof Iterator) { - return ((Iterator) object).hasNext() == false; + return !((Iterator) object).hasNext(); } if (object instanceof Enumeration) { - return ((Enumeration) object).hasMoreElements() == false; + return !((Enumeration) object).hasMoreElements(); } try { return Array.getLength(object) == 0; diff --git a/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java b/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java index 4e85fb487..de2f5fe62 100644 --- a/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java @@ -225,7 +225,7 @@ public abstract class AbstractMapBag implements Bag { if (parent.modCount != mods) { throw new ConcurrentModificationException(); } - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(); } final MutableInteger mut = current.getValue(); @@ -427,7 +427,7 @@ public abstract class AbstractMapBag implements Bag { @Override public boolean equals(final Object obj) { - if (obj instanceof MutableInteger == false) { + if (!(obj instanceof MutableInteger)) { return false; } return ((MutableInteger) obj).value == value; @@ -558,7 +558,7 @@ public abstract class AbstractMapBag implements Bag { if (object == this) { return true; } - if (object instanceof Bag == false) { + if (!(object instanceof Bag)) { return false; } final Bag other = (Bag) object; diff --git a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java index daad131d2..550ce16f5 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java @@ -422,7 +422,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { boolean modified = false; final Iterator it = iterator(); while (it.hasNext()) { - if (coll.contains(it.next()) == false) { + if (!coll.contains(it.next())) { it.remove(); modified = true; } @@ -509,7 +509,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } final Object value = parent.normalMap.get(lastKey); @@ -594,7 +594,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } super.remove(); // removes from maps[0] @@ -629,7 +629,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; @@ -679,7 +679,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } // store value as remove may change the entry in the decorator (eg.TreeMap) @@ -762,7 +762,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } // store value as remove may change the entry in the decorator (eg.TreeMap) diff --git a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java index 20094bed9..ff6922368 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java @@ -1362,7 +1362,7 @@ public class TreeBidiMap, V extends Comparable> if (obj == this) { return true; } - if (obj instanceof Map == false) { + if (!(obj instanceof Map)) { return false; } final Map other = (Map) obj; @@ -1375,7 +1375,7 @@ public class TreeBidiMap, V extends Comparable> for (final MapIterator it = getMapIterator(dataElement); it.hasNext(); ) { final Object key = it.next(); final Object value = it.getValue(); - if (value.equals(other.get(key)) == false) { + if (!value.equals(other.get(key))) { return false; } } @@ -1575,7 +1575,7 @@ public class TreeBidiMap, V extends Comparable> @Override public boolean contains(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; @@ -1586,7 +1586,7 @@ public class TreeBidiMap, V extends Comparable> @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; @@ -1616,7 +1616,7 @@ public class TreeBidiMap, V extends Comparable> @Override public boolean contains(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; @@ -1627,7 +1627,7 @@ public class TreeBidiMap, V extends Comparable> @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; diff --git a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java index 6a08cba81..e9110705a 100644 --- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java @@ -113,7 +113,7 @@ public class CompositeCollection implements Collection, Serializable { @Override public boolean isEmpty() { for (final Collection item : all) { - if (item.isEmpty() == false) { + if (!item.isEmpty()) { return false; } } @@ -262,7 +262,7 @@ public class CompositeCollection implements Collection, Serializable { return false; } for (final Object item : coll) { - if (contains(item) == false) { + if (!contains(item)) { return false; } } diff --git a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java index 005dc285a..0fb3cb024 100644 --- a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java @@ -139,7 +139,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @throws IllegalArgumentException if the add is invalid */ protected void validate(final E object) { - if (predicate.evaluate(object) == false) { + if (!predicate.evaluate(object)) { throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" + predicate + "' rejected it"); } diff --git a/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java b/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java index baa36f512..c2d2fc12a 100644 --- a/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java @@ -98,7 +98,7 @@ public final class UnmodifiableBoundedCollection extends AbstractCollectionDe } } - if (collection instanceof BoundedCollection == false) { + if (!(collection instanceof BoundedCollection)) { throw new IllegalArgumentException("Collection is not a bounded collection."); } return new UnmodifiableBoundedCollection<>((BoundedCollection) collection); diff --git a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java index 88ebfd9f2..e7b28a6b2 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java +++ b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java @@ -94,7 +94,7 @@ public class ComparatorChain implements Comparator, Serializable { comparatorChain = new ArrayList<>(1); comparatorChain.add(comparator); orderingBits = new BitSet(1); - if (reverse == true) { + if (reverse) { orderingBits.set(0); } } @@ -153,7 +153,7 @@ public class ComparatorChain implements Comparator, Serializable { checkLocked(); comparatorChain.add(comparator); - if (reverse == true) { + if (reverse) { orderingBits.set(comparatorChain.size() - 1); } } @@ -183,7 +183,7 @@ public class ComparatorChain implements Comparator, Serializable { checkLocked(); comparatorChain.set(index, comparator); - if (reverse == true) { + if (reverse) { orderingBits.set(index); } else { orderingBits.clear(index); @@ -239,7 +239,7 @@ public class ComparatorChain implements Comparator, Serializable { * @throws UnsupportedOperationException if the {@link ComparatorChain} is locked */ private void checkLocked() { - if (isLocked == true) { + if (isLocked) { throw new UnsupportedOperationException( "Comparator ordering cannot be changed after the first comparison is performed"); } @@ -268,7 +268,7 @@ public class ComparatorChain implements Comparator, Serializable { */ @Override public int compare(final E o1, final E o2) throws UnsupportedOperationException { - if (isLocked == false) { + if (!isLocked) { checkChainIntegrity(); isLocked = true; } @@ -281,7 +281,7 @@ public class ComparatorChain implements Comparator, Serializable { int retval = comparator.compare(o1, o2); if (retval != 0) { // invert the order if it is a reverse sort - if (orderingBits.get(comparatorIndex) == true) { + if (orderingBits.get(comparatorIndex)) { if (retval > 0) { retval = -1; } else { diff --git a/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java index 32dc5c76f..3f600d72e 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java @@ -107,7 +107,7 @@ public class ConstantTransformer implements Transformer, Serializabl if (obj == this) { return true; } - if (obj instanceof ConstantTransformer == false) { + if (!(obj instanceof ConstantTransformer)) { return false; } final Object otherConstant = ((ConstantTransformer) obj).getConstant(); diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java b/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java index 4ddaf716b..918851312 100644 --- a/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java @@ -143,7 +143,7 @@ public class SwitchClosure implements Closure, Serializable { @Override public void execute(final E input) { for (int i = 0; i < iPredicates.length; i++) { - if (iPredicates[i].evaluate(input) == true) { + if (iPredicates[i].evaluate(input)) { iClosures[i].execute(input); return; } diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java index 4f5030d94..31dd04784 100644 --- a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java @@ -158,7 +158,7 @@ public class SwitchTransformer implements Transformer, Serializable @Override public O transform(final I input) { for (int i = 0; i < iPredicates.length; i++) { - if (iPredicates[i].evaluate(input) == true) { + if (iPredicates[i].evaluate(input)) { return iTransformers[i].transform(input); } } diff --git a/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java index c4d786575..824267940 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java @@ -144,7 +144,7 @@ public class ArrayIterator implements ResettableIterator { @Override @SuppressWarnings("unchecked") public E next() { - if (hasNext() == false) { + if (!hasNext()) { throw new NoSuchElementException(); } return (E) Array.get(array, index++); diff --git a/src/main/java/org/apache/commons/collections4/iterators/ArrayListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ArrayListIterator.java index 08452b71b..b5486709c 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ArrayListIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ArrayListIterator.java @@ -115,7 +115,7 @@ public class ArrayListIterator extends ArrayIterator @Override @SuppressWarnings("unchecked") public E previous() { - if (hasPrevious() == false) { + if (!hasPrevious()) { throw new NoSuchElementException(); } this.lastItemIndex = --this.index; @@ -131,7 +131,7 @@ public class ArrayListIterator extends ArrayIterator @Override @SuppressWarnings("unchecked") public E next() { - if (hasNext() == false) { + if (!hasNext()) { throw new NoSuchElementException(); } this.lastItemIndex = this.index; diff --git a/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java b/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java index f84b624ca..aff22f302 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java @@ -238,7 +238,7 @@ public class CollatingIterator implements Iterator { */ @Override public E next() throws NoSuchElementException { - if (hasNext() == false) { + if (!hasNext()) { throw new NoSuchElementException(); } final int leastIndex = least(); @@ -346,7 +346,7 @@ public class CollatingIterator implements Iterator { int leastIndex = -1; E leastObject = null; for (int i = 0; i < values.size(); i++) { - if (valueSet.get(i) == false) { + if (!valueSet.get(i)) { set(i); } if (valueSet.get(i)) { diff --git a/src/main/java/org/apache/commons/collections4/iterators/EntrySetMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EntrySetMapIterator.java index 3bd50be86..d9ec6e44b 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EntrySetMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EntrySetMapIterator.java @@ -92,7 +92,7 @@ public class EntrySetMapIterator implements MapIterator, ResettableI */ @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } iterator.remove(); diff --git a/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java b/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java index bb93ed889..36e727188 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java +++ b/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java @@ -180,7 +180,7 @@ public class IteratorChain implements Iterator { * Checks whether the iterator chain is now locked and in use. */ private void checkLocked() { - if (isLocked == true) { + if (isLocked) { throw new UnsupportedOperationException( "IteratorChain cannot be changed after the first use of a method from the Iterator interface"); } @@ -191,7 +191,7 @@ public class IteratorChain implements Iterator { * from all Iterator interface methods. */ private void lockChain() { - if (isLocked == false) { + if (!isLocked) { isLocked = true; } } @@ -212,7 +212,7 @@ public class IteratorChain implements Iterator { lastUsedIterator = currentIterator; } - while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) { + while (!currentIterator.hasNext() && !iteratorChain.isEmpty()) { currentIterator = iteratorChain.remove(); } } diff --git a/src/main/java/org/apache/commons/collections4/iterators/LazyIteratorChain.java b/src/main/java/org/apache/commons/collections4/iterators/LazyIteratorChain.java index 2c5b7efc2..111c6020e 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/LazyIteratorChain.java +++ b/src/main/java/org/apache/commons/collections4/iterators/LazyIteratorChain.java @@ -90,7 +90,7 @@ public abstract class LazyIteratorChain implements Iterator { lastUsedIterator = currentIterator; } - while (currentIterator.hasNext() == false && !chainExhausted) { + while (!currentIterator.hasNext() && !chainExhausted) { final Iterator nextIterator = nextIterator(++callCounter); if (nextIterator != null) { currentIterator = nextIterator; diff --git a/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java b/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java index e37a576c6..7f0752005 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java @@ -84,7 +84,7 @@ public class LoopingIterator implements ResettableIterator { if (collection.isEmpty()) { throw new NoSuchElementException("There are no elements for this iterator to loop on"); } - if (iterator.hasNext() == false) { + if (!iterator.hasNext()) { reset(); } return iterator.next(); diff --git a/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java index 0f1fc3dd1..0719a4459 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java @@ -87,7 +87,7 @@ public class LoopingListIterator implements ResettableListIterator { throw new NoSuchElementException( "There are no elements for this iterator to loop on"); } - if (iterator.hasNext() == false) { + if (!iterator.hasNext()) { reset(); } return iterator.next(); @@ -110,7 +110,7 @@ public class LoopingListIterator implements ResettableListIterator { throw new NoSuchElementException( "There are no elements for this iterator to loop on"); } - if (iterator.hasNext() == false) { + if (!iterator.hasNext()) { return 0; } return iterator.nextIndex(); @@ -144,7 +144,7 @@ public class LoopingListIterator implements ResettableListIterator { throw new NoSuchElementException( "There are no elements for this iterator to loop on"); } - if (iterator.hasPrevious() == false) { + if (!iterator.hasPrevious()) { E result = null; while (iterator.hasNext()) { result = iterator.next(); @@ -172,7 +172,7 @@ public class LoopingListIterator implements ResettableListIterator { throw new NoSuchElementException( "There are no elements for this iterator to loop on"); } - if (iterator.hasPrevious() == false) { + if (!iterator.hasPrevious()) { return list.size() - 1; } return iterator.previousIndex(); diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java index b05a017df..f76405bca 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java @@ -120,7 +120,7 @@ public class ObjectArrayIterator implements ResettableIterator { */ @Override public E next() { - if (hasNext() == false) { + if (!hasNext()) { throw new NoSuchElementException(); } return this.array[this.index++]; diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator.java index ae9e1d081..fdf820935 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator.java @@ -108,7 +108,7 @@ public class ObjectArrayListIterator extends ObjectArrayIterator */ @Override public E previous() { - if (hasPrevious() == false) { + if (!hasPrevious()) { throw new NoSuchElementException(); } this.lastItemIndex = --this.index; @@ -123,7 +123,7 @@ public class ObjectArrayListIterator extends ObjectArrayIterator */ @Override public E next() { - if (hasNext() == false) { + if (!hasNext()) { throw new NoSuchElementException(); } this.lastItemIndex = this.index; diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java index d16f1b5d9..7c0b182a5 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java @@ -182,7 +182,7 @@ public class ObjectGraphIterator implements Iterator { currentIterator = iterator; } - while (currentIterator.hasNext() && hasNext == false) { + while (currentIterator.hasNext() && !hasNext) { E next = currentIterator.next(); if (transformer != null) { next = transformer.transform(next); @@ -218,7 +218,7 @@ public class ObjectGraphIterator implements Iterator { @Override public E next() { updateCurrentIterator(); - if (hasNext == false) { + if (!hasNext) { throw new NoSuchElementException("No more elements in the iteration"); } lastUsedIterator = currentIterator; diff --git a/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java index e73c16869..0abf9e4ae 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java @@ -132,7 +132,7 @@ public class ReverseListIterator implements ResettableListIterator { */ @Override public void remove() { - if (validForUpdate == false) { + if (!validForUpdate) { throw new IllegalStateException("Cannot remove from list until next() or previous() called"); } iterator.remove(); @@ -147,7 +147,7 @@ public class ReverseListIterator implements ResettableListIterator { */ @Override public void set(final E obj) { - if (validForUpdate == false) { + if (!validForUpdate) { throw new IllegalStateException("Cannot set to list until next() or previous() called"); } iterator.set(obj); @@ -164,7 +164,7 @@ public class ReverseListIterator implements ResettableListIterator { public void add(final E obj) { // the validForUpdate flag is needed as the necessary previous() // method call re-enables remove and add - if (validForUpdate == false) { + if (!validForUpdate) { throw new IllegalStateException("Cannot add to list until next() or previous() called"); } validForUpdate = false; diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/AbstractMapEntry.java b/src/main/java/org/apache/commons/collections4/keyvalue/AbstractMapEntry.java index f5f87171e..7b76e2354 100644 --- a/src/main/java/org/apache/commons/collections4/keyvalue/AbstractMapEntry.java +++ b/src/main/java/org/apache/commons/collections4/keyvalue/AbstractMapEntry.java @@ -67,7 +67,7 @@ public abstract class AbstractMapEntry extends AbstractKeyValue impl if (obj == this) { return true; } - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry other = (Map.Entry) obj; diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java b/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java index 17950761d..8d6d3cc49 100644 --- a/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java +++ b/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java @@ -129,7 +129,7 @@ public class DefaultKeyValue extends AbstractKeyValue { if (obj == this) { return true; } - if (obj instanceof DefaultKeyValue == false) { + if (!(obj instanceof DefaultKeyValue)) { return false; } diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/TiedMapEntry.java b/src/main/java/org/apache/commons/collections4/keyvalue/TiedMapEntry.java index 100534078..832681745 100644 --- a/src/main/java/org/apache/commons/collections4/keyvalue/TiedMapEntry.java +++ b/src/main/java/org/apache/commons/collections4/keyvalue/TiedMapEntry.java @@ -104,7 +104,7 @@ public class TiedMapEntry implements Map.Entry, KeyValue, Seri if (obj == this) { return true; } - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry other = (Map.Entry) obj; diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java index eb8dff7a9..51134e8ee 100644 --- a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java +++ b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java @@ -300,7 +300,7 @@ public abstract class AbstractLinkedList implements List { boolean modified = false; final Iterator it = iterator(); while (it.hasNext()) { - if (coll.contains(it.next()) == false) { + if (!coll.contains(it.next())) { it.remove(); modified = true; } @@ -375,7 +375,7 @@ public abstract class AbstractLinkedList implements List { if (obj == this) { return true; } - if (obj instanceof List == false) { + if (!(obj instanceof List)) { return false; } final List other = (List) obj; diff --git a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java index e120d9ceb..01569eb08 100644 --- a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java +++ b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java @@ -474,7 +474,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se */ @Override public int nextIndex() { - if (nextIndexValid == false) { + if (!nextIndexValid) { if (next == parent.header) { nextIndex = parent.size(); } else { diff --git a/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java b/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java index 84a014d3e..529077ee1 100644 --- a/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java +++ b/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java @@ -147,7 +147,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { @Override public void add(final int index, final E object) { // adds element if it is not contained already - if (set.contains(object) == false) { + if (!set.contains(object)) { set.add(object); super.add(index, object); } @@ -273,7 +273,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { @Override public boolean retainAll(final Collection coll) { final boolean result = set.retainAll(coll); - if (result == false) { + if (!result) { return false; } if (set.isEmpty()) { @@ -418,7 +418,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { @Override public void add(final E object) { - if (set.contains(object) == false) { + if (!set.contains(object)) { super.add(object); set.add(object); } diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java index 23e3d6756..0614f140b 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java @@ -869,10 +869,10 @@ public class AbstractHashedMap extends AbstractMap implements Iterab @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } - if (contains(obj) == false) { + if (!contains(obj)) { return false; } final Map.Entry entry = (Map.Entry) obj; @@ -1130,7 +1130,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (obj == this) { return true; } - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry other = (Map.Entry) obj; @@ -1338,7 +1338,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (obj == this) { return true; } - if (obj instanceof Map == false) { + if (!(obj instanceof Map)) { return false; } final Map map = (Map) obj; @@ -1351,11 +1351,11 @@ public class AbstractHashedMap extends AbstractMap implements Iterab final Object key = it.next(); final Object value = it.getValue(); if (value == null) { - if (map.get(key) != null || map.containsKey(key) == false) { + if (map.get(key) != null || !map.containsKey(key)) { return false; } } else { - if (value.equals(map.get(key)) == false) { + if (!value.equals(map.get(key))) { return false; } } diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java index 4fd244583..e201dffd3 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java @@ -674,7 +674,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap if (obj == this) { return true; } - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } diff --git a/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java b/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java index 0895894ef..cee0eca8c 100644 --- a/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java +++ b/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java @@ -119,7 +119,7 @@ public class FixedSizeMap //----------------------------------------------------------------------- @Override public V put(final K key, final V value) { - if (map.containsKey(key) == false) { + if (!map.containsKey(key)) { throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size"); } return map.put(key, value); diff --git a/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java b/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java index 2ac244086..b9363f55c 100644 --- a/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java @@ -128,7 +128,7 @@ public class FixedSizeSortedMap //----------------------------------------------------------------------- @Override public V put(final K key, final V value) { - if (map.containsKey(key) == false) { + if (!map.containsKey(key)) { throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size"); } return map.put(key, value); diff --git a/src/main/java/org/apache/commons/collections4/map/Flat3Map.java b/src/main/java/org/apache/commons/collections4/map/Flat3Map.java index 4f1e657b5..38c1f05bd 100644 --- a/src/main/java/org/apache/commons/collections4/map/Flat3Map.java +++ b/src/main/java/org/apache/commons/collections4/map/Flat3Map.java @@ -652,7 +652,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl @Override public K next() { - if (hasNext() == false) { + if (!hasNext()) { throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY); } canRemove = true; @@ -662,7 +662,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID); } parent.remove(getKey()); @@ -672,7 +672,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl @Override public K getKey() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); } switch (nextIndex) { @@ -688,7 +688,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl @Override public V getValue() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID); } switch (nextIndex) { @@ -704,7 +704,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl @Override public V setValue(final V value) { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID); } final V old = getValue(); @@ -779,7 +779,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; @@ -884,7 +884,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (removed) { return false; } - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry other = (Map.Entry) obj; @@ -1178,7 +1178,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (delegateMap != null) { return delegateMap.equals(obj); } - if (obj instanceof Map == false) { + if (!(obj instanceof Map)) { return false; } final Map other = (Map) obj; @@ -1189,7 +1189,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl Object otherValue = null; switch (size) { // drop through case 3: - if (other.containsKey(key3) == false) { + if (!other.containsKey(key3)) { return false; } otherValue = other.get(key3); @@ -1197,7 +1197,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl return false; } case 2: - if (other.containsKey(key2) == false) { + if (!other.containsKey(key2)) { return false; } otherValue = other.get(key2); @@ -1205,7 +1205,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl return false; } case 1: - if (other.containsKey(key1) == false) { + if (!other.containsKey(key1)) { return false; } otherValue = other.get(key1); diff --git a/src/main/java/org/apache/commons/collections4/map/LazyMap.java b/src/main/java/org/apache/commons/collections4/map/LazyMap.java index ceeaeb1fc..91b06d669 100644 --- a/src/main/java/org/apache/commons/collections4/map/LazyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/LazyMap.java @@ -161,7 +161,7 @@ public class LazyMap extends AbstractMapDecorator implements Seriali @Override public V get(final Object key) { // create value for key if key is not currently in the map - if (map.containsKey(key) == false) { + if (!map.containsKey(key)) { @SuppressWarnings("unchecked") final K castKey = (K) key; final V value = factory.transform(castKey); diff --git a/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java b/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java index 9417b8d5c..4639ab644 100644 --- a/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java @@ -632,7 +632,7 @@ public class ListOrderedMap @Override @SuppressWarnings("unchecked") public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } if (getEntrySet().contains(obj)) { @@ -753,7 +753,7 @@ public class ListOrderedMap @Override public void remove() { - if (readable == false) { + if (!readable) { throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID); } iterator.remove(); @@ -763,7 +763,7 @@ public class ListOrderedMap @Override public K getKey() { - if (readable == false) { + if (!readable) { throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); } return last; @@ -771,7 +771,7 @@ public class ListOrderedMap @Override public V getValue() { - if (readable == false) { + if (!readable) { throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID); } return parent.get(last); @@ -779,7 +779,7 @@ public class ListOrderedMap @Override public V setValue(final V value) { - if (readable == false) { + if (!readable) { throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID); } return parent.map.put(last, value); @@ -794,7 +794,7 @@ public class ListOrderedMap @Override public String toString() { - if (readable == true) { + if (readable) { return "Iterator[" + getKey() + "=" + getValue() + "]"; } return "Iterator[]"; 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 059db753f..fb50eb045 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java @@ -220,7 +220,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme return false; } final boolean removed = valuesForKey.remove(value); - if (removed == false) { + if (!removed) { return false; } if (valuesForKey.isEmpty()) { diff --git a/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java b/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java index 01e125ebb..a2785c7b2 100644 --- a/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java @@ -144,10 +144,10 @@ public class PredicatedMap * @throws IllegalArgumentException if invalid */ protected void validate(final K key, final V value) { - if (keyPredicate != null && keyPredicate.evaluate(key) == false) { + if (keyPredicate != null && !keyPredicate.evaluate(key)) { throw new IllegalArgumentException("Cannot add key - Predicate rejected it"); } - if (valuePredicate != null && valuePredicate.evaluate(value) == false) { + if (valuePredicate != null && !valuePredicate.evaluate(value)) { throw new IllegalArgumentException("Cannot add value - Predicate rejected it"); } } @@ -162,7 +162,7 @@ public class PredicatedMap */ @Override protected V checkSetValue(final V value) { - if (valuePredicate.evaluate(value) == false) { + if (!valuePredicate.evaluate(value)) { throw new IllegalArgumentException("Cannot set value - Predicate rejected it"); } return value; diff --git a/src/main/java/org/apache/commons/collections4/map/SingletonMap.java b/src/main/java/org/apache/commons/collections4/map/SingletonMap.java index 08f4f0b73..72ebdcefa 100644 --- a/src/main/java/org/apache/commons/collections4/map/SingletonMap.java +++ b/src/main/java/org/apache/commons/collections4/map/SingletonMap.java @@ -436,7 +436,7 @@ public class SingletonMap @Override public K next() { - if (hasNext == false) { + if (!hasNext) { throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY); } hasNext = false; @@ -446,12 +446,12 @@ public class SingletonMap @Override public boolean hasPrevious() { - return hasNext == false; + return !hasNext; } @Override public K previous() { - if (hasNext == true) { + if (hasNext) { throw new NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY); } hasNext = true; @@ -465,7 +465,7 @@ public class SingletonMap @Override public K getKey() { - if (canGetSet == false) { + if (!canGetSet) { throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); } return parent.getKey(); @@ -473,7 +473,7 @@ public class SingletonMap @Override public V getValue() { - if (canGetSet == false) { + if (!canGetSet) { throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID); } return parent.getValue(); @@ -481,7 +481,7 @@ public class SingletonMap @Override public V setValue(final V value) { - if (canGetSet == false) { + if (!canGetSet) { throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID); } return parent.setValue(value); @@ -562,7 +562,7 @@ public class SingletonMap if (obj == this) { return true; } - if (obj instanceof Map == false) { + if (!(obj instanceof Map)) { return false; } final Map other = (Map) obj; diff --git a/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java b/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java index 8d6790973..470d76e0d 100644 --- a/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java +++ b/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java @@ -420,7 +420,7 @@ public final class StaticBucketMap extends AbstractIterableMap { if (obj == this) { return true; } - if (obj instanceof Map == false) { + if (!(obj instanceof Map)) { return false; } final Map other = (Map) obj; @@ -479,7 +479,7 @@ public final class StaticBucketMap extends AbstractIterableMap { if (obj == this) { return true; } - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } @@ -607,7 +607,7 @@ public final class StaticBucketMap extends AbstractIterableMap { @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } final Map.Entry entry = (Map.Entry) obj; 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 7ee3d838e..0207dff2e 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java @@ -198,7 +198,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { if (parent.modCount != mods) { throw new ConcurrentModificationException(); } - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(); } final MutableInteger mut = current.getValue(); @@ -288,7 +288,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { @Override public boolean equals(final Object obj) { - if (obj instanceof MutableInteger == false) { + if (!(obj instanceof MutableInteger)) { return false; } return ((MutableInteger) obj).value == value; @@ -350,7 +350,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } final int count = parent.getCount(lastElement); @@ -402,7 +402,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException("Iterator remove() can only be called once after next()"); } decorated.remove(); @@ -536,7 +536,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { if (object == this) { return true; } - if (object instanceof MultiSet == false) { + if (!(object instanceof MultiSet)) { return false; } final MultiSet other = (MultiSet) object; 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 ef8b59763..489b0c409 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java @@ -165,7 +165,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen /** {@inheritDoc} */ @Override public void remove() { - if (canRemove == false) { + if (!canRemove) { throw new IllegalStateException(); } final int count = current.getCount(); @@ -374,7 +374,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen @Override public boolean contains(final Object obj) { - if (obj instanceof Entry == false) { + if (!(obj instanceof Entry)) { return false; } final Entry entry = (Entry) obj; @@ -384,7 +384,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen @Override public boolean remove(final Object obj) { - if (obj instanceof Entry == false) { + if (!(obj instanceof Entry)) { return false; } final Entry entry = (Entry) obj; @@ -469,7 +469,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen if (object == this) { return true; } - if (object instanceof MultiSet == false) { + if (!(object instanceof MultiSet)) { return false; } final MultiSet other = (MultiSet) object; diff --git a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java index d09a04017..12d51910b 100644 --- a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java +++ b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java @@ -112,7 +112,7 @@ public class CompositeSet implements Set, Serializable { @Override public boolean isEmpty() { for (final Set item : all) { - if (item.isEmpty() == false) { + if (!item.isEmpty()) { return false; } } @@ -257,7 +257,7 @@ public class CompositeSet implements Set, Serializable { return false; } for (final Object item : coll) { - if (contains(item) == false) { + if (!contains(item)) { return false; } } diff --git a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java index 88078df94..6bbb6a1c8 100644 --- a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java @@ -248,7 +248,7 @@ public class ListOrderedSet @Override public boolean retainAll(final Collection coll) { final boolean result = decorated().retainAll(coll); - if (result == false) { + if (!result) { return false; } if (decorated().isEmpty()) { 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 244095eb4..dc5c7eefc 100644 --- a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java @@ -1404,10 +1404,10 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { @Override public boolean remove(final Object obj) { - if (obj instanceof Map.Entry == false) { + if (!(obj instanceof Map.Entry)) { return false; } - if (contains(obj) == false) { + if (!contains(obj)) { return false; } final Map.Entry entry = (Map.Entry) obj; diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index 7ecae7fac..98bfd370c 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -609,12 +609,12 @@ public class CollectionUtilsTest extends MockTestCase { assertNull(lastElement); final Collection strings = Arrays.asList("a", "b", "c"); - final StringBuffer result = new StringBuffer(); + final StringBuilder result = new StringBuilder(); result.append(CollectionUtils.forAllButLastDo(strings, (Closure) input -> result.append(input+";"))); assertEquals("a;b;c", result.toString()); final Collection oneString = Arrays.asList("a"); - final StringBuffer resultOne = new StringBuffer(); + final StringBuilder resultOne = new StringBuilder(); resultOne.append(CollectionUtils.forAllButLastDo(oneString, (Closure) input -> resultOne.append(input+";"))); assertEquals("a", resultOne.toString()); assertNull(CollectionUtils.forAllButLastDo(strings, (Closure) null)); // do not remove cast