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
This commit is contained in:
parent
784f4752fc
commit
4f43347950
|
@ -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 <O> int cardinality(O obj, final Iterable<? super O> coll) {
|
||||
if (coll instanceof Set<?>) {
|
||||
return (((Set<? super O>) coll).contains(obj) ? 1 : 0);
|
||||
return ((Set<? super O>) coll).contains(obj) ? 1 : 0;
|
||||
}
|
||||
if (coll instanceof Bag<?>) {
|
||||
return ((Bag<? super O>) 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ public class ExtendedProperties extends Hashtable<String, Object> {
|
|||
*/
|
||||
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<String, Object> {
|
|||
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<String, Object> {
|
|||
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, Object> {
|
|||
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<String, Object> {
|
|||
// 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<String, Object> {
|
|||
if (defaults != null) {
|
||||
return defaults.getVector(key, defaultValue);
|
||||
} else {
|
||||
return ((defaultValue == null) ? new Vector<String>() : defaultValue);
|
||||
return defaultValue == null ? new Vector<String>() : defaultValue;
|
||||
}
|
||||
} else {
|
||||
throw new ClassCastException('\'' + key + "' doesn't map to a Vector object");
|
||||
|
@ -1125,7 +1125,7 @@ public class ExtendedProperties extends Hashtable<String, Object> {
|
|||
if (defaults != null) {
|
||||
return defaults.getList(key, defaultValue);
|
||||
} else {
|
||||
return ((defaultValue == null) ? new ArrayList<String>() : defaultValue);
|
||||
return defaultValue == null ? new ArrayList<String>() : defaultValue;
|
||||
}
|
||||
} else {
|
||||
throw new ClassCastException('\'' + key + "' doesn't map to a List object");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -194,7 +194,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
public boolean hasNext() {
|
||||
return (itemCount > 0 || entryIterator.hasNext());
|
||||
return itemCount > 0 || entryIterator.hasNext();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -141,7 +141,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
* @return true if the map is empty
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (nodeCount == 0);
|
||||
return nodeCount == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,7 +156,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
*/
|
||||
public boolean containsKey(final Object key) {
|
||||
checkKey(key);
|
||||
return (lookupKey(key) != null);
|
||||
return lookupKey(key) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +171,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
*/
|
||||
public boolean containsValue(final Object value) {
|
||||
checkValue(value);
|
||||
return (lookupValue(value) != null);
|
||||
return lookupValue(value) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -566,7 +566,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> 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<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
Node<K, V> parent = node.getParent(dataElement);
|
||||
Node<K, V> 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<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
Node<K, V> parent = node.getParent(dataElement);
|
||||
Node<K, V> 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<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
Node<K, V> 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<K, V> y = getRightChild(getGrandParent(currentNode, dataElement), dataElement);
|
||||
|
||||
|
@ -943,12 +943,12 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> 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<K, V> replacement = ((deletedNode.getLeft(dataElement) != null) ?
|
||||
deletedNode.getLeft(dataElement) : deletedNode.getRight(dataElement));
|
||||
Node<K, V> 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<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
private void doRedBlackDeleteFixup(final Node<K, V> replacementNode, final DataElement dataElement) {
|
||||
Node<K, V> currentNode = replacementNode;
|
||||
|
||||
while ((currentNode != rootNode[dataElement.ordinal()]) && (isBlack(currentNode, dataElement))) {
|
||||
while (currentNode != rootNode[dataElement.ordinal()] && isBlack(currentNode, dataElement)) {
|
||||
if (currentNode.isLeftChild(dataElement)) {
|
||||
Node<K, V> siblingNode = getRightChild(getParent(currentNode, dataElement), dataElement);
|
||||
|
||||
|
@ -1098,9 +1098,9 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
Node<K, V> yFormerLeftChild = y.getLeft(dataElement);
|
||||
Node<K, V> 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<K extends Comparable<K>, V extends Comparable<V>> 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<K extends Comparable<K>, V extends Comparable<V>> 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<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
@Override
|
||||
public boolean contains(final Object obj) {
|
||||
checkNonNullComparable(obj, VALUE);
|
||||
return (lookupValue(obj) != null);
|
||||
return lookupValue(obj) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,7 +100,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
|||
*/
|
||||
protected BlockingBuffer(Buffer<E> buffer, long timeoutMillis) {
|
||||
super(buffer);
|
||||
this.timeout = (timeoutMillis < 0 ? 0 : timeoutMillis);
|
||||
this.timeout = timeoutMillis < 0 ? 0 : timeoutMillis;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -179,7 +179,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
|||
|
||||
public boolean isFull() {
|
||||
// size() is synchronized
|
||||
return (size() == maxSize());
|
||||
return size() == maxSize();
|
||||
}
|
||||
|
||||
public int maxSize() {
|
||||
|
|
|
@ -151,7 +151,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
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<E> extends AbstractCollection<E>
|
|||
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<E> extends AbstractCollection<E>
|
|||
private boolean isFirst = full;
|
||||
|
||||
public boolean hasNext() {
|
||||
return isFirst || (index != end);
|
||||
return isFirst || index != end;
|
||||
}
|
||||
|
||||
public E next() {
|
||||
|
|
|
@ -316,7 +316,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
final E element = elements[index];
|
||||
int hole = index;
|
||||
|
||||
while ((hole * 2) <= size) {
|
||||
while (hole * 2 <= size) {
|
||||
int child = hole * 2;
|
||||
|
||||
// if we have a right child and that child can not be percolated
|
||||
|
@ -348,7 +348,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
final E element = elements[index];
|
||||
int hole = index;
|
||||
|
||||
while ((hole * 2) <= size) {
|
||||
while (hole * 2 <= size) {
|
||||
int child = hole * 2;
|
||||
|
||||
// if we have a right child and that child can not be percolated
|
||||
|
|
|
@ -161,7 +161,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
|
|||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (size() == 0);
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +180,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> 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;) {
|
||||
|
|
|
@ -120,8 +120,8 @@ public class ComparableComparator<E extends Comparable<? super E>> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -340,9 +340,9 @@ public class ComparatorChain<E> implements Comparator<E>, 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;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public class FixedOrderComparator<T> implements Comparator<T>, 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<T> implements Comparator<T>, 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<T> implements Comparator<T>, 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<T> implements Comparator<T>, 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;
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@ public class NullComparator<E> implements Comparator<E>, 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<E> implements Comparator<E>, 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,8 +119,8 @@ public class TransformingComparator<E> implements Comparator<E>, 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;
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ public class SequencesComparator<T> {
|
|||
*/
|
||||
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<T> {
|
|||
// 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<T> {
|
|||
// 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<T> {
|
|||
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<T> {
|
|||
}
|
||||
|
||||
// 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<T> {
|
|||
|
||||
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<T> {
|
|||
|
||||
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<T>(sequence1.get(i)));
|
||||
++i;
|
||||
++j;
|
||||
} else {
|
||||
if ((end1 - start1) > (end2 - start2)) {
|
||||
if (end1 - start1 > end2 - start2) {
|
||||
script.append(new DeleteCommand<T>(sequence1.get(i)));
|
||||
++i;
|
||||
} else {
|
||||
|
|
|
@ -72,7 +72,7 @@ public final class AndPredicate<T> implements Predicate<T>, PredicateDecorator<T
|
|||
* @return true if both decorated predicates return true
|
||||
*/
|
||||
public boolean evaluate(T object) {
|
||||
return (iPredicate1.evaluate(object) && iPredicate2.evaluate(object));
|
||||
return iPredicate1.evaluate(object) && iPredicate2.evaluate(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -165,19 +165,19 @@ public class ComparatorPredicate<T> implements Predicate<T>, 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.");
|
||||
|
|
|
@ -69,7 +69,7 @@ public final class IdentityPredicate<T> implements Predicate<T>, Serializable {
|
|||
* @return true if input is the same object as the stored value
|
||||
*/
|
||||
public boolean evaluate(T object) {
|
||||
return (iValue == object);
|
||||
return iValue == object;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ public final class InstanceofPredicate implements Predicate<Object>, Serializabl
|
|||
* @return true if input is of stored type
|
||||
*/
|
||||
public boolean evaluate(Object object) {
|
||||
return (iType.isInstance(object));
|
||||
return iType.isInstance(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,9 +55,9 @@ public class InstantiateFactory<T> implements Factory<T>, 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");
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class NotNullPredicate<T> implements Predicate<T>, Serializable {
|
|||
* @return true if not null
|
||||
*/
|
||||
public boolean evaluate(T object) {
|
||||
return (object != null);
|
||||
return object != null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
|
|
|
@ -67,7 +67,7 @@ public final class NotPredicate<T> implements Predicate<T>, PredicateDecorator<T
|
|||
* @return true if predicate returns false
|
||||
*/
|
||||
public boolean evaluate(T object) {
|
||||
return !(iPredicate.evaluate(object));
|
||||
return !iPredicate.evaluate(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class NullPredicate<T> implements Predicate<T>, Serializable {
|
|||
* @return true if input is null
|
||||
*/
|
||||
public boolean evaluate(T object) {
|
||||
return (object == null);
|
||||
return object == null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
|
|
|
@ -72,7 +72,7 @@ public final class OrPredicate<T> implements Predicate<T>, PredicateDecorator<T>
|
|||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,7 +143,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
* @return true if there is a next element to return
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return (index < endIndex);
|
||||
return index < endIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -116,7 +116,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
* @return true if there is a previous element to return
|
||||
*/
|
||||
public boolean hasPrevious() {
|
||||
return (this.index > this.startIndex);
|
||||
return this.index > this.startIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -154,7 +154,7 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
}
|
||||
|
||||
public int previousIndex() {
|
||||
return (nextIndex-1);
|
||||
return nextIndex-1;
|
||||
}
|
||||
|
||||
/** Not supported. */
|
||||
|
|
|
@ -68,7 +68,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
|
|||
* @return <code>true</code> if there are more elements
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return (collection.size() > 0);
|
||||
return collection.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -119,7 +119,7 @@ public class ObjectArrayIterator<E>
|
|||
* @return true if there is a next element to return
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return (this.index < this.endIndex);
|
||||
return this.index < this.endIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
* @return true if there is a previous element to return
|
||||
*/
|
||||
public boolean hasPrevious() {
|
||||
return (this.index > this.startIndex);
|
||||
return this.index > this.startIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SingletonIterator<E>
|
|||
* @return true if the single object hasn't been returned yet
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return (beforeFirst && !removed);
|
||||
return beforeFirst && !removed;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,7 +74,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, 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<E> implements ListIterator<E>, ResettableList
|
|||
* @return 0 or -1 depending on current state.
|
||||
*/
|
||||
public int previousIndex() {
|
||||
return (beforeFirst ? -1 : 0);
|
||||
return beforeFirst ? -1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,7 +105,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (size() == 0);
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
public E get(int index) {
|
||||
|
@ -413,7 +413,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
* @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<E> implements List<E> {
|
|||
}
|
||||
// Search the list and get the node
|
||||
Node<E> 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<E> implements List<E> {
|
|||
|
||||
@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
|
||||
|
|
|
@ -589,17 +589,17 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> 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
|
||||
|
|
|
@ -153,7 +153,7 @@ public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
|
|||
decorated().addAll(Collections.<E>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<E> extends AbstractSerializableListDecorator<E> {
|
|||
public E set(int index, E element) {
|
||||
int size = decorated().size();
|
||||
if (index >= size) {
|
||||
decorated().addAll(Collections.<E>nCopies((index - size) + 1, null));
|
||||
decorated().addAll(Collections.<E>nCopies(index - size + 1, null));
|
||||
}
|
||||
return decorated().set(index, element);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
add(size(), object);
|
||||
|
||||
// compares sizes to detect if collection changed
|
||||
return (sizeBefore != size());
|
||||
return sizeBefore != size();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -166,7 +166,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*/
|
||||
@Override
|
||||
public boolean contains(Object object) {
|
||||
return (indexOf(object) >= 0);
|
||||
return indexOf(object) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,7 +336,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
return this;
|
||||
}
|
||||
|
||||
AVLNode<E> nextNode = ((indexRelativeToMe < 0) ? getLeftSubTree() : getRightSubTree());
|
||||
AVLNode<E> nextNode = indexRelativeToMe < 0 ? getLeftSubTree() : getRightSubTree();
|
||||
if (nextNode == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -456,14 +456,14 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* Gets the left node, returning null if its a faedelung.
|
||||
*/
|
||||
private AVLNode<E> getLeftSubTree() {
|
||||
return (leftIsPrevious ? null : left);
|
||||
return leftIsPrevious ? null : left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right node, returning null if its a faedelung.
|
||||
*/
|
||||
private AVLNode<E> getRightSubTree() {
|
||||
return (rightIsNext ? null : right);
|
||||
return rightIsNext ? null : right;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -472,7 +472,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @return the rightmost child (greatest index)
|
||||
*/
|
||||
private AVLNode<E> max() {
|
||||
return (getRightSubTree() == null) ? this : right.max();
|
||||
return getRightSubTree() == null ? this : right.max();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -481,7 +481,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @return the leftmost child (smallest index)
|
||||
*/
|
||||
private AVLNode<E> min() {
|
||||
return (getLeftSubTree() == null) ? this : left.min();
|
||||
return getLeftSubTree() == null ? this : left.min();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -651,7 +651,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* Returns the height of the node or -1 if the node is null.
|
||||
*/
|
||||
private int getHeight(AVLNode<E> node) {
|
||||
return (node == null ? -1 : node.height);
|
||||
return node == null ? -1 : node.height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -702,8 +702,8 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @param previous the previous node in the linked list
|
||||
*/
|
||||
private void setLeft(AVLNode<E> node, AVLNode<E> previous) {
|
||||
leftIsPrevious = (node == null);
|
||||
left = (leftIsPrevious ? previous : node);
|
||||
leftIsPrevious = node == null;
|
||||
left = leftIsPrevious ? previous : node;
|
||||
recalcHeight();
|
||||
}
|
||||
|
||||
|
@ -714,8 +714,8 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @param next the next node in the linked list
|
||||
*/
|
||||
private void setRight(AVLNode<E> node, AVLNode<E> next) {
|
||||
rightIsNext = (node == null);
|
||||
right = (rightIsNext ? next : node);
|
||||
rightIsNext = node == null;
|
||||
right = rightIsNext ? next : node;
|
||||
recalcHeight();
|
||||
}
|
||||
|
||||
|
@ -822,7 +822,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
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<E> extends AbstractList<E> {
|
|||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return (nextIndex < parent.size());
|
||||
return nextIndex < parent.size();
|
||||
}
|
||||
|
||||
public E next() {
|
||||
|
@ -860,7 +860,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
}
|
||||
|
||||
public boolean hasPrevious() {
|
||||
return (nextIndex > 0);
|
||||
return nextIndex > 0;
|
||||
}
|
||||
|
||||
public E previous() {
|
||||
|
|
|
@ -206,7 +206,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (size == 0);
|
||||
return size == 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -379,7 +379,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
if (entry instanceof Map.Entry) {
|
||||
Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry;
|
||||
Entry<K, V> 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<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return (next != null);
|
||||
return next != null;
|
||||
}
|
||||
|
||||
protected HashEntry<K, V> nextEntry() {
|
||||
|
|
|
@ -198,7 +198,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
*/
|
||||
public K nextKey(Object key) {
|
||||
LinkEntry<K, V> 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<K, V> extends AbstractHashedMap<K, V> im
|
|||
*/
|
||||
public K previousKey(Object key) {
|
||||
LinkEntry<K, V> 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<K, V> extends AbstractHashedMap<K, V> im
|
|||
throw new IndexOutOfBoundsException("Index " + index + " is invalid for size " + size);
|
||||
}
|
||||
LinkEntry<K, V> 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<K, V> extends AbstractHashedMap<K, V> 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<K, V> nextEntry() {
|
||||
|
|
|
@ -214,7 +214,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
if (entry == null) {
|
||||
return false;
|
||||
}
|
||||
return (entry.getValue() != null);
|
||||
return entry.getValue() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -453,8 +453,8 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected boolean isEqualKey(Object key1, Object key2) {
|
||||
key2 = (keyType == ReferenceStrength.HARD ? key2 : ((Reference<K>) key2).get());
|
||||
return (key1 == key2 || key1.equals(key2));
|
||||
key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference<K>) key2).get();
|
||||
return key1 == key2 || key1.equals(key2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -617,7 +617,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public K getKey() {
|
||||
return (K) ((parent.keyType == ReferenceStrength.HARD) ? key : ((Reference<K>) key).get());
|
||||
return (K) (parent.keyType == ReferenceStrength.HARD ? key : ((Reference<K>) key).get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -629,7 +629,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public V getValue() {
|
||||
return (V) ((parent.valueType == ReferenceStrength.HARD) ? value : ((Reference<V>) value).get());
|
||||
return (V) (parent.valueType == ReferenceStrength.HARD ? value : ((Reference<V>) value).get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -670,7 +670,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
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<K, V> extends AbstractHashedMap<K, V>
|
|||
* @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<K, V> extends AbstractHashedMap<K, V>
|
|||
public ReferenceBaseIterator(AbstractReferenceMap<K, V> 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<K, V> extends AbstractHashedMap<K, V>
|
|||
while (nextNull()) {
|
||||
ReferenceEntry<K, V> e = entry;
|
||||
int i = index;
|
||||
while ((e == null) && (i > 0)) {
|
||||
while (e == null && i > 0) {
|
||||
i--;
|
||||
e = (ReferenceEntry<K, V>) parent.data[i];
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
}
|
||||
|
||||
private boolean nextNull() {
|
||||
return (nextKey == null) || (nextValue == null);
|
||||
return nextKey == null || nextValue == null;
|
||||
}
|
||||
|
||||
protected ReferenceEntry<K, V> nextEntry() {
|
||||
|
|
|
@ -465,7 +465,7 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> 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;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return (nextIndex < parent.size);
|
||||
return nextIndex < parent.size;
|
||||
}
|
||||
|
||||
public K next() {
|
||||
|
@ -784,7 +784,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return (nextIndex < parent.size);
|
||||
return nextIndex < parent.size;
|
||||
}
|
||||
|
||||
public Map.Entry<K, V> nextEntry() {
|
||||
|
@ -1161,11 +1161,11 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, 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<K, V> implements IterableMap<K, V>, 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();
|
||||
|
|
|
@ -109,7 +109,7 @@ public class IdentityMap<K, V>
|
|||
*/
|
||||
@Override
|
||||
protected boolean isEqualKey(Object key1, Object key2) {
|
||||
return (key1 == key2);
|
||||
return key1 == key2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ public class IdentityMap<K, V>
|
|||
*/
|
||||
@Override
|
||||
protected boolean isEqualValue(Object value1, Object value2) {
|
||||
return (value1 == value2);
|
||||
return value1 == value2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,8 +160,8 @@ public class IdentityMap<K, V>
|
|||
}
|
||||
Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
|
||||
return
|
||||
(getKey() == other.getKey()) &&
|
||||
(getValue() == other.getValue());
|
||||
getKey() == other.getKey() &&
|
||||
getValue() == other.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -124,7 +124,7 @@ public class LRUMap<K, V>
|
|||
* @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<K, V>
|
|||
* @return <code>true</code> if the map is full
|
||||
*/
|
||||
public boolean isFull() {
|
||||
return (size >= maxSize);
|
||||
return size >= maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -229,9 +229,9 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
h ^= key2.hashCode();
|
||||
}
|
||||
h += ~(h << 9);
|
||||
h ^= (h >>> 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<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
h ^= key3.hashCode();
|
||||
}
|
||||
h += ~(h << 9);
|
||||
h ^= (h >>> 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<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
h ^= key4.hashCode();
|
||||
}
|
||||
h += ~(h << 9);
|
||||
h ^= (h >>> 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<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
h ^= key5.hashCode();
|
||||
}
|
||||
h += ~(h << 9);
|
||||
h ^= (h >>> 14);
|
||||
h += (h << 4);
|
||||
h ^= (h >>> 10);
|
||||
h ^= h >>> 14;
|
||||
h += h << 4;
|
||||
h ^= h >>> 10;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
} else {
|
||||
result = coll.add((V) value);
|
||||
}
|
||||
return (result ? value : null);
|
||||
return result ? value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -402,7 +402,7 @@ public class PassiveExpiringMap<K, V>
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ public class PredicatedMap<K, V>
|
|||
*/
|
||||
@Override
|
||||
protected boolean isSetValueChecking() {
|
||||
return (valuePredicate != null);
|
||||
return valuePredicate != null;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -219,7 +219,7 @@ public class SingletonMap<K, V>
|
|||
* @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<K, V>
|
|||
* @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<K, V>
|
|||
* @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<K, V>
|
|||
* @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<K, V>
|
|||
}
|
||||
|
||||
public boolean hasPrevious() {
|
||||
return (hasNext == false);
|
||||
return hasNext == false;
|
||||
}
|
||||
|
||||
public K previous() {
|
||||
|
@ -566,9 +566,9 @@ public class SingletonMap<K, V>
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ public class TransformedMap<K, V>
|
|||
*/
|
||||
@Override
|
||||
protected boolean isSetValueChecking() {
|
||||
return (valueTransformer != null);
|
||||
return valueTransformer != null;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -189,7 +189,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
public int hashCode() {
|
||||
int code = 0;
|
||||
for (E e : this) {
|
||||
code += (e == null ? 0 : e.hashCode());
|
||||
code += e == null ? 0 : e.hashCode();
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public final class MapBackedSet<E, V> implements Set<E>, 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<? extends E> coll) {
|
||||
|
@ -122,13 +122,13 @@ public final class MapBackedSet<E, V> implements Set<E>, 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) {
|
||||
|
|
|
@ -32,9 +32,9 @@ public abstract class AbstractKeyAnalyzer<K> implements KeyAnalyzer<K> {
|
|||
@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<K>)o1).compareTo(o2);
|
||||
|
|
|
@ -148,9 +148,9 @@ abstract class AbstractTrie<K, V> extends AbstractMap<K, V>
|
|||
*/
|
||||
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<K, V> extends AbstractMap<K, V>
|
|||
* 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<K, V> extends AbstractMap<K, V>
|
|||
|
||||
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) {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ByteArrayKeyAnalyzer extends AbstractKeyAnalyzer<byte[]> {
|
|||
* {@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<byte[]> {
|
|||
}
|
||||
|
||||
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<byte[]> {
|
|||
@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) {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ByteKeyAnalyzer extends AbstractKeyAnalyzer<Byte> {
|
|||
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<Byte> {
|
|||
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);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class CharArrayKeyAnalyzer extends AbstractKeyAnalyzer<char[]> {
|
|||
* {@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<char[]> {
|
|||
|
||||
if (k != f) {
|
||||
int x = k ^ f;
|
||||
return i * LENGTH + (Integer.numberOfLeadingZeros(x) - LENGTH);
|
||||
return i * LENGTH + Integer.numberOfLeadingZeros(x) - LENGTH;
|
||||
}
|
||||
|
||||
if (k != 0) {
|
||||
|
|
|
@ -90,7 +90,7 @@ public class CharacterKeyAnalyzer extends AbstractKeyAnalyzer<Character> {
|
|||
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<Character> {
|
|||
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);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class IntegerKeyAnalyzer extends AbstractKeyAnalyzer<Integer> {
|
|||
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<Integer> {
|
|||
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);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class LongKeyAnalyzer extends AbstractKeyAnalyzer<Long> {
|
|||
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<Long> {
|
|||
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);
|
||||
|
|
|
@ -1050,7 +1050,7 @@ public class PatriciaTrie<K, V> extends PatriciaTrieBase<K, V> implements Trie<K
|
|||
TrieEntry<K,V> last) {
|
||||
super(first);
|
||||
|
||||
this.excludedKey = (last != null ? last.getKey() : null);
|
||||
this.excludedKey = last != null ? last.getKey() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -555,7 +555,7 @@ abstract class PatriciaTrieBase<K, V> extends AbstractTrie<K, V> {
|
|||
}
|
||||
|
||||
TrieEntry<K, V> parent = h.parent;
|
||||
TrieEntry<K, V> child = (h.left == h) ? h.right : h.left;
|
||||
TrieEntry<K, V> child = h.left == h ? h.right : h.left;
|
||||
|
||||
if (parent.left == h) {
|
||||
parent.left = child;
|
||||
|
@ -594,7 +594,7 @@ abstract class PatriciaTrieBase<K, V> extends AbstractTrie<K, V> {
|
|||
// Fix P's parent, predecessor and child Nodes
|
||||
{
|
||||
TrieEntry<K, V> parent = p.parent;
|
||||
TrieEntry<K, V> child = (p.left == h) ? p.right : p.left;
|
||||
TrieEntry<K, V> child = p.left == h ? p.right : p.left;
|
||||
|
||||
// if it was looping to itself previously,
|
||||
// it will now be pointed from it's parent
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ShortKeyAnalyzer implements KeyAnalyzer<Short> {
|
|||
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<Short> {
|
|||
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);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class StringKeyAnalyzer extends AbstractKeyAnalyzer<String> {
|
|||
* {@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<String> {
|
|||
|
||||
if (k != f) {
|
||||
int x = k ^ f;
|
||||
return i * LENGTH + (Integer.numberOfLeadingZeros(x) - LENGTH);
|
||||
return i * LENGTH + Integer.numberOfLeadingZeros(x) - LENGTH;
|
||||
}
|
||||
|
||||
if (k != 0) {
|
||||
|
|
|
@ -899,7 +899,7 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
// -----------------------------------------------------------------------
|
||||
private static Predicate<Number> EQUALS_TWO = new Predicate<Number>() {
|
||||
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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -332,7 +332,7 @@ public class ListUtilsTest extends BulkTest {
|
|||
|
||||
private static Predicate<Number> EQUALS_TWO = new Predicate<Number>() {
|
||||
public boolean evaluate(Number input) {
|
||||
return (input.intValue() == 2);
|
||||
return input.intValue() == 2;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,9 +354,9 @@ public abstract class AbstractBagTest<T> 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<T> 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<T> 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());
|
||||
}
|
||||
|
|
|
@ -282,7 +282,7 @@ public abstract class AbstractCollectionTest<E> 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<E> 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<E> 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<E> 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<E> 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<E> 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<E> extends AbstractObjectTest {
|
|||
// TODO: It'd be nicer to detect a common superclass
|
||||
HashSet<Class<?>> classes = new HashSet<Class<?>>();
|
||||
for (Object element : array) {
|
||||
classes.add((element == null) ? null : element.getClass());
|
||||
classes.add(element == null ? null : element.getClass());
|
||||
}
|
||||
if (classes.size() > 1) {
|
||||
return;
|
||||
|
|
|
@ -92,8 +92,8 @@ public class BooleanComparatorTest extends AbstractComparatorTest<Boolean> {
|
|||
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
|
||||
|
|
|
@ -193,7 +193,7 @@ public abstract class AbstractMapIteratorTest<K, V> 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<K, V> it = makeObject();
|
||||
Map<K, V> map = getMap();
|
||||
Map<K, V> confirmed = getConfirmedMap();
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ArrayIterator2Test<E> extends AbstractIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ArrayIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ArrayListIteratorTest<E> extends ArrayIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest<Integer> {
|
|||
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<Integer> {
|
|||
iter.remove();
|
||||
}
|
||||
}
|
||||
assertEquals(expectedSize, (evens.size() + odds.size()));
|
||||
assertEquals(expectedSize, evens.size() + odds.size());
|
||||
}
|
||||
|
||||
public void testNullComparator() {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class IteratorChainTest extends AbstractIteratorTest<String> {
|
|||
iter.next();
|
||||
} catch (Exception e) {
|
||||
assertTrue("NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ListIteratorWrapper2Test<E> extends AbstractIteratorTest<E> {
|
|||
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<E> extends AbstractIteratorTest<E> {
|
|||
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
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ListIteratorWrapperTest<E> extends AbstractIteratorTest<E> {
|
|||
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<E> extends AbstractIteratorTest<E> {
|
|||
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
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ObjectArrayIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ObjectArrayListIteratorTest<E> extends ObjectArrayIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SingletonIterator2Test<E> extends AbstractIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class SingletonIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
} catch (Exception e) {
|
||||
assertTrue(
|
||||
"NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,14 +103,14 @@ public class SingletonListIteratorTest<E> extends AbstractListIteratorTest<E> {
|
|||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class UniqueFilterIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
iter.next();
|
||||
} catch (Exception e) {
|
||||
assertTrue("NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -625,9 +625,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
|
|||
|
||||
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<E> extends AbstractCollectionTest<E> {
|
|||
|
||||
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<E> extends AbstractCollectionTest<E> {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -1400,7 +1400,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> {
|
|||
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<E> extends AbstractLinkedListTest<E> {
|
|||
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]);
|
||||
|
|
|
@ -593,7 +593,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> {
|
|||
// 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")
|
||||
|
|
|
@ -305,7 +305,7 @@ public abstract class AbstractMapTest<K, V> 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<K, V> 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<K, V> 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<K, V> 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<K, V> 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
|
||||
|
|
|
@ -39,7 +39,7 @@ public class PredicatedMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
|
||||
protected static final Predicate<Object> testPredicate = new Predicate<Object>() {
|
||||
public boolean evaluate(Object o) {
|
||||
return (o instanceof String);
|
||||
return o instanceof String;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class PredicatedSortedMapTest<K, V> extends AbstractSortedMapTest<K, V> {
|
|||
|
||||
protected static final Predicate<Object> testPredicate = new Predicate<Object>() {
|
||||
public boolean evaluate(Object o) {
|
||||
return (o instanceof String);
|
||||
return o instanceof String;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -223,14 +223,14 @@ public class ListOrderedSetTest<E>
|
|||
// 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<E>
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof A || obj instanceof B);
|
||||
return obj instanceof A || obj instanceof B;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,7 +65,7 @@ public class PredicatedSortedSetTest<E> extends AbstractSortedSetTest<E> {
|
|||
protected Predicate<E> testPredicate =
|
||||
new Predicate<E>() {
|
||||
public boolean evaluate(E o) {
|
||||
return (o instanceof String) && (((String) o).startsWith("A"));
|
||||
return o instanceof String && ((String) o).startsWith("A");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue