Use final.

Simplify expressions.
This commit is contained in:
Gary Gregory 2021-07-10 09:39:06 -04:00
parent 08b0dd116e
commit 3cbb1dce0b
46 changed files with 119 additions and 119 deletions

View File

@ -1568,10 +1568,10 @@ public class CollectionUtils {
return ((Object[]) object).length == 0; return ((Object[]) object).length == 0;
} }
if (object instanceof Iterator<?>) { if (object instanceof Iterator<?>) {
return ((Iterator<?>) object).hasNext() == false; return !((Iterator<?>) object).hasNext();
} }
if (object instanceof Enumeration<?>) { if (object instanceof Enumeration<?>) {
return ((Enumeration<?>) object).hasMoreElements() == false; return !((Enumeration<?>) object).hasMoreElements();
} }
try { try {
return Array.getLength(object) == 0; return Array.getLength(object) == 0;

View File

@ -225,7 +225,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
if (parent.modCount != mods) { if (parent.modCount != mods) {
throw new ConcurrentModificationException(); throw new ConcurrentModificationException();
} }
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
final MutableInteger mut = current.getValue(); final MutableInteger mut = current.getValue();
@ -427,7 +427,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj instanceof MutableInteger == false) { if (!(obj instanceof MutableInteger)) {
return false; return false;
} }
return ((MutableInteger) obj).value == value; return ((MutableInteger) obj).value == value;
@ -558,7 +558,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
if (object == this) { if (object == this) {
return true; return true;
} }
if (object instanceof Bag == false) { if (!(object instanceof Bag)) {
return false; return false;
} }
final Bag<?> other = (Bag<?>) object; final Bag<?> other = (Bag<?>) object;

View File

@ -422,7 +422,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
boolean modified = false; boolean modified = false;
final Iterator<E> it = iterator(); final Iterator<E> it = iterator();
while (it.hasNext()) { while (it.hasNext()) {
if (coll.contains(it.next()) == false) { if (!coll.contains(it.next())) {
it.remove(); it.remove();
modified = true; modified = true;
} }
@ -509,7 +509,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); throw new IllegalStateException("Iterator remove() can only be called once after next()");
} }
final Object value = parent.normalMap.get(lastKey); final Object value = parent.normalMap.get(lastKey);
@ -594,7 +594,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); throw new IllegalStateException("Iterator remove() can only be called once after next()");
} }
super.remove(); // removes from maps[0] super.remove(); // removes from maps[0]
@ -629,7 +629,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@ -679,7 +679,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); 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) // store value as remove may change the entry in the decorator (eg.TreeMap)
@ -762,7 +762,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); 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) // store value as remove may change the entry in the decorator (eg.TreeMap)

View File

@ -1362,7 +1362,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map == false) { if (!(obj instanceof Map)) {
return false; return false;
} }
final Map<?, ?> other = (Map<?, ?>) obj; final Map<?, ?> other = (Map<?, ?>) obj;
@ -1375,7 +1375,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
for (final MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) { for (final MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) {
final Object key = it.next(); final Object key = it.next();
final Object value = it.getValue(); final Object value = it.getValue();
if (value.equals(other.get(key)) == false) { if (!value.equals(other.get(key))) {
return false; return false;
} }
} }
@ -1575,7 +1575,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
@Override @Override
public boolean contains(final Object obj) { public boolean contains(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@ -1586,7 +1586,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@ -1616,7 +1616,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
@Override @Override
public boolean contains(final Object obj) { public boolean contains(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@ -1627,7 +1627,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;

View File

@ -113,7 +113,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
for (final Collection<E> item : all) { for (final Collection<E> item : all) {
if (item.isEmpty() == false) { if (!item.isEmpty()) {
return false; return false;
} }
} }
@ -262,7 +262,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
return false; return false;
} }
for (final Object item : coll) { for (final Object item : coll) {
if (contains(item) == false) { if (!contains(item)) {
return false; return false;
} }
} }

View File

@ -139,7 +139,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
* @throws IllegalArgumentException if the add is invalid * @throws IllegalArgumentException if the add is invalid
*/ */
protected void validate(final E object) { protected void validate(final E object) {
if (predicate.evaluate(object) == false) { if (!predicate.evaluate(object)) {
throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" + throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" +
predicate + "' rejected it"); predicate + "' rejected it");
} }

View File

@ -98,7 +98,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
} }
} }
if (collection instanceof BoundedCollection == false) { if (!(collection instanceof BoundedCollection)) {
throw new IllegalArgumentException("Collection is not a bounded collection."); throw new IllegalArgumentException("Collection is not a bounded collection.");
} }
return new UnmodifiableBoundedCollection<>((BoundedCollection<E>) collection); return new UnmodifiableBoundedCollection<>((BoundedCollection<E>) collection);

View File

@ -94,7 +94,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
comparatorChain = new ArrayList<>(1); comparatorChain = new ArrayList<>(1);
comparatorChain.add(comparator); comparatorChain.add(comparator);
orderingBits = new BitSet(1); orderingBits = new BitSet(1);
if (reverse == true) { if (reverse) {
orderingBits.set(0); orderingBits.set(0);
} }
} }
@ -153,7 +153,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
checkLocked(); checkLocked();
comparatorChain.add(comparator); comparatorChain.add(comparator);
if (reverse == true) { if (reverse) {
orderingBits.set(comparatorChain.size() - 1); orderingBits.set(comparatorChain.size() - 1);
} }
} }
@ -183,7 +183,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
checkLocked(); checkLocked();
comparatorChain.set(index, comparator); comparatorChain.set(index, comparator);
if (reverse == true) { if (reverse) {
orderingBits.set(index); orderingBits.set(index);
} else { } else {
orderingBits.clear(index); orderingBits.clear(index);
@ -239,7 +239,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
* @throws UnsupportedOperationException if the {@link ComparatorChain} is locked * @throws UnsupportedOperationException if the {@link ComparatorChain} is locked
*/ */
private void checkLocked() { private void checkLocked() {
if (isLocked == true) { if (isLocked) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Comparator ordering cannot be changed after the first comparison is performed"); "Comparator ordering cannot be changed after the first comparison is performed");
} }
@ -268,7 +268,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
*/ */
@Override @Override
public int compare(final E o1, final E o2) throws UnsupportedOperationException { public int compare(final E o1, final E o2) throws UnsupportedOperationException {
if (isLocked == false) { if (!isLocked) {
checkChainIntegrity(); checkChainIntegrity();
isLocked = true; isLocked = true;
} }
@ -281,7 +281,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
int retval = comparator.compare(o1, o2); int retval = comparator.compare(o1, o2);
if (retval != 0) { if (retval != 0) {
// invert the order if it is a reverse sort // invert the order if it is a reverse sort
if (orderingBits.get(comparatorIndex) == true) { if (orderingBits.get(comparatorIndex)) {
if (retval > 0) { if (retval > 0) {
retval = -1; retval = -1;
} else { } else {

View File

@ -107,7 +107,7 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof ConstantTransformer == false) { if (!(obj instanceof ConstantTransformer)) {
return false; return false;
} }
final Object otherConstant = ((ConstantTransformer<?, ?>) obj).getConstant(); final Object otherConstant = ((ConstantTransformer<?, ?>) obj).getConstant();

View File

@ -143,7 +143,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
@Override @Override
public void execute(final E input) { public void execute(final E input) {
for (int i = 0; i < iPredicates.length; i++) { for (int i = 0; i < iPredicates.length; i++) {
if (iPredicates[i].evaluate(input) == true) { if (iPredicates[i].evaluate(input)) {
iClosures[i].execute(input); iClosures[i].execute(input);
return; return;
} }

View File

@ -158,7 +158,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
@Override @Override
public O transform(final I input) { public O transform(final I input) {
for (int i = 0; i < iPredicates.length; i++) { for (int i = 0; i < iPredicates.length; i++) {
if (iPredicates[i].evaluate(input) == true) { if (iPredicates[i].evaluate(input)) {
return iTransformers[i].transform(input); return iTransformers[i].transform(input);
} }
} }

View File

@ -144,7 +144,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public E next() { public E next() {
if (hasNext() == false) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
return (E) Array.get(array, index++); return (E) Array.get(array, index++);

View File

@ -115,7 +115,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public E previous() { public E previous() {
if (hasPrevious() == false) { if (!hasPrevious()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
this.lastItemIndex = --this.index; this.lastItemIndex = --this.index;
@ -131,7 +131,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public E next() { public E next() {
if (hasNext() == false) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
this.lastItemIndex = this.index; this.lastItemIndex = this.index;

View File

@ -238,7 +238,7 @@ public class CollatingIterator<E> implements Iterator<E> {
*/ */
@Override @Override
public E next() throws NoSuchElementException { public E next() throws NoSuchElementException {
if (hasNext() == false) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
final int leastIndex = least(); final int leastIndex = least();
@ -346,7 +346,7 @@ public class CollatingIterator<E> implements Iterator<E> {
int leastIndex = -1; int leastIndex = -1;
E leastObject = null; E leastObject = null;
for (int i = 0; i < values.size(); i++) { for (int i = 0; i < values.size(); i++) {
if (valueSet.get(i) == false) { if (!valueSet.get(i)) {
set(i); set(i);
} }
if (valueSet.get(i)) { if (valueSet.get(i)) {

View File

@ -92,7 +92,7 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
*/ */
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); throw new IllegalStateException("Iterator remove() can only be called once after next()");
} }
iterator.remove(); iterator.remove();

View File

@ -180,7 +180,7 @@ public class IteratorChain<E> implements Iterator<E> {
* Checks whether the iterator chain is now locked and in use. * Checks whether the iterator chain is now locked and in use.
*/ */
private void checkLocked() { private void checkLocked() {
if (isLocked == true) { if (isLocked) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"IteratorChain cannot be changed after the first use of a method from the Iterator interface"); "IteratorChain cannot be changed after the first use of a method from the Iterator interface");
} }
@ -191,7 +191,7 @@ public class IteratorChain<E> implements Iterator<E> {
* from all Iterator interface methods. * from all Iterator interface methods.
*/ */
private void lockChain() { private void lockChain() {
if (isLocked == false) { if (!isLocked) {
isLocked = true; isLocked = true;
} }
} }
@ -212,7 +212,7 @@ public class IteratorChain<E> implements Iterator<E> {
lastUsedIterator = currentIterator; lastUsedIterator = currentIterator;
} }
while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) { while (!currentIterator.hasNext() && !iteratorChain.isEmpty()) {
currentIterator = iteratorChain.remove(); currentIterator = iteratorChain.remove();
} }
} }

View File

@ -90,7 +90,7 @@ public abstract class LazyIteratorChain<E> implements Iterator<E> {
lastUsedIterator = currentIterator; lastUsedIterator = currentIterator;
} }
while (currentIterator.hasNext() == false && !chainExhausted) { while (!currentIterator.hasNext() && !chainExhausted) {
final Iterator<? extends E> nextIterator = nextIterator(++callCounter); final Iterator<? extends E> nextIterator = nextIterator(++callCounter);
if (nextIterator != null) { if (nextIterator != null) {
currentIterator = nextIterator; currentIterator = nextIterator;

View File

@ -84,7 +84,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
if (collection.isEmpty()) { if (collection.isEmpty()) {
throw new NoSuchElementException("There are no elements for this iterator to loop on"); throw new NoSuchElementException("There are no elements for this iterator to loop on");
} }
if (iterator.hasNext() == false) { if (!iterator.hasNext()) {
reset(); reset();
} }
return iterator.next(); return iterator.next();

View File

@ -87,7 +87,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
throw new NoSuchElementException( throw new NoSuchElementException(
"There are no elements for this iterator to loop on"); "There are no elements for this iterator to loop on");
} }
if (iterator.hasNext() == false) { if (!iterator.hasNext()) {
reset(); reset();
} }
return iterator.next(); return iterator.next();
@ -110,7 +110,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
throw new NoSuchElementException( throw new NoSuchElementException(
"There are no elements for this iterator to loop on"); "There are no elements for this iterator to loop on");
} }
if (iterator.hasNext() == false) { if (!iterator.hasNext()) {
return 0; return 0;
} }
return iterator.nextIndex(); return iterator.nextIndex();
@ -144,7 +144,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
throw new NoSuchElementException( throw new NoSuchElementException(
"There are no elements for this iterator to loop on"); "There are no elements for this iterator to loop on");
} }
if (iterator.hasPrevious() == false) { if (!iterator.hasPrevious()) {
E result = null; E result = null;
while (iterator.hasNext()) { while (iterator.hasNext()) {
result = iterator.next(); result = iterator.next();
@ -172,7 +172,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
throw new NoSuchElementException( throw new NoSuchElementException(
"There are no elements for this iterator to loop on"); "There are no elements for this iterator to loop on");
} }
if (iterator.hasPrevious() == false) { if (!iterator.hasPrevious()) {
return list.size() - 1; return list.size() - 1;
} }
return iterator.previousIndex(); return iterator.previousIndex();

View File

@ -120,7 +120,7 @@ public class ObjectArrayIterator<E> implements ResettableIterator<E> {
*/ */
@Override @Override
public E next() { public E next() {
if (hasNext() == false) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
return this.array[this.index++]; return this.array[this.index++];

View File

@ -108,7 +108,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
*/ */
@Override @Override
public E previous() { public E previous() {
if (hasPrevious() == false) { if (!hasPrevious()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
this.lastItemIndex = --this.index; this.lastItemIndex = --this.index;
@ -123,7 +123,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
*/ */
@Override @Override
public E next() { public E next() {
if (hasNext() == false) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
this.lastItemIndex = this.index; this.lastItemIndex = this.index;

View File

@ -182,7 +182,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
currentIterator = iterator; currentIterator = iterator;
} }
while (currentIterator.hasNext() && hasNext == false) { while (currentIterator.hasNext() && !hasNext) {
E next = currentIterator.next(); E next = currentIterator.next();
if (transformer != null) { if (transformer != null) {
next = transformer.transform(next); next = transformer.transform(next);
@ -218,7 +218,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
@Override @Override
public E next() { public E next() {
updateCurrentIterator(); updateCurrentIterator();
if (hasNext == false) { if (!hasNext) {
throw new NoSuchElementException("No more elements in the iteration"); throw new NoSuchElementException("No more elements in the iteration");
} }
lastUsedIterator = currentIterator; lastUsedIterator = currentIterator;

View File

@ -132,7 +132,7 @@ public class ReverseListIterator<E> implements ResettableListIterator<E> {
*/ */
@Override @Override
public void remove() { public void remove() {
if (validForUpdate == false) { if (!validForUpdate) {
throw new IllegalStateException("Cannot remove from list until next() or previous() called"); throw new IllegalStateException("Cannot remove from list until next() or previous() called");
} }
iterator.remove(); iterator.remove();
@ -147,7 +147,7 @@ public class ReverseListIterator<E> implements ResettableListIterator<E> {
*/ */
@Override @Override
public void set(final E obj) { public void set(final E obj) {
if (validForUpdate == false) { if (!validForUpdate) {
throw new IllegalStateException("Cannot set to list until next() or previous() called"); throw new IllegalStateException("Cannot set to list until next() or previous() called");
} }
iterator.set(obj); iterator.set(obj);
@ -164,7 +164,7 @@ public class ReverseListIterator<E> implements ResettableListIterator<E> {
public void add(final E obj) { public void add(final E obj) {
// the validForUpdate flag is needed as the necessary previous() // the validForUpdate flag is needed as the necessary previous()
// method call re-enables remove and add // method call re-enables remove and add
if (validForUpdate == false) { if (!validForUpdate) {
throw new IllegalStateException("Cannot add to list until next() or previous() called"); throw new IllegalStateException("Cannot add to list until next() or previous() called");
} }
validForUpdate = false; validForUpdate = false;

View File

@ -67,7 +67,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;

View File

@ -129,7 +129,7 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof DefaultKeyValue == false) { if (!(obj instanceof DefaultKeyValue)) {
return false; return false;
} }

View File

@ -104,7 +104,7 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;

View File

@ -300,7 +300,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
boolean modified = false; boolean modified = false;
final Iterator<E> it = iterator(); final Iterator<E> it = iterator();
while (it.hasNext()) { while (it.hasNext()) {
if (coll.contains(it.next()) == false) { if (!coll.contains(it.next())) {
it.remove(); it.remove();
modified = true; modified = true;
} }
@ -375,7 +375,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof List == false) { if (!(obj instanceof List)) {
return false; return false;
} }
final List<?> other = (List<?>) obj; final List<?> other = (List<?>) obj;

View File

@ -474,7 +474,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se
*/ */
@Override @Override
public int nextIndex() { public int nextIndex() {
if (nextIndexValid == false) { if (!nextIndexValid) {
if (next == parent.header) { if (next == parent.header) {
nextIndex = parent.size(); nextIndex = parent.size();
} else { } else {

View File

@ -147,7 +147,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
@Override @Override
public void add(final int index, final E object) { public void add(final int index, final E object) {
// adds element if it is not contained already // adds element if it is not contained already
if (set.contains(object) == false) { if (!set.contains(object)) {
set.add(object); set.add(object);
super.add(index, object); super.add(index, object);
} }
@ -273,7 +273,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
@Override @Override
public boolean retainAll(final Collection<?> coll) { public boolean retainAll(final Collection<?> coll) {
final boolean result = set.retainAll(coll); final boolean result = set.retainAll(coll);
if (result == false) { if (!result) {
return false; return false;
} }
if (set.isEmpty()) { if (set.isEmpty()) {
@ -418,7 +418,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
@Override @Override
public void add(final E object) { public void add(final E object) {
if (set.contains(object) == false) { if (!set.contains(object)) {
super.add(object); super.add(object);
set.add(object); set.add(object);
} }

View File

@ -869,10 +869,10 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
if (contains(obj) == false) { if (!contains(obj)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@ -1130,7 +1130,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
@ -1338,7 +1338,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map == false) { if (!(obj instanceof Map)) {
return false; return false;
} }
final Map<?, ?> map = (Map<?, ?>) obj; final Map<?, ?> map = (Map<?, ?>) obj;
@ -1351,11 +1351,11 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
final Object key = it.next(); final Object key = it.next();
final Object value = it.getValue(); final Object value = it.getValue();
if (value == null) { if (value == null) {
if (map.get(key) != null || map.containsKey(key) == false) { if (map.get(key) != null || !map.containsKey(key)) {
return false; return false;
} }
} else { } else {
if (value.equals(map.get(key)) == false) { if (!value.equals(map.get(key))) {
return false; return false;
} }
} }

View File

@ -674,7 +674,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }

View File

@ -119,7 +119,7 @@ public class FixedSizeMap<K, V>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override @Override
public V put(final K key, final V value) { 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"); throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
} }
return map.put(key, value); return map.put(key, value);

View File

@ -128,7 +128,7 @@ public class FixedSizeSortedMap<K, V>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override @Override
public V put(final K key, final V value) { 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"); throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
} }
return map.put(key, value); return map.put(key, value);

View File

@ -652,7 +652,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
@Override @Override
public K next() { public K next() {
if (hasNext() == false) { if (!hasNext()) {
throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY); throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
} }
canRemove = true; canRemove = true;
@ -662,7 +662,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID); throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
} }
parent.remove(getKey()); parent.remove(getKey());
@ -672,7 +672,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
@Override @Override
public K getKey() { public K getKey() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
} }
switch (nextIndex) { switch (nextIndex) {
@ -688,7 +688,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
@Override @Override
public V getValue() { public V getValue() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID); throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
} }
switch (nextIndex) { switch (nextIndex) {
@ -704,7 +704,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
@Override @Override
public V setValue(final V value) { public V setValue(final V value) {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID); throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
} }
final V old = getValue(); final V old = getValue();
@ -779,7 +779,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@ -884,7 +884,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
if (removed) { if (removed) {
return false; return false;
} }
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
@ -1178,7 +1178,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
if (delegateMap != null) { if (delegateMap != null) {
return delegateMap.equals(obj); return delegateMap.equals(obj);
} }
if (obj instanceof Map == false) { if (!(obj instanceof Map)) {
return false; return false;
} }
final Map<?, ?> other = (Map<?, ?>) obj; final Map<?, ?> other = (Map<?, ?>) obj;
@ -1189,7 +1189,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
Object otherValue = null; Object otherValue = null;
switch (size) { // drop through switch (size) { // drop through
case 3: case 3:
if (other.containsKey(key3) == false) { if (!other.containsKey(key3)) {
return false; return false;
} }
otherValue = other.get(key3); otherValue = other.get(key3);
@ -1197,7 +1197,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
return false; return false;
} }
case 2: case 2:
if (other.containsKey(key2) == false) { if (!other.containsKey(key2)) {
return false; return false;
} }
otherValue = other.get(key2); otherValue = other.get(key2);
@ -1205,7 +1205,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
return false; return false;
} }
case 1: case 1:
if (other.containsKey(key1) == false) { if (!other.containsKey(key1)) {
return false; return false;
} }
otherValue = other.get(key1); otherValue = other.get(key1);

View File

@ -161,7 +161,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Seriali
@Override @Override
public V get(final Object key) { public V get(final Object key) {
// create value for key if key is not currently in the map // create value for key if key is not currently in the map
if (map.containsKey(key) == false) { if (!map.containsKey(key)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final K castKey = (K) key; final K castKey = (K) key;
final V value = factory.transform(castKey); final V value = factory.transform(castKey);

View File

@ -632,7 +632,7 @@ public class ListOrderedMap<K, V>
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
if (getEntrySet().contains(obj)) { if (getEntrySet().contains(obj)) {
@ -753,7 +753,7 @@ public class ListOrderedMap<K, V>
@Override @Override
public void remove() { public void remove() {
if (readable == false) { if (!readable) {
throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID); throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
} }
iterator.remove(); iterator.remove();
@ -763,7 +763,7 @@ public class ListOrderedMap<K, V>
@Override @Override
public K getKey() { public K getKey() {
if (readable == false) { if (!readable) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
} }
return last; return last;
@ -771,7 +771,7 @@ public class ListOrderedMap<K, V>
@Override @Override
public V getValue() { public V getValue() {
if (readable == false) { if (!readable) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID); throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
} }
return parent.get(last); return parent.get(last);
@ -779,7 +779,7 @@ public class ListOrderedMap<K, V>
@Override @Override
public V setValue(final V value) { public V setValue(final V value) {
if (readable == false) { if (!readable) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID); throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
} }
return parent.map.put(last, value); return parent.map.put(last, value);
@ -794,7 +794,7 @@ public class ListOrderedMap<K, V>
@Override @Override
public String toString() { public String toString() {
if (readable == true) { if (readable) {
return "Iterator[" + getKey() + "=" + getValue() + "]"; return "Iterator[" + getKey() + "=" + getValue() + "]";
} }
return "Iterator[]"; return "Iterator[]";

View File

@ -220,7 +220,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
return false; return false;
} }
final boolean removed = valuesForKey.remove(value); final boolean removed = valuesForKey.remove(value);
if (removed == false) { if (!removed) {
return false; return false;
} }
if (valuesForKey.isEmpty()) { if (valuesForKey.isEmpty()) {

View File

@ -144,10 +144,10 @@ public class PredicatedMap<K, V>
* @throws IllegalArgumentException if invalid * @throws IllegalArgumentException if invalid
*/ */
protected void validate(final K key, final V value) { 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"); 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"); throw new IllegalArgumentException("Cannot add value - Predicate rejected it");
} }
} }
@ -162,7 +162,7 @@ public class PredicatedMap<K, V>
*/ */
@Override @Override
protected V checkSetValue(final V value) { protected V checkSetValue(final V value) {
if (valuePredicate.evaluate(value) == false) { if (!valuePredicate.evaluate(value)) {
throw new IllegalArgumentException("Cannot set value - Predicate rejected it"); throw new IllegalArgumentException("Cannot set value - Predicate rejected it");
} }
return value; return value;

View File

@ -436,7 +436,7 @@ public class SingletonMap<K, V>
@Override @Override
public K next() { public K next() {
if (hasNext == false) { if (!hasNext) {
throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY); throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
} }
hasNext = false; hasNext = false;
@ -446,12 +446,12 @@ public class SingletonMap<K, V>
@Override @Override
public boolean hasPrevious() { public boolean hasPrevious() {
return hasNext == false; return !hasNext;
} }
@Override @Override
public K previous() { public K previous() {
if (hasNext == true) { if (hasNext) {
throw new NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY); throw new NoSuchElementException(AbstractHashedMap.NO_PREVIOUS_ENTRY);
} }
hasNext = true; hasNext = true;
@ -465,7 +465,7 @@ public class SingletonMap<K, V>
@Override @Override
public K getKey() { public K getKey() {
if (canGetSet == false) { if (!canGetSet) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID); throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
} }
return parent.getKey(); return parent.getKey();
@ -473,7 +473,7 @@ public class SingletonMap<K, V>
@Override @Override
public V getValue() { public V getValue() {
if (canGetSet == false) { if (!canGetSet) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID); throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
} }
return parent.getValue(); return parent.getValue();
@ -481,7 +481,7 @@ public class SingletonMap<K, V>
@Override @Override
public V setValue(final V value) { public V setValue(final V value) {
if (canGetSet == false) { if (!canGetSet) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID); throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
} }
return parent.setValue(value); return parent.setValue(value);
@ -562,7 +562,7 @@ public class SingletonMap<K, V>
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map == false) { if (!(obj instanceof Map)) {
return false; return false;
} }
final Map<?, ?> other = (Map<?, ?>) obj; final Map<?, ?> other = (Map<?, ?>) obj;

View File

@ -420,7 +420,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map<?, ?> == false) { if (!(obj instanceof Map<?, ?>)) {
return false; return false;
} }
final Map<?, ?> other = (Map<?, ?>) obj; final Map<?, ?> other = (Map<?, ?>) obj;
@ -479,7 +479,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj instanceof Map.Entry<?, ?> == false) { if (!(obj instanceof Map.Entry<?, ?>)) {
return false; return false;
} }
@ -607,7 +607,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry<?, ?> == false) { if (!(obj instanceof Map.Entry<?, ?>)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;

View File

@ -198,7 +198,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
if (parent.modCount != mods) { if (parent.modCount != mods) {
throw new ConcurrentModificationException(); throw new ConcurrentModificationException();
} }
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
final MutableInteger mut = current.getValue(); final MutableInteger mut = current.getValue();
@ -288,7 +288,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj instanceof MutableInteger == false) { if (!(obj instanceof MutableInteger)) {
return false; return false;
} }
return ((MutableInteger) obj).value == value; return ((MutableInteger) obj).value == value;
@ -350,7 +350,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); throw new IllegalStateException("Iterator remove() can only be called once after next()");
} }
final int count = parent.getCount(lastElement); final int count = parent.getCount(lastElement);
@ -402,7 +402,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()"); throw new IllegalStateException("Iterator remove() can only be called once after next()");
} }
decorated.remove(); decorated.remove();
@ -536,7 +536,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
if (object == this) { if (object == this) {
return true; return true;
} }
if (object instanceof MultiSet == false) { if (!(object instanceof MultiSet)) {
return false; return false;
} }
final MultiSet<?> other = (MultiSet<?>) object; final MultiSet<?> other = (MultiSet<?>) object;

View File

@ -165,7 +165,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void remove() { public void remove() {
if (canRemove == false) { if (!canRemove) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
final int count = current.getCount(); final int count = current.getCount();
@ -374,7 +374,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
@Override @Override
public boolean contains(final Object obj) { public boolean contains(final Object obj) {
if (obj instanceof Entry<?> == false) { if (!(obj instanceof Entry<?>)) {
return false; return false;
} }
final Entry<?> entry = (Entry<?>) obj; final Entry<?> entry = (Entry<?>) obj;
@ -384,7 +384,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Entry<?> == false) { if (!(obj instanceof Entry<?>)) {
return false; return false;
} }
final Entry<?> entry = (Entry<?>) obj; final Entry<?> entry = (Entry<?>) obj;
@ -469,7 +469,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
if (object == this) { if (object == this) {
return true; return true;
} }
if (object instanceof MultiSet == false) { if (!(object instanceof MultiSet)) {
return false; return false;
} }
final MultiSet<?> other = (MultiSet<?>) object; final MultiSet<?> other = (MultiSet<?>) object;

View File

@ -112,7 +112,7 @@ public class CompositeSet<E> implements Set<E>, Serializable {
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
for (final Set<E> item : all) { for (final Set<E> item : all) {
if (item.isEmpty() == false) { if (!item.isEmpty()) {
return false; return false;
} }
} }
@ -257,7 +257,7 @@ public class CompositeSet<E> implements Set<E>, Serializable {
return false; return false;
} }
for (final Object item : coll) { for (final Object item : coll) {
if (contains(item) == false) { if (!contains(item)) {
return false; return false;
} }
} }

View File

@ -248,7 +248,7 @@ public class ListOrderedSet<E>
@Override @Override
public boolean retainAll(final Collection<?> coll) { public boolean retainAll(final Collection<?> coll) {
final boolean result = decorated().retainAll(coll); final boolean result = decorated().retainAll(coll);
if (result == false) { if (!result) {
return false; return false;
} }
if (decorated().isEmpty()) { if (decorated().isEmpty()) {

View File

@ -1404,10 +1404,10 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
@Override @Override
public boolean remove(final Object obj) { public boolean remove(final Object obj) {
if (obj instanceof Map.Entry == false) { if (!(obj instanceof Map.Entry)) {
return false; return false;
} }
if (contains(obj) == false) { if (!contains(obj)) {
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;

View File

@ -609,12 +609,12 @@ public class CollectionUtilsTest extends MockTestCase {
assertNull(lastElement); assertNull(lastElement);
final Collection<String> strings = Arrays.asList("a", "b", "c"); final Collection<String> strings = Arrays.asList("a", "b", "c");
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
result.append(CollectionUtils.forAllButLastDo(strings, (Closure<String>) input -> result.append(input+";"))); result.append(CollectionUtils.forAllButLastDo(strings, (Closure<String>) input -> result.append(input+";")));
assertEquals("a;b;c", result.toString()); assertEquals("a;b;c", result.toString());
final Collection<String> oneString = Arrays.asList("a"); final Collection<String> oneString = Arrays.asList("a");
final StringBuffer resultOne = new StringBuffer(); final StringBuilder resultOne = new StringBuilder();
resultOne.append(CollectionUtils.forAllButLastDo(oneString, (Closure<String>) input -> resultOne.append(input+";"))); resultOne.append(CollectionUtils.forAllButLastDo(oneString, (Closure<String>) input -> resultOne.append(input+";")));
assertEquals("a", resultOne.toString()); assertEquals("a", resultOne.toString());
assertNull(CollectionUtils.forAllButLastDo(strings, (Closure<String>) null)); // do not remove cast assertNull(CollectionUtils.forAllButLastDo(strings, (Closure<String>) null)); // do not remove cast