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;
}
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;

View File

@ -225,7 +225,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
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<E> implements Bag<E> {
@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<E> implements Bag<E> {
if (object == this) {
return true;
}
if (object instanceof Bag == false) {
if (!(object instanceof Bag)) {
return false;
}
final Bag<?> other = (Bag<?>) object;

View File

@ -422,7 +422,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
boolean modified = false;
final Iterator<E> 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<K, V> implements BidiMap<K, V> {
@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<K, V> implements BidiMap<K, V> {
@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<K, V> implements BidiMap<K, V> {
@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<K, V> implements BidiMap<K, V> {
@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<K, V> implements BidiMap<K, V> {
@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)

View File

@ -1362,7 +1362,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
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<K extends Comparable<K>, V extends Comparable<V>>
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<K extends Comparable<K>, V extends Comparable<V>>
@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<K extends Comparable<K>, V extends Comparable<V>>
@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<K extends Comparable<K>, V extends Comparable<V>>
@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<K extends Comparable<K>, V extends Comparable<V>>
@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;

View File

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

View File

@ -139,7 +139,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
* @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");
}

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.");
}
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.add(comparator);
orderingBits = new BitSet(1);
if (reverse == true) {
if (reverse) {
orderingBits.set(0);
}
}
@ -153,7 +153,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
checkLocked();
comparatorChain.add(comparator);
if (reverse == true) {
if (reverse) {
orderingBits.set(comparatorChain.size() - 1);
}
}
@ -183,7 +183,7 @@ public class ComparatorChain<E> implements Comparator<E>, 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<E> implements Comparator<E>, 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<E> implements Comparator<E>, 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<E> implements Comparator<E>, 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 {

View File

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

View File

@ -143,7 +143,7 @@ public class SwitchClosure<E> implements Closure<E>, 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;
}

View File

@ -158,7 +158,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, 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);
}
}

View File

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

View File

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

View File

@ -238,7 +238,7 @@ public class CollatingIterator<E> implements Iterator<E> {
*/
@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<E> implements Iterator<E> {
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)) {

View File

@ -92,7 +92,7 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
*/
@Override
public void remove() {
if (canRemove == false) {
if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()");
}
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.
*/
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<E> implements Iterator<E> {
* from all Iterator interface methods.
*/
private void lockChain() {
if (isLocked == false) {
if (!isLocked) {
isLocked = true;
}
}
@ -212,7 +212,7 @@ public class IteratorChain<E> implements Iterator<E> {
lastUsedIterator = currentIterator;
}
while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) {
while (!currentIterator.hasNext() && !iteratorChain.isEmpty()) {
currentIterator = iteratorChain.remove();
}
}

View File

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

View File

@ -84,7 +84,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
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();

View File

@ -87,7 +87,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
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<E> implements ResettableListIterator<E> {
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<E> implements ResettableListIterator<E> {
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<E> implements ResettableListIterator<E> {
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();

View File

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

View File

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

View File

@ -182,7 +182,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
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<E> implements Iterator<E> {
@Override
public E next() {
updateCurrentIterator();
if (hasNext == false) {
if (!hasNext) {
throw new NoSuchElementException("No more elements in the iteration");
}
lastUsedIterator = currentIterator;

View File

@ -132,7 +132,7 @@ public class ReverseListIterator<E> implements ResettableListIterator<E> {
*/
@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<E> implements ResettableListIterator<E> {
*/
@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<E> implements ResettableListIterator<E> {
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;

View File

@ -67,7 +67,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> 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;

View File

@ -129,7 +129,7 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
if (obj == this) {
return true;
}
if (obj instanceof DefaultKeyValue == false) {
if (!(obj instanceof DefaultKeyValue)) {
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) {
return true;
}
if (obj instanceof Map.Entry == false) {
if (!(obj instanceof Map.Entry)) {
return false;
}
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;

View File

@ -300,7 +300,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
boolean modified = false;
final Iterator<E> 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<E> implements List<E> {
if (obj == this) {
return true;
}
if (obj instanceof List == false) {
if (!(obj instanceof List)) {
return false;
}
final List<?> other = (List<?>) obj;

View File

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

View File

@ -147,7 +147,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
@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<E> extends AbstractSerializableListDecorator<E> {
@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<E> extends AbstractSerializableListDecorator<E> {
@Override
public void add(final E object) {
if (set.contains(object) == false) {
if (!set.contains(object)) {
super.add(object);
set.add(object);
}

View File

@ -869,10 +869,10 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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;
}
}

View File

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

View File

@ -119,7 +119,7 @@ public class FixedSizeMap<K, V>
//-----------------------------------------------------------------------
@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);

View File

@ -128,7 +128,7 @@ public class FixedSizeSortedMap<K, V>
//-----------------------------------------------------------------------
@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);

View File

@ -652,7 +652,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
return false;
}
case 1:
if (other.containsKey(key1) == false) {
if (!other.containsKey(key1)) {
return false;
}
otherValue = other.get(key1);

View File

@ -161,7 +161,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> 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);

View File

@ -632,7 +632,7 @@ public class ListOrderedMap<K, V>
@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<K, V>
@Override
public void remove() {
if (readable == false) {
if (!readable) {
throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
}
iterator.remove();
@ -763,7 +763,7 @@ public class ListOrderedMap<K, V>
@Override
public K getKey() {
if (readable == false) {
if (!readable) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
}
return last;
@ -771,7 +771,7 @@ public class ListOrderedMap<K, V>
@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<K, V>
@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<K, V>
@Override
public String toString() {
if (readable == true) {
if (readable) {
return "Iterator[" + getKey() + "=" + getValue() + "]";
}
return "Iterator[]";

View File

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

View File

@ -144,10 +144,10 @@ public class PredicatedMap<K, V>
* @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<K, V>
*/
@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;

View File

@ -436,7 +436,7 @@ public class SingletonMap<K, V>
@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<K, V>
@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<K, V>
@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<K, V>
@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<K, V>
@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<K, V>
if (obj == this) {
return true;
}
if (obj instanceof Map == false) {
if (!(obj instanceof Map)) {
return false;
}
final Map<?, ?> other = (Map<?, ?>) obj;

View File

@ -420,7 +420,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
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<K, V> extends AbstractIterableMap<K, V> {
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<K, V> extends AbstractIterableMap<K, V> {
@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;

View File

@ -198,7 +198,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
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<E> extends AbstractMultiSet<E> {
@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<E> extends AbstractMultiSet<E> {
@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<E> extends AbstractMultiSet<E> {
@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<E> extends AbstractMultiSet<E> {
if (object == this) {
return true;
}
if (object instanceof MultiSet == false) {
if (!(object instanceof MultiSet)) {
return false;
}
final MultiSet<?> other = (MultiSet<?>) object;

View File

@ -165,7 +165,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> 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<E> extends AbstractCollection<E> 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<E> extends AbstractCollection<E> 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<E> extends AbstractCollection<E> implemen
if (object == this) {
return true;
}
if (object instanceof MultiSet == false) {
if (!(object instanceof MultiSet)) {
return false;
}
final MultiSet<?> other = (MultiSet<?>) object;

View File

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

View File

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

View File

@ -1404,10 +1404,10 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
@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;

View File

@ -609,12 +609,12 @@ public class CollectionUtilsTest extends MockTestCase {
assertNull(lastElement);
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+";")));
assertEquals("a;b;c", result.toString());
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+";")));
assertEquals("a", resultOne.toString());
assertNull(CollectionUtils.forAllButLastDo(strings, (Closure<String>) null)); // do not remove cast