From 4f43347950a1f6d61223f6e78b2376ada764b3fb Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 7 Jan 2013 17:04:52 +0000 Subject: [PATCH] Remove unnecessary parentheses (except for some bit expressions.) git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1429897 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections/CollectionUtils.java | 8 ++--- .../commons/collections/ComparatorUtils.java | 4 +-- .../collections/ExtendedProperties.java | 16 ++++----- .../apache/commons/collections/MapUtils.java | 6 ++-- .../collections/bag/AbstractMapBag.java | 2 +- .../collections/bidimap/TreeBidiMap.java | 36 +++++++++---------- .../collections/buffer/BlockingBuffer.java | 2 +- .../collections/buffer/BoundedBuffer.java | 2 +- .../collections/buffer/BoundedFifoBuffer.java | 6 ++-- .../collections/buffer/PriorityBuffer.java | 4 +-- .../buffer/UnboundedFifoBuffer.java | 4 +-- .../comparators/ComparableComparator.java | 4 +-- .../comparators/ComparatorChain.java | 4 +-- .../comparators/FixedOrderComparator.java | 10 +++--- .../comparators/NullComparator.java | 8 ++--- .../comparators/TransformingComparator.java | 4 +-- .../sequence/SequencesComparator.java | 36 +++++++++---------- .../collections/functors/AndPredicate.java | 2 +- .../functors/ComparatorPredicate.java | 10 +++--- .../functors/IdentityPredicate.java | 2 +- .../functors/InstanceofPredicate.java | 2 +- .../functors/InstantiateFactory.java | 6 ++-- .../functors/NotNullPredicate.java | 2 +- .../collections/functors/NotPredicate.java | 2 +- .../collections/functors/NullPredicate.java | 2 +- .../collections/functors/OrPredicate.java | 2 +- .../collections/iterators/ArrayIterator.java | 2 +- .../iterators/ArrayListIterator.java | 2 +- .../iterators/FilterListIterator.java | 2 +- .../iterators/LoopingIterator.java | 2 +- .../iterators/ObjectArrayIterator.java | 2 +- .../iterators/ObjectArrayListIterator.java | 2 +- .../iterators/SingletonIterator.java | 2 +- .../iterators/SingletonListIterator.java | 4 +-- .../collections/list/AbstractLinkedList.java | 12 +++---- .../list/CursorableLinkedList.java | 6 ++-- .../commons/collections/list/GrowthList.java | 4 +-- .../collections/list/SetUniqueList.java | 2 +- .../commons/collections/list/TreeList.java | 28 +++++++-------- .../collections/map/AbstractHashedMap.java | 20 +++++------ .../collections/map/AbstractLinkedMap.java | 10 +++--- .../collections/map/AbstractReferenceMap.java | 22 ++++++------ .../commons/collections/map/CompositeMap.java | 2 +- .../commons/collections/map/Flat3Map.java | 30 ++++++++-------- .../commons/collections/map/IdentityMap.java | 8 ++--- .../commons/collections/map/LRUMap.java | 4 +-- .../commons/collections/map/MultiKeyMap.java | 24 ++++++------- .../collections/map/MultiValueMap.java | 2 +- .../collections/map/PassiveExpiringMap.java | 2 +- .../collections/map/PredicatedMap.java | 2 +- .../commons/collections/map/SingletonMap.java | 14 ++++---- .../collections/map/TransformedMap.java | 2 +- .../commons/collections/set/CompositeSet.java | 2 +- .../commons/collections/set/MapBackedSet.java | 6 ++-- .../collections/trie/AbstractKeyAnalyzer.java | 4 +-- .../collections/trie/AbstractTrie.java | 8 ++--- .../trie/ByteArrayKeyAnalyzer.java | 10 +++--- .../collections/trie/ByteKeyAnalyzer.java | 6 ++-- .../trie/CharArrayKeyAnalyzer.java | 4 +-- .../trie/CharacterKeyAnalyzer.java | 6 ++-- .../collections/trie/IntegerKeyAnalyzer.java | 6 ++-- .../collections/trie/LongKeyAnalyzer.java | 6 ++-- .../collections/trie/PatriciaTrie.java | 2 +- .../collections/trie/PatriciaTrieBase.java | 4 +-- .../collections/trie/ShortKeyAnalyzer.java | 6 ++-- .../collections/trie/StringKeyAnalyzer.java | 4 +-- .../collections/CollectionUtilsTest.java | 4 +-- .../collections/ExtendedPropertiesTest.java | 18 +++++----- .../commons/collections/ListUtilsTest.java | 2 +- .../commons/collections/MockTestCase.java | 2 +- .../collections/bag/AbstractBagTest.java | 18 +++++----- .../collection/AbstractCollectionTest.java | 22 ++++++------ .../comparators/BooleanComparatorTest.java | 4 +-- .../iterators/AbstractMapIteratorTest.java | 2 +- .../iterators/ArrayIterator2Test.java | 2 +- .../iterators/ArrayIteratorTest.java | 2 +- .../iterators/ArrayListIteratorTest.java | 2 +- .../iterators/CollatingIteratorTest.java | 4 +-- .../iterators/IteratorChainTest.java | 2 +- .../iterators/ListIteratorWrapper2Test.java | 4 +-- .../iterators/ListIteratorWrapperTest.java | 4 +-- .../iterators/ObjectArrayIteratorTest.java | 2 +- .../ObjectArrayListIteratorTest.java | 2 +- .../iterators/SingletonIterator2Test.java | 2 +- .../iterators/SingletonIteratorTest.java | 2 +- .../iterators/SingletonListIteratorTest.java | 4 +-- .../iterators/UniqueFilterIteratorTest.java | 2 +- .../collections/list/AbstractListTest.java | 10 +++--- .../list/CursorableLinkedListTest.java | 4 +-- .../collections/list/SetUniqueListTest.java | 2 +- .../collections/map/AbstractMapTest.java | 20 +++++------ .../collections/map/PredicatedMapTest.java | 2 +- .../map/PredicatedSortedMapTest.java | 2 +- .../collections/set/ListOrderedSetTest.java | 6 ++-- .../set/PredicatedSortedSetTest.java | 2 +- 95 files changed, 313 insertions(+), 313 deletions(-) diff --git a/src/main/java/org/apache/commons/collections/CollectionUtils.java b/src/main/java/org/apache/commons/collections/CollectionUtils.java index 2ae6e8e43..14702d50a 100644 --- a/src/main/java/org/apache/commons/collections/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections/CollectionUtils.java @@ -384,7 +384,7 @@ public class CollectionUtils { * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { - return (a.size() < b.size()) && CollectionUtils.isSubCollection(a, b); + return a.size() < b.size() && CollectionUtils.isSubCollection(a, b); } /** @@ -425,7 +425,7 @@ public class CollectionUtils { */ public static int cardinality(O obj, final Iterable coll) { if (coll instanceof Set) { - return (((Set) coll).contains(obj) ? 1 : 0); + return ((Set) coll).contains(obj) ? 1 : 0; } if (coll instanceof Bag) { return ((Bag) coll).getCount(obj); @@ -827,7 +827,7 @@ public class CollectionUtils { if (collection == null) { throw new NullPointerException("The collection must not be null"); } - return (object != null && collection.add(object)); + return object != null && collection.add(object); } /** @@ -1153,7 +1153,7 @@ public class CollectionUtils { * @since 3.2 */ public static boolean isEmpty(Collection coll) { - return (coll == null || coll.isEmpty()); + return coll == null || coll.isEmpty(); } /** diff --git a/src/main/java/org/apache/commons/collections/ComparatorUtils.java b/src/main/java/org/apache/commons/collections/ComparatorUtils.java index ee81d0bdb..08c7b1d7d 100644 --- a/src/main/java/org/apache/commons/collections/ComparatorUtils.java +++ b/src/main/java/org/apache/commons/collections/ComparatorUtils.java @@ -220,7 +220,7 @@ public class ComparatorUtils { comparator = NATURAL_COMPARATOR; } int c = comparator.compare(o1, o2); - return (c < 0) ? o1 : o2; + return c < 0 ? o1 : o2; } /** @@ -239,7 +239,7 @@ public class ComparatorUtils { comparator = NATURAL_COMPARATOR; } int c = comparator.compare(o1, o2); - return (c > 0) ? o1 : o2; + return c > 0 ? o1 : o2; } } diff --git a/src/main/java/org/apache/commons/collections/ExtendedProperties.java b/src/main/java/org/apache/commons/collections/ExtendedProperties.java index e5e1dcc8d..0aaf3cb0a 100644 --- a/src/main/java/org/apache/commons/collections/ExtendedProperties.java +++ b/src/main/java/org/apache/commons/collections/ExtendedProperties.java @@ -190,7 +190,7 @@ public class ExtendedProperties extends Hashtable { */ protected String interpolate(String base) { // COPIED from [configuration] 2003-12-29 - return (interpolateHelper(base, null)); + return interpolateHelper(base, null); } /** @@ -227,8 +227,8 @@ public class ExtendedProperties extends Hashtable { StringBuilder result = new StringBuilder(); // FIXME: we should probably allow the escaping of the start token - while (((begin = base.indexOf(START_TOKEN, prec + END_TOKEN.length())) > -1) - && ((end = base.indexOf(END_TOKEN, begin)) > -1)) { + while ((begin = base.indexOf(START_TOKEN, prec + END_TOKEN.length())) > -1 + && (end = base.indexOf(END_TOKEN, begin)) > -1) { result.append(base.substring(prec + END_TOKEN.length(), begin)); variable = base.substring(begin + START_TOKEN.length(), end); @@ -329,7 +329,7 @@ public class ExtendedProperties extends Hashtable { if (!line.endsWith("\\")) { return false; } - return (countPreceding(line, line.length() - 1, '\\') % 2 == 0); + return countPreceding(line, line.length() - 1, '\\') % 2 == 0; } /** @@ -359,7 +359,7 @@ public class ExtendedProperties extends Hashtable { String line = readLine(); while (line != null) { line = line.trim(); - if ((line.length() != 0) && (line.charAt(0) != '#')) { + if (line.length() != 0 && line.charAt(0) != '#') { if (endsWithSlash(line)) { line = line.substring(0, line.length() - 1); buffer.append(line); @@ -795,7 +795,7 @@ public class ExtendedProperties extends Hashtable { // we also need to rebuild the keysAsListed or else // things get *very* confusing for (int i = 0; i < keysAsListed.size(); i++) { - if (( keysAsListed.get(i)).equals(key)) { + if (keysAsListed.get(i).equals(key)) { keysAsListed.remove(i); break; } @@ -1071,7 +1071,7 @@ public class ExtendedProperties extends Hashtable { if (defaults != null) { return defaults.getVector(key, defaultValue); } else { - return ((defaultValue == null) ? new Vector() : defaultValue); + return defaultValue == null ? new Vector() : defaultValue; } } else { throw new ClassCastException('\'' + key + "' doesn't map to a Vector object"); @@ -1125,7 +1125,7 @@ public class ExtendedProperties extends Hashtable { if (defaults != null) { return defaults.getList(key, defaultValue); } else { - return ((defaultValue == null) ? new ArrayList() : defaultValue); + return defaultValue == null ? new ArrayList() : defaultValue; } } else { throw new ClassCastException('\'' + key + "' doesn't map to a List object"); diff --git a/src/main/java/org/apache/commons/collections/MapUtils.java b/src/main/java/org/apache/commons/collections/MapUtils.java index e7597c7b7..0500a2fcf 100644 --- a/src/main/java/org/apache/commons/collections/MapUtils.java +++ b/src/main/java/org/apache/commons/collections/MapUtils.java @@ -161,7 +161,7 @@ public class MapUtils { } if (answer instanceof Number) { Number n = (Number) answer; - return (n.intValue() != 0) ? Boolean.TRUE : Boolean.FALSE; + return n.intValue() != 0 ? Boolean.TRUE : Boolean.FALSE; } } } @@ -986,7 +986,7 @@ public class MapUtils { if (childValue instanceof Map && !lineage.contains(childValue)) { verbosePrintInternal( out, - (childKey == null ? "null" : childKey), + childKey == null ? "null" : childKey, (Map) childValue, lineage, debug); @@ -1186,7 +1186,7 @@ public class MapUtils { * @since 3.2 */ public static boolean isEmpty(Map map) { - return (map == null || map.isEmpty()); + return map == null || map.isEmpty(); } /** diff --git a/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java b/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java index 2b2ab2108..786b435df 100644 --- a/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java +++ b/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java @@ -194,7 +194,7 @@ public abstract class AbstractMapBag implements Bag { /** {@inheritDoc} */ public boolean hasNext() { - return (itemCount > 0 || entryIterator.hasNext()); + return itemCount > 0 || entryIterator.hasNext(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java b/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java index 684be6324..4833b4514 100644 --- a/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java +++ b/src/main/java/org/apache/commons/collections/bidimap/TreeBidiMap.java @@ -141,7 +141,7 @@ public class TreeBidiMap, V extends Comparable> imple * @return true if the map is empty */ public boolean isEmpty() { - return (nodeCount == 0); + return nodeCount == 0; } /** @@ -156,7 +156,7 @@ public class TreeBidiMap, V extends Comparable> imple */ public boolean containsKey(final Object key) { checkKey(key); - return (lookupKey(key) != null); + return lookupKey(key) != null; } /** @@ -171,7 +171,7 @@ public class TreeBidiMap, V extends Comparable> imple */ public boolean containsValue(final Object value) { checkValue(value); - return (lookupValue(value) != null); + return lookupValue(value) != null; } /** @@ -566,7 +566,7 @@ public class TreeBidiMap, V extends Comparable> imple rval = node; break; } else { - node = (cmp < 0) ? node.getLeft(dataElement) : node.getRight(dataElement); + node = cmp < 0 ? node.getLeft(dataElement) : node.getRight(dataElement); } } @@ -606,7 +606,7 @@ public class TreeBidiMap, V extends Comparable> imple Node parent = node.getParent(dataElement); Node child = node; - while ((parent != null) && (child == parent.getRight(dataElement))) { + while (parent != null && child == parent.getRight(dataElement)) { child = parent; parent = parent.getParent(dataElement); } @@ -640,7 +640,7 @@ public class TreeBidiMap, V extends Comparable> imple Node parent = node.getParent(dataElement); Node child = node; - while ((parent != null) && (child == parent.getLeft(dataElement))) { + while (parent != null && child == parent.getLeft(dataElement)) { child = parent; parent = parent.getParent(dataElement); } @@ -874,9 +874,9 @@ public class TreeBidiMap, V extends Comparable> imple Node currentNode = insertedNode; makeRed(currentNode, dataElement); - while ((currentNode != null) - && (currentNode != rootNode[dataElement.ordinal()]) - && (isRed(currentNode.getParent(dataElement), dataElement))) { + while (currentNode != null + && currentNode != rootNode[dataElement.ordinal()] + && isRed(currentNode.getParent(dataElement), dataElement)) { if (currentNode.isLeftChild(dataElement)) { Node y = getRightChild(getGrandParent(currentNode, dataElement), dataElement); @@ -943,12 +943,12 @@ public class TreeBidiMap, V extends Comparable> imple for (DataElement dataElement : DataElement.values()) { // if deleted node has both left and children, swap with // the next greater node - if ((deletedNode.getLeft(dataElement) != null) && (deletedNode.getRight(dataElement) != null)) { + if (deletedNode.getLeft(dataElement) != null && deletedNode.getRight(dataElement) != null) { swapPosition(nextGreater(deletedNode, dataElement), deletedNode, dataElement); } - Node replacement = ((deletedNode.getLeft(dataElement) != null) ? - deletedNode.getLeft(dataElement) : deletedNode.getRight(dataElement)); + Node replacement = deletedNode.getLeft(dataElement) != null ? + deletedNode.getLeft(dataElement) : deletedNode.getRight(dataElement); if (replacement != null) { replacement.setParent(deletedNode.getParent(dataElement), dataElement); @@ -1009,7 +1009,7 @@ public class TreeBidiMap, V extends Comparable> imple private void doRedBlackDeleteFixup(final Node replacementNode, final DataElement dataElement) { Node currentNode = replacementNode; - while ((currentNode != rootNode[dataElement.ordinal()]) && (isBlack(currentNode, dataElement))) { + while (currentNode != rootNode[dataElement.ordinal()] && isBlack(currentNode, dataElement)) { if (currentNode.isLeftChild(dataElement)) { Node siblingNode = getRightChild(getParent(currentNode, dataElement), dataElement); @@ -1098,9 +1098,9 @@ public class TreeBidiMap, V extends Comparable> imple Node yFormerLeftChild = y.getLeft(dataElement); Node yFormerRightChild = y.getRight(dataElement); boolean xWasLeftChild = - (x.getParent(dataElement) != null) && (x == x.getParent(dataElement).getLeft(dataElement)); + x.getParent(dataElement) != null && x == x.getParent(dataElement).getLeft(dataElement); boolean yWasLeftChild = - (y.getParent(dataElement) != null) && (y == y.getParent(dataElement).getLeft(dataElement)); + y.getParent(dataElement) != null && y == y.getParent(dataElement).getLeft(dataElement); // Swap, handling special cases of one being the other's parent. if (x == yFormerParent) { // x was y's parent @@ -1355,7 +1355,7 @@ public class TreeBidiMap, V extends Comparable> imple for (MapIterator it = getMapIterator(dataElement); it.hasNext(); ) { Object key = it.next(); Object value = it.getValue(); - total += (key.hashCode() ^ value.hashCode()); + total += key.hashCode() ^ value.hashCode(); } } return total; @@ -1450,7 +1450,7 @@ public class TreeBidiMap, V extends Comparable> imple @Override public boolean contains(final Object obj) { checkNonNullComparable(obj, KEY); - return (lookupKey(obj) != null); + return lookupKey(obj) != null; } @Override @@ -1477,7 +1477,7 @@ public class TreeBidiMap, V extends Comparable> imple @Override public boolean contains(final Object obj) { checkNonNullComparable(obj, VALUE); - return (lookupValue(obj) != null); + return lookupValue(obj) != null; } @Override diff --git a/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java b/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java index 63344a55a..902edc215 100644 --- a/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java +++ b/src/main/java/org/apache/commons/collections/buffer/BlockingBuffer.java @@ -100,7 +100,7 @@ public class BlockingBuffer extends SynchronizedBuffer { */ protected BlockingBuffer(Buffer buffer, long timeoutMillis) { super(buffer); - this.timeout = (timeoutMillis < 0 ? 0 : timeoutMillis); + this.timeout = timeoutMillis < 0 ? 0 : timeoutMillis; } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java b/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java index c346aa27a..180aa43eb 100644 --- a/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java +++ b/src/main/java/org/apache/commons/collections/buffer/BoundedBuffer.java @@ -179,7 +179,7 @@ public class BoundedBuffer extends SynchronizedBuffer implements BoundedCo public boolean isFull() { // size() is synchronized - return (size() == maxSize()); + return size() == maxSize(); } public int maxSize() { diff --git a/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java b/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java index e531dbbd4..658f2628c 100644 --- a/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java +++ b/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java @@ -151,7 +151,7 @@ public class BoundedFifoBuffer extends AbstractCollection elements[i] = (E) in.readObject(); } start = 0; - full = (size == maxElements); + full = size == maxElements; if (full) { end = 0; } else { @@ -172,7 +172,7 @@ public class BoundedFifoBuffer extends AbstractCollection if (end < start) { size = maxElements - start + end; } else if (end == start) { - size = (full ? maxElements : 0); + size = full ? maxElements : 0; } else { size = end - start; } @@ -348,7 +348,7 @@ public class BoundedFifoBuffer extends AbstractCollection private boolean isFirst = full; public boolean hasNext() { - return isFirst || (index != end); + return isFirst || index != end; } public E next() { diff --git a/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java b/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java index 70f657959..90968ebe8 100644 --- a/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java +++ b/src/main/java/org/apache/commons/collections/buffer/PriorityBuffer.java @@ -316,7 +316,7 @@ public class PriorityBuffer extends AbstractCollection implements Buffer extends AbstractCollection implements Buffer extends AbstractCollection implements Buf */ @Override public boolean isEmpty() { - return (size() == 0); + return size() == 0; } /** @@ -180,7 +180,7 @@ public class UnboundedFifoBuffer extends AbstractCollection implements Buf if (size() + 1 >= buffer.length) { // copy contents to a new buffer array - E[] tmp = (E[]) new Object[((buffer.length - 1) * 2) + 1]; + E[] tmp = (E[]) new Object[(buffer.length - 1) * 2 + 1]; int j = 0; // move head to element zero in the new array for (int i = head; i != tail;) { diff --git a/src/main/java/org/apache/commons/collections/comparators/ComparableComparator.java b/src/main/java/org/apache/commons/collections/comparators/ComparableComparator.java index 653147394..d13835f03 100644 --- a/src/main/java/org/apache/commons/collections/comparators/ComparableComparator.java +++ b/src/main/java/org/apache/commons/collections/comparators/ComparableComparator.java @@ -120,8 +120,8 @@ public class ComparableComparator> implements Co */ @Override public boolean equals(Object object) { - return (this == object) || - ((null != object) && (object.getClass().equals(this.getClass()))); + return this == object || + null != object && object.getClass().equals(this.getClass()); } } diff --git a/src/main/java/org/apache/commons/collections/comparators/ComparatorChain.java b/src/main/java/org/apache/commons/collections/comparators/ComparatorChain.java index e6571e7bb..6d68364bc 100644 --- a/src/main/java/org/apache/commons/collections/comparators/ComparatorChain.java +++ b/src/main/java/org/apache/commons/collections/comparators/ComparatorChain.java @@ -340,9 +340,9 @@ public class ComparatorChain implements Comparator, Serializable { } if (object.getClass().equals(this.getClass())) { ComparatorChain chain = (ComparatorChain) object; - return ((null == orderingBits ? null == chain.orderingBits : orderingBits + return (null == orderingBits ? null == chain.orderingBits : orderingBits .equals(chain.orderingBits)) && (null == comparatorChain ? null == chain.comparatorChain - : comparatorChain.equals(chain.comparatorChain))); + : comparatorChain.equals(chain.comparatorChain)); } return false; } diff --git a/src/main/java/org/apache/commons/collections/comparators/FixedOrderComparator.java b/src/main/java/org/apache/commons/collections/comparators/FixedOrderComparator.java index d14c77be1..8d5a71a95 100644 --- a/src/main/java/org/apache/commons/collections/comparators/FixedOrderComparator.java +++ b/src/main/java/org/apache/commons/collections/comparators/FixedOrderComparator.java @@ -182,7 +182,7 @@ public class FixedOrderComparator implements Comparator, Serializable { public boolean add(T obj) { checkLocked(); Integer position = map.put(obj, new Integer(counter++)); - return (position == null); + return position == null; } /** @@ -205,7 +205,7 @@ public class FixedOrderComparator implements Comparator, Serializable { throw new IllegalArgumentException(existingObj + " not known to " + this); } Integer result = map.put(newObj, position); - return (result == null); + return result == null; } // Comparator methods @@ -235,7 +235,7 @@ public class FixedOrderComparator implements Comparator, Serializable { case AFTER: return position1 == null ? position2 == null ? 0 : 1 : -1; case EXCEPTION: - Object unknownObj = (position1 == null) ? obj1 : obj2; + Object unknownObj = position1 == null ? obj1 : obj2; throw new IllegalArgumentException("Attempting to compare unknown object " + unknownObj); default: //could be null @@ -285,12 +285,12 @@ public class FixedOrderComparator implements Comparator, Serializable { } if (object.getClass().equals(this.getClass())) { FixedOrderComparator comp = (FixedOrderComparator) object; - return (null == map ? null == comp.map : map.equals(comp.map) && + return null == map ? null == comp.map : map.equals(comp.map) && null == unknownObjectBehavior ? null == comp.unknownObjectBehavior : unknownObjectBehavior == comp.unknownObjectBehavior && counter == comp.counter && isLocked == comp.isLocked && - unknownObjectBehavior == comp.unknownObjectBehavior); + unknownObjectBehavior == comp.unknownObjectBehavior; } return false; } diff --git a/src/main/java/org/apache/commons/collections/comparators/NullComparator.java b/src/main/java/org/apache/commons/collections/comparators/NullComparator.java index 40b6fe5c9..d6800628b 100644 --- a/src/main/java/org/apache/commons/collections/comparators/NullComparator.java +++ b/src/main/java/org/apache/commons/collections/comparators/NullComparator.java @@ -137,8 +137,8 @@ public class NullComparator implements Comparator, Serializable { **/ public int compare(E o1, E o2) { if(o1 == o2) { return 0; } - if(o1 == null) { return (this.nullsAreHigh ? 1 : -1); } - if(o2 == null) { return (this.nullsAreHigh ? -1 : 1); } + if(o1 == null) { return this.nullsAreHigh ? 1 : -1; } + if(o2 == null) { return this.nullsAreHigh ? -1 : 1; } return this.nonNullComparator.compare(o1, o2); } @@ -173,8 +173,8 @@ public class NullComparator implements Comparator, Serializable { NullComparator other = (NullComparator) obj; - return ((this.nullsAreHigh == other.nullsAreHigh) && - (this.nonNullComparator.equals(other.nonNullComparator))); + return this.nullsAreHigh == other.nullsAreHigh && + this.nonNullComparator.equals(other.nonNullComparator); } } diff --git a/src/main/java/org/apache/commons/collections/comparators/TransformingComparator.java b/src/main/java/org/apache/commons/collections/comparators/TransformingComparator.java index a6cb687b6..582b39b26 100644 --- a/src/main/java/org/apache/commons/collections/comparators/TransformingComparator.java +++ b/src/main/java/org/apache/commons/collections/comparators/TransformingComparator.java @@ -119,8 +119,8 @@ public class TransformingComparator implements Comparator, Serializable { } if (object.getClass().equals(this.getClass())) { TransformingComparator comp = (TransformingComparator) object; - return (null == decorated ? null == comp.decorated : decorated.equals(comp.decorated) && - null == transformer ? null == comp.transformer : transformer.equals(comp.transformer)); + return null == decorated ? null == comp.decorated : decorated.equals(comp.decorated) && + null == transformer ? null == comp.transformer : transformer.equals(comp.transformer); } return false; } diff --git a/src/main/java/org/apache/commons/collections/comparators/sequence/SequencesComparator.java b/src/main/java/org/apache/commons/collections/comparators/sequence/SequencesComparator.java index 4e120618b..b29289cf4 100644 --- a/src/main/java/org/apache/commons/collections/comparators/sequence/SequencesComparator.java +++ b/src/main/java/org/apache/commons/collections/comparators/sequence/SequencesComparator.java @@ -101,8 +101,8 @@ public class SequencesComparator { */ private Snake buildSnake(int start, int diag, int end1, int end2) { int end = start; - while (((end - diag) < end2) - && (end < end1) + while (end - diag < end2 + && end < end1 && sequence1.get(end).equals(sequence2.get(end - diag))) { ++end; } @@ -130,13 +130,13 @@ public class SequencesComparator { // Initialisations int m = end1 - start1; int n = end2 - start2; - if ((m == 0) || (n == 0)) { + if (m == 0 || n == 0) { return null; } int delta = m - n; int sum = n + m; - int offset = ((sum % 2 == 0) ? sum : (sum + 1)) / 2; + int offset = (sum % 2 == 0 ? sum : sum + 1) / 2; vDown[1+offset] = start1; vUp[1+offset] = end1 + 1; @@ -146,7 +146,7 @@ public class SequencesComparator { // First step int i = k + offset; - if ((k == -d) || ((k != d) && (vDown[i-1] < vDown[i+1]))) { + if (k == -d || k != d && vDown[i-1] < vDown[i+1]) { vDown[i] = vDown[i+1]; } else { vDown[i] = vDown[i-1] + 1; @@ -155,12 +155,12 @@ public class SequencesComparator { int x = vDown[i]; int y = x - start1 + start2 - k; - while ((x < end1) && (y < end2) && (sequence1.get(x).equals(sequence2.get(y)))) { + while (x < end1 && y < end2 && sequence1.get(x).equals(sequence2.get(y))) { vDown[i] = ++x; ++y; } // Second step - if (((delta % 2) != 0 ) && ((delta - d) <= k) && (k <= (delta + d))) { + if (delta % 2 != 0 && delta - d <= k && k <= delta + d) { if (vUp[i-delta] <= vDown[i]) { return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2); } @@ -168,11 +168,11 @@ public class SequencesComparator { } // Up - for (int k = (delta - d); k <= (delta + d); k += 2) { + for (int k = delta - d; k <= delta + d; k += 2) { // First step int i = k + offset - delta; - if ((k == (delta - d)) - || ((k != (delta + d)) && (vUp[i+1] <= vUp[i-1]))) { + if (k == delta - d + || k != delta + d && vUp[i+1] <= vUp[i-1]) { vUp[i] = vUp[i+1] - 1; } else { vUp[i] = vUp[i-1]; @@ -180,13 +180,13 @@ public class SequencesComparator { int x = vUp[i] - 1; int y = x - start1 + start2 - k; - while ((x >= start1) && (y >= start2) + while (x >= start1 && y >= start2 && sequence1.get(x).equals(sequence2.get(y))) { vUp[i] = x--; y--; } // Second step - if (((delta % 2) == 0) && (-d <= k) && (k <= d) ) { + if (delta % 2 == 0 && -d <= k && k <= d ) { if (vUp[i] <= vDown[i + delta]) { return buildSnake(vUp[i], k + start1 - start2, end1, end2); } @@ -213,19 +213,19 @@ public class SequencesComparator { Snake middle = getMiddleSnake(start1, end1, start2, end2); - if ((middle == null) - || ((middle.getStart() == end1) && (middle.getDiag() == (end1 - end2))) - || ((middle.getEnd() == start1) && (middle.getDiag() == (start1 - start2)))) { + if (middle == null + || middle.getStart() == end1 && middle.getDiag() == end1 - end2 + || middle.getEnd() == start1 && middle.getDiag() == start1 - start2) { int i = start1; int j = start2; - while ((i < end1) || (j < end2)) { - if ((i < end1) && (j < end2) && sequence1.get(i).equals(sequence2.get(j))) { + while (i < end1 || j < end2) { + if (i < end1 && j < end2 && sequence1.get(i).equals(sequence2.get(j))) { script.append(new KeepCommand(sequence1.get(i))); ++i; ++j; } else { - if ((end1 - start1) > (end2 - start2)) { + if (end1 - start1 > end2 - start2) { script.append(new DeleteCommand(sequence1.get(i))); ++i; } else { diff --git a/src/main/java/org/apache/commons/collections/functors/AndPredicate.java b/src/main/java/org/apache/commons/collections/functors/AndPredicate.java index 9ee218fdc..245c5fcd8 100644 --- a/src/main/java/org/apache/commons/collections/functors/AndPredicate.java +++ b/src/main/java/org/apache/commons/collections/functors/AndPredicate.java @@ -72,7 +72,7 @@ public final class AndPredicate implements Predicate, PredicateDecorator implements Predicate, Serializable { int comparison = comparator.compare(object, target); switch (criterion) { case EQUAL: - result = (comparison == 0); + result = comparison == 0; break; case GREATER: - result = (comparison > 0); + result = comparison > 0; break; case LESS: - result = (comparison < 0); + result = comparison < 0; break; case GREATER_OR_EQUAL: - result = (comparison >= 0); + result = comparison >= 0; break; case LESS_OR_EQUAL: - result = (comparison <= 0); + result = comparison <= 0; break; default: throw new IllegalStateException("The current criterion '" + criterion + "' is invalid."); diff --git a/src/main/java/org/apache/commons/collections/functors/IdentityPredicate.java b/src/main/java/org/apache/commons/collections/functors/IdentityPredicate.java index 3b8abe091..8bcd5e895 100644 --- a/src/main/java/org/apache/commons/collections/functors/IdentityPredicate.java +++ b/src/main/java/org/apache/commons/collections/functors/IdentityPredicate.java @@ -69,7 +69,7 @@ public final class IdentityPredicate implements Predicate, Serializable { * @return true if input is the same object as the stored value */ public boolean evaluate(T object) { - return (iValue == object); + return iValue == object; } /** diff --git a/src/main/java/org/apache/commons/collections/functors/InstanceofPredicate.java b/src/main/java/org/apache/commons/collections/functors/InstanceofPredicate.java index f5f1ee944..5f672916f 100644 --- a/src/main/java/org/apache/commons/collections/functors/InstanceofPredicate.java +++ b/src/main/java/org/apache/commons/collections/functors/InstanceofPredicate.java @@ -67,7 +67,7 @@ public final class InstanceofPredicate implements Predicate, Serializabl * @return true if input is of stored type */ public boolean evaluate(Object object) { - return (iType.isInstance(object)); + return iType.isInstance(object); } /** diff --git a/src/main/java/org/apache/commons/collections/functors/InstantiateFactory.java b/src/main/java/org/apache/commons/collections/functors/InstantiateFactory.java index 37e8f1a03..248203592 100644 --- a/src/main/java/org/apache/commons/collections/functors/InstantiateFactory.java +++ b/src/main/java/org/apache/commons/collections/functors/InstantiateFactory.java @@ -55,9 +55,9 @@ public class InstantiateFactory implements Factory, Serializable { if (classToInstantiate == null) { throw new IllegalArgumentException("Class to instantiate must not be null"); } - if (((paramTypes == null) && (args != null)) - || ((paramTypes != null) && (args == null)) - || ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) { + if (paramTypes == null && args != null + || paramTypes != null && args == null + || paramTypes != null && args != null && paramTypes.length != args.length) { throw new IllegalArgumentException("Parameter types must match the arguments"); } diff --git a/src/main/java/org/apache/commons/collections/functors/NotNullPredicate.java b/src/main/java/org/apache/commons/collections/functors/NotNullPredicate.java index 8c68ed191..c194901ec 100644 --- a/src/main/java/org/apache/commons/collections/functors/NotNullPredicate.java +++ b/src/main/java/org/apache/commons/collections/functors/NotNullPredicate.java @@ -60,7 +60,7 @@ public final class NotNullPredicate implements Predicate, Serializable { * @return true if not null */ public boolean evaluate(T object) { - return (object != null); + return object != null; } private Object readResolve() { diff --git a/src/main/java/org/apache/commons/collections/functors/NotPredicate.java b/src/main/java/org/apache/commons/collections/functors/NotPredicate.java index 1bf0e3fe0..6dc66f42e 100644 --- a/src/main/java/org/apache/commons/collections/functors/NotPredicate.java +++ b/src/main/java/org/apache/commons/collections/functors/NotPredicate.java @@ -67,7 +67,7 @@ public final class NotPredicate implements Predicate, PredicateDecorator implements Predicate, Serializable { * @return true if input is null */ public boolean evaluate(T object) { - return (object == null); + return object == null; } private Object readResolve() { diff --git a/src/main/java/org/apache/commons/collections/functors/OrPredicate.java b/src/main/java/org/apache/commons/collections/functors/OrPredicate.java index dc8009fb3..ccdaf2dbf 100644 --- a/src/main/java/org/apache/commons/collections/functors/OrPredicate.java +++ b/src/main/java/org/apache/commons/collections/functors/OrPredicate.java @@ -72,7 +72,7 @@ public final class OrPredicate implements Predicate, PredicateDecorator * @return true if either decorated predicate returns true */ public boolean evaluate(T object) { - return (iPredicate1.evaluate(object) || iPredicate2.evaluate(object)); + return iPredicate1.evaluate(object) || iPredicate2.evaluate(object); } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/ArrayIterator.java b/src/main/java/org/apache/commons/collections/iterators/ArrayIterator.java index 3c71fd063..9e6f699ac 100644 --- a/src/main/java/org/apache/commons/collections/iterators/ArrayIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/ArrayIterator.java @@ -143,7 +143,7 @@ public class ArrayIterator implements ResettableIterator { * @return true if there is a next element to return */ public boolean hasNext() { - return (index < endIndex); + return index < endIndex; } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/ArrayListIterator.java b/src/main/java/org/apache/commons/collections/iterators/ArrayListIterator.java index f832f9fc3..de1cbd732 100644 --- a/src/main/java/org/apache/commons/collections/iterators/ArrayListIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/ArrayListIterator.java @@ -116,7 +116,7 @@ public class ArrayListIterator extends ArrayIterator * @return true if there is a previous element to return */ public boolean hasPrevious() { - return (this.index > this.startIndex); + return this.index > this.startIndex; } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/FilterListIterator.java b/src/main/java/org/apache/commons/collections/iterators/FilterListIterator.java index d0a11fdd2..918e0e5ca 100644 --- a/src/main/java/org/apache/commons/collections/iterators/FilterListIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/FilterListIterator.java @@ -154,7 +154,7 @@ public class FilterListIterator implements ListIterator { } public int previousIndex() { - return (nextIndex-1); + return nextIndex-1; } /** Not supported. */ diff --git a/src/main/java/org/apache/commons/collections/iterators/LoopingIterator.java b/src/main/java/org/apache/commons/collections/iterators/LoopingIterator.java index c9d33f7f2..329b181de 100644 --- a/src/main/java/org/apache/commons/collections/iterators/LoopingIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/LoopingIterator.java @@ -68,7 +68,7 @@ public class LoopingIterator implements ResettableIterator { * @return true if there are more elements */ public boolean hasNext() { - return (collection.size() > 0); + return collection.size() > 0; } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java b/src/main/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java index 12698c92a..a2e1e6402 100644 --- a/src/main/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java @@ -119,7 +119,7 @@ public class ObjectArrayIterator * @return true if there is a next element to return */ public boolean hasNext() { - return (this.index < this.endIndex); + return this.index < this.endIndex; } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/ObjectArrayListIterator.java b/src/main/java/org/apache/commons/collections/iterators/ObjectArrayListIterator.java index 1b2846cb0..d850cb473 100644 --- a/src/main/java/org/apache/commons/collections/iterators/ObjectArrayListIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/ObjectArrayListIterator.java @@ -106,7 +106,7 @@ public class ObjectArrayListIterator extends ObjectArrayIterator * @return true if there is a previous element to return */ public boolean hasPrevious() { - return (this.index > this.startIndex); + return this.index > this.startIndex; } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/SingletonIterator.java b/src/main/java/org/apache/commons/collections/iterators/SingletonIterator.java index d4ed5ea02..bc598a888 100644 --- a/src/main/java/org/apache/commons/collections/iterators/SingletonIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/SingletonIterator.java @@ -73,7 +73,7 @@ public class SingletonIterator * @return true if the single object hasn't been returned yet */ public boolean hasNext() { - return (beforeFirst && !removed); + return beforeFirst && !removed; } /** diff --git a/src/main/java/org/apache/commons/collections/iterators/SingletonListIterator.java b/src/main/java/org/apache/commons/collections/iterators/SingletonListIterator.java index 1a3495049..a90f826e7 100644 --- a/src/main/java/org/apache/commons/collections/iterators/SingletonListIterator.java +++ b/src/main/java/org/apache/commons/collections/iterators/SingletonListIterator.java @@ -74,7 +74,7 @@ public class SingletonListIterator implements ListIterator, ResettableList * @return 0 or 1 depending on current state. */ public int nextIndex() { - return (beforeFirst ? 0 : 1); + return beforeFirst ? 0 : 1; } /** @@ -85,7 +85,7 @@ public class SingletonListIterator implements ListIterator, ResettableList * @return 0 or -1 depending on current state. */ public int previousIndex() { - return (beforeFirst ? -1 : 0); + return beforeFirst ? -1 : 0; } /** diff --git a/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java index 4dec69186..4413c5df8 100644 --- a/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java +++ b/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java @@ -105,7 +105,7 @@ public abstract class AbstractLinkedList implements List { } public boolean isEmpty() { - return (size() == 0); + return size() == 0; } public E get(int index) { @@ -413,7 +413,7 @@ public abstract class AbstractLinkedList implements List { * @return true if equal */ protected boolean isEqualValue(Object value1, Object value2) { - return (value1 == value2 || (value1 == null ? false : value1.equals(value2))); + return value1 == value2 || (value1 == null ? false : value1.equals(value2)); } /** @@ -550,7 +550,7 @@ public abstract class AbstractLinkedList implements List { } // Search the list and get the node Node node; - if (index < (size / 2)) { + if (index < size / 2) { // Search forwards node = header.next; for (int currentIndex = 0; currentIndex < index; currentIndex++) { @@ -895,17 +895,17 @@ public abstract class AbstractLinkedList implements List { @Override public boolean hasNext() { - return (nextIndex() < sub.size); + return nextIndex() < sub.size; } @Override public boolean hasPrevious() { - return (previousIndex() >= 0); + return previousIndex() >= 0; } @Override public int nextIndex() { - return (super.nextIndex() - sub.offset); + return super.nextIndex() - sub.offset; } @Override diff --git a/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java b/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java index 0f0b358d5..0c9edec0a 100644 --- a/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java +++ b/src/main/java/org/apache/commons/collections/list/CursorableLinkedList.java @@ -589,17 +589,17 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se @Override public boolean hasNext() { - return (nextIndex() < sub.size); + return nextIndex() < sub.size; } @Override public boolean hasPrevious() { - return (previousIndex() >= 0); + return previousIndex() >= 0; } @Override public int nextIndex() { - return (super.nextIndex() - sub.offset); + return super.nextIndex() - sub.offset; } @Override diff --git a/src/main/java/org/apache/commons/collections/list/GrowthList.java b/src/main/java/org/apache/commons/collections/list/GrowthList.java index 76e8c3183..b0e2001a3 100644 --- a/src/main/java/org/apache/commons/collections/list/GrowthList.java +++ b/src/main/java/org/apache/commons/collections/list/GrowthList.java @@ -153,7 +153,7 @@ public class GrowthList extends AbstractSerializableListDecorator { decorated().addAll(Collections.nCopies(index - size, null)); result = true; } - return (decorated().addAll(index, coll) | result); + return decorated().addAll(index, coll) | result; } //----------------------------------------------------------------------- @@ -180,7 +180,7 @@ public class GrowthList extends AbstractSerializableListDecorator { public E set(int index, E element) { int size = decorated().size(); if (index >= size) { - decorated().addAll(Collections.nCopies((index - size) + 1, null)); + decorated().addAll(Collections.nCopies(index - size + 1, null)); } return decorated().set(index, element); } diff --git a/src/main/java/org/apache/commons/collections/list/SetUniqueList.java b/src/main/java/org/apache/commons/collections/list/SetUniqueList.java index 9cb924d7d..44890f1a0 100644 --- a/src/main/java/org/apache/commons/collections/list/SetUniqueList.java +++ b/src/main/java/org/apache/commons/collections/list/SetUniqueList.java @@ -137,7 +137,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { add(size(), object); // compares sizes to detect if collection changed - return (sizeBefore != size()); + return sizeBefore != size(); } /** diff --git a/src/main/java/org/apache/commons/collections/list/TreeList.java b/src/main/java/org/apache/commons/collections/list/TreeList.java index 66e9c7d9c..dc7b139e9 100644 --- a/src/main/java/org/apache/commons/collections/list/TreeList.java +++ b/src/main/java/org/apache/commons/collections/list/TreeList.java @@ -166,7 +166,7 @@ public class TreeList extends AbstractList { */ @Override public boolean contains(Object object) { - return (indexOf(object) >= 0); + return indexOf(object) >= 0; } /** @@ -336,7 +336,7 @@ public class TreeList extends AbstractList { return this; } - AVLNode nextNode = ((indexRelativeToMe < 0) ? getLeftSubTree() : getRightSubTree()); + AVLNode nextNode = indexRelativeToMe < 0 ? getLeftSubTree() : getRightSubTree(); if (nextNode == null) { return null; } @@ -456,14 +456,14 @@ public class TreeList extends AbstractList { * Gets the left node, returning null if its a faedelung. */ private AVLNode getLeftSubTree() { - return (leftIsPrevious ? null : left); + return leftIsPrevious ? null : left; } /** * Gets the right node, returning null if its a faedelung. */ private AVLNode getRightSubTree() { - return (rightIsNext ? null : right); + return rightIsNext ? null : right; } /** @@ -472,7 +472,7 @@ public class TreeList extends AbstractList { * @return the rightmost child (greatest index) */ private AVLNode max() { - return (getRightSubTree() == null) ? this : right.max(); + return getRightSubTree() == null ? this : right.max(); } /** @@ -481,7 +481,7 @@ public class TreeList extends AbstractList { * @return the leftmost child (smallest index) */ private AVLNode min() { - return (getLeftSubTree() == null) ? this : left.min(); + return getLeftSubTree() == null ? this : left.min(); } /** @@ -651,7 +651,7 @@ public class TreeList extends AbstractList { * Returns the height of the node or -1 if the node is null. */ private int getHeight(AVLNode node) { - return (node == null ? -1 : node.height); + return node == null ? -1 : node.height; } /** @@ -702,8 +702,8 @@ public class TreeList extends AbstractList { * @param previous the previous node in the linked list */ private void setLeft(AVLNode node, AVLNode previous) { - leftIsPrevious = (node == null); - left = (leftIsPrevious ? previous : node); + leftIsPrevious = node == null; + left = leftIsPrevious ? previous : node; recalcHeight(); } @@ -714,8 +714,8 @@ public class TreeList extends AbstractList { * @param next the next node in the linked list */ private void setRight(AVLNode node, AVLNode next) { - rightIsNext = (node == null); - right = (rightIsNext ? next : node); + rightIsNext = node == null; + right = rightIsNext ? next : node; recalcHeight(); } @@ -822,7 +822,7 @@ public class TreeList extends AbstractList { super(); this.parent = parent; this.expectedModCount = parent.modCount; - this.next = (parent.root == null ? null : parent.root.get(fromIndex)); + this.next = parent.root == null ? null : parent.root.get(fromIndex); this.nextIndex = fromIndex; this.currentIndex = -1; } @@ -841,7 +841,7 @@ public class TreeList extends AbstractList { } public boolean hasNext() { - return (nextIndex < parent.size()); + return nextIndex < parent.size(); } public E next() { @@ -860,7 +860,7 @@ public class TreeList extends AbstractList { } public boolean hasPrevious() { - return (nextIndex > 0); + return nextIndex > 0; } public E previous() { diff --git a/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java b/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java index a8ae5315c..ea7b70d2f 100644 --- a/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java +++ b/src/main/java/org/apache/commons/collections/map/AbstractHashedMap.java @@ -206,7 +206,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab */ @Override public boolean isEmpty() { - return (size == 0); + return size == 0; } //----------------------------------------------------------------------- @@ -379,7 +379,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab * @return the converted key */ protected Object convertKey(Object key) { - return (key == null ? NULL : key); + return key == null ? NULL : key; } /** @@ -394,9 +394,9 @@ public class AbstractHashedMap extends AbstractMap implements Iterab // same as JDK 1.4 int h = key.hashCode(); h += ~(h << 9); - h ^= (h >>> 14); - h += (h << 4); - h ^= (h >>> 10); + h ^= h >>> 14; + h += h << 4; + h ^= h >>> 10; return h; } @@ -410,7 +410,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab * @return true if equal */ protected boolean isEqualKey(Object key1, Object key2) { - return (key1 == key2 || key1.equals(key2)); + return key1 == key2 || key1.equals(key2); } /** @@ -423,7 +423,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab * @return true if equal */ protected boolean isEqualValue(Object value1, Object value2) { - return (value1 == value2 || value1.equals(value2)); + return value1 == value2 || value1.equals(value2); } /** @@ -436,7 +436,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab * @return the bucket index */ protected int hashIndex(int hashCode, int dataSize) { - return hashCode & (dataSize - 1); + return hashCode & dataSize - 1; } //----------------------------------------------------------------------- @@ -852,7 +852,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (entry instanceof Map.Entry) { Map.Entry e = (Map.Entry) entry; Entry match = parent.getEntry(e.getKey()); - return (match != null && match.equals(e)); + return match != null && match.equals(e); } return false; } @@ -1155,7 +1155,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab } public boolean hasNext() { - return (next != null); + return next != null; } protected HashEntry nextEntry() { diff --git a/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java b/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java index 19e172219..9afb168d2 100644 --- a/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java +++ b/src/main/java/org/apache/commons/collections/map/AbstractLinkedMap.java @@ -198,7 +198,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im */ public K nextKey(Object key) { LinkEntry entry = getEntry(key); - return (entry == null || entry.after == header ? null : entry.after.getKey()); + return entry == null || entry.after == header ? null : entry.after.getKey(); } @Override @@ -214,7 +214,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im */ public K previousKey(Object key) { LinkEntry entry = getEntry(key); - return (entry == null || entry.before == header ? null : entry.before.getKey()); + return entry == null || entry.before == header ? null : entry.before.getKey(); } //----------------------------------------------------------------------- @@ -233,7 +233,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im throw new IndexOutOfBoundsException("Index " + index + " is invalid for size " + size); } LinkEntry entry; - if (index < (size / 2)) { + if (index < size / 2) { // Search forwards entry = header.after; for (int currentIndex = 0; currentIndex < index; currentIndex++) { @@ -540,11 +540,11 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im } public boolean hasNext() { - return (next != parent.header); + return next != parent.header; } public boolean hasPrevious() { - return (next.before != parent.header); + return next.before != parent.header; } protected LinkEntry nextEntry() { diff --git a/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java index d2b96b888..c84f868f0 100644 --- a/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java @@ -214,7 +214,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap if (entry == null) { return false; } - return (entry.getValue() != null); + return entry.getValue() != null; } /** @@ -453,8 +453,8 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override @SuppressWarnings("unchecked") protected boolean isEqualKey(Object key1, Object key2) { - key2 = (keyType == ReferenceStrength.HARD ? key2 : ((Reference) key2).get()); - return (key1 == key2 || key1.equals(key2)); + key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference) key2).get(); + return key1 == key2 || key1.equals(key2); } /** @@ -617,7 +617,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override @SuppressWarnings("unchecked") public K getKey() { - return (K) ((parent.keyType == ReferenceStrength.HARD) ? key : ((Reference) key).get()); + return (K) (parent.keyType == ReferenceStrength.HARD ? key : ((Reference) key).get()); } /** @@ -629,7 +629,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override @SuppressWarnings("unchecked") public V getValue() { - return (V) ((parent.valueType == ReferenceStrength.HARD) ? value : ((Reference) value).get()); + return (V) (parent.valueType == ReferenceStrength.HARD ? value : ((Reference) value).get()); } /** @@ -670,7 +670,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap Map.Entry entry = (Map.Entry)obj; Object entryKey = entry.getKey(); // convert to hard reference Object entryValue = entry.getValue(); // convert to hard reference - if ((entryKey == null) || (entryValue == null)) { + if (entryKey == null || entryValue == null) { return false; } // compare using map methods, aiding identity subclass @@ -722,8 +722,8 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap * @return true or false */ boolean purge(Reference ref) { - boolean r = (parent.keyType != ReferenceStrength.HARD) && (key == ref); - r = r || ((parent.valueType != ReferenceStrength.HARD) && (value == ref)); + boolean r = parent.keyType != ReferenceStrength.HARD && key == ref; + r = r || parent.valueType != ReferenceStrength.HARD && value == ref; if (r) { if (parent.keyType != ReferenceStrength.HARD) { ((Reference) key).clear(); @@ -771,7 +771,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap public ReferenceBaseIterator(AbstractReferenceMap parent) { super(); this.parent = parent; - index = (parent.size() != 0 ? parent.data.length : 0); + index = parent.size() != 0 ? parent.data.length : 0; // have to do this here! size() invocation above // may have altered the modCount. expectedModCount = parent.modCount; @@ -782,7 +782,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap while (nextNull()) { ReferenceEntry e = entry; int i = index; - while ((e == null) && (i > 0)) { + while (e == null && i > 0) { i--; e = (ReferenceEntry) parent.data[i]; } @@ -809,7 +809,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap } private boolean nextNull() { - return (nextKey == null) || (nextValue == null); + return nextKey == null || nextValue == null; } protected ReferenceEntry nextEntry() { diff --git a/src/main/java/org/apache/commons/collections/map/CompositeMap.java b/src/main/java/org/apache/commons/collections/map/CompositeMap.java index d09864066..5b1f2d443 100644 --- a/src/main/java/org/apache/commons/collections/map/CompositeMap.java +++ b/src/main/java/org/apache/commons/collections/map/CompositeMap.java @@ -465,7 +465,7 @@ public class CompositeMap extends AbstractIterableMap implements Ser public boolean equals(Object obj) { if (obj instanceof Map) { Map map = (Map) obj; - return (this.entrySet().equals(map.entrySet())); + return this.entrySet().equals(map.entrySet()); } return false; } diff --git a/src/main/java/org/apache/commons/collections/map/Flat3Map.java b/src/main/java/org/apache/commons/collections/map/Flat3Map.java index 7468fdf9a..ae147a554 100644 --- a/src/main/java/org/apache/commons/collections/map/Flat3Map.java +++ b/src/main/java/org/apache/commons/collections/map/Flat3Map.java @@ -184,7 +184,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl * @return true if the map is currently size zero */ public boolean isEmpty() { - return (size() == 0); + return size() == 0; } //----------------------------------------------------------------------- @@ -346,17 +346,17 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl delegateMap.put(key, value); return null; case 2: - hash3 = (key == null ? 0 : key.hashCode()); + hash3 = key == null ? 0 : key.hashCode(); key3 = key; value3 = value; break; case 1: - hash2 = (key == null ? 0 : key.hashCode()); + hash2 = key == null ? 0 : key.hashCode(); key2 = key; value2 = value; break; case 0: - hash1 = (key == null ? 0 : key.hashCode()); + hash1 = key == null ? 0 : key.hashCode(); key1 = key; value1 = value; break; @@ -626,7 +626,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl } public boolean hasNext() { - return (nextIndex < parent.size); + return nextIndex < parent.size; } public K next() { @@ -784,7 +784,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl } public boolean hasNext() { - return (nextIndex < parent.size); + return nextIndex < parent.size; } public Map.Entry nextEntry() { @@ -1161,11 +1161,11 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl int total = 0; switch (size) { // drop through case 3: - total += (hash3 ^ (value3 == null ? 0 : value3.hashCode())); + total += hash3 ^ (value3 == null ? 0 : value3.hashCode()); case 2: - total += (hash2 ^ (value2 == null ? 0 : value2.hashCode())); + total += hash2 ^ (value2 == null ? 0 : value2.hashCode()); case 1: - total += (hash1 ^ (value1 == null ? 0 : value1.hashCode())); + total += hash1 ^ (value1 == null ? 0 : value1.hashCode()); } return total; } @@ -1187,19 +1187,19 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl buf.append('{'); switch (size) { // drop through case 3: - buf.append((key3 == this ? "(this Map)" : key3)); + buf.append(key3 == this ? "(this Map)" : key3); buf.append('='); - buf.append((value3 == this ? "(this Map)" : value3)); + buf.append(value3 == this ? "(this Map)" : value3); buf.append(','); case 2: - buf.append((key2 == this ? "(this Map)" : key2)); + buf.append(key2 == this ? "(this Map)" : key2); buf.append('='); - buf.append((value2 == this ? "(this Map)" : value2)); + buf.append(value2 == this ? "(this Map)" : value2); buf.append(','); case 1: - buf.append((key1 == this ? "(this Map)" : key1)); + buf.append(key1 == this ? "(this Map)" : key1); buf.append('='); - buf.append((value1 == this ? "(this Map)" : value1)); + buf.append(value1 == this ? "(this Map)" : value1); } buf.append('}'); return buf.toString(); diff --git a/src/main/java/org/apache/commons/collections/map/IdentityMap.java b/src/main/java/org/apache/commons/collections/map/IdentityMap.java index 84021442f..2dd63b269 100644 --- a/src/main/java/org/apache/commons/collections/map/IdentityMap.java +++ b/src/main/java/org/apache/commons/collections/map/IdentityMap.java @@ -109,7 +109,7 @@ public class IdentityMap */ @Override protected boolean isEqualKey(Object key1, Object key2) { - return (key1 == key2); + return key1 == key2; } /** @@ -122,7 +122,7 @@ public class IdentityMap */ @Override protected boolean isEqualValue(Object value1, Object value2) { - return (value1 == value2); + return value1 == value2; } /** @@ -160,8 +160,8 @@ public class IdentityMap } Map.Entry other = (Map.Entry) obj; return - (getKey() == other.getKey()) && - (getValue() == other.getValue()); + getKey() == other.getKey() && + getValue() == other.getValue(); } @Override diff --git a/src/main/java/org/apache/commons/collections/map/LRUMap.java b/src/main/java/org/apache/commons/collections/map/LRUMap.java index 65696554c..15fd388bd 100644 --- a/src/main/java/org/apache/commons/collections/map/LRUMap.java +++ b/src/main/java/org/apache/commons/collections/map/LRUMap.java @@ -124,7 +124,7 @@ public class LRUMap * @since 3.1 */ public LRUMap(int maxSize, float loadFactor, boolean scanUntilRemovable) { - super((maxSize < 1 ? DEFAULT_CAPACITY : maxSize), loadFactor); + super(maxSize < 1 ? DEFAULT_CAPACITY : maxSize, loadFactor); if (maxSize < 1) { throw new IllegalArgumentException("LRUMap max size must be greater than 0"); } @@ -373,7 +373,7 @@ public class LRUMap * @return true if the map is full */ public boolean isFull() { - return (size >= maxSize); + return size >= maxSize; } /** diff --git a/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java b/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java index a512c8774..ebbe03032 100644 --- a/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java +++ b/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java @@ -229,9 +229,9 @@ public class MultiKeyMap extends AbstractMapDecorator>> 14); - h += (h << 4); - h ^= (h >>> 10); + h ^= h >>> 14; + h += h << 4; + h ^= h >>> 10; return h; } @@ -365,9 +365,9 @@ public class MultiKeyMap extends AbstractMapDecorator>> 14); - h += (h << 4); - h ^= (h >>> 10); + h ^= h >>> 14; + h += h << 4; + h ^= h >>> 10; return h; } @@ -511,9 +511,9 @@ public class MultiKeyMap extends AbstractMapDecorator>> 14); - h += (h << 4); - h ^= (h >>> 10); + h ^= h >>> 14; + h += h << 4; + h ^= h >>> 10; return h; } @@ -667,9 +667,9 @@ public class MultiKeyMap extends AbstractMapDecorator>> 14); - h += (h << 4); - h ^= (h >>> 10); + h ^= h >>> 14; + h += h << 4; + h ^= h >>> 10; return h; } diff --git a/src/main/java/org/apache/commons/collections/map/MultiValueMap.java b/src/main/java/org/apache/commons/collections/map/MultiValueMap.java index e707c89e7..d961a76aa 100644 --- a/src/main/java/org/apache/commons/collections/map/MultiValueMap.java +++ b/src/main/java/org/apache/commons/collections/map/MultiValueMap.java @@ -261,7 +261,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme } else { result = coll.add((V) value); } - return (result ? value : null); + return result ? value : null; } /** diff --git a/src/main/java/org/apache/commons/collections/map/PassiveExpiringMap.java b/src/main/java/org/apache/commons/collections/map/PassiveExpiringMap.java index 5aa2ca3a6..83e53c3d2 100644 --- a/src/main/java/org/apache/commons/collections/map/PassiveExpiringMap.java +++ b/src/main/java/org/apache/commons/collections/map/PassiveExpiringMap.java @@ -402,7 +402,7 @@ public class PassiveExpiringMap private boolean isExpired(long now, Long expirationTimeObject) { if (expirationTimeObject != null) { long expirationTime = expirationTimeObject.longValue(); - return (expirationTime >= 0 && now >= expirationTime); + return expirationTime >= 0 && now >= expirationTime; } return false; } diff --git a/src/main/java/org/apache/commons/collections/map/PredicatedMap.java b/src/main/java/org/apache/commons/collections/map/PredicatedMap.java index 0554eabe1..7c2614ea9 100644 --- a/src/main/java/org/apache/commons/collections/map/PredicatedMap.java +++ b/src/main/java/org/apache/commons/collections/map/PredicatedMap.java @@ -169,7 +169,7 @@ public class PredicatedMap */ @Override protected boolean isSetValueChecking() { - return (valuePredicate != null); + return valuePredicate != null; } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections/map/SingletonMap.java b/src/main/java/org/apache/commons/collections/map/SingletonMap.java index a9ec85f1c..615636cc5 100644 --- a/src/main/java/org/apache/commons/collections/map/SingletonMap.java +++ b/src/main/java/org/apache/commons/collections/map/SingletonMap.java @@ -219,7 +219,7 @@ public class SingletonMap * @return true if the map contains the key */ public boolean containsKey(Object key) { - return (isEqualKey(key)); + return isEqualKey(key); } /** @@ -229,7 +229,7 @@ public class SingletonMap * @return true if the map contains the key */ public boolean containsValue(Object value) { - return (isEqualValue(value)); + return isEqualValue(value); } //----------------------------------------------------------------------- @@ -383,7 +383,7 @@ public class SingletonMap * @return true if equal */ protected boolean isEqualKey(Object key) { - return (key == null ? getKey() == null : key.equals(getKey())); + return key == null ? getKey() == null : key.equals(getKey()); } /** @@ -393,7 +393,7 @@ public class SingletonMap * @return true if equal */ protected boolean isEqualValue(Object value) { - return (value == null ? getValue() == null : value.equals(getValue())); + return value == null ? getValue() == null : value.equals(getValue()); } //----------------------------------------------------------------------- @@ -424,7 +424,7 @@ public class SingletonMap } public boolean hasPrevious() { - return (hasNext == false); + return hasNext == false; } public K previous() { @@ -566,9 +566,9 @@ public class SingletonMap public String toString() { return new StringBuilder(128) .append('{') - .append((getKey() == this ? "(this Map)" : getKey())) + .append(getKey() == this ? "(this Map)" : getKey()) .append('=') - .append((getValue() == this ? "(this Map)" : getValue())) + .append(getValue() == this ? "(this Map)" : getValue()) .append('}') .toString(); } diff --git a/src/main/java/org/apache/commons/collections/map/TransformedMap.java b/src/main/java/org/apache/commons/collections/map/TransformedMap.java index a61310769..51964456d 100644 --- a/src/main/java/org/apache/commons/collections/map/TransformedMap.java +++ b/src/main/java/org/apache/commons/collections/map/TransformedMap.java @@ -225,7 +225,7 @@ public class TransformedMap */ @Override protected boolean isSetValueChecking() { - return (valueTransformer != null); + return valueTransformer != null; } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections/set/CompositeSet.java b/src/main/java/org/apache/commons/collections/set/CompositeSet.java index 5cc41d519..7e5aaf5f3 100644 --- a/src/main/java/org/apache/commons/collections/set/CompositeSet.java +++ b/src/main/java/org/apache/commons/collections/set/CompositeSet.java @@ -189,7 +189,7 @@ public class CompositeSet extends CompositeCollection implements Set { public int hashCode() { int code = 0; for (E e : this) { - code += (e == null ? 0 : e.hashCode()); + code += e == null ? 0 : e.hashCode(); } return code; } diff --git a/src/main/java/org/apache/commons/collections/set/MapBackedSet.java b/src/main/java/org/apache/commons/collections/set/MapBackedSet.java index 8a38ece21..01409c857 100644 --- a/src/main/java/org/apache/commons/collections/set/MapBackedSet.java +++ b/src/main/java/org/apache/commons/collections/set/MapBackedSet.java @@ -114,7 +114,7 @@ public final class MapBackedSet implements Set, Serializable { public boolean add(E obj) { int size = map.size(); map.put(obj, dummyValue); - return (map.size() != size); + return map.size() != size; } public boolean addAll(Collection coll) { @@ -122,13 +122,13 @@ public final class MapBackedSet implements Set, Serializable { for (E e : coll) { map.put(e, dummyValue); } - return (map.size() != size); + return map.size() != size; } public boolean remove(Object obj) { int size = map.size(); map.remove(obj); - return (map.size() != size); + return map.size() != size; } public boolean removeAll(Collection coll) { diff --git a/src/main/java/org/apache/commons/collections/trie/AbstractKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/AbstractKeyAnalyzer.java index 79f7439c0..e29af3ff4 100644 --- a/src/main/java/org/apache/commons/collections/trie/AbstractKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/AbstractKeyAnalyzer.java @@ -32,9 +32,9 @@ public abstract class AbstractKeyAnalyzer implements KeyAnalyzer { @SuppressWarnings("unchecked") public int compare(K o1, K o2) { if (o1 == null) { - return (o2 == null) ? 0 : -1; + return o2 == null ? 0 : -1; } else if (o2 == null) { - return (o1 == null) ? 0 : 1; + return o1 == null ? 0 : 1; } return ((Comparable)o1).compareTo(o2); diff --git a/src/main/java/org/apache/commons/collections/trie/AbstractTrie.java b/src/main/java/org/apache/commons/collections/trie/AbstractTrie.java index e48ade4b1..89fc8f889 100644 --- a/src/main/java/org/apache/commons/collections/trie/AbstractTrie.java +++ b/src/main/java/org/apache/commons/collections/trie/AbstractTrie.java @@ -148,9 +148,9 @@ abstract class AbstractTrie extends AbstractMap */ final boolean compareKeys(K key, K other) { if (key == null) { - return (other == null); + return other == null; } else if (other == null) { - return (key == null); + return key == null; } return keyAnalyzer.compare(key, other) == 0; @@ -160,7 +160,7 @@ abstract class AbstractTrie extends AbstractMap * Returns true if both values are either null or equal */ static boolean compare(Object a, Object b) { - return (a == null ? b == null : a.equals(b)); + return a == null ? b == null : a.equals(b); } /** @@ -178,7 +178,7 @@ abstract class AbstractTrie extends AbstractMap public BasicEntry(K key) { this.key = key; - this.hashCode = (key != null ? key.hashCode() : 0); + this.hashCode = key != null ? key.hashCode() : 0; } public BasicEntry(K key, V value) { diff --git a/src/main/java/org/apache/commons/collections/trie/ByteArrayKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/ByteArrayKeyAnalyzer.java index 72bd8ff16..9c98f5bb6 100644 --- a/src/main/java/org/apache/commons/collections/trie/ByteArrayKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/ByteArrayKeyAnalyzer.java @@ -87,7 +87,7 @@ public class ByteArrayKeyAnalyzer extends AbstractKeyAnalyzer { * {@inheritDoc} */ public int lengthInBits(byte[] key) { - return (key != null ? key.length * bitsPerElement() : 0); + return key != null ? key.length * bitsPerElement() : 0; } /** @@ -129,14 +129,14 @@ public class ByteArrayKeyAnalyzer extends AbstractKeyAnalyzer { } for (int i = 0; i < length; i++) { - int index = prefix + (offsetInBits + i); + int index = prefix + offsetInBits + i; boolean value = isBitSet(key, index, lengthInBits); if (value) { allNull = false; } - int otherIndex = prefix + (otherOffsetInBits + i); + int otherIndex = prefix + otherOffsetInBits + i; boolean otherValue = isBitSet(other, otherIndex, otherLengthInBits); if (value != otherValue) { @@ -179,9 +179,9 @@ public class ByteArrayKeyAnalyzer extends AbstractKeyAnalyzer { @Override public int compare(byte[] o1, byte[] o2) { if (o1 == null) { - return (o2 == null) ? 0 : -1; + return o2 == null ? 0 : -1; } else if (o2 == null) { - return (o1 == null) ? 0 : 1; + return o1 == null ? 0 : 1; } if (o1.length != o2.length) { diff --git a/src/main/java/org/apache/commons/collections/trie/ByteKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/ByteKeyAnalyzer.java index 80e99a187..1157cda18 100644 --- a/src/main/java/org/apache/commons/collections/trie/ByteKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/ByteKeyAnalyzer.java @@ -85,7 +85,7 @@ public class ByteKeyAnalyzer extends AbstractKeyAnalyzer { return NULL_BIT_KEY; } - byte otherValue = (other != null ? other.byteValue() : 0); + byte otherValue = other != null ? other.byteValue() : 0; if (keyValue != otherValue) { int xorValue = keyValue ^ otherValue; @@ -105,12 +105,12 @@ public class ByteKeyAnalyzer extends AbstractKeyAnalyzer { public boolean isPrefix(Byte prefix, int offsetInBits, int lengthInBits, Byte key) { - int value1 = (prefix.byteValue() << offsetInBits); + int value1 = prefix.byteValue() << offsetInBits; int value2 = key.byteValue(); int mask = 0; for (int i = 0; i < lengthInBits; i++) { - mask |= (0x1 << i); + mask |= 0x1 << i; } return (value1 & mask) == (value2 & mask); diff --git a/src/main/java/org/apache/commons/collections/trie/CharArrayKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/CharArrayKeyAnalyzer.java index 07cfd7937..d47d780e9 100644 --- a/src/main/java/org/apache/commons/collections/trie/CharArrayKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/CharArrayKeyAnalyzer.java @@ -59,7 +59,7 @@ public class CharArrayKeyAnalyzer extends AbstractKeyAnalyzer { * {@inheritDoc} */ public int lengthInBits(char[] key) { - return (key != null ? key.length * LENGTH : 0); + return key != null ? key.length * LENGTH : 0; } /** @@ -106,7 +106,7 @@ public class CharArrayKeyAnalyzer extends AbstractKeyAnalyzer { if (k != f) { int x = k ^ f; - return i * LENGTH + (Integer.numberOfLeadingZeros(x) - LENGTH); + return i * LENGTH + Integer.numberOfLeadingZeros(x) - LENGTH; } if (k != 0) { diff --git a/src/main/java/org/apache/commons/collections/trie/CharacterKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/CharacterKeyAnalyzer.java index 63755bce3..70271725b 100644 --- a/src/main/java/org/apache/commons/collections/trie/CharacterKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/CharacterKeyAnalyzer.java @@ -90,7 +90,7 @@ public class CharacterKeyAnalyzer extends AbstractKeyAnalyzer { other = Character.MIN_VALUE; } - char otherValue = (other != null ? other.charValue() : Character.MIN_VALUE); + char otherValue = other != null ? other.charValue() : Character.MIN_VALUE; if (keyValue != otherValue) { int xorValue = keyValue ^ otherValue; @@ -110,12 +110,12 @@ public class CharacterKeyAnalyzer extends AbstractKeyAnalyzer { public boolean isPrefix(Character prefix, int offsetInBits, int lengthInBits, Character key) { - int value1 = (prefix.charValue() << offsetInBits); + int value1 = prefix.charValue() << offsetInBits; int value2 = key.charValue(); int mask = 0; for(int i = 0; i < lengthInBits; i++) { - mask |= (0x1 << i); + mask |= 0x1 << i; } return (value1 & mask) == (value2 & mask); diff --git a/src/main/java/org/apache/commons/collections/trie/IntegerKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/IntegerKeyAnalyzer.java index 09c568e16..d5c5f6b1b 100644 --- a/src/main/java/org/apache/commons/collections/trie/IntegerKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/IntegerKeyAnalyzer.java @@ -85,7 +85,7 @@ public class IntegerKeyAnalyzer extends AbstractKeyAnalyzer { return NULL_BIT_KEY; } - int otherValue = (other != null ? other.intValue() : 0); + int otherValue = other != null ? other.intValue() : 0; if (keyValue != otherValue) { int xorValue = keyValue ^ otherValue; @@ -105,12 +105,12 @@ public class IntegerKeyAnalyzer extends AbstractKeyAnalyzer { public boolean isPrefix(Integer prefix, int offsetInBits, int lengthInBits, Integer key) { - int value1 = (prefix.intValue() << offsetInBits); + int value1 = prefix.intValue() << offsetInBits; int value2 = key.intValue(); int mask = 0; for (int i = 0; i < lengthInBits; i++) { - mask |= (0x1 << i); + mask |= 0x1 << i; } return (value1 & mask) == (value2 & mask); diff --git a/src/main/java/org/apache/commons/collections/trie/LongKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/LongKeyAnalyzer.java index f659a3966..689b5a298 100644 --- a/src/main/java/org/apache/commons/collections/trie/LongKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/LongKeyAnalyzer.java @@ -85,7 +85,7 @@ public class LongKeyAnalyzer extends AbstractKeyAnalyzer { return NULL_BIT_KEY; } - long otherValue = (other != null ? other.longValue() : 0L); + long otherValue = other != null ? other.longValue() : 0L; if (keyValue != otherValue) { long xorValue = keyValue ^ otherValue; @@ -105,12 +105,12 @@ public class LongKeyAnalyzer extends AbstractKeyAnalyzer { public boolean isPrefix(Long prefix, int offsetInBits, int lengthInBits, Long key) { - long value1 = (prefix.longValue() << offsetInBits); + long value1 = prefix.longValue() << offsetInBits; long value2 = key.longValue(); long mask = 0L; for (int i = 0; i < lengthInBits; i++) { - mask |= (0x1L << i); + mask |= 0x1L << i; } return (value1 & mask) == (value2 & mask); diff --git a/src/main/java/org/apache/commons/collections/trie/PatriciaTrie.java b/src/main/java/org/apache/commons/collections/trie/PatriciaTrie.java index d090e792e..5e5d56a4b 100644 --- a/src/main/java/org/apache/commons/collections/trie/PatriciaTrie.java +++ b/src/main/java/org/apache/commons/collections/trie/PatriciaTrie.java @@ -1050,7 +1050,7 @@ public class PatriciaTrie extends PatriciaTrieBase implements Trie last) { super(first); - this.excludedKey = (last != null ? last.getKey() : null); + this.excludedKey = last != null ? last.getKey() : null; } /** diff --git a/src/main/java/org/apache/commons/collections/trie/PatriciaTrieBase.java b/src/main/java/org/apache/commons/collections/trie/PatriciaTrieBase.java index 33a4893aa..f5fd88940 100644 --- a/src/main/java/org/apache/commons/collections/trie/PatriciaTrieBase.java +++ b/src/main/java/org/apache/commons/collections/trie/PatriciaTrieBase.java @@ -555,7 +555,7 @@ abstract class PatriciaTrieBase extends AbstractTrie { } TrieEntry parent = h.parent; - TrieEntry child = (h.left == h) ? h.right : h.left; + TrieEntry child = h.left == h ? h.right : h.left; if (parent.left == h) { parent.left = child; @@ -594,7 +594,7 @@ abstract class PatriciaTrieBase extends AbstractTrie { // Fix P's parent, predecessor and child Nodes { TrieEntry parent = p.parent; - TrieEntry child = (p.left == h) ? p.right : p.left; + TrieEntry child = p.left == h ? p.right : p.left; // if it was looping to itself previously, // it will now be pointed from it's parent diff --git a/src/main/java/org/apache/commons/collections/trie/ShortKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/ShortKeyAnalyzer.java index 4b8f32e7d..6df3a3441 100644 --- a/src/main/java/org/apache/commons/collections/trie/ShortKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/ShortKeyAnalyzer.java @@ -85,7 +85,7 @@ public class ShortKeyAnalyzer implements KeyAnalyzer { return NULL_BIT_KEY; } - int otherValue = (other != null ? other.shortValue() : 0); + int otherValue = other != null ? other.shortValue() : 0; if (keyValue != otherValue) { int xorValue = keyValue ^ otherValue; @@ -112,12 +112,12 @@ public class ShortKeyAnalyzer implements KeyAnalyzer { public boolean isPrefix(Short prefix, int offsetInBits, int lengthInBits, Short key) { - int value1 = (prefix.shortValue() << offsetInBits); + int value1 = prefix.shortValue() << offsetInBits; int value2 = key.shortValue(); int mask = 0; for (int i = 0; i < lengthInBits; i++) { - mask |= (0x1 << i); + mask |= 0x1 << i; } return (value1 & mask) == (value2 & mask); diff --git a/src/main/java/org/apache/commons/collections/trie/StringKeyAnalyzer.java b/src/main/java/org/apache/commons/collections/trie/StringKeyAnalyzer.java index 3272d2c42..b3f04b23c 100644 --- a/src/main/java/org/apache/commons/collections/trie/StringKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections/trie/StringKeyAnalyzer.java @@ -59,7 +59,7 @@ public class StringKeyAnalyzer extends AbstractKeyAnalyzer { * {@inheritDoc} */ public int lengthInBits(String key) { - return (key != null ? key.length() * LENGTH : 0); + return key != null ? key.length() * LENGTH : 0; } /** @@ -106,7 +106,7 @@ public class StringKeyAnalyzer extends AbstractKeyAnalyzer { if (k != f) { int x = k ^ f; - return i * LENGTH + (Integer.numberOfLeadingZeros(x) - LENGTH); + return i * LENGTH + Integer.numberOfLeadingZeros(x) - LENGTH; } if (k != 0) { diff --git a/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java index ffe1b439f..b5bc8e934 100644 --- a/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java @@ -899,7 +899,7 @@ public class CollectionUtilsTest extends MockTestCase { // ----------------------------------------------------------------------- private static Predicate EQUALS_TWO = new Predicate() { public boolean evaluate(Number input) { - return (input.intValue() == 2); + return input.intValue() == 2; } }; @@ -1203,7 +1203,7 @@ public class CollectionUtilsTest extends MockTestCase { // or eltb, although this isn't strictly part of the // contract. Object eltc = intersection.iterator().next(); - assertTrue((eltc == elta && eltc != eltb) || (eltc != elta && eltc == eltb)); + assertTrue(eltc == elta && eltc != eltb || eltc != elta && eltc == eltb); // In any event, this element remains equal, // to both elta and eltb. diff --git a/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java b/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java index 71d864f10..dd191914e 100644 --- a/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java +++ b/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java @@ -60,28 +60,28 @@ public class ExtendedPropertiesTest extends TestCase { * now add another and get a Vector/list */ eprop.addProperty("number", "2"); - assertTrue("This returns array", (eprop.getVector("number") instanceof java.util.Vector)); - assertTrue("This returns array", (eprop.getList("number") instanceof java.util.List)); + assertTrue("This returns array", eprop.getVector("number") instanceof java.util.Vector); + assertTrue("This returns array", eprop.getList("number") instanceof java.util.List); /* * now test dan's new fix where we get the first scalar * when we access a vector/list valued * property */ - assertTrue("This returns scalar", (eprop.getString("number") instanceof String)); + assertTrue("This returns scalar", eprop.getString("number") instanceof String); /* * test comma separated string properties */ String prop = "hey, that's a test"; eprop.setProperty("prop.string", prop); - assertTrue("This returns vector", (eprop.getVector("prop.string") instanceof java.util.Vector)); - assertTrue("This returns list", (eprop.getList("prop.string") instanceof java.util.List)); + assertTrue("This returns vector", eprop.getVector("prop.string") instanceof java.util.Vector); + assertTrue("This returns list", eprop.getList("prop.string") instanceof java.util.List); String prop2 = "hey\\, that's a test"; eprop.remove("prop.string"); eprop.setProperty("prop.string", prop2); - assertTrue("This returns array", (eprop.getString("prop.string") instanceof java.lang.String)); + assertTrue("This returns array", eprop.getString("prop.string") instanceof java.lang.String); /* * test subset : we want to make sure that the EP doesn't reprocess the data @@ -91,9 +91,9 @@ public class ExtendedPropertiesTest extends TestCase { ExtendedProperties subEprop = eprop.subset("prop"); assertTrue("Returns the full string", subEprop.getString("string").equals(prop)); - assertTrue("This returns string for subset", (subEprop.getString("string") instanceof java.lang.String)); - assertTrue("This returns array for subset", (subEprop.getVector("string") instanceof java.util.Vector)); - assertTrue("This returns array for subset", (subEprop.getList("string") instanceof java.util.List)); + assertTrue("This returns string for subset", subEprop.getString("string") instanceof java.lang.String); + assertTrue("This returns array for subset", subEprop.getVector("string") instanceof java.util.Vector); + assertTrue("This returns array for subset", subEprop.getList("string") instanceof java.util.List); } diff --git a/src/test/java/org/apache/commons/collections/ListUtilsTest.java b/src/test/java/org/apache/commons/collections/ListUtilsTest.java index 83f36229a..bde792eb3 100644 --- a/src/test/java/org/apache/commons/collections/ListUtilsTest.java +++ b/src/test/java/org/apache/commons/collections/ListUtilsTest.java @@ -332,7 +332,7 @@ public class ListUtilsTest extends BulkTest { private static Predicate EQUALS_TWO = new Predicate() { public boolean evaluate(Number input) { - return (input.intValue() == 2); + return input.intValue() == 2; } }; diff --git a/src/test/java/org/apache/commons/collections/MockTestCase.java b/src/test/java/org/apache/commons/collections/MockTestCase.java index 6dfb14694..ffda18c7c 100644 --- a/src/test/java/org/apache/commons/collections/MockTestCase.java +++ b/src/test/java/org/apache/commons/collections/MockTestCase.java @@ -59,7 +59,7 @@ public abstract class MockTestCase { try { EasyMock.verify(i.next()); } catch (AssertionError e) { - throw new AssertionError((i.previousIndex() + 1) + "" + throw new AssertionError(i.previousIndex() + 1 + "" + e.getMessage()); } } diff --git a/src/test/java/org/apache/commons/collections/bag/AbstractBagTest.java b/src/test/java/org/apache/commons/collections/bag/AbstractBagTest.java index e381f0d9f..451c30fde 100644 --- a/src/test/java/org/apache/commons/collections/bag/AbstractBagTest.java +++ b/src/test/java/org/apache/commons/collections/bag/AbstractBagTest.java @@ -354,9 +354,9 @@ public abstract class AbstractBagTest extends AbstractObjectTest { Object[] array = bag.toArray(); int a = 0, b = 0, c = 0; for (Object element : array) { - a += (element.equals("A") ? 1 : 0); - b += (element.equals("B") ? 1 : 0); - c += (element.equals("C") ? 1 : 0); + a += element.equals("A") ? 1 : 0; + b += element.equals("B") ? 1 : 0; + c += element.equals("C") ? 1 : 0; } assertEquals(2, a); assertEquals(2, b); @@ -374,9 +374,9 @@ public abstract class AbstractBagTest extends AbstractObjectTest { String[] array = bag.toArray(new String[0]); int a = 0, b = 0, c = 0; for (String element : array) { - a += (element.equals("A") ? 1 : 0); - b += (element.equals("B") ? 1 : 0); - c += (element.equals("C") ? 1 : 0); + a += element.equals("A") ? 1 : 0; + b += element.equals("B") ? 1 : 0; + c += element.equals("C") ? 1 : 0; } assertEquals(2, a); assertEquals(2, b); @@ -444,9 +444,9 @@ public abstract class AbstractBagTest extends AbstractObjectTest { assertEquals(bag.hashCode(), bag2.hashCode()); int total = 0; - total += ("A".hashCode() ^ 2); - total += ("B".hashCode() ^ 2); - total += ("C".hashCode() ^ 1); + total += "A".hashCode() ^ 2; + total += "B".hashCode() ^ 2; + total += "C".hashCode() ^ 1; assertEquals(total, bag.hashCode()); assertEquals(total, bag2.hashCode()); } diff --git a/src/test/java/org/apache/commons/collections/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections/collection/AbstractCollectionTest.java index 94f4c1bb5..7c91815a9 100644 --- a/src/test/java/org/apache/commons/collections/collection/AbstractCollectionTest.java +++ b/src/test/java/org/apache/commons/collections/collection/AbstractCollectionTest.java @@ -282,7 +282,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { // skip values already matched continue; } - if (o == confirmedValues[i] || (o != null && o.equals(confirmedValues[i]))) { + if (o == confirmedValues[i] || o != null && o.equals(confirmedValues[i])) { // values matched matched[i] = true; match = true; @@ -703,9 +703,9 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { // make sure calls to "containsAll" don't change anything verify(); - int min = (getFullElements().length < 2 ? 0 : 2); - int max = (getFullElements().length == 1 ? 1 : - (getFullElements().length <= 5 ? getFullElements().length - 1 : 5)); + int min = getFullElements().length < 2 ? 0 : 2; + int max = getFullElements().length == 1 ? 1 : + getFullElements().length <= 5 ? getFullElements().length - 1 : 5; col = Arrays.asList(getFullElements()).subList(min, max); assertTrue("Full collection should containAll partial full elements", getCollection().containsAll(col)); @@ -931,9 +931,9 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { resetFull(); int size = getCollection().size(); - int min = (getFullElements().length < 2 ? 0 : 2); - int max = (getFullElements().length == 1 ? 1 : - (getFullElements().length <= 5 ? getFullElements().length - 1 : 5)); + int min = getFullElements().length < 2 ? 0 : 2; + int max = getFullElements().length == 1 ? 1 : + getFullElements().length <= 5 ? getFullElements().length - 1 : 5; Collection all = Arrays.asList(getFullElements()).subList(min, max); assertTrue("Full collection removeAll should work", getCollection().removeAll(all)); getConfirmed().removeAll(all); @@ -987,8 +987,8 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { if (getFullElements().length > 1) { resetFull(); size = getCollection().size(); - int min = (getFullElements().length < 2 ? 0 : 2); - int max = (getFullElements().length <= 5 ? getFullElements().length - 1 : 5); + int min = getFullElements().length < 2 ? 0 : 2; + int max = getFullElements().length <= 5 ? getFullElements().length - 1 : 5; assertTrue("Collection should changed by partial retainAll", getCollection().retainAll(elements.subList(min, max))); getConfirmed().retainAll(elements.subList(min, max)); @@ -1051,7 +1051,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { continue; } if (array[i] == confirmedArray[j] - || (array[i] != null && array[i].equals(confirmedArray[j]))) { + || array[i] != null && array[i].equals(confirmedArray[j])) { matched[j] = true; match = true; break; @@ -1105,7 +1105,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { // TODO: It'd be nicer to detect a common superclass HashSet> classes = new HashSet>(); for (Object element : array) { - classes.add((element == null) ? null : element.getClass()); + classes.add(element == null ? null : element.getClass()); } if (classes.size() > 1) { return; diff --git a/src/test/java/org/apache/commons/collections/comparators/BooleanComparatorTest.java b/src/test/java/org/apache/commons/collections/comparators/BooleanComparatorTest.java index 5ef2d5789..cc5a7afec 100644 --- a/src/test/java/org/apache/commons/collections/comparators/BooleanComparatorTest.java +++ b/src/test/java/org/apache/commons/collections/comparators/BooleanComparatorTest.java @@ -92,8 +92,8 @@ public class BooleanComparatorTest extends AbstractComparatorTest { assertEquals(new BooleanComparator(true),BooleanComparator.getTrueFirstComparator()); assertSame(BooleanComparator.getTrueFirstComparator(),BooleanComparator.booleanComparator(true)); - assertTrue(!(new BooleanComparator().equals(new BooleanComparator(true)))); - assertTrue(!(new BooleanComparator(true).equals(new BooleanComparator(false)))); + assertTrue(!new BooleanComparator().equals(new BooleanComparator(true))); + assertTrue(!new BooleanComparator(true).equals(new BooleanComparator(false))); } // utilities diff --git a/src/test/java/org/apache/commons/collections/iterators/AbstractMapIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/AbstractMapIteratorTest.java index 850328c3c..92be1d3f3 100644 --- a/src/test/java/org/apache/commons/collections/iterators/AbstractMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/AbstractMapIteratorTest.java @@ -193,7 +193,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest } V newValue = addSetValues()[0]; - V newValue2 = (addSetValues().length == 1 ? addSetValues()[0] : addSetValues()[1]); + V newValue2 = addSetValues().length == 1 ? addSetValues()[0] : addSetValues()[1]; MapIterator it = makeObject(); Map map = getMap(); Map confirmed = getConfirmedMap(); diff --git a/src/test/java/org/apache/commons/collections/iterators/ArrayIterator2Test.java b/src/test/java/org/apache/commons/collections/iterators/ArrayIterator2Test.java index e6bc29623..a87f25fe5 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ArrayIterator2Test.java +++ b/src/test/java/org/apache/commons/collections/iterators/ArrayIterator2Test.java @@ -75,7 +75,7 @@ public class ArrayIterator2Test extends AbstractIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/ArrayIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/ArrayIteratorTest.java index e05acb1c3..a1c1ef4be 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/ArrayIteratorTest.java @@ -64,7 +64,7 @@ public class ArrayIteratorTest extends AbstractIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/ArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/ArrayListIteratorTest.java index 40d1b2f4b..73763f4ea 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/ArrayListIteratorTest.java @@ -79,7 +79,7 @@ public class ArrayListIteratorTest extends ArrayIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/CollatingIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/CollatingIteratorTest.java index 4bbcf7674..6183f7473 100644 --- a/src/test/java/org/apache/commons/collections/iterators/CollatingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/CollatingIteratorTest.java @@ -121,7 +121,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { for (int i = 0; i < 20; i++) { assertTrue(iter.hasNext()); assertEquals(new Integer(i),iter.next()); - assertEquals((i % 2) == 0 ? 1 : 0,iter.getIteratorIndex()); + assertEquals(i % 2 == 0 ? 1 : 0,iter.getIteratorIndex()); } assertTrue(!iter.hasNext()); } @@ -235,7 +235,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { iter.remove(); } } - assertEquals(expectedSize, (evens.size() + odds.size())); + assertEquals(expectedSize, evens.size() + odds.size()); } public void testNullComparator() { diff --git a/src/test/java/org/apache/commons/collections/iterators/IteratorChainTest.java b/src/test/java/org/apache/commons/collections/iterators/IteratorChainTest.java index 7e2eef3ef..4f3b84b48 100644 --- a/src/test/java/org/apache/commons/collections/iterators/IteratorChainTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/IteratorChainTest.java @@ -86,7 +86,7 @@ public class IteratorChainTest extends AbstractIteratorTest { iter.next(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapper2Test.java b/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapper2Test.java index fcc391458..1fee75dba 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapper2Test.java +++ b/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapper2Test.java @@ -77,7 +77,7 @@ public class ListIteratorWrapper2Test extends AbstractIteratorTest { iter.next(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } // now, read it backwards @@ -92,7 +92,7 @@ public class ListIteratorWrapper2Test extends AbstractIteratorTest { iter.previous(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } // now, read it forwards again diff --git a/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapperTest.java b/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapperTest.java index 75ce5296f..643b2b350 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapperTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/ListIteratorWrapperTest.java @@ -78,7 +78,7 @@ public class ListIteratorWrapperTest extends AbstractIteratorTest { iter.next(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } // now, read it backwards @@ -93,7 +93,7 @@ public class ListIteratorWrapperTest extends AbstractIteratorTest { iter.previous(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } // now, read it forwards again diff --git a/src/test/java/org/apache/commons/collections/iterators/ObjectArrayIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/ObjectArrayIteratorTest.java index caf7e806c..cad3b0303 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ObjectArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/ObjectArrayIteratorTest.java @@ -80,7 +80,7 @@ public class ObjectArrayIteratorTest extends AbstractIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/ObjectArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/ObjectArrayListIteratorTest.java index 72797e537..c9f5d711a 100644 --- a/src/test/java/org/apache/commons/collections/iterators/ObjectArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/ObjectArrayListIteratorTest.java @@ -76,7 +76,7 @@ public class ObjectArrayListIteratorTest extends ObjectArrayIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/SingletonIterator2Test.java b/src/test/java/org/apache/commons/collections/iterators/SingletonIterator2Test.java index c7e975168..9c05120a3 100644 --- a/src/test/java/org/apache/commons/collections/iterators/SingletonIterator2Test.java +++ b/src/test/java/org/apache/commons/collections/iterators/SingletonIterator2Test.java @@ -77,7 +77,7 @@ public class SingletonIterator2Test extends AbstractIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/SingletonIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/SingletonIteratorTest.java index fa0f17e33..e9d2eb746 100644 --- a/src/test/java/org/apache/commons/collections/iterators/SingletonIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/SingletonIteratorTest.java @@ -78,7 +78,7 @@ public class SingletonIteratorTest extends AbstractIteratorTest { } catch (Exception e) { assertTrue( "NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/SingletonListIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/SingletonListIteratorTest.java index 8c2848a6f..09a5e9459 100644 --- a/src/test/java/org/apache/commons/collections/iterators/SingletonListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/SingletonListIteratorTest.java @@ -103,14 +103,14 @@ public class SingletonListIteratorTest extends AbstractListIteratorTest { iter.next(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } iter.previous(); try { iter.previous(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/iterators/UniqueFilterIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/UniqueFilterIteratorTest.java index fccbb6f7f..4cb446ae8 100644 --- a/src/test/java/org/apache/commons/collections/iterators/UniqueFilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/UniqueFilterIteratorTest.java @@ -80,7 +80,7 @@ public class UniqueFilterIteratorTest extends AbstractIteratorTest { iter.next(); } catch (Exception e) { assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); + e.getClass().equals(new NoSuchElementException().getClass())); } } diff --git a/src/test/java/org/apache/commons/collections/list/AbstractListTest.java b/src/test/java/org/apache/commons/collections/list/AbstractListTest.java index 11b717043..84f7a9ac0 100644 --- a/src/test/java/org/apache/commons/collections/list/AbstractListTest.java +++ b/src/test/java/org/apache/commons/collections/list/AbstractListTest.java @@ -625,9 +625,9 @@ public abstract class AbstractListTest extends AbstractCollectionTest { for (int i = 0; i < elements.length; i++) { E n = other[i % other.length]; - E v = (getCollection()).set(i, n); + E v = getCollection().set(i, n); assertEquals("Set should return correct element", elements[i], v); - (getConfirmed()).set(i, n); + getConfirmed().set(i, n); verify(); } } @@ -643,7 +643,7 @@ public abstract class AbstractListTest extends AbstractCollectionTest { resetFull(); try { - (getCollection()).set(0, getFullElements()[0]); + getCollection().set(0, getFullElements()[0]); fail("Emtpy collection should not support set."); } catch (UnsupportedOperationException e) { // expected @@ -754,8 +754,8 @@ public abstract class AbstractListTest extends AbstractCollectionTest { int max = getFullElements().length; for (int i = 0; i < max; i++) { resetFull(); - E o1 = (getCollection()).remove(i); - E o2 = (getConfirmed()).remove(i); + E o1 = getCollection().remove(i); + E o2 = getConfirmed().remove(i); assertEquals("remove should return correct element", o1, o2); verify(); } diff --git a/src/test/java/org/apache/commons/collections/list/CursorableLinkedListTest.java b/src/test/java/org/apache/commons/collections/list/CursorableLinkedListTest.java index 56d9cf5cf..00fefebc8 100644 --- a/src/test/java/org/apache/commons/collections/list/CursorableLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections/list/CursorableLinkedListTest.java @@ -1400,7 +1400,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { assertEquals("5", elts[4]); assertEquals(5, elts.length); - String[] elts2 = (list.toArray(new String[0])); + String[] elts2 = list.toArray(new String[0]); assertEquals("1", elts2[0]); assertEquals("2", elts2[1]); assertEquals("3", elts2[2]); @@ -1418,7 +1418,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { assertEquals(5, elts3.length); String[] elts4 = new String[3]; - String[] elts4b = (list.toArray(elts4)); + String[] elts4b = list.toArray(elts4); assertTrue(elts4 != elts4b); assertEquals("1", elts4b[0]); assertEquals("2", elts4b[1]); diff --git a/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java b/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java index 4591ecc77..a4d7aa5db 100644 --- a/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java +++ b/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java @@ -593,7 +593,7 @@ public class SetUniqueListTest extends AbstractListTest { // make sure retainAll completes under 5 seconds // TODO if test is migrated to JUnit 4, add a Timeout rule. // http://kentbeck.github.com/junit/javadoc/latest/org/junit/rules/Timeout.html - assertTrue((stop - start) < 5000); + assertTrue(stop - start < 5000); } @SuppressWarnings("serial") diff --git a/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java b/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java index cc90638e1..61cb7d25c 100644 --- a/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java +++ b/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java @@ -305,7 +305,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { "hello", "goodbye", "we'll", "see", "you", "all", "again", "key", "key2", - (isAllowNullKey() && !JDK12) ? null : "nonnullkey" + isAllowNullKey() && !JDK12 ? null : "nonnullkey" }; return (K[]) result; } @@ -358,9 +358,9 @@ public abstract class AbstractMapTest extends AbstractObjectTest { Object[] result = new Object[] { "blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev", "hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv", - (isAllowNullValue() && !JDK12) ? null : "nonnullvalue", + isAllowNullValue() && !JDK12 ? null : "nonnullvalue", "value", - (isAllowDuplicateValues()) ? "value" : "value2", + isAllowDuplicateValues() ? "value" : "value2", }; return (V[]) result; } @@ -379,9 +379,9 @@ public abstract class AbstractMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public V[] getNewSampleValues() { Object[] result = new Object[] { - (isAllowNullValue() && !JDK12 && isAllowDuplicateValues()) ? null : "newnonnullvalue", + isAllowNullValue() && !JDK12 && isAllowDuplicateValues() ? null : "newnonnullvalue", "newvalue", - (isAllowDuplicateValues()) ? "newvalue" : "newvalue2", + isAllowDuplicateValues() ? "newvalue" : "newvalue2", "newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv", "newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv", "newseev", "newyouv", "newallv", "newagainv", @@ -505,11 +505,11 @@ public abstract class AbstractMapTest extends AbstractObjectTest { for (int i = 0; i < keys.length - 1; i++) { for (int j = i + 1; j < keys.length; j++) { assertTrue("failure in test: duplicate null keys.", - (keys[i] != null || keys[j] != null)); + keys[i] != null || keys[j] != null); assertTrue( "failure in test: duplicate non-null key.", - (keys[i] == null || keys[j] == null || (!keys[i].equals(keys[j]) && !keys[j] - .equals(keys[i])))); + keys[i] == null || keys[j] == null || !keys[i].equals(keys[j]) && !keys[j] + .equals(keys[i])); } assertTrue("failure in test: found null key, but isNullKeySupported " + "is false.", keys[i] != null || isAllowNullKey()); @@ -1627,9 +1627,9 @@ public abstract class AbstractMapTest extends AbstractObjectTest { public void testMapEntrySetIteratorEntrySetValue() { K key1 = getSampleKeys()[0]; - K key2 = (getSampleKeys().length == 1 ? getSampleKeys()[0] : getSampleKeys()[1]); + K key2 = getSampleKeys().length == 1 ? getSampleKeys()[0] : getSampleKeys()[1]; V newValue1 = getNewSampleValues()[0]; - V newValue2 = (getNewSampleValues().length ==1 ? getNewSampleValues()[0] : getNewSampleValues()[1]); + V newValue2 = getNewSampleValues().length ==1 ? getNewSampleValues()[0] : getNewSampleValues()[1]; resetFull(); // explicitly get entries as sample values/keys are connected for some maps diff --git a/src/test/java/org/apache/commons/collections/map/PredicatedMapTest.java b/src/test/java/org/apache/commons/collections/map/PredicatedMapTest.java index 2ab28e7ce..38c0cbb89 100644 --- a/src/test/java/org/apache/commons/collections/map/PredicatedMapTest.java +++ b/src/test/java/org/apache/commons/collections/map/PredicatedMapTest.java @@ -39,7 +39,7 @@ public class PredicatedMapTest extends AbstractIterableMapTest { protected static final Predicate testPredicate = new Predicate() { public boolean evaluate(Object o) { - return (o instanceof String); + return o instanceof String; } }; diff --git a/src/test/java/org/apache/commons/collections/map/PredicatedSortedMapTest.java b/src/test/java/org/apache/commons/collections/map/PredicatedSortedMapTest.java index 01b17349d..7c0855fa5 100644 --- a/src/test/java/org/apache/commons/collections/map/PredicatedSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections/map/PredicatedSortedMapTest.java @@ -41,7 +41,7 @@ public class PredicatedSortedMapTest extends AbstractSortedMapTest { protected static final Predicate testPredicate = new Predicate() { public boolean evaluate(Object o) { - return (o instanceof String); + return o instanceof String; } }; diff --git a/src/test/java/org/apache/commons/collections/set/ListOrderedSetTest.java b/src/test/java/org/apache/commons/collections/set/ListOrderedSetTest.java index 408598d77..e0fab9344 100644 --- a/src/test/java/org/apache/commons/collections/set/ListOrderedSetTest.java +++ b/src/test/java/org/apache/commons/collections/set/ListOrderedSetTest.java @@ -223,14 +223,14 @@ public class ListOrderedSetTest // make sure retainAll completes under 5 seconds // TODO if test is migrated to JUnit 4, add a Timeout rule. // http://kentbeck.github.com/junit/javadoc/latest/org/junit/rules/Timeout.html - assertTrue((stop - start) < 5000); + assertTrue(stop - start < 5000); } static class A { @Override public boolean equals(Object obj) { - return (obj instanceof A || obj instanceof B); + return obj instanceof A || obj instanceof B; } @Override @@ -243,7 +243,7 @@ public class ListOrderedSetTest @Override public boolean equals(Object obj) { - return (obj instanceof A || obj instanceof B); + return obj instanceof A || obj instanceof B; } @Override diff --git a/src/test/java/org/apache/commons/collections/set/PredicatedSortedSetTest.java b/src/test/java/org/apache/commons/collections/set/PredicatedSortedSetTest.java index 81b140b24..82a208d26 100644 --- a/src/test/java/org/apache/commons/collections/set/PredicatedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections/set/PredicatedSortedSetTest.java @@ -65,7 +65,7 @@ public class PredicatedSortedSetTest extends AbstractSortedSetTest { protected Predicate testPredicate = new Predicate() { public boolean evaluate(E o) { - return (o instanceof String) && (((String) o).startsWith("A")); + return o instanceof String && ((String) o).startsWith("A"); } };