mirror of
https://github.com/apache/commons-collections.git
synced 2025-03-01 22:39:08 +00:00
Remove unnecessary parens
This commit is contained in:
parent
b9c22565fe
commit
12bdb33dc0
@ -103,7 +103,7 @@ public class ArrayStack<E> extends ArrayList<E> {
|
||||
* stack to satisfy this request
|
||||
*/
|
||||
public E peek(final int n) throws EmptyStackException {
|
||||
final int m = (size() - n) - 1;
|
||||
final int m = size() - n - 1;
|
||||
if (m < 0) {
|
||||
throw new EmptyStackException();
|
||||
}
|
||||
@ -152,8 +152,8 @@ public class ArrayStack<E> extends ArrayList<E> {
|
||||
int n = 1; // Current distance
|
||||
while (i >= 0) {
|
||||
final Object current = get(i);
|
||||
if ((object == null && current == null) ||
|
||||
(object != null && object.equals(current))) {
|
||||
if (object == null && current == null ||
|
||||
object != null && object.equals(current)) {
|
||||
return n;
|
||||
}
|
||||
i--;
|
||||
|
@ -338,7 +338,7 @@ public class IterableUtils {
|
||||
return new FluentIterable<E>() {
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
final List<E> list = (iterable instanceof List<?>) ?
|
||||
final List<E> list = iterable instanceof List<?> ?
|
||||
(List<E>) iterable :
|
||||
IteratorUtils.toList(iterable.iterator());
|
||||
return new ReverseListIterator<>(list);
|
||||
|
@ -326,7 +326,7 @@ public class ListUtils {
|
||||
final Object obj1 = it1.next();
|
||||
final Object obj2 = it2.next();
|
||||
|
||||
if (!(Objects.equals(obj1, obj2))) {
|
||||
if (!Objects.equals(obj1, obj2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class SplitMapUtils {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ("WrappedGet".hashCode() << 4) | get.hashCode();
|
||||
return "WrappedGet".hashCode() << 4 | get.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -178,7 +178,7 @@ public class SplitMapUtils {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ("WrappedPut".hashCode() << 4) | put.hashCode();
|
||||
return "WrappedPut".hashCode() << 4 | put.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -235,7 +235,7 @@ public class SplitMapUtils {
|
||||
Objects.requireNonNull(get, "get");
|
||||
if (get instanceof Map) {
|
||||
return get instanceof IterableMap ?
|
||||
((IterableMap<K, V>) get) :
|
||||
(IterableMap<K, V>) get :
|
||||
MapUtils.iterableMap((Map<K, V>) get);
|
||||
}
|
||||
return new WrappedGet<>(get);
|
||||
|
@ -41,7 +41,7 @@ public class BitMap {
|
||||
* @return the number of bit maps necessary.
|
||||
*/
|
||||
public static int numberOfBitMaps(final int numberOfBits) {
|
||||
return ((numberOfBits - 1) >> DIVIDE_BY_64) + 1;
|
||||
return (numberOfBits - 1 >> DIVIDE_BY_64) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ public class EnhancedDoubleHasher implements Hasher {
|
||||
final int end = offset + Math.min(len, Long.BYTES);
|
||||
for (int i = offset; i < end; i++) {
|
||||
shift -= Byte.SIZE;
|
||||
val |= ((long) (byteArray[i] & 0xFF) << shift);
|
||||
val |= (long) (byteArray[i] & 0xFF) << shift;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@ -139,7 +139,7 @@ public class EnhancedDoubleHasher implements Hasher {
|
||||
// See Hacker's Delight (2nd ed), section 9.3.
|
||||
// Assume divisor is positive.
|
||||
// Divide half the unsigned number and then double the quotient result.
|
||||
final long quotient = ((dividend >>> 1) / divisor) << 1;
|
||||
final long quotient = (dividend >>> 1) / divisor << 1;
|
||||
final long remainder = dividend - quotient * divisor;
|
||||
// remainder in [0, 2 * divisor)
|
||||
return (int) (remainder >= divisor ? remainder - divisor : remainder);
|
||||
|
@ -163,7 +163,7 @@ public final class Shape {
|
||||
* (number of indexes) is less than or equal to 2*number of bit maps the
|
||||
* cardinality is sparse within the shape.
|
||||
*/
|
||||
return cardinality <= (BitMap.numberOfBitMaps(getNumberOfBits()) * 2);
|
||||
return cardinality <= BitMap.numberOfBitMaps(getNumberOfBits()) * 2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +119,7 @@ public final class SimpleBloomFilter implements BloomFilter {
|
||||
"BitMapProducer set a bit higher than the limit for the shape: %s", shape.getNumberOfBits() - 1));
|
||||
}
|
||||
if (idxLimit == idx[0]) {
|
||||
final long excess = (bitMap[idxLimit] >> shape.getNumberOfBits());
|
||||
final long excess = bitMap[idxLimit] >> shape.getNumberOfBits();
|
||||
if (excess != 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("BitMapProducer set a bit higher than the limit for the shape: %s",
|
||||
|
@ -138,7 +138,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
|
||||
final boolean v1 = b1.booleanValue();
|
||||
final boolean v2 = b2.booleanValue();
|
||||
|
||||
return (v1 ^ v2) ? ( (v1 ^ trueFirst) ? 1 : -1 ) : 0;
|
||||
return v1 ^ v2 ? v1 ^ trueFirst ? 1 : -1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,9 +167,9 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
return (this == object) ||
|
||||
((object instanceof BooleanComparator) &&
|
||||
(this.trueFirst == ((BooleanComparator) object).trueFirst));
|
||||
return this == object ||
|
||||
object instanceof BooleanComparator &&
|
||||
this.trueFirst == ((BooleanComparator) object).trueFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,8 +339,8 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
|
||||
}
|
||||
if (object.getClass().equals(this.getClass())) {
|
||||
final ComparatorChain<?> chain = (ComparatorChain<?>) object;
|
||||
return (Objects.equals(orderingBits, chain.orderingBits)) &&
|
||||
(Objects.equals(comparatorChain, chain.comparatorChain));
|
||||
return Objects.equals(orderingBits, chain.orderingBits) &&
|
||||
Objects.equals(comparatorChain, chain.comparatorChain);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ public class TransformingComparator<I, O> implements Comparator<I>, Serializable
|
||||
}
|
||||
if (object.getClass().equals(this.getClass())) {
|
||||
final TransformingComparator<?, ?> comp = (TransformingComparator<?, ?>) object;
|
||||
return (Objects.equals(decorated, comp.decorated)) &&
|
||||
(Objects.equals(transformer, comp.transformer));
|
||||
return Objects.equals(decorated, comp.decorated) &&
|
||||
Objects.equals(transformer, comp.transformer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -65,9 +65,9 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
||||
*/
|
||||
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(final Class<?>[] paramTypes,
|
||||
final Object[] args) {
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,9 @@ public class InvokerTransformer<I, O> implements Transformer<I, O> {
|
||||
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes,
|
||||
final Object[] args) {
|
||||
Objects.requireNonNull(methodName, "methodName");
|
||||
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("The parameter types must match the arguments");
|
||||
}
|
||||
if (paramTypes == null || paramTypes.length == 0) {
|
||||
|
@ -112,8 +112,8 @@ public class PermutationIterator<E> implements Iterator<List<E>> {
|
||||
int indexOfLargestMobileInteger = -1;
|
||||
int largestKey = -1;
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
if ((direction[i] && i < keys.length - 1 && keys[i] > keys[i + 1]) ||
|
||||
(!direction[i] && i > 0 && keys[i] > keys[i - 1])) {
|
||||
if (direction[i] && i < keys.length - 1 && keys[i] > keys[i + 1] ||
|
||||
!direction[i] && i > 0 && keys[i] > keys[i - 1]) {
|
||||
if (keys[i] > largestKey) { // NOPMD
|
||||
largestKey = keys[i];
|
||||
indexOfLargestMobileInteger = i;
|
||||
|
@ -376,7 +376,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
||||
final ListIterator<?> it1 = listIterator();
|
||||
final ListIterator<?> it2 = other.listIterator();
|
||||
while (it1.hasNext() && it2.hasNext()) {
|
||||
if (!(Objects.equals(it1.next(), it2.next()))) {
|
||||
if (!Objects.equals(it1.next(), it2.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se
|
||||
* @param node the node that was added
|
||||
*/
|
||||
protected void nodeInserted(final Node<E> node) {
|
||||
if ((node.previous == current) || (next.previous == node)) {
|
||||
if (node.previous == current || next.previous == node) {
|
||||
next = node;
|
||||
} else {
|
||||
nextIndexValid = false;
|
||||
|
@ -971,7 +971,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||
@SuppressWarnings("unchecked")
|
||||
public V get(final Object key) {
|
||||
final V v;
|
||||
return (((v = map.get(key)) != null) || map.containsKey(key))
|
||||
return (v = map.get(key)) != null || map.containsKey(key)
|
||||
? v
|
||||
: value.transform((K) key);
|
||||
}
|
||||
|
@ -157,13 +157,13 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||
}
|
||||
int hash = key.hashCode();
|
||||
hash += ~(hash << 15);
|
||||
hash ^= (hash >>> 10);
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >>> 6);
|
||||
hash ^= hash >>> 10;
|
||||
hash += hash << 3;
|
||||
hash ^= hash >>> 6;
|
||||
hash += ~(hash << 11);
|
||||
hash ^= (hash >>> 16);
|
||||
hash ^= hash >>> 16;
|
||||
hash %= buckets.length;
|
||||
return (hash < 0) ? hash * -1 : hash;
|
||||
return hash < 0 ? hash * -1 : hash;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -465,8 +465,8 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((key == null ? 0 : key.hashCode()) ^
|
||||
(value == null ? 0 : value.hashCode()));
|
||||
return (key == null ? 0 : key.hashCode()) ^
|
||||
(value == null ? 0 : value.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -479,9 +479,8 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||
}
|
||||
|
||||
final Map.Entry<?, ?> e2 = (Map.Entry<?, ?>) obj;
|
||||
return (
|
||||
(key == null ? e2.getKey() == null : key.equals(e2.getKey())) &&
|
||||
(value == null ? e2.getValue() == null : value.equals(e2.getValue())));
|
||||
return (key == null ? e2.getKey() == null : key.equals(e2.getKey())) &&
|
||||
(value == null ? e2.getValue() == null : value.equals(e2.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -403,7 +403,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
|
||||
final Object otherElement = other.getElement();
|
||||
|
||||
return this.getCount() == other.getCount() &&
|
||||
(Objects.equals(element, otherElement));
|
||||
Objects.equals(element, otherElement);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -411,7 +411,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final E element = getElement();
|
||||
return ((element == null) ? 0 : element.hashCode()) ^ getCount();
|
||||
return (element == null ? 0 : element.hashCode()) ^ getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +100,7 @@ public class PropertiesFactory extends AbstractPropertiesFactory<Properties> {
|
||||
|
||||
@Override
|
||||
public synchronized boolean equals(final Object o) {
|
||||
return (o instanceof Properties) && ((Properties) o).isEmpty();
|
||||
return o instanceof Properties && ((Properties) o).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,7 +203,7 @@ public class SequencesComparator<T> {
|
||||
++y;
|
||||
}
|
||||
// Second step
|
||||
if ((delta % 2 != 0 && delta - d <= k && k <= delta + d) && (vUp[i-delta] <= vDown[i])) { // NOPMD
|
||||
if (delta % 2 != 0 && delta - d <= k && k <= delta + d && vUp[i-delta] <= vDown[i]) { // NOPMD
|
||||
return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2);
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ public class SequencesComparator<T> {
|
||||
y--;
|
||||
}
|
||||
// Second step
|
||||
if ((delta % 2 == 0 && -d <= k && k <= d) && (vUp[i] <= vDown[i + delta])) { // NOPMD
|
||||
if (delta % 2 == 0 && -d <= k && k <= d && vUp[i] <= vDown[i + delta]) { // NOPMD
|
||||
return buildSnake(vUp[i], k + start1 - start2, end1, end2);
|
||||
}
|
||||
}
|
||||
|
@ -88,10 +88,10 @@ public class ClosureUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testInvokeClosure() {
|
||||
StringBuffer buf = new StringBuffer("Hello"); // Only StringBuffer has setLength() method
|
||||
StringBuilder buf = new StringBuilder("Hello"); // Only StringBuffer has setLength() method
|
||||
ClosureUtils.invokerClosure("reverse").execute(buf);
|
||||
assertEquals("olleH", buf.toString());
|
||||
buf = new StringBuffer("Hello");
|
||||
buf = new StringBuilder("Hello");
|
||||
ClosureUtils.invokerClosure("setLength", new Class[] {Integer.TYPE}, new Object[] {Integer.valueOf(2)}).execute(buf);
|
||||
assertEquals("He", buf.toString());
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class FactoryUtilsTest {
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj instanceof Mock1 && (iVal == ((Mock1) obj).iVal)) {
|
||||
if (obj instanceof Mock1 && iVal == ((Mock1) obj).iVal) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -156,7 +156,7 @@ public class FactoryUtilsTest {
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj instanceof Mock2 && (iVal == ((Mock2) obj).iVal)) {
|
||||
if (obj instanceof Mock2 && iVal == ((Mock2) obj).iVal) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -287,6 +287,6 @@ public abstract class AbstractCountingBloomFilterTest<T extends CountingBloomFil
|
||||
bf1.merge(hasher);
|
||||
bf1.remove(hasher);
|
||||
assertEquals(0, bf1.cardinality());
|
||||
assertTrue(bf1.forEachCount((x, y) -> (false)), "Hasher in removes results in value not equal to 0");
|
||||
assertTrue(bf1.forEachCount((x, y) -> false), "Hasher in removes results in value not equal to 0");
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class BitMapTest {
|
||||
assertTrue(BitMap.contains(ary, 0));
|
||||
|
||||
assertFalse(BitMap.contains(ary, 63));
|
||||
ary[0] = (1L << 63);
|
||||
ary[0] = 1L << 63;
|
||||
assertTrue(BitMap.contains(ary, 63));
|
||||
assertThrows(ArrayIndexOutOfBoundsException.class, () -> BitMap.contains(aryT, 64));
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class SetOperationsTest {
|
||||
int dotProduct = /* [1,2] & [2,3] = [2] = */ 1;
|
||||
int cardinalityA = 2;
|
||||
int cardinalityB = 2;
|
||||
expected = 1 - (dotProduct / Math.sqrt(cardinalityA * cardinalityB));
|
||||
expected = 1 - dotProduct / Math.sqrt(cardinalityA * cardinalityB);
|
||||
assertSymmetricOperation(expected, SetOperations::cosineDistance, filter1, filter2);
|
||||
|
||||
filter1 = createFilter(shape, from1);
|
||||
@ -88,7 +88,7 @@ public class SetOperationsTest {
|
||||
dotProduct = /* [1..17] & [11..27] = [] = */ 7;
|
||||
cardinalityA = 17;
|
||||
cardinalityB = 17;
|
||||
expected = 1 - (dotProduct / Math.sqrt(cardinalityA * cardinalityB));
|
||||
expected = 1 - dotProduct / Math.sqrt(cardinalityA * cardinalityB);
|
||||
assertSymmetricOperation(expected, SetOperations::cosineDistance, filter1, filter2);
|
||||
|
||||
// test with no values
|
||||
@ -168,7 +168,7 @@ public class SetOperationsTest {
|
||||
filter2 = createFilter(shape, from11);
|
||||
final double intersection = /* [1..17] & [11..27] = [11..17] = */ 7.0;
|
||||
final int union = /* [1..17] | [11..27] = [1..27] = */ 27;
|
||||
final double expected = 1 - (intersection / union);
|
||||
final double expected = 1 - intersection / union;
|
||||
assertSymmetricOperation(expected, SetOperations::jaccardDistance, filter1, filter2);
|
||||
|
||||
// test no values
|
||||
|
@ -282,7 +282,7 @@ public class MultiKeyTest {
|
||||
assertEquals(mk1.hashCode(), mk2.hashCode());
|
||||
assertTrue(mk1.hashCode() != mk3.hashCode());
|
||||
|
||||
final int total = (0 ^ ONE.hashCode()) ^ TWO.hashCode();
|
||||
final int total = 0 ^ ONE.hashCode() ^ TWO.hashCode();
|
||||
assertEquals(total, mk1.hashCode());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user