Fixed checkstyle.

Add missing newlines at end of files.

Remove redundant modifiers.

Fix incorrect Apache license header.

Fix whitespace around elements.

Remove tab characters.

Fix right-curly location.

Correct modifier order.
This commit is contained in:
Alex Herbert 2020-02-18 23:07:19 +00:00
parent 72f45156d3
commit 4797acefba
163 changed files with 2073 additions and 2085 deletions

View File

@ -38,7 +38,7 @@
<fileSet> <fileSet>
<directory>src</directory> <directory>src</directory>
<excludes> <excludes>
<exclude>**/*.cgi</exclude> <exclude>**/*.cgi</exclude>
</excludes> </excludes>
</fileSet> </fileSet>
</fileSets> </fileSets>

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@
<!-- Ignore missing javadoc for Get/Put interfaces, they refer to java.util.Map --> <!-- Ignore missing javadoc for Get/Put interfaces, they refer to java.util.Map -->
<suppress checks="JavadocMethod" files="Get.java" /> <suppress checks="JavadocMethod" files="Get.java" />
<suppress checks="JavadocMethod" files="Put.java" /> <suppress checks="JavadocMethod" files="Put.java" />
<!-- Ignore missing javadoc param for unsupported method --> <!-- Ignore missing javadoc param for unsupported method -->
<suppress checks="JavadocMethod" files="FilterListIterator.java" lines="116,166" /> <suppress checks="JavadocMethod" files="FilterListIterator.java" lines="116,166" />
</suppressions> </suppressions>

View File

@ -20,7 +20,7 @@ limitations under the License.
"-//Puppy Crawl//DTD Check Configuration 1.1//EN" "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
"http://www.puppycrawl.com/dtds/configuration_1_1.dtd"> "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
<!-- Apache Commons Lang customization of default Checkstyle behavior --> <!-- Apache Commons Collections customization of default Checkstyle behavior -->
<module name="Checker"> <module name="Checker">
<property name="localeLanguage" value="en"/> <property name="localeLanguage" value="en"/>
<module name="JavadocPackage"/> <module name="JavadocPackage"/>

View File

@ -73,7 +73,7 @@ public class CollectionUtils {
* @param a the first collection * @param a the first collection
* @param b the second collection * @param b the second collection
*/ */
public CardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) { CardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) {
cardinalityA = CollectionUtils.<O>getCardinalityMap(a); cardinalityA = CollectionUtils.<O>getCardinalityMap(a);
cardinalityB = CollectionUtils.<O>getCardinalityMap(b); cardinalityB = CollectionUtils.<O>getCardinalityMap(b);
} }
@ -140,7 +140,7 @@ public class CollectionUtils {
* @param a the first collection * @param a the first collection
* @param b the second collection * @param b the second collection
*/ */
public SetOperationCardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) { SetOperationCardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) {
super(a, b); super(a, b);
elements = new HashSet<>(); elements = new HashSet<>();
addAll(elements, a); addAll(elements, a);
@ -555,15 +555,15 @@ public class CollectionUtils {
* @return {@code true} iff the collections contain the same elements with the same cardinalities. * @return {@code true} iff the collections contain the same elements with the same cardinalities.
*/ */
public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b) { public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b) {
if(a.size() != b.size()) { if (a.size() != b.size()) {
return false; return false;
} }
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b); final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b);
if(helper.cardinalityA.size() != helper.cardinalityB.size()) { if (helper.cardinalityA.size() != helper.cardinalityB.size()) {
return false; return false;
} }
for( final Object obj : helper.cardinalityA.keySet()) { for (final Object obj : helper.cardinalityA.keySet()) {
if(helper.freqA(obj) != helper.freqB(obj)) { if (helper.freqA(obj) != helper.freqB(obj)) {
return false; return false;
} }
} }
@ -598,7 +598,7 @@ public class CollectionUtils {
final Equator<? super E> equator) { final Equator<? super E> equator) {
Objects.requireNonNull(equator, "equator"); Objects.requireNonNull(equator, "equator");
if(a.size() != b.size()) { if (a.size() != b.size()) {
return false; return false;
} }
@ -622,7 +622,7 @@ public class CollectionUtils {
private final Equator<? super O> equator; private final Equator<? super O> equator;
private final O object; private final O object;
public EquatorWrapper(final Equator<? super O> equator, final O object) { EquatorWrapper(final Equator<? super O> equator, final O object) {
this.equator = equator; this.equator = equator;
this.object = object; this.object = object;
} }
@ -1318,7 +1318,7 @@ public class CollectionUtils {
if (i < 0) { if (i < 0) {
throw new IndexOutOfBoundsException("Index cannot be negative: " + i); throw new IndexOutOfBoundsException("Index cannot be negative: " + i);
} }
if (object instanceof Map<?,?>) { if (object instanceof Map<?, ?>) {
final Map<?, ?> map = (Map<?, ?>) object; final Map<?, ?> map = (Map<?, ?>) object;
final Iterator<?> iterator = map.entrySet().iterator(); final Iterator<?> iterator = map.entrySet().iterator();
return IteratorUtils.get(iterator, i); return IteratorUtils.get(iterator, i);
@ -1355,7 +1355,7 @@ public class CollectionUtils {
* @return the object at the specified index * @return the object at the specified index
* @throws IndexOutOfBoundsException if the index is invalid * @throws IndexOutOfBoundsException if the index is invalid
*/ */
public static <K,V> Map.Entry<K, V> get(final Map<K,V> map, final int index) { public static <K, V> Map.Entry<K, V> get(final Map<K, V> map, final int index) {
checkIndexBounds(index); checkIndexBounds(index);
return get(map.entrySet(), index); return get(map.entrySet(), index);
} }
@ -1383,7 +1383,7 @@ public class CollectionUtils {
return 0; return 0;
} }
int total = 0; int total = 0;
if (object instanceof Map<?,?>) { if (object instanceof Map<?, ?>) {
total = ((Map<?, ?>) object).size(); total = ((Map<?, ?>) object).size();
} else if (object instanceof Collection<?>) { } else if (object instanceof Collection<?>) {
total = ((Collection<?>) object).size(); total = ((Collection<?>) object).size();

View File

@ -1,12 +1,18 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license * Licensed to the Apache Software Foundation (ASF) under one or more
* agreements. See the NOTICE file distributed with this work for additional information regarding * contributor license agreements. See the NOTICE file distributed with
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the * this work for additional information regarding copyright ownership.
* "License"); you may not use this file except in compliance with the License. You may obtain a * The ASF licenses this file to You under the Apache License, Version 2.0
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable * (the "License"); you may not use this file except in compliance with
* law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * the License. You may obtain a copy of the License at
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License *
* for the specific language governing permissions and limitations under the License. * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.apache.commons.collections4; package org.apache.commons.collections4;

View File

@ -478,7 +478,7 @@ public class IterableUtils {
private static final class UnmodifiableIterable<E> extends FluentIterable<E> { private static final class UnmodifiableIterable<E> extends FluentIterable<E> {
private final Iterable<E> unmodifiable; private final Iterable<E> unmodifiable;
public UnmodifiableIterable(final Iterable<E> iterable) { UnmodifiableIterable(final Iterable<E> iterable) {
super(); super();
this.unmodifiable = iterable; this.unmodifiable = iterable;
} }

View File

@ -808,7 +808,7 @@ public class IteratorUtils {
* Convenience method, allows easy iteration over NodeLists: * Convenience method, allows easy iteration over NodeLists:
* <pre> * <pre>
* Iterator&lt;Node&gt; iterator = IteratorUtils.nodeListIterator(node); * Iterator&lt;Node&gt; iterator = IteratorUtils.nodeListIterator(node);
* for(Node childNode : IteratorUtils.asIterable(iterator)) { * for (Node childNode : IteratorUtils.asIterable(iterator)) {
* ... * ...
* } * }
* </pre> * </pre>
@ -1247,7 +1247,7 @@ public class IteratorUtils {
Objects.requireNonNull(predicate, "predicate"); Objects.requireNonNull(predicate, "predicate");
if (iterator != null) { if (iterator != null) {
for(int index = 0; iterator.hasNext(); index++) { for (int index = 0; iterator.hasNext(); index++) {
final E element = iterator.next(); final E element = iterator.next();
if (predicate.evaluate(element)) { if (predicate.evaluate(element)) {
return index; return index;
@ -1469,7 +1469,7 @@ public class IteratorUtils {
stringBuilder.append(transformer.transform(element)); stringBuilder.append(transformer.transform(element));
stringBuilder.append(delimiter); stringBuilder.append(delimiter);
} }
if(stringBuilder.length() > prefix.length()) { if (stringBuilder.length() > prefix.length()) {
stringBuilder.setLength(stringBuilder.length() - delimiter.length()); stringBuilder.setLength(stringBuilder.length() - delimiter.length());
} }
} }

View File

@ -611,7 +611,7 @@ public class ListUtils {
private static final class LcsVisitor<E> implements CommandVisitor<E> { private static final class LcsVisitor<E> implements CommandVisitor<E> {
private final ArrayList<E> sequence; private final ArrayList<E> sequence;
public LcsVisitor() { LcsVisitor() {
sequence = new ArrayList<>(); sequence = new ArrayList<>();
} }
@ -639,23 +639,21 @@ public class ListUtils {
* A simple wrapper to use a CharSequence as List. * A simple wrapper to use a CharSequence as List.
*/ */
private static final class CharSequenceAsList extends AbstractList<Character> { private static final class CharSequenceAsList extends AbstractList<Character> {
private final CharSequence sequence;
private final CharSequence sequence; CharSequenceAsList(final CharSequence sequence) {
this.sequence = sequence;
}
public CharSequenceAsList(final CharSequence sequence) { @Override
this.sequence = sequence; public Character get(final int index) {
} return Character.valueOf(sequence.charAt(index));
}
@Override
public Character get( final int index ) {
return Character.valueOf(sequence.charAt( index ));
}
@Override
public int size() {
return sequence.length();
}
@Override
public int size() {
return sequence.length();
}
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -58,7 +58,7 @@ public class SetUtils {
* @param <E> the element type * @param <E> the element type
* @since 4.1 * @since 4.1
*/ */
public static abstract class SetView<E> extends AbstractSet<E> { public abstract static class SetView<E> extends AbstractSet<E> {
/** /**
* Copies the contents of this view into the provided set. * Copies the contents of this view into the provided set.

View File

@ -191,7 +191,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
* *
* @param parent the parent bag * @param parent the parent bag
*/ */
public BagIterator(final AbstractMapBag<E> parent) { BagIterator(final AbstractMapBag<E> parent) {
this.parent = parent; this.parent = parent;
this.entryIterator = parent.map.entrySet().iterator(); this.entryIterator = parent.map.entrySet().iterator();
this.current = null; this.current = null;
@ -507,7 +507,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
@Override @Override
public Set<E> uniqueSet() { public Set<E> uniqueSet() {
if (uniqueSet == null) { if (uniqueSet == null) {
uniqueSet = UnmodifiableSet.<E> unmodifiableSet(map.keySet()); uniqueSet = UnmodifiableSet.<E>unmodifiableSet(map.keySet());
} }
return uniqueSet; return uniqueSet;
} }

View File

@ -111,7 +111,7 @@ public final class CollectionBag<E> extends AbstractBagDecorator<E> {
public boolean containsAll(final Collection<?> coll) { public boolean containsAll(final Collection<?> coll) {
final Iterator<?> e = coll.iterator(); final Iterator<?> e = coll.iterator();
while (e.hasNext()) { while (e.hasNext()) {
if(!contains(e.next())) { if (!contains(e.next())) {
return false; return false;
} }
} }

View File

@ -92,7 +92,7 @@ public final class CollectionSortedBag<E> extends AbstractSortedBagDecorator<E>
public boolean containsAll(final Collection<?> coll) { public boolean containsAll(final Collection<?> coll) {
final Iterator<?> e = coll.iterator(); final Iterator<?> e = coll.iterator();
while (e.hasNext()) { while (e.hasNext()) {
if(!contains(e.next())) { if (!contains(e.next())) {
return false; return false;
} }
} }

View File

@ -88,7 +88,7 @@ public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
*/ */
@Override @Override
public boolean add(final E object) { public boolean add(final E object) {
if(comparator() == null && !(object instanceof Comparable)) { if (comparator() == null && !(object instanceof Comparable)) {
Objects.requireNonNull(object, "object"); Objects.requireNonNull(object, "object");
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " + throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
"a naturally ordered TreeBag as it does not implement Comparable"); "a naturally ordered TreeBag as it does not implement Comparable");

View File

@ -108,7 +108,7 @@ public final class UnmodifiableBag<E>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override @Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator()); return UnmodifiableIterator.<E>unmodifiableIterator(decorated().iterator());
} }
@Override @Override
@ -163,7 +163,7 @@ public final class UnmodifiableBag<E>
@Override @Override
public Set<E> uniqueSet() { public Set<E> uniqueSet() {
final Set<E> set = decorated().uniqueSet(); final Set<E> set = decorated().uniqueSet();
return UnmodifiableSet.<E> unmodifiableSet(set); return UnmodifiableSet.<E>unmodifiableSet(set);
} }
} }

View File

@ -344,7 +344,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
/** /**
* Inner class View. * Inner class View.
*/ */
protected static abstract class View<K, V, E> extends AbstractCollectionDecorator<E> { protected abstract static class View<K, V, E> extends AbstractCollectionDecorator<E> {
/** Generated serial version ID. */ /** Generated serial version ID. */
private static final long serialVersionUID = 4621510560119690639L; private static final long serialVersionUID = 4621510560119690639L;

View File

@ -1465,7 +1465,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
stream.defaultReadObject(); stream.defaultReadObject();
rootNode = new Node[2]; rootNode = new Node[2];
final int size = stream.readInt(); final int size = stream.readInt();
for(int i = 0; i < size; i++){ for (int i = 0; i < size; i++){
final K k =(K) stream.readObject(); final K k =(K) stream.readObject();
final V v =(V) stream.readObject(); final V v =(V) stream.readObject();
put(k, v); put(k, v);
@ -1521,7 +1521,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
/** /**
* Create a new TreeBidiMap.KeyView. * Create a new TreeBidiMap.KeyView.
*/ */
public KeyView(final DataElement orderType) { KeyView(final DataElement orderType) {
super(orderType); super(orderType);
} }
@ -1548,7 +1548,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
/** /**
* Create a new TreeBidiMap.ValueView. * Create a new TreeBidiMap.ValueView.
*/ */
public ValueView(final DataElement orderType) { ValueView(final DataElement orderType) {
super(orderType); super(orderType);
} }
@ -1792,7 +1792,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
/** /**
* Create a new TreeBidiMap.InverseViewMapIterator. * Create a new TreeBidiMap.InverseViewMapIterator.
*/ */
public InverseViewMapIterator(final DataElement orderType) { InverseViewMapIterator(final DataElement orderType) {
super(orderType); super(orderType);
} }

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -168,7 +167,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
* @param other the other Bloom filter. * @param other the other Bloom filter.
*/ */
@Override @Override
abstract public void merge(BloomFilter other); public abstract void merge(BloomFilter other);
/** /**
* Merge the decomposed Bloom filter defined by the hasher into this Bloom * Merge the decomposed Bloom filter defined by the hasher into this Bloom
@ -179,7 +178,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
* this filter, or if the hasher is not the specified one * this filter, or if the hasher is not the specified one
*/ */
@Override @Override
abstract public void merge(Hasher hasher); public abstract void merge(Hasher hasher);
@Override @Override
public int orCardinality(final BloomFilter other) { public int orCardinality(final BloomFilter other) {

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -64,7 +63,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
if (other instanceof BitSetBloomFilter) { if (other instanceof BitSetBloomFilter) {
verifyShape(other); verifyShape(other);
final BitSet result = (BitSet) bitSet.clone(); final BitSet result = (BitSet) bitSet.clone();
result.and(((BitSetBloomFilter)other).bitSet); result.and(((BitSetBloomFilter) other).bitSet);
return result.cardinality(); return result.cardinality();
} }
return super.andCardinality(other); return super.andCardinality(other);
@ -101,7 +100,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
public void merge(final BloomFilter other) { public void merge(final BloomFilter other) {
verifyShape(other); verifyShape(other);
if (other instanceof BitSetBloomFilter) { if (other instanceof BitSetBloomFilter) {
bitSet.or(((BitSetBloomFilter)other).bitSet); bitSet.or(((BitSetBloomFilter) other).bitSet);
} else { } else {
bitSet.or(BitSet.valueOf(other.getBits())); bitSet.or(BitSet.valueOf(other.getBits()));
} }
@ -118,7 +117,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
if (other instanceof BitSetBloomFilter) { if (other instanceof BitSetBloomFilter) {
verifyShape(other); verifyShape(other);
final BitSet result = (BitSet) bitSet.clone(); final BitSet result = (BitSet) bitSet.clone();
result.or(((BitSetBloomFilter)other).bitSet); result.or(((BitSetBloomFilter) other).bitSet);
return result.cardinality(); return result.cardinality();
} }
return super.orCardinality(other); return super.orCardinality(other);
@ -134,7 +133,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
if (other instanceof BitSetBloomFilter) { if (other instanceof BitSetBloomFilter) {
verifyShape(other); verifyShape(other);
final BitSet result = (BitSet) bitSet.clone(); final BitSet result = (BitSet) bitSet.clone();
result.xor(((BitSetBloomFilter)other).bitSet); result.xor(((BitSetBloomFilter) other).bitSet);
return result.cardinality(); return result.cardinality();
} }
return super.xorCardinality(other); return super.xorCardinality(other);

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -105,7 +104,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
public int andCardinality(final BloomFilter other) { public int andCardinality(final BloomFilter other) {
if (other instanceof CountingBloomFilter) { if (other instanceof CountingBloomFilter) {
final Set<Integer> result = new HashSet<>(counts.keySet()); final Set<Integer> result = new HashSet<>(counts.keySet());
result.retainAll(((CountingBloomFilter)other).counts.keySet()); result.retainAll(((CountingBloomFilter) other).counts.keySet());
return result.size(); return result.size();
} }
return super.andCardinality(other); return super.andCardinality(other);
@ -229,7 +228,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
public void remove(final Hasher hasher) { public void remove(final Hasher hasher) {
verifyHasher(hasher); verifyHasher(hasher);
final Set<Integer> lst = new HashSet<>(); final Set<Integer> lst = new HashSet<>();
hasher.getBits(getShape()).forEachRemaining((Consumer<Integer>)lst::add); hasher.getBits(getShape()).forEachRemaining((Consumer<Integer>) lst::add);
remove(lst.stream()); remove(lst.stream());
} }

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -35,7 +34,7 @@ public final class SetOperations {
* @return the jaccard distance. * @return the jaccard distance.
*/ */
public static double cosineDistance(final BloomFilter first, final BloomFilter second) { public static double cosineDistance(final BloomFilter first, final BloomFilter second) {
return 1.0 - cosineSimilarity(first,second); return 1.0 - cosineSimilarity(first, second);
} }
/** /**
@ -64,9 +63,9 @@ public final class SetOperations {
* @return an estimate of the size of the intersection between the two filters. * @return an estimate of the size of the intersection between the two filters.
*/ */
public static long estimateIntersectionSize(final BloomFilter first, final BloomFilter second) { public static long estimateIntersectionSize(final BloomFilter first, final BloomFilter second) {
verifyShape(first,second); verifyShape(first, second);
// do subtraction early to avoid Long overflow. // do subtraction early to avoid Long overflow.
return estimateSize(first) - estimateUnionSize(first,second) + estimateSize(second); return estimateSize(first) - estimateUnionSize(first, second) + estimateSize(second);
} }
/** /**
@ -93,7 +92,7 @@ public final class SetOperations {
* @return an estimate of the size of the union between the two filters. * @return an estimate of the size of the union between the two filters.
*/ */
public static long estimateUnionSize(final BloomFilter first, final BloomFilter second) { public static long estimateUnionSize(final BloomFilter first, final BloomFilter second) {
verifyShape(first,second); verifyShape(first, second);
final Shape shape = first.getShape(); final Shape shape = first.getShape();
final double estimate = -(shape.getNumberOfBits() * final double estimate = -(shape.getNumberOfBits() *
Math.log(1.0 - first.orCardinality(second) * 1.0 / shape.getNumberOfBits())) / Math.log(1.0 - first.orCardinality(second) * 1.0 / shape.getNumberOfBits())) /
@ -109,7 +108,7 @@ public final class SetOperations {
* @return the Hamming distance. * @return the Hamming distance.
*/ */
public static int hammingDistance(final BloomFilter first, final BloomFilter second) { public static int hammingDistance(final BloomFilter first, final BloomFilter second) {
verifyShape(first,second); verifyShape(first, second);
return first.xorCardinality(second); return first.xorCardinality(second);
} }
@ -123,7 +122,7 @@ public final class SetOperations {
* @return the Jaccard distance. * @return the Jaccard distance.
*/ */
public static double jaccardDistance(final BloomFilter first, final BloomFilter second) { public static double jaccardDistance(final BloomFilter first, final BloomFilter second) {
return 1.0 - jaccardSimilarity(first,second); return 1.0 - jaccardSimilarity(first, second);
} }
/** /**

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -291,7 +290,7 @@ public class Shape {
* @return the number of bytes in the Bloom filter. * @return the number of bytes in the Bloom filter.
*/ */
public int getNumberOfBytes() { public int getNumberOfBytes() {
return Double.valueOf(Math.ceil(numberOfBits / (double)Byte.SIZE )).intValue(); return Double.valueOf(Math.ceil(numberOfBits / (double) Byte.SIZE )).intValue();
} }
/** /**
@ -347,4 +346,4 @@ public class Shape {
HashFunctionIdentity.asCommonString(hashFunctionIdentity), HashFunctionIdentity.asCommonString(hashFunctionIdentity),
numberOfItems, numberOfBits, numberOfHashFunctions); numberOfItems, numberOfBits, numberOfHashFunctions);
} }
} }

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -15,9 +14,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* Implementations of org.apache.commons.collections4.bloomfilter.hasher.HasherFunction * Implementations of org.apache.commons.collections4.bloomfilter.hasher.HasherFunction
* interface. * interface.
*
* @since 4.5 * @since 4.5
*/ */
package org.apache.commons.collections4.bloomfilter.hasher.function; package org.apache.commons.collections4.bloomfilter.hasher.function;

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -15,9 +14,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* Implementations of org.apache.commons.collections4.bloomfilter.Hasher * Implementations of org.apache.commons.collections4.bloomfilter.Hasher
* interface. * interface.
*
* @since 4.5 * @since 4.5
*/ */
package org.apache.commons.collections4.bloomfilter.hasher; package org.apache.commons.collections4.bloomfilter.hasher;

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -15,6 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* A collection of extensible Bloom filter classes and interfaces. * A collection of extensible Bloom filter classes and interfaces.
* *

View File

@ -173,7 +173,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
public boolean equals(final Object object) { public boolean equals(final Object object) {
return (this == object) || return (this == object) ||
((object instanceof BooleanComparator) && ((object instanceof BooleanComparator) &&
(this.trueFirst == ((BooleanComparator)object).trueFirst)); (this.trueFirst == ((BooleanComparator) object).trueFirst));
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -182,7 +182,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
public void setComparator(final int index, final Comparator<E> comparator, final boolean reverse) { public void setComparator(final int index, final Comparator<E> comparator, final boolean reverse) {
checkLocked(); checkLocked();
comparatorChain.set(index,comparator); comparatorChain.set(index, comparator);
if (reverse == true) { if (reverse == true) {
orderingBits.set(index); orderingBits.set(index);
} else { } else {
@ -278,7 +278,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) { for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) {
final Comparator<? super E> comparator = comparators.next(); final Comparator<? super E> comparator = comparators.next();
int retval = comparator.compare(o1,o2); int retval = comparator.compare(o1, o2);
if (retval != 0) { if (retval != 0) {
// invert the order if it is a reverse sort // invert the order if it is a reverse sort
if (orderingBits.get(comparatorIndex) == true) { if (orderingBits.get(comparatorIndex) == true) {

View File

@ -132,9 +132,15 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
**/ **/
@Override @Override
public int compare(final E o1, final E o2) { public int compare(final E o1, final E o2) {
if(o1 == o2) { return 0; } if (o1 == o2) {
if(o1 == null) { return this.nullsAreHigh ? 1 : -1; } return 0;
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); return this.nonNullComparator.compare(o1, o2);
} }
@ -163,14 +169,19 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
**/ **/
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if(obj == null) { return false; } if (obj == null) {
if(obj == this) { return true; } return false;
if(!obj.getClass().equals(this.getClass())) { return false; } }
if (obj == this) {
return true;
}
if (!obj.getClass().equals(this.getClass())) {
return false;
}
final NullComparator<?> other = (NullComparator<?>) obj; final NullComparator<?> other = (NullComparator<?>) obj;
return this.nullsAreHigh == other.nullsAreHigh && return this.nullsAreHigh == other.nullsAreHigh &&
this.nonNullComparator.equals(other.nonNullComparator); this.nonNullComparator.equals(other.nonNullComparator);
} }
} }

View File

@ -107,7 +107,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
*/ */
@Override @Override
public O transform(final I input) { public O transform(final I input) {
if(iPredicate.evaluate(input)){ if (iPredicate.evaluate(input)){
return iTrueTransformer.transform(input); return iTrueTransformer.transform(input);
} }
return iFalseTransformer.transform(input); return iFalseTransformer.transform(input);

View File

@ -1,15 +1,18 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this * contributor license agreements. See the NOTICE file distributed with
* work for additional information regarding copyright ownership. The ASF * this work for additional information regarding copyright ownership.
* licenses this file to You under the Apache License, Version 2.0 (the * The ASF licenses this file to You under the Apache License, Version 2.0
* "License"); you may not use this file except in compliance with the License. * (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law *
* or agreed to in writing, software distributed under the License is * http://www.apache.org/licenses/LICENSE-2.0
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
* KIND, either express or implied. See the License for the specific language * Unless required by applicable law or agreed to in writing, software
* governing permissions and limitations under the License. * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.apache.commons.collections4.iterators; package org.apache.commons.collections4.iterators;

View File

@ -208,7 +208,7 @@ public class IteratorChain<E> implements Iterator<E> {
protected void updateCurrentIterator() { protected void updateCurrentIterator() {
if (currentIterator == null) { if (currentIterator == null) {
if (iteratorChain.isEmpty()) { if (iteratorChain.isEmpty()) {
currentIterator = EmptyIterator.<E> emptyIterator(); currentIterator = EmptyIterator.<E>emptyIterator();
} else { } else {
currentIterator = iteratorChain.remove(); currentIterator = iteratorChain.remove();
} }

View File

@ -1,15 +1,18 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this * contributor license agreements. See the NOTICE file distributed with
* work for additional information regarding copyright ownership. The ASF * this work for additional information regarding copyright ownership.
* licenses this file to You under the Apache License, Version 2.0 (the * The ASF licenses this file to You under the Apache License, Version 2.0
* "License"); you may not use this file except in compliance with the License. * (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law *
* or agreed to in writing, software distributed under the License is * http://www.apache.org/licenses/LICENSE-2.0
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
* KIND, either express or implied. See the License for the specific language * Unless required by applicable law or agreed to in writing, software
* governing permissions and limitations under the License. * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.apache.commons.collections4.iterators; package org.apache.commons.collections4.iterators;
@ -129,7 +132,7 @@ public class IteratorIterable<E> implements Iterable<E> {
@Override @Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
if (iterator instanceof ResettableIterator) { if (iterator instanceof ResettableIterator) {
((ResettableIterator<? extends E>)iterator).reset(); ((ResettableIterator<? extends E>) iterator).reset();
} }
return typeSafeIterator; return typeSafeIterator;
} }

View File

@ -1,9 +1,10 @@
/* /*
* Copyright 2013 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one or more
* * contributor license agreements. See the NOTICE file distributed with
* Licensed under the Apache License, Version 2.0 (the "License"); * this work for additional information regarding copyright ownership.
* you may not use this file except in compliance with the License. * The ASF licenses this file to You under the Apache License, Version 2.0
* You may obtain a copy of the License at * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -137,7 +137,7 @@ public class SingletonListIterator<E> implements ResettableListIterator<E> {
*/ */
@Override @Override
public void remove() { public void remove() {
if(!nextCalled || removed) { if (!nextCalled || removed) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
object = null; object = null;

View File

@ -1,15 +1,18 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this * contributor license agreements. See the NOTICE file distributed with
* work for additional information regarding copyright ownership. The ASF * this work for additional information regarding copyright ownership.
* licenses this file to You under the Apache License, Version 2.0 (the * The ASF licenses this file to You under the Apache License, Version 2.0
* "License"); you may not use this file except in compliance with the License. * (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law *
* or agreed to in writing, software distributed under the License is * http://www.apache.org/licenses/LICENSE-2.0
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
* KIND, either express or implied. See the License for the specific language * Unless required by applicable law or agreed to in writing, software
* governing permissions and limitations under the License. * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.apache.commons.collections4.iterators; package org.apache.commons.collections4.iterators;

View File

@ -112,7 +112,7 @@ public class ZippingIterator<E> implements Iterator<E> {
return true; return true;
} }
while(iterators.hasNext()) { while (iterators.hasNext()) {
final Iterator<? extends E> childIterator = iterators.next(); final Iterator<? extends E> childIterator = iterators.next();
if (childIterator.hasNext()) { if (childIterator.hasNext()) {
nextIterator = childIterator; nextIterator = childIterator;

View File

@ -227,8 +227,7 @@ public class MultiKey<K> implements Serializable {
* Calculate the hash code of the instance using the provided keys. * Calculate the hash code of the instance using the provided keys.
* @param keys the keys to calculate the hash code for * @param keys the keys to calculate the hash code for
*/ */
private void calculateHashCode(final Object[] keys) private void calculateHashCode(final Object[] keys) {
{
int total = 0; int total = 0;
for (final Object key : keys) { for (final Object key : keys) {
if (key != null) { if (key != null) {

View File

@ -108,7 +108,7 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return false; return false;
} }
final Map.Entry<?,?> other = (Map.Entry<?,?>) obj; final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
final Object value = getValue(); final Object value = getValue();
return return
(key == null ? other.getKey() == null : key.equals(other.getKey())) && (key == null ? other.getKey() == null : key.equals(other.getKey())) &&

View File

@ -1164,7 +1164,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* @param <K> the type of the keys in the map * @param <K> the type of the keys in the map
* @param <V> the type of the values in the map * @param <V> the type of the values in the map
*/ */
protected static abstract class HashIterator<K, V> { protected abstract static class HashIterator<K, V> {
/** The parent map */ /** The parent map */
private final AbstractHashedMap<K, V> parent; private final AbstractHashedMap<K, V> parent;
@ -1349,11 +1349,11 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
if (obj instanceof Map == false) { if (obj instanceof Map == false) {
return false; return false;
} }
final Map<?,?> map = (Map<?,?>) obj; final Map<?, ?> map = (Map<?, ?>) obj;
if (map.size() != size()) { if (map.size() != size()) {
return false; return false;
} }
final MapIterator<?,?> it = mapIterator(); final MapIterator<?, ?> it = mapIterator();
try { try {
while (it.hasNext()) { while (it.hasNext()) {
final Object key = it.next(); final Object key = it.next();

View File

@ -543,7 +543,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
/** /**
* Base Iterator that iterates in link order. * Base Iterator that iterates in link order.
*/ */
protected static abstract class LinkIterator<K, V> { protected abstract static class LinkIterator<K, V> {
/** The parent map */ /** The parent map */
protected final AbstractLinkedMap<K, V> parent; protected final AbstractLinkedMap<K, V> parent;

View File

@ -679,7 +679,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
return false; return false;
} }
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>)obj; final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
final Object entryKey = entry.getKey(); // convert to hard reference final Object entryKey = entry.getKey(); // convert to hard reference
final Object entryValue = entry.getValue(); // convert to hard reference final Object entryValue = entry.getValue(); // convert to hard reference
if (entryKey == null || entryValue == null) { if (entryKey == null || entryValue == null) {
@ -794,7 +794,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
int expectedModCount; int expectedModCount;
public ReferenceBaseIterator(final AbstractReferenceMap<K, V> parent) { ReferenceBaseIterator(final AbstractReferenceMap<K, V> parent) {
super(); super();
this.parent = parent; this.parent = parent;
index = parent.size() != 0 ? parent.data.length : 0; index = parent.size() != 0 ? parent.data.length : 0;
@ -876,7 +876,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
static class ReferenceEntrySetIterator<K, V> static class ReferenceEntrySetIterator<K, V>
extends ReferenceBaseIterator<K, V> implements Iterator<Map.Entry<K, V>> { extends ReferenceBaseIterator<K, V> implements Iterator<Map.Entry<K, V>> {
public ReferenceEntrySetIterator(final AbstractReferenceMap<K, V> parent) { ReferenceEntrySetIterator(final AbstractReferenceMap<K, V> parent) {
super(parent); super(parent);
} }
@ -973,7 +973,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
/** the hashCode of the key (even if the reference points to a value) */ /** the hashCode of the key (even if the reference points to a value) */
private final int hash; private final int hash;
public SoftRef(final int hash, final T r, final ReferenceQueue<? super T> q) { SoftRef(final int hash, final T r, final ReferenceQueue<? super T> q) {
super(r, q); super(r, q);
this.hash = hash; this.hash = hash;
} }
@ -991,7 +991,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
/** the hashCode of the key (even if the reference points to a value) */ /** the hashCode of the key (even if the reference points to a value) */
private final int hash; private final int hash;
public WeakRef(final int hash, final T r, final ReferenceQueue<? super T> q) { WeakRef(final int hash, final T r, final ReferenceQueue<? super T> q) {
super(r, q); super(r, q);
this.hash = hash; this.hash = hash;
} }

View File

@ -809,7 +809,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
private final int index; private final int index;
private volatile boolean removed; private volatile boolean removed;
public FlatMapEntry(final Flat3Map<K, V> parent, final int index) { FlatMapEntry(final Flat3Map<K, V> parent, final int index) {
this.parent = parent; this.parent = parent;
this.index = index; this.index = index;
this.removed = false; this.removed = false;
@ -918,7 +918,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
} }
static abstract class EntryIterator<K, V> { abstract static class EntryIterator<K, V> {
private final Flat3Map<K, V> parent; private final Flat3Map<K, V> parent;
private int nextIndex = 0; private int nextIndex = 0;
private FlatMapEntry<K, V> currentEntry = null; private FlatMapEntry<K, V> currentEntry = null;
@ -926,7 +926,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
/** /**
* Create a new Flat3Map.EntryIterator. * Create a new Flat3Map.EntryIterator.
*/ */
public EntryIterator(final Flat3Map<K, V> parent) { EntryIterator(final Flat3Map<K, V> parent) {
this.parent = parent; this.parent = parent;
} }
@ -1031,7 +1031,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
/** /**
* KeySetIterator * KeySetIterator
*/ */
static class KeySetIterator<K> extends EntryIterator<K, Object> implements Iterator<K>{ static class KeySetIterator<K> extends EntryIterator<K, Object> implements Iterator<K> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
KeySetIterator(final Flat3Map<K, ?> parent) { KeySetIterator(final Flat3Map<K, ?> parent) {

View File

@ -269,7 +269,7 @@ public class LRUMap<K, V>
if (entry.after != header) { if (entry.after != header) {
modCount++; modCount++;
// remove // remove
if(entry.before == null) { if (entry.before == null) {
throw new IllegalStateException("Entry.before is null." + throw new IllegalStateException("Entry.before is null." +
" This should not occur if your keys are immutable, and you have used synchronization properly."); " This should not occur if your keys are immutable, and you have used synchronization properly.");
} }

View File

@ -86,7 +86,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Seriali
* @throws NullPointerException if map or factory is null * @throws NullPointerException if map or factory is null
* @since 4.0 * @since 4.0
*/ */
public static <K, V> LazyMap<K, V> lazyMap(final Map<K, V> map, final Factory< ? extends V> factory) { public static <K, V> LazyMap<K, V> lazyMap(final Map<K, V> map, final Factory<? extends V> factory) {
return new LazyMap<>(map, factory); return new LazyMap<>(map, factory);
} }
@ -113,7 +113,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Seriali
* @param factory the factory to use, must not be null * @param factory the factory to use, must not be null
* @throws NullPointerException if map or factory is null * @throws NullPointerException if map or factory is null
*/ */
protected LazyMap(final Map<K,V> map, final Factory<? extends V> factory) { protected LazyMap(final Map<K, V> map, final Factory<? extends V> factory) {
super(map); super(map);
this.factory = FactoryTransformer.factoryTransformer(Objects.requireNonNull(factory, "factory")); this.factory = FactoryTransformer.factoryTransformer(Objects.requireNonNull(factory, "factory"));
} }
@ -125,7 +125,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Seriali
* @param factory the factory to use, must not be null * @param factory the factory to use, must not be null
* @throws NullPointerException if map or factory is null * @throws NullPointerException if map or factory is null
*/ */
protected LazyMap(final Map<K,V> map, final Transformer<? super K, ? extends V> factory) { protected LazyMap(final Map<K, V> map, final Transformer<? super K, ? extends V> factory) {
super(map); super(map);
this.factory = Objects.requireNonNull(factory, "factory"); this.factory = Objects.requireNonNull(factory, "factory");
} }

View File

@ -63,7 +63,7 @@ import org.apache.commons.collections4.Transformer;
* @param <V> the type of the values in this map * @param <V> the type of the values in this map
* @since 3.0 * @since 3.0
*/ */
public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> { public class LazySortedMap<K, V> extends LazyMap<K, V> implements SortedMap<K, V> {
/** Serialization version */ /** Serialization version */
private static final long serialVersionUID = 2715322183617658933L; private static final long serialVersionUID = 2715322183617658933L;
@ -108,7 +108,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
* @param factory the factory to use, must not be null * @param factory the factory to use, must not be null
* @throws NullPointerException if map or factory is null * @throws NullPointerException if map or factory is null
*/ */
protected LazySortedMap(final SortedMap<K,V> map, final Factory<? extends V> factory) { protected LazySortedMap(final SortedMap<K, V> map, final Factory<? extends V> factory) {
super(map, factory); super(map, factory);
} }
@ -119,7 +119,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
* @param factory the factory to use, must not be null * @param factory the factory to use, must not be null
* @throws NullPointerException if map or factory is null * @throws NullPointerException if map or factory is null
*/ */
protected LazySortedMap(final SortedMap<K,V> map, final Transformer<? super K, ? extends V> factory) { protected LazySortedMap(final SortedMap<K, V> map, final Transformer<? super K, ? extends V> factory) {
super(map, factory); super(map, factory);
} }
@ -129,8 +129,8 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
* *
* @return the decorated map * @return the decorated map
*/ */
protected SortedMap<K,V> getSortedMap() { protected SortedMap<K, V> getSortedMap() {
return (SortedMap<K,V>) map; return (SortedMap<K, V>) map;
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -150,20 +150,20 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
} }
@Override @Override
public SortedMap<K,V> subMap(final K fromKey, final K toKey) { public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
final SortedMap<K,V> map = getSortedMap().subMap(fromKey, toKey); final SortedMap<K, V> map = getSortedMap().subMap(fromKey, toKey);
return new LazySortedMap<>(map, factory); return new LazySortedMap<>(map, factory);
} }
@Override @Override
public SortedMap<K,V> headMap(final K toKey) { public SortedMap<K, V> headMap(final K toKey) {
final SortedMap<K,V> map = getSortedMap().headMap(toKey); final SortedMap<K, V> map = getSortedMap().headMap(toKey);
return new LazySortedMap<>(map, factory); return new LazySortedMap<>(map, factory);
} }
@Override @Override
public SortedMap<K,V> tailMap(final K fromKey) { public SortedMap<K, V> tailMap(final K fromKey) {
final SortedMap<K,V> map = getSortedMap().tailMap(fromKey); final SortedMap<K, V> map = getSortedMap().tailMap(fromKey);
return new LazySortedMap<>(map, factory); return new LazySortedMap<>(map, factory);
} }

View File

@ -600,7 +600,7 @@ public class ListOrderedMap<K, V>
private final List<K> insertOrder; private final List<K> insertOrder;
private Set<Map.Entry<K, V>> entrySet; private Set<Map.Entry<K, V>> entrySet;
public EntrySetView(final ListOrderedMap<K, V> parent, final List<K> insertOrder) { EntrySetView(final ListOrderedMap<K, V> parent, final List<K> insertOrder) {
super(); super();
this.parent = parent; this.parent = parent;
this.insertOrder = insertOrder; this.insertOrder = insertOrder;

View File

@ -91,7 +91,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public static <K, V> MultiValueMap<K, V> multiValueMap(final Map<K, ? super Collection<V>> map) { public static <K, V> MultiValueMap<K, V> multiValueMap(final Map<K, ? super Collection<V>> map) {
return MultiValueMap.<K, V, ArrayList> multiValueMap((Map<K, ? super Collection>) map, ArrayList.class); return MultiValueMap.<K, V, ArrayList>multiValueMap((Map<K, ? super Collection>) map, ArrayList.class);
} }
/** /**
@ -517,7 +517,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
private final Collection<V> values; private final Collection<V> values;
private final Iterator<V> iterator; private final Iterator<V> iterator;
public ValuesIterator(final Object key) { ValuesIterator(final Object key) {
this.key = key; this.key = key;
this.values = getCollection(key); this.values = getCollection(key);
this.iterator = values.iterator(); this.iterator = values.iterator();
@ -552,7 +552,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
private final Class<T> clazz; private final Class<T> clazz;
public ReflectionFactory(final Class<T> clazz) { ReflectionFactory(final Class<T> clazz) {
this.clazz = clazz; this.clazz = clazz;
} }

View File

@ -572,11 +572,11 @@ public class SingletonMap<K, V>
if (obj instanceof Map == false) { if (obj instanceof Map == false) {
return false; return false;
} }
final Map<?,?> other = (Map<?,?>) obj; final Map<?, ?> other = (Map<?, ?>) obj;
if (other.size() != 1) { if (other.size() != 1) {
return false; return false;
} }
final Map.Entry<?,?> entry = other.entrySet().iterator().next(); final Map.Entry<?, ?> entry = other.entrySet().iterator().next();
return isEqualKey(entry.getKey()) && isEqualValue(entry.getValue()); return isEqualKey(entry.getKey()) && isEqualValue(entry.getValue());
} }

View File

@ -500,7 +500,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
/** /**
* The lock object, which also includes a count of the nodes in this lock. * The lock object, which also includes a count of the nodes in this lock.
*/ */
private final static class Lock { private static final class Lock {
public int size; public int size;
} }

View File

@ -109,7 +109,7 @@ public abstract class AbstractListValuedMap<K, V> extends AbstractMultiValuedMap
*/ */
private class WrappedList extends WrappedCollection implements List<V> { private class WrappedList extends WrappedCollection implements List<V> {
public WrappedList(final K key) { WrappedList(final K key) {
super(key); super(key);
} }
@ -220,13 +220,13 @@ public abstract class AbstractListValuedMap<K, V> extends AbstractMultiValuedMap
private List<V> values; private List<V> values;
private ListIterator<V> iterator; private ListIterator<V> iterator;
public ValuesListIterator(final K key) { ValuesListIterator(final K key) {
this.key = key; this.key = key;
this.values = ListUtils.emptyIfNull(getMap().get(key)); this.values = ListUtils.emptyIfNull(getMap().get(key));
this.iterator = values.listIterator(); this.iterator = values.listIterator();
} }
public ValuesListIterator(final K key, final int index) { ValuesListIterator(final K key, final int index) {
this.key = key; this.key = key;
this.values = ListUtils.emptyIfNull(getMap().get(key)); this.values = ListUtils.emptyIfNull(getMap().get(key));
this.iterator = values.listIterator(index); this.iterator = values.listIterator(index);

View File

@ -398,7 +398,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
protected final K key; protected final K key;
public WrappedCollection(final K key) { WrappedCollection(final K key) {
this.key = key; this.key = key;
} }
@ -636,7 +636,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
*/ */
private class MultiValuedMapEntry extends AbstractMapEntry<K, V> { private class MultiValuedMapEntry extends AbstractMapEntry<K, V> {
public MultiValuedMapEntry(final K key, final V value) { MultiValuedMapEntry(final K key, final V value) {
super(key, value); super(key, value);
} }
@ -656,7 +656,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
private Entry<K, V> current = null; private Entry<K, V> current = null;
public MultiValuedMapIterator() { MultiValuedMapIterator() {
this.it = AbstractMultiValuedMap.this.entries().iterator(); this.it = AbstractMultiValuedMap.this.entries().iterator();
} }
@ -734,7 +734,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
private final Collection<V> values; private final Collection<V> values;
private final Iterator<V> iterator; private final Iterator<V> iterator;
public ValuesIterator(final Object key) { ValuesIterator(final Object key) {
this.key = key; this.key = key;
this.values = getMap().get(key); this.values = getMap().get(key);
this.iterator = values.iterator(); this.iterator = values.iterator();

View File

@ -109,7 +109,7 @@ public abstract class AbstractSetValuedMap<K, V> extends AbstractMultiValuedMap<
*/ */
private class WrappedSet extends WrappedCollection implements Set<V> { private class WrappedSet extends WrappedCollection implements Set<V> {
public WrappedSet(final K key) { WrappedSet(final K key) {
super(key); super(key);
} }
@ -133,5 +133,4 @@ public abstract class AbstractSetValuedMap<K, V> extends AbstractMultiValuedMap<
} }
} }
} }

View File

@ -165,7 +165,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
* *
* @param parent the parent multiset * @param parent the parent multiset
*/ */
public MapBasedMultiSetIterator(final AbstractMapMultiSet<E> parent) { MapBasedMultiSetIterator(final AbstractMapMultiSet<E> parent) {
this.parent = parent; this.parent = parent;
this.entryIterator = parent.map.entrySet().iterator(); this.entryIterator = parent.map.entrySet().iterator();
this.current = null; this.current = null;

View File

@ -138,7 +138,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
* *
* @param parent the parent multiset * @param parent the parent multiset
*/ */
public MultiSetIterator(final AbstractMultiSet<E> parent) { MultiSetIterator(final AbstractMultiSet<E> parent) {
this.parent = parent; this.parent = parent;
this.entryIterator = parent.entrySet().iterator(); this.entryIterator = parent.entrySet().iterator();
this.current = null; this.current = null;
@ -404,7 +404,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
/** /**
* Inner class AbstractEntry. * Inner class AbstractEntry.
*/ */
protected static abstract class AbstractEntry<E> implements Entry<E> { protected abstract static class AbstractEntry<E> implements Entry<E> {
@Override @Override
public boolean equals(final Object object) { public boolean equals(final Object object) {

View File

@ -104,7 +104,7 @@ public final class UnmodifiableMultiSet<E>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override @Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator()); return UnmodifiableIterator.<E>unmodifiableIterator(decorated().iterator());
} }
@Override @Override

View File

@ -1,19 +1,19 @@
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<body> <body>
<p> <p>
Commons-Collections contains implementations, enhancements and utilities Commons-Collections contains implementations, enhancements and utilities

View File

@ -40,7 +40,7 @@ import java.util.Properties;
*/ */
public abstract class AbstractPropertiesFactory<T extends Properties> { public abstract class AbstractPropertiesFactory<T extends Properties> {
/** /**
* Enumerat5es property formats. * Enumerat5es property formats.
* *
* @since 4.5 * @since 4.5
@ -82,7 +82,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence. * @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
*/ */
public T load(final ClassLoader classLoader, final String name) throws IOException { public T load(final ClassLoader classLoader, final String name) throws IOException {
try (final InputStream inputStream = classLoader.getResourceAsStream(name)) { try (InputStream inputStream = classLoader.getResourceAsStream(name)) {
return load(inputStream, PropertyFormat.toPropertyFormat(name)); return load(inputStream, PropertyFormat.toPropertyFormat(name));
} }
} }
@ -100,7 +100,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
* the file. * the file.
*/ */
public T load(final File file) throws FileNotFoundException, IOException { public T load(final File file) throws FileNotFoundException, IOException {
try (final FileInputStream inputStream = new FileInputStream(file)) { try (FileInputStream inputStream = new FileInputStream(file)) {
return load(inputStream, PropertyFormat.toPropertyFormat(file.getName())); return load(inputStream, PropertyFormat.toPropertyFormat(file.getName()));
} }
} }
@ -154,7 +154,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence. * @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
*/ */
public T load(final Path path) throws IOException { public T load(final Path path) throws IOException {
try (final InputStream inputStream = Files.newInputStream(path)) { try (InputStream inputStream = Files.newInputStream(path)) {
return load(inputStream, PropertyFormat.toPropertyFormat(Objects.toString(path.getFileName(), null))); return load(inputStream, PropertyFormat.toPropertyFormat(Objects.toString(path.getFileName(), null)));
} }
} }
@ -182,7 +182,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence. * @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
*/ */
public T load(final String name) throws IOException { public T load(final String name) throws IOException {
try (final FileInputStream inputStream = new FileInputStream(name)) { try (FileInputStream inputStream = new FileInputStream(name)) {
return load(inputStream, PropertyFormat.toPropertyFormat(name)); return load(inputStream, PropertyFormat.toPropertyFormat(name));
} }
} }
@ -208,7 +208,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence. * @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
*/ */
public T load(final URL url) throws IOException { public T load(final URL url) throws IOException {
try (final InputStream inputStream = url.openStream()) { try (InputStream inputStream = url.openStream()) {
return load(inputStream, PropertyFormat.toPropertyFormat(url.getFile())); return load(inputStream, PropertyFormat.toPropertyFormat(url.getFile()));
} }
} }

View File

@ -183,7 +183,7 @@ public class SequencesComparator<T> {
vDown[1+offset] = start1; vDown[1+offset] = start1;
vUp[1+offset] = end1 + 1; vUp[1+offset] = end1 + 1;
for (int d = 0; d <= offset ; ++d) { for (int d = 0; d <= offset; ++d) {
// Down // Down
for (int k = -d; k <= d; k += 2) { for (int k = -d; k <= d; k += 2) {
// First step // First step
@ -314,7 +314,7 @@ public class SequencesComparator<T> {
* @param end end index of the snake * @param end end index of the snake
* @param diag diagonal number * @param diag diagonal number
*/ */
public Snake(final int start, final int end, final int diag) { Snake(final int start, final int end, final int diag) {
this.start = start; this.start = start;
this.end = end; this.end = end;
this.diag = diag; this.diag = diag;

View File

@ -150,11 +150,11 @@ public abstract class AbstractBitwiseTrie<K, V> extends AbstractMap<K, V>
protected V value; protected V value;
public BasicEntry(final K key) { BasicEntry(final K key) {
this.key = key; this.key = key;
} }
public BasicEntry(final K key, final V value) { BasicEntry(final K key, final V value) {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
@ -198,7 +198,7 @@ public abstract class AbstractBitwiseTrie<K, V> extends AbstractMap<K, V>
return false; return false;
} }
final Map.Entry<?, ?> other = (Map.Entry<?, ?>)o; final Map.Entry<?, ?> other = (Map.Entry<?, ?>) o;
if (compare(key, other.getKey()) if (compare(key, other.getKey())
&& compare(value, other.getValue())) { && compare(value, other.getValue())) {
return true; return true;

View File

@ -55,7 +55,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
*/ */
private transient volatile Set<K> keySet; private transient volatile Set<K> keySet;
private transient volatile Collection<V> values; private transient volatile Collection<V> values;
private transient volatile Set<Map.Entry<K,V>> entrySet; private transient volatile Set<Map.Entry<K, V>> entrySet;
/** The current size of the {@link org.apache.commons.collections4.Trie}. */ /** The current size of the {@link org.apache.commons.collections4.Trie}. */
private transient int size = 0; private transient int size = 0;
@ -192,7 +192,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
TrieEntry<K, V> addEntry(final TrieEntry<K, V> entry, final int lengthInBits) { TrieEntry<K, V> addEntry(final TrieEntry<K, V> entry, final int lengthInBits) {
TrieEntry<K, V> current = root.left; TrieEntry<K, V> current = root.left;
TrieEntry<K, V> path = root; TrieEntry<K, V> path = root;
while(true) { while (true) {
if (current.bitIndex >= entry.bitIndex if (current.bitIndex >= entry.bitIndex
|| current.bitIndex <= path.bitIndex) { || current.bitIndex <= path.bitIndex) {
entry.predecessor = entry; entry.predecessor = entry;
@ -247,14 +247,14 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
* <p> * <p>
* This may throw ClassCastException if the object is not of type K. * This may throw ClassCastException if the object is not of type K.
*/ */
TrieEntry<K,V> getEntry(final Object k) { TrieEntry<K, V> getEntry(final Object k) {
final K key = castKey(k); final K key = castKey(k);
if (key == null) { if (key == null) {
return null; return null;
} }
final int lengthInBits = lengthInBits(key); final int lengthInBits = lengthInBits(key);
final TrieEntry<K,V> entry = getNearestEntryForKey(key, lengthInBits); final TrieEntry<K, V> entry = getNearestEntryForKey(key, lengthInBits);
return !entry.isEmpty() && compareKeys(key, entry.key) ? entry : null; return !entry.isEmpty() && compareKeys(key, entry.key) ? entry : null;
} }
@ -385,7 +385,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
} }
@Override @Override
public Set<Map.Entry<K,V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
if (entrySet == null) { if (entrySet == null) {
entrySet = new EntrySet(); entrySet = new EntrySet();
} }
@ -453,7 +453,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
TrieEntry<K, V> getNearestEntryForKey(final K key, final int lengthInBits) { TrieEntry<K, V> getNearestEntryForKey(final K key, final int lengthInBits) {
TrieEntry<K, V> current = root.left; TrieEntry<K, V> current = root.left;
TrieEntry<K, V> path = root; TrieEntry<K, V> path = root;
while(true) { while (true) {
if (current.bitIndex <= path.bitIndex) { if (current.bitIndex <= path.bitIndex) {
return current; return current;
} }
@ -752,7 +752,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
* Goes left through the tree until it finds a valid node. * Goes left through the tree until it finds a valid node.
*/ */
TrieEntry<K, V> followLeft(TrieEntry<K, V> node) { TrieEntry<K, V> followLeft(TrieEntry<K, V> node) {
while(true) { while (true) {
TrieEntry<K, V> child = node.left; TrieEntry<K, V> child = node.left;
// if we hit root and it didn't have a node, go right instead. // if we hit root and it didn't have a node, go right instead.
if (child.isEmpty()) { if (child.isEmpty()) {
@ -878,7 +878,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
* Returns an entry strictly higher than the given key, * Returns an entry strictly higher than the given key,
* or null if no such entry exists. * or null if no such entry exists.
*/ */
TrieEntry<K,V> higherEntry(final K key) { TrieEntry<K, V> higherEntry(final K key) {
// TODO: Cleanup so that we don't actually have to add/remove from the // TODO: Cleanup so that we don't actually have to add/remove from the
// tree. (We do it here because there are other well-defined // tree. (We do it here because there are other well-defined
// functions to perform the search.) // functions to perform the search.)
@ -931,7 +931,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
* Returns a key-value mapping associated with the least key greater * Returns a key-value mapping associated with the least key greater
* than or equal to the given key, or null if there is no such key. * than or equal to the given key, or null if there is no such key.
*/ */
TrieEntry<K,V> ceilingEntry(final K key) { TrieEntry<K, V> ceilingEntry(final K key) {
// Basically: // Basically:
// Follow the steps of adding an entry, but instead... // Follow the steps of adding an entry, but instead...
// //
@ -990,7 +990,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
* Returns a key-value mapping associated with the greatest key * Returns a key-value mapping associated with the greatest key
* strictly less than the given key, or null if there is no such key. * strictly less than the given key, or null if there is no such key.
*/ */
TrieEntry<K,V> lowerEntry(final K key) { TrieEntry<K, V> lowerEntry(final K key) {
// Basically: // Basically:
// Follow the steps of adding an entry, but instead... // Follow the steps of adding an entry, but instead...
// //
@ -1042,7 +1042,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
* Returns a key-value mapping associated with the greatest key * Returns a key-value mapping associated with the greatest key
* less than or equal to the given key, or null if there is no such key. * less than or equal to the given key, or null if there is no such key.
*/ */
TrieEntry<K,V> floorEntry(final K key) { TrieEntry<K, V> floorEntry(final K key) {
// TODO: Cleanup so that we don't actually have to add/remove from the // TODO: Cleanup so that we don't actually have to add/remove from the
// tree. (We do it here because there are other well-defined // tree. (We do it here because there are other well-defined
// functions to perform the search.) // functions to perform the search.)
@ -1091,7 +1091,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
TrieEntry<K, V> subtree(final K prefix, final int offsetInBits, final int lengthInBits) { TrieEntry<K, V> subtree(final K prefix, final int offsetInBits, final int lengthInBits) {
TrieEntry<K, V> current = root.left; TrieEntry<K, V> current = root.left;
TrieEntry<K, V> path = root; TrieEntry<K, V> path = root;
while(true) { while (true) {
if (current.bitIndex <= path.bitIndex || lengthInBits <= current.bitIndex) { if (current.bitIndex <= path.bitIndex || lengthInBits <= current.bitIndex) {
break; break;
} }
@ -1264,7 +1264,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* A {@link org.apache.commons.collections4.Trie} is a set of {@link TrieEntry} nodes. * A {@link org.apache.commons.collections4.Trie} is a set of {@link TrieEntry} nodes.
*/ */
protected static class TrieEntry<K,V> extends BasicEntry<K, V> { protected static class TrieEntry<K, V> extends BasicEntry<K, V> {
private static final long serialVersionUID = 4596023148184140013L; private static final long serialVersionUID = 4596023148184140013L;
@ -1272,16 +1272,16 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
protected int bitIndex; protected int bitIndex;
/** The parent of this entry. */ /** The parent of this entry. */
protected TrieEntry<K,V> parent; protected TrieEntry<K, V> parent;
/** The left child of this entry. */ /** The left child of this entry. */
protected TrieEntry<K,V> left; protected TrieEntry<K, V> left;
/** The right child of this entry. */ /** The right child of this entry. */
protected TrieEntry<K,V> right; protected TrieEntry<K, V> right;
/** The entry who uplinks to this entry. */ /** The entry who uplinks to this entry. */
protected TrieEntry<K,V> predecessor; protected TrieEntry<K, V> predecessor;
public TrieEntry(final K key, final V value, final int bitIndex) { public TrieEntry(final K key, final V value, final int bitIndex) {
super(key, value); super(key, value);
@ -1365,7 +1365,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
buffer.append(", "); buffer.append(", ");
if (predecessor != null) { if (predecessor != null) {
if(predecessor.bitIndex == -1) { if (predecessor.bitIndex == -1) {
buffer.append("predecessor=").append("ROOT"); buffer.append("predecessor=").append("ROOT");
} else { } else {
buffer.append("predecessor=").append(predecessor.getKey()).append(" ["). buffer.append("predecessor=").append(predecessor.getKey()).append(" [").
@ -1382,10 +1382,10 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* This is a entry set view of the {@link Trie} as returned by {@link Map#entrySet()}. * This is a entry set view of the {@link Trie} as returned by {@link Map#entrySet()}.
*/ */
private class EntrySet extends AbstractSet<Map.Entry<K,V>> { private class EntrySet extends AbstractSet<Map.Entry<K, V>> {
@Override @Override
public Iterator<Map.Entry<K,V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
return new EntryIterator(); return new EntryIterator();
} }
@ -1395,7 +1395,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
return false; return false;
} }
final TrieEntry<K,V> candidate = getEntry(((Map.Entry<?, ?>)o).getKey()); final TrieEntry<K, V> candidate = getEntry(((Map.Entry<?, ?>) o).getKey());
return candidate != null && candidate.equals(o); return candidate != null && candidate.equals(o);
} }
@ -1425,9 +1425,9 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* An {@link Iterator} that returns {@link Entry} Objects. * An {@link Iterator} that returns {@link Entry} Objects.
*/ */
private class EntryIterator extends TrieIterator<Map.Entry<K,V>> { private class EntryIterator extends TrieIterator<Map.Entry<K, V>> {
@Override @Override
public Map.Entry<K,V> next() { public Map.Entry<K, V> next() {
return nextEntry(); return nextEntry();
} }
} }
@ -1552,12 +1552,12 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* Returns the next {@link TrieEntry}. * Returns the next {@link TrieEntry}.
*/ */
protected TrieEntry<K,V> nextEntry() { protected TrieEntry<K, V> nextEntry() {
if (expectedModCount != AbstractPatriciaTrie.this.modCount) { if (expectedModCount != AbstractPatriciaTrie.this.modCount) {
throw new ConcurrentModificationException(); throw new ConcurrentModificationException();
} }
final TrieEntry<K,V> e = next; final TrieEntry<K, V> e = next;
if (e == null) { if (e == null) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
@ -1650,12 +1650,12 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
return nextEntry; return nextEntry;
} }
protected TrieEntry<K,V> previousEntry() { protected TrieEntry<K, V> previousEntry() {
if (expectedModCount != AbstractPatriciaTrie.this.modCount) { if (expectedModCount != AbstractPatriciaTrie.this.modCount) {
throw new ConcurrentModificationException(); throw new ConcurrentModificationException();
} }
final TrieEntry<K,V> e = previous; final TrieEntry<K, V> e = previous;
if (e == null) { if (e == null) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
@ -1881,7 +1881,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
@Override @Override
public K firstKey() { public K firstKey() {
Map.Entry<K,V> e = null; Map.Entry<K, V> e = null;
if (fromKey == null) { if (fromKey == null) {
e = firstEntry(); e = firstEntry();
} else { } else {
@ -1901,7 +1901,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
@Override @Override
public K lastKey() { public K lastKey() {
Map.Entry<K,V> e; Map.Entry<K, V> e;
if (toKey == null) { if (toKey == null) {
e = lastEntry(); e = lastEntry();
} else { } else {
@ -1965,7 +1965,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* Creates a {@link RangeEntrySet}. * Creates a {@link RangeEntrySet}.
*/ */
public RangeEntrySet(final RangeMap delegate) { RangeEntrySet(final RangeMap delegate) {
this.delegate = Objects.requireNonNull(delegate, "delegate"); this.delegate = Objects.requireNonNull(delegate, "delegate");
} }
@ -2049,14 +2049,14 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* An {@link Iterator} for {@link RangeEntrySet}s. * An {@link Iterator} for {@link RangeEntrySet}s.
*/ */
private final class EntryIterator extends TrieIterator<Map.Entry<K,V>> { private final class EntryIterator extends TrieIterator<Map.Entry<K, V>> {
private final K excludedKey; private final K excludedKey;
/** /**
* Creates a {@link EntryIterator}. * Creates a {@link EntryIterator}.
*/ */
private EntryIterator(final TrieEntry<K,V> first, final TrieEntry<K,V> last) { private EntryIterator(final TrieEntry<K, V> first, final TrieEntry<K, V> last) {
super(first); super(first);
this.excludedKey = last != null ? last.getKey() : null; this.excludedKey = last != null ? last.getKey() : null;
} }
@ -2067,7 +2067,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
} }
@Override @Override
public Map.Entry<K,V> next() { public Map.Entry<K, V> next() {
if (next == null || compare(next.key, excludedKey)) { if (next == null || compare(next.key, excludedKey)) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
@ -2124,7 +2124,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
fromKey = entry == null ? null : entry.getKey(); fromKey = entry == null ? null : entry.getKey();
if (fromKey != null) { if (fromKey != null) {
final TrieEntry<K, V> prior = previousEntry((TrieEntry<K, V>)entry); final TrieEntry<K, V> prior = previousEntry((TrieEntry<K, V>) entry);
fromKey = prior == null ? null : prior.getKey(); fromKey = prior == null ? null : prior.getKey();
} }
@ -2138,7 +2138,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
toKey = entry == null ? null : entry.getKey(); toKey = entry == null ? null : entry.getKey();
if (toKey != null) { if (toKey != null) {
entry = nextEntry((TrieEntry<K, V>)entry); entry = nextEntry((TrieEntry<K, V>) entry);
toKey = entry == null ? null : entry.getKey(); toKey = entry == null ? null : entry.getKey();
} }
@ -2152,7 +2152,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
public K firstKey() { public K firstKey() {
fixup(); fixup();
Map.Entry<K,V> e = null; Map.Entry<K, V> e = null;
if (fromKey == null) { if (fromKey == null) {
e = firstEntry(); e = firstEntry();
} else { } else {
@ -2171,7 +2171,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
public K lastKey() { public K lastKey() {
fixup(); fixup();
Map.Entry<K,V> e = null; Map.Entry<K, V> e = null;
if (toKey == null) { if (toKey == null) {
e = lastEntry(); e = lastEntry();
} else { } else {
@ -2275,7 +2275,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
/** /**
* Creates a {@link PrefixRangeEntrySet}. * Creates a {@link PrefixRangeEntrySet}.
*/ */
public PrefixRangeEntrySet(final PrefixRangeMap delegate) { PrefixRangeEntrySet(final PrefixRangeMap delegate) {
super(delegate); super(delegate);
this.delegate = delegate; this.delegate = delegate;
} }
@ -2286,14 +2286,14 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
} }
@Override @Override
public Iterator<Map.Entry<K,V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
if (AbstractPatriciaTrie.this.modCount != expectedModCount) { if (AbstractPatriciaTrie.this.modCount != expectedModCount) {
prefixStart = subtree(delegate.prefix, delegate.offsetInBits, delegate.lengthInBits); prefixStart = subtree(delegate.prefix, delegate.offsetInBits, delegate.lengthInBits);
expectedModCount = AbstractPatriciaTrie.this.modCount; expectedModCount = AbstractPatriciaTrie.this.modCount;
} }
if (prefixStart == null) { if (prefixStart == null) {
final Set<Map.Entry<K,V>> empty = Collections.emptySet(); final Set<Map.Entry<K, V>> empty = Collections.emptySet();
return empty.iterator(); return empty.iterator();
} else if (delegate.lengthInBits > prefixStart.bitIndex) { } else if (delegate.lengthInBits > prefixStart.bitIndex) {
return new SingletonIterator(prefixStart); return new SingletonIterator(prefixStart);
@ -2311,7 +2311,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
private int hit = 0; private int hit = 0;
public SingletonIterator(final TrieEntry<K, V> entry) { SingletonIterator(final TrieEntry<K, V> entry) {
this.entry = entry; this.entry = entry;
} }
@ -2368,7 +2368,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
} }
@Override @Override
public Map.Entry<K,V> next() { public Map.Entry<K, V> next() {
final Map.Entry<K, V> entry = nextEntry(); final Map.Entry<K, V> entry = nextEntry();
if (lastOne) { if (lastOne) {
next = null; next = null;
@ -2419,7 +2419,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
stream.defaultReadObject(); stream.defaultReadObject();
root = new TrieEntry<>(null, null, -1); root = new TrieEntry<>(null, null, -1);
final int size = stream.readInt(); final int size = stream.readInt();
for(int i = 0; i < size; i++){ for (int i = 0; i < size; i++){
final K k = (K) stream.readObject(); final K k = (K) stream.readObject();
final V v = (V) stream.readObject(); final V v = (V) stream.readObject();
put(k, v); put(k, v);

View File

@ -74,7 +74,7 @@ public class StringKeyAnalyzer extends KeyAnalyzer<String> {
// then figure out which bit makes the difference // then figure out which bit makes the difference
// and return it. // and return it.
char k = 0, f = 0; char k = 0, f = 0;
for(int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
final int index1 = beginIndex1 + i; final int index1 = beginIndex1 + i;
final int index2 = beginIndex2 + i; final int index2 = beginIndex2 + i;

View File

@ -1,13 +1,13 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. --> language governing permissions and limitations under the License. -->
<document> <document>
@ -442,7 +442,7 @@ hadoopBloomFilter.add( new Key( "pear".getBytes () ) ); ]]></source>
</li> </li>
</ol> </ol>
<subsection id="S2.SS1" <subsection id="S2.SS1"
name="2.1 Exploring the HashFunctionIdentity name="2.1 Exploring the HashFunctionIdentity
and HashFunction"> and HashFunction">
<p> <p>
@ -961,7 +961,7 @@ for ( Map.Entry < BloomFilter , Collection < T >> entry : shards ) {
} }
} }
} }
// result is either null or contains the desired value. // result is either null or contains the desired value.
]]></source> ]]></source>
</subsection> </subsection>
<subsection id="S3.SS3" name="3.3 Future directions"> <subsection id="S3.SS3" name="3.3 Future directions">
@ -1134,4 +1134,4 @@ for ( Map.Entry < BloomFilter , Collection < T >> entry : shards ) {
</section> </section>
</body> </body>
</document> </document>

View File

@ -104,10 +104,10 @@ Notably MultiValueMap is a new more flexible implementation of MultiHashMap.
</p> </p>
<p> <p>
<b>Collections 3.2.2</b> Serialization support for unsafe classes in the functor package is disabled by default as <b>Collections 3.2.2</b> Serialization support for unsafe classes in the functor package is disabled by default as
this can be exploited for remote code execution attacks. To re-enable the feature the system property this can be exploited for remote code execution attacks. To re-enable the feature the system property
"org.apache.commons.collections.enableUnsafeSerialization" needs to be set to "true". Classes considered to be "org.apache.commons.collections.enableUnsafeSerialization" needs to be set to "true". Classes considered to be
unsafe are: CloneTransformer, ForClosure, InstantiateFactory, InstantiateTransformer, InvokerTransformer, unsafe are: CloneTransformer, ForClosure, InstantiateFactory, InstantiateTransformer, InvokerTransformer,
PrototypeCloneFactory, PrototypeSerializationFactory, WhileClosure. Fixes COLLECTIONS-580. Other bug fixes as well. PrototypeCloneFactory, PrototypeSerializationFactory, WhileClosure. Fixes COLLECTIONS-580. Other bug fixes as well.
</p> </p>
@ -130,11 +130,11 @@ API for Iterable instances (FluentIterable).
</p> </p>
<p> <p>
Additionally, serialization support for unsafe classes in the functor package Additionally, serialization support for unsafe classes in the functor package
has been completely removed (see entry for Collections 3.2.2 for more details). has been completely removed (see entry for Collections 3.2.2 for more details).
</p> </p>
<p> <p>
<b>Collections 4.2</b> fixes some bugs in 4.1 and adds a few new enhancements: <b>Collections 4.2</b> fixes some bugs in 4.1 and adds a few new enhancements:
Updates the platform requirement from Java 6 to 7, Updates the platform requirement from Java 6 to 7,
adds Automatic-Module-Name MANIFEST entry for Java 9 compatibility, and adds Automatic-Module-Name MANIFEST entry for Java 9 compatibility, and
adds a few new APIs. adds a few new APIs.

View File

@ -33,18 +33,18 @@ Commons-Collections and the Java Collections Framework provide a wide variety of
<script> <script>
<![CDATA[ <![CDATA[
function showHide(showObj,hideObj) { function showHide(showObj,hideObj) {
if (document.getElementById) { // DOM3 = IE5, NS6 if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(showObj).style.display='block'; document.getElementById(showObj).style.display='block';
document.getElementById(hideObj).style.display='none'; document.getElementById(hideObj).style.display='none';
} else { } else {
if (document.layers) { // Netscape 4 if (document.layers) { // Netscape 4
document.layers[showObj].display='block'; document.layers[showObj].display='block';
document.layers[hideObj].display='none'; document.layers[hideObj].display='none';
} else { // IE 4 } else { // IE 4
eval("document.all."+showObj+".style.display='block'"); eval("document.all."+showObj+".style.display='block'");
eval("document.all."+hideObj+".style.display='none'"); eval("document.all."+hideObj+".style.display='none'");
} }
} }
} }
function showMapMain() { function showMapMain() {
showHide('mapmain','collectionmain'); showHide('mapmain','collectionmain');

View File

@ -44,8 +44,8 @@ All users are strongly encouraged to updated to this release.
<h3>Compatibility</h3> <h3>Compatibility</h3>
<p> <p>
This release is fully source and binary compatible with 3.2. For changes since the This release is fully source and binary compatible with 3.2. For changes since the
3.1 release see the <a href="release_3_2.html">3.2 Release Notes</a>. Note that the method 3.1 release see the <a href="release_3_2.html">3.2 Release Notes</a>. Note that the method
'protected java.util.Set createSetBasedOnList(java.util.Set, java.util.List)' has been 'protected java.util.Set createSetBasedOnList(java.util.Set, java.util.List)' has been
added. added.
</p> </p>

View File

@ -76,7 +76,7 @@ have changed.
<li>BoundedBuffer: use either ArrayBlockingBuffer(capacity) or LinkedBlockingBuffer(capacity) in java.util.concurrent</li> <li>BoundedBuffer: use either ArrayBlockingBuffer(capacity) or LinkedBlockingBuffer(capacity) in java.util.concurrent</li>
<li>UnboundedFifoBuffer: use either java.util.LinkedList or java.util.concurrent.LinkedBlockingBuffer</li> <li>UnboundedFifoBuffer: use either java.util.LinkedList or java.util.concurrent.LinkedBlockingBuffer</li>
</ul> </ul>
</li> </li>
<li>Removed features now supported by the JDK or other Apache Commons libraries <li>Removed features now supported by the JDK or other Apache Commons libraries
<ul> <ul>
<li>FastArrayList: use java.util.concurrent.CopyOnWriteArrayList</li> <li>FastArrayList: use java.util.concurrent.CopyOnWriteArrayList</li>
@ -126,20 +126,20 @@ have changed.
<li>CollectionUtils#isEqualCollection(Collection, Collection, Equator). Thanks to Matt Lachman.</li> <li>CollectionUtils#isEqualCollection(Collection, Collection, Equator). Thanks to Matt Lachman.</li>
<li>*Utils#emptyIfNull(*) methods in classes CollectionUtils, ListUtils, SetUtils and MapUtils. Thanks to Arman Sharif.</li> <li>*Utils#emptyIfNull(*) methods in classes CollectionUtils, ListUtils, SetUtils and MapUtils. Thanks to Arman Sharif.</li>
<li>CollectionUtils#containsAll(Collection, Collection) with guaranteed runtime complexity of O(n + m) and space complexity of O(n). This method may yield much better performance than Collection.containsAll(Collection) depending on the use-case and type of collection used. Thanks to Adrian Nistor, Mert Guldur.</li> <li>CollectionUtils#containsAll(Collection, Collection) with guaranteed runtime complexity of O(n + m) and space complexity of O(n). This method may yield much better performance than Collection.containsAll(Collection) depending on the use-case and type of collection used. Thanks to Adrian Nistor, Mert Guldur.</li>
<li>CollectionUtils#permutations(Collection) to generate all permutations of a collection. Thanks to Benoit Corne.</li> <li>CollectionUtils#permutations(Collection) to generate all permutations of a collection. Thanks to Benoit Corne.</li>
<li>ListUtils#select() and ListUtils#selectRejected() methods. Thanks to Adam Dyga.</li> <li>ListUtils#select() and ListUtils#selectRejected() methods. Thanks to Adam Dyga.</li>
<li>ListUtils#partition() to split a List into consecutive sublists. Thanks to Chris Shayan.</li> <li>ListUtils#partition() to split a List into consecutive sublists. Thanks to Chris Shayan.</li>
<li>CollectionUtils#forAllDo(Iterator, Closure). Thanks to Adrian Cumiskey.</li> <li>CollectionUtils#forAllDo(Iterator, Closure). Thanks to Adrian Cumiskey.</li>
<li>ListUtils#defaultIfNull(List, List). Thanks to Ivan Hristov.</li> <li>ListUtils#defaultIfNull(List, List). Thanks to Ivan Hristov.</li>
<li>CollectionUtils#filterInverse(Iterable, Predicate). Thanks to Jean-Noel Rouvignac.</li> <li>CollectionUtils#filterInverse(Iterable, Predicate). Thanks to Jean-Noel Rouvignac.</li>
<li>CollectionUtils#subtract(Iterable, Iterable, Predicate). Thanks to Chris Shayan.</li> <li>CollectionUtils#subtract(Iterable, Iterable, Predicate). Thanks to Chris Shayan.</li>
<li>CollectionUtils#collate(...) to merge two sorted Collections using the standard O(n) merge algorithm. Thanks to Julius Davies.</li> <li>CollectionUtils#collate(...) to merge two sorted Collections using the standard O(n) merge algorithm. Thanks to Julius Davies.</li>
<li>CollectionUtils#extractSingleton(Collection). Thanks to Geoffrey De Smet.</li> <li>CollectionUtils#extractSingleton(Collection). Thanks to Geoffrey De Smet.</li>
<li>MapUtils#populateMap(MultiMap, ...) to support also "MultiMap" instances as input. Thanks to John Hunsley.</li> <li>MapUtils#populateMap(MultiMap, ...) to support also "MultiMap" instances as input. Thanks to John Hunsley.</li>
<li>ListUtils#indexOf(List, Predicate). Thanks to Nathan Egge.</li> <li>ListUtils#indexOf(List, Predicate). Thanks to Nathan Egge.</li>
<li>MapUtils#populateMap(Map, Iterable, Transformer, ...). Thanks to Dave Meikle.</li> <li>MapUtils#populateMap(Map, Iterable, Transformer, ...). Thanks to Dave Meikle.</li>
<li>Added new method "get(int)" to "CircularFifoQueue". Thanks to Sebb.</li> <li>Added new method "get(int)" to "CircularFifoQueue". Thanks to Sebb.</li>
<li>Added serialVersionUID fields for "CompositeCollection", "CompositeSet", "EmptyMapMutator", "EmptySetMutator". Thanks to sebb.</li> <li>Added serialVersionUID fields for "CompositeCollection", "CompositeSet", "EmptyMapMutator", "EmptySetMutator". Thanks to sebb.</li>
<li>Added support for using custom "Equator" objects in "EqualPredicate". Thanks to Stephen Kestle.</li> <li>Added support for using custom "Equator" objects in "EqualPredicate". Thanks to Stephen Kestle.</li>
<li>Added method "CollatingIterator#getIteratorIndex()". Thanks to Fredrik Kjellberg.</li> <li>Added method "CollatingIterator#getIteratorIndex()". Thanks to Fredrik Kjellberg.</li>
<li>Added serialization support for "TreeBidiMap". Thanks to Christian Gruenberg.</li> <li>Added serialization support for "TreeBidiMap". Thanks to Christian Gruenberg.</li>
@ -161,7 +161,7 @@ have changed.
<li>Renamed "V MultiMap#remove(K, V)" to "boolean MultiMap#removeMapping(K, V)" <li>Renamed "V MultiMap#remove(K, V)" to "boolean MultiMap#removeMapping(K, V)"
to avoid future conflicts with a default method of the Map interface in Java 8.</li> to avoid future conflicts with a default method of the Map interface in Java 8.</li>
<li>Refactored the test framework for Bag implementations to extend from "AbstractCollectionTest" by decorating <li>Refactored the test framework for Bag implementations to extend from "AbstractCollectionTest" by decorating
the concrete Bag instance with a CollectionBag or CollectionSortedBag.</li> the concrete Bag instance with a CollectionBag or CollectionSortedBag.</li>
<li>"UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable" <li>"UnmodifiableBoundedCollection" does now also implement the marker interface "Unmodifiable"
similar as all other unmodifiable decorators.</li> similar as all other unmodifiable decorators.</li>
<li>"UnmodifiableTrie#unmodifiableTrie(Trie)" will not decorate again an already unmodifiable Trie. <li>"UnmodifiableTrie#unmodifiableTrie(Trie)" will not decorate again an already unmodifiable Trie.
@ -213,66 +213,66 @@ have changed.
<li>Tree traversal with a TreeListIterator will not be affected anymore by the removal of an element directly after a call to previous(). Thanks to Jeffrey Barnes.</li> <li>Tree traversal with a TreeListIterator will not be affected anymore by the removal of an element directly after a call to previous(). Thanks to Jeffrey Barnes.</li>
<li>Adapt and/or ignore several unit tests when run on a IBM J9 VM (specification version 1.6.0) due to a faulty "java.util.TreeMap" implementation.</li> <li>Adapt and/or ignore several unit tests when run on a IBM J9 VM (specification version 1.6.0) due to a faulty "java.util.TreeMap" implementation.</li>
<li>SetUniqueList.set(int, E) now works correctly if the object to be inserted is already placed at the given position. Thanks to Thomas Vahrst, John Vasileff.</li> <li>SetUniqueList.set(int, E) now works correctly if the object to be inserted is already placed at the given position. Thanks to Thomas Vahrst, John Vasileff.</li>
<li>MultiKeyMap.clone() now correctly calls super.clone(). Thanks to Thomas Vahrst.</li> <li>MultiKeyMap.clone() now correctly calls super.clone(). Thanks to Thomas Vahrst.</li>
<li>Improve performance of "TreeList#addAll" and "TreeList(Collection)" by converting the input collection into an AVL tree and efficiently merge it into the existing tree. Thanks to Jeffrey Barnes.</li> <li>Improve performance of "TreeList#addAll" and "TreeList(Collection)" by converting the input collection into an AVL tree and efficiently merge it into the existing tree. Thanks to Jeffrey Barnes.</li>
<li>Fixed performance issue in "SetUniqueList#retainAll" method for large collections. Thanks to Mert Guldur.</li> <li>Fixed performance issue in "SetUniqueList#retainAll" method for large collections. Thanks to Mert Guldur.</li>
<li>Fixed performance issue in "ListOrderedSet#retainAll" method for large collections. Thanks to Adrian Nistor.</li> <li>Fixed performance issue in "ListOrderedSet#retainAll" method for large collections. Thanks to Adrian Nistor.</li>
<li>Improved performance of "ListOrderedMap#remove(Object)" method. Thanks to Adrian Nistor.</li> <li>Improved performance of "ListOrderedMap#remove(Object)" method. Thanks to Adrian Nistor.</li>
<li>Update javadoc for "ListUtils#lazyList()" and "ListUtils#fixedSizeList()". Thanks to Benedikt Ritter.</li> <li>Update javadoc for "ListUtils#lazyList()" and "ListUtils#fixedSizeList()". Thanks to Benedikt Ritter.</li>
<li>Added clarifying javadoc wrt runtime complexity of "AbstractDualBidiMap#retainAll". Thanks to Adrian Nistor.</li> <li>Added clarifying javadoc wrt runtime complexity of "AbstractDualBidiMap#retainAll". Thanks to Adrian Nistor.</li>
<li>Added clarifying javadoc wrt runtime complexity of "AbstractLinkedList#retainAll". Thanks to Adrian Nistor.</li> <li>Added clarifying javadoc wrt runtime complexity of "AbstractLinkedList#retainAll". Thanks to Adrian Nistor.</li>
<li>Added clarifying javadoc wrt runtime complexity of "AbstractLinkedList#removeAll". Thanks to Adrian Nistor.</li> <li>Added clarifying javadoc wrt runtime complexity of "AbstractLinkedList#removeAll". Thanks to Adrian Nistor.</li>
<li>Fixed several compilation issues with older Java 1.6 compilers.</li> <li>Fixed several compilation issues with older Java 1.6 compilers.</li>
<li>Improved performance of "removeAll()" method for sets returned by "DualHashBidiMap#entrySet()". Thanks to Adrian Nistor.</li> <li>Improved performance of "removeAll()" method for sets returned by "DualHashBidiMap#entrySet()". Thanks to Adrian Nistor.</li>
<li>Improved performance of "CollectionUtils#subtract" methods. Thanks to Adrian Nistor.</li> <li>Improved performance of "CollectionUtils#subtract" methods. Thanks to Adrian Nistor.</li>
<li>Fixed possible "IndexOutOfBoundsException" in "ListOrderedMap#putAll". Thanks to Adrian Nistor.</li> <li>Fixed possible "IndexOutOfBoundsException" in "ListOrderedMap#putAll". Thanks to Adrian Nistor.</li>
<li>Improved performance of "SetUniqueList#addAll" method. Thanks to Adrian Nistor.</li> <li>Improved performance of "SetUniqueList#addAll" method. Thanks to Adrian Nistor.</li>
<li>Improved performance of "ListOrderedSet#addAll" method. Thanks to Adrian Nistor.</li> <li>Improved performance of "ListOrderedSet#addAll" method. Thanks to Adrian Nistor.</li>
<li>Improved performance of "SetUniqueList#removeAll". Thanks to Adrian Nistor.</li> <li>Improved performance of "SetUniqueList#removeAll". Thanks to Adrian Nistor.</li>
<li>Improved performance of "ListOrderedSet#remove(Object)" in case the object is not contained in the Set. Thanks to Adrian Nistor.</li> <li>Improved performance of "ListOrderedSet#remove(Object)" in case the object is not contained in the Set. Thanks to Adrian Nistor.</li>
<li>Improved performance of "ListUtils#subtract" method. Thanks to Adrian Nistor.</li> <li>Improved performance of "ListUtils#subtract" method. Thanks to Adrian Nistor.</li>
<li>Added missing null check in "CollectionUtils#addIgnoreNull(Collection, Object)". Thanks to Shin Hwei Tan.</li> <li>Added missing null check in "CollectionUtils#addIgnoreNull(Collection, Object)". Thanks to Shin Hwei Tan.</li>
<li>Fixed javadoc for "MapUtils#toProperties(Map)". Thanks to Shin Hwei Tan.</li> <li>Fixed javadoc for "MapUtils#toProperties(Map)". Thanks to Shin Hwei Tan.</li>
<li>Clarified javadoc for "TransformerUtils#mapTransformer" for null input. Thanks to Shin Hwei Tan.</li> <li>Clarified javadoc for "TransformerUtils#mapTransformer" for null input. Thanks to Shin Hwei Tan.</li>
<li>Clarified javadoc for "FactoryUtils#prototypeFactory" for null input. Thanks to Shin Hwei Tan.</li> <li>Clarified javadoc for "FactoryUtils#prototypeFactory" for null input. Thanks to Shin Hwei Tan.</li>
<li>Fixed inconsistent javadoc for "MapUtils#synchronizedMap(Map)". Thanks to Shin Hwei Tan.</li> <li>Fixed inconsistent javadoc for "MapUtils#synchronizedMap(Map)". Thanks to Shin Hwei Tan.</li>
<li>Fixed infinite loop when calling "UnmodifiableBoundedCollection#unmodifiableBoundedCollection()". Thanks to Dave Brosius.</li> <li>Fixed infinite loop when calling "UnmodifiableBoundedCollection#unmodifiableBoundedCollection()". Thanks to Dave Brosius.</li>
<li>Fixed javadoc for several methods wrt expected NullPointerExceptions. Thanks to Shin Hwei Tan.</li> <li>Fixed javadoc for several methods wrt expected NullPointerExceptions. Thanks to Shin Hwei Tan.</li>
<li>"DualTreeBidiMap" now uses the correct comparator for the reverse map during de-serialization.</li> <li>"DualTreeBidiMap" now uses the correct comparator for the reverse map during de-serialization.</li>
<li>"TransformedMap" in the package "splitmap" can now be serialized.</li> <li>"TransformedMap" in the package "splitmap" can now be serialized.</li>
<li>"FilterListIterator#hasNext" does not throw a NullPointerException anymore to comply to the Java iterator specification. Thanks to Sai Zhang.</li> <li>"FilterListIterator#hasNext" does not throw a NullPointerException anymore to comply to the Java iterator specification. Thanks to Sai Zhang.</li>
<li>"ListUtils#intersection(List, List)" will now also work correctly if there are duplicate elements in the provided lists. Thanks to Mark Shead.</li> <li>"ListUtils#intersection(List, List)" will now also work correctly if there are duplicate elements in the provided lists. Thanks to Mark Shead.</li>
<li>"AbstractCollectionDecorator" will now use internally "decorated()" to access the decorated collection. Thanks to Adam Gent.</li> <li>"AbstractCollectionDecorator" will now use internally "decorated()" to access the decorated collection. Thanks to Adam Gent.</li>
<li>Removed debug output in "MapUtils#getNumber(Map)". Thanks to Michael Akerman.</li> <li>Removed debug output in "MapUtils#getNumber(Map)". Thanks to Michael Akerman.</li>
<li>Fixed javadoc for all "transformedXXX(XXX)" methods in the respective Utils classes to clarify that existing objects in the list are not transformed. Thanks to Paul Benedict.</li> <li>Fixed javadoc for all "transformedXXX(XXX)" methods in the respective Utils classes to clarify that existing objects in the list are not transformed. Thanks to Paul Benedict.</li>
<li>Singleton classes in package "functors" are now correctly de-serialized. Thanks to Goran Hacek.</li> <li>Singleton classes in package "functors" are now correctly de-serialized. Thanks to Goran Hacek.</li>
<li>Removed broken methods "equals(Object)" and "hashCode()" in class "NOPClosure". Thanks to Goran Hacek.</li> <li>Removed broken methods "equals(Object)" and "hashCode()" in class "NOPClosure". Thanks to Goran Hacek.</li>
<li>Simplified exceptions as the cause is available from the parent. Thanks to sebb.</li> <li>Simplified exceptions as the cause is available from the parent. Thanks to sebb.</li>
<li>Fixed cache assignment for "TreeBidiMap#entrySet". Thanks to sebb.</li> <li>Fixed cache assignment for "TreeBidiMap#entrySet". Thanks to sebb.</li>
<li>Synchronized access to lock in "StaticBucketMap#size()". Thanks to sebb.</li> <li>Synchronized access to lock in "StaticBucketMap#size()". Thanks to sebb.</li>
<li>Added clarification to javadoc of "ListOrderedMap" that "IdentityMap" and "CaseInsensitiveMap" are not supported. Thanks to Tom Parker.</li> <li>Added clarification to javadoc of "ListOrderedMap" that "IdentityMap" and "CaseInsensitiveMap" are not supported. Thanks to Tom Parker.</li>
<li>Improve javadoc of "CollatingIterator" wrt the used "Comparator" and throw a NullPointerException in "CollatingIterator#least" if no comparator is set. Thanks to Michael Krkoska.</li> <li>Improve javadoc of "CollatingIterator" wrt the used "Comparator" and throw a NullPointerException in "CollatingIterator#least" if no comparator is set. Thanks to Michael Krkoska.</li>
<li>"LRUMap#keySet()#remove(Object)" will not throw a "ConcurrentModificationException" anymore. Thanks to Joerg Schaible.</li> <li>"LRUMap#keySet()#remove(Object)" will not throw a "ConcurrentModificationException" anymore. Thanks to Joerg Schaible.</li>
<li>Improved performance of "ListUtils#intersection(List, List)". Thanks to Thomas Rogan, Jilles van Gurp.</li> <li>Improved performance of "ListUtils#intersection(List, List)". Thanks to Thomas Rogan, Jilles van Gurp.</li>
<li>Changed behavior of "CaseInsensitiveMap" constructor to be compliant with "HashMap" in case the initial capacity is set to zero. Thanks to Maarten Brak.</li> <li>Changed behavior of "CaseInsensitiveMap" constructor to be compliant with "HashMap" in case the initial capacity is set to zero. Thanks to Maarten Brak.</li>
<li>Improved performance of "StaticBucketMap#putAll(Map)" by iterating over the entry set. Thanks to sebb.</li> <li>Improved performance of "StaticBucketMap#putAll(Map)" by iterating over the entry set. Thanks to sebb.</li>
<li>Avoid redundant null check in "IteratorUtils#getIterator(Object)". Thanks to sebb.</li> <li>Avoid redundant null check in "IteratorUtils#getIterator(Object)". Thanks to sebb.</li>
<li>Use a private method to populate the object in "AbstractHashedMap(Map)". Thanks to sebb.</li> <li>Use a private method to populate the object in "AbstractHashedMap(Map)". Thanks to sebb.</li>
<li>Fixed javadoc of "LRUMap" wrt to the maxSize parameter of the constructor. Thanks to ori.</li> <li>Fixed javadoc of "LRUMap" wrt to the maxSize parameter of the constructor. Thanks to ori.</li>
<li>Use of final keyword where applicable, minor performance improvements by properly initializing the capacity of newly created collections when known in advance. Thanks to Peter Lawrey, Gary Gregory.</li> <li>Use of final keyword where applicable, minor performance improvements by properly initializing the capacity of newly created collections when known in advance. Thanks to Peter Lawrey, Gary Gregory.</li>
<li>"SetUniqueList#subList()#contains(Object)" will now correctly check the subList rather than the parent list. Thanks to Christian Semrau.</li> <li>"SetUniqueList#subList()#contains(Object)" will now correctly check the subList rather than the parent list. Thanks to Christian Semrau.</li>
<li>"SetUniqueList#set(int, Object)" will now correctly enforce the uniqueness constraint. Thanks to Rafał Figas,Bjorn Townsend.</li> <li>"SetUniqueList#set(int, Object)" will now correctly enforce the uniqueness constraint. Thanks to Rafał Figas,Bjorn Townsend.</li>
<li>Improved javadoc for "Unmodifiable*" classes wrt behavior when the users tries to modify the collection. Thanks to Emmanuel Bourg.</li> <li>Improved javadoc for "Unmodifiable*" classes wrt behavior when the users tries to modify the collection. Thanks to Emmanuel Bourg.</li>
<li>"CaseInsensitiveMap" will now convert input strings to lower-case in a locale-independant manner. Thanks to Benjamin Bentmann.</li> <li>"CaseInsensitiveMap" will now convert input strings to lower-case in a locale-independant manner. Thanks to Benjamin Bentmann.</li>
<li>Fixed javadoc for "ListUtils#transformedList(List)" to clarify that existing objects in the list are not transformed. Thanks to Paul Benedict.</li> <li>Fixed javadoc for "ListUtils#transformedList(List)" to clarify that existing objects in the list are not transformed. Thanks to Paul Benedict.</li>
<li>"MultiKey" will now be correctly serialized/de-serialized. Thanks to Joerg Schaible.</li> <li>"MultiKey" will now be correctly serialized/de-serialized. Thanks to Joerg Schaible.</li>
<li>Fixed javadoc for methods "firstKey()" and "lastKey()" in class "AbstractLinkedMap". Thanks to Lisen Mu.</li> <li>Fixed javadoc for methods "firstKey()" and "lastKey()" in class "AbstractLinkedMap". Thanks to Lisen Mu.</li>
<li>"Flat3Map#remove(Object)" will now return the correct value mapped to the removed key if the size of the map is less or equal 3. Thanks to ori.</li> <li>"Flat3Map#remove(Object)" will now return the correct value mapped to the removed key if the size of the map is less or equal 3. Thanks to ori.</li>
<li>Removed unused variables in "TreeBidiMap". Thanks to Henri Yandell.</li> <li>Removed unused variables in "TreeBidiMap". Thanks to Henri Yandell.</li>
<li>"SetUniqueList.addAll(int, Collection)" now correctly add the collection at the provided index. Thanks to Joe Kelly.</li> <li>"SetUniqueList.addAll(int, Collection)" now correctly add the collection at the provided index. Thanks to Joe Kelly.</li>
<li>Fixed several unit tests which were using parameters to "assertEquals(...)" in wrong order. Thanks to Mark Hindess.</li> <li>Fixed several unit tests which were using parameters to "assertEquals(...)" in wrong order. Thanks to Mark Hindess.</li>
<li>"MultiValueMap#put(Object, Object)" and "MultiValueMap#putAll(Object, Collection)" now correctly return if the map has changed by this operation.</li> <li>"MultiValueMap#put(Object, Object)" and "MultiValueMap#putAll(Object, Collection)" now correctly return if the map has changed by this operation.</li>
<li>"CollectionUtils#removeAll" wrongly called "ListUtils#retainAll". Thanks to Tom Leccese.</li> <li>"CollectionUtils#removeAll" wrongly called "ListUtils#retainAll". Thanks to Tom Leccese.</li>
<li>Calling "setValue(Object)" on any Entry returned by a "Flat3Map" will now correctly set the value for the current entry. Thanks to Matt Bishop.</li> <li>Calling "setValue(Object)" on any Entry returned by a "Flat3Map" will now correctly set the value for the current entry. Thanks to Matt Bishop.</li>
<li>"MultiKey#toString()" will now use "Arrays#toString(List)". Thanks to Hendrik Maryns.</li> <li>"MultiKey#toString()" will now use "Arrays#toString(List)". Thanks to Hendrik Maryns.</li>
</ul> </ul>

View File

@ -29,8 +29,8 @@ Apache Commons Collections is a project to develop and maintain collection
classes based on and inspired by the JDK collection framework. classes based on and inspired by the JDK collection framework.
</p> </p>
<p> <p>
This 4.2 release is a minor and updates the platform requirement from Java 6 to 7. This 4.2 release is a minor and updates the platform requirement from Java 6 to 7.
This release fixes several bugs present in previous releases of the 4.X branch. This release fixes several bugs present in previous releases of the 4.X branch.
</p> </p>
<p> <p>
All users are strongly encouraged to updated to this release. All users are strongly encouraged to updated to this release.

View File

@ -55,7 +55,7 @@
<subsection name="Fixed in Apache Commons Collections 3.2.2 and 4.1"> <subsection name="Fixed in Apache Commons Collections 3.2.2 and 4.1">
<p><b>High: Remote Code Execution during object de-serialization</b></p> <p><b>High: Remote Code Execution during object de-serialization</b></p>
<p>The Apache Commons Collections library contains various classes <p>The Apache Commons Collections library contains various classes
in the "functor" package which are serializable and use reflection. in the "functor" package which are serializable and use reflection.
This can be exploited for remote code execution attacks by injecting This can be exploited for remote code execution attacks by injecting
@ -64,9 +64,9 @@
library in their classpath and do not perform any kind of input library in their classpath and do not perform any kind of input
validation.</p> validation.</p>
<p>The implemented fix can be tracked via its related issue <p>The implemented fix can be tracked via its related issue
<a href="https://issues.apache.org/jira/browse/COLLECTIONS-580">COLLECTIONS-580</a>:</p> <a href="https://issues.apache.org/jira/browse/COLLECTIONS-580">COLLECTIONS-580</a>:</p>
<ul> <ul>
<li><b>3.2.2</b>: de-serialization of unsafe classes in the functor package <li><b>3.2.2</b>: de-serialization of unsafe classes in the functor package
will trigger an "UnsupportedOperationException" by default. In order to re-enable will trigger an "UnsupportedOperationException" by default. In order to re-enable
@ -83,11 +83,11 @@
problems prior to their publication. No CVE id was assigned for the Apache Commons problems prior to their publication. No CVE id was assigned for the Apache Commons
Collections library, please refer to [1] or [2] for more information about the general Collections library, please refer to [1] or [2] for more information about the general
problem with Java serialization.</p> problem with Java serialization.</p>
<p>Affects: 3.0 - 4.0</p> <p>Affects: 3.0 - 4.0</p>
<p>Related links:</p> <p>Related links:</p>
<ol> <ol>
<li>Vulnerability Report for Oracle Weblogic Server: <li>Vulnerability Report for Oracle Weblogic Server:
<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4852">CVE-2015-4852</a></li> <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4852">CVE-2015-4852</a></li>

View File

@ -44,18 +44,18 @@ This document highlights some key features to get you started.
</ul> </ul>
<subsection name='Note On Synchronization'> <subsection name='Note On Synchronization'>
<p> <p>
Commons-collections uses a design approach to synchronization similar Commons-collections uses a design approach to synchronization similar
to the standard Java collections. The majority of the various implementations to the standard Java collections. The majority of the various implementations
of collections, maps and bags are not thread safe without additional of collections, maps and bags are not thread safe without additional
synchronization. The appropriate <code>synchronizeXXX</code> method on <code>Collections</code> is one way that these implementations can be synchronized for use in a synchronization. The appropriate <code>synchronizeXXX</code> method on <code>Collections</code> is one way that these implementations can be synchronized for use in a
multithreaded application. multithreaded application.
</p> </p>
<p> <p>
The class level javadocs should indicate whether a particular The class level javadocs should indicate whether a particular
implementation is safe for multithreaded access without additional implementation is safe for multithreaded access without additional
synchronization. Where there is no expicit indication that the implementation synchronization. Where there is no expicit indication that the implementation
is thread safe then it should be assumed that synchronization is required. is thread safe then it should be assumed that synchronization is required.
Please report the missing documentation to the commons development team. Please report the missing documentation to the commons development team.
</p> </p>
</subsection> </subsection>
@ -69,7 +69,7 @@ Thus, the <code>Set</code> and <code>SortedSet</code> interfaces are provided fo
These classes provide useful methods for working with that collection type. These classes provide useful methods for working with that collection type.
</p> </p>
<p> <p>
The most methods are found on the two 'root' collection utility classes - The most methods are found on the two 'root' collection utility classes -
<code>CollectionUtils</code> and <code>MapUtils.</code> <code>CollectionUtils</code> and <code>MapUtils.</code>
As all other collection interfaces extend <code>Collection</code> or <code>Map</code> these utilities can be used widely. As all other collection interfaces extend <code>Collection</code> or <code>Map</code> these utilities can be used widely.
They include intersection, counting, iteration, functor and typecasting operations amongst others. They include intersection, counting, iteration, functor and typecasting operations amongst others.
@ -92,7 +92,7 @@ MapIterator it = map.mapIterator();
while (it.hasNext()) { while (it.hasNext()) {
Object key = it.next(); Object key = it.next();
Object value = it.getValue(); Object value = it.getValue();
it.setValue(newValue); it.setValue(newValue);
} }
</source> </source>

View File

@ -76,7 +76,7 @@ public class BagUtilsTest {
assertTrue("Returned object should be a PredicatedBag.", assertTrue("Returned object should be a PredicatedBag.",
bag instanceof PredicatedBag); bag instanceof PredicatedBag);
try { try {
BagUtils.predicatedBag(null,truePredicate); BagUtils.predicatedBag(null, truePredicate);
fail("Expecting NullPointerException for null bag."); fail("Expecting NullPointerException for null bag.");
} catch (final NullPointerException ex) { } catch (final NullPointerException ex) {
// expected // expected

View File

@ -287,7 +287,7 @@ class BulkTestSuiteMaker {
* *
* @param startingClass the starting class * @param startingClass the starting class
*/ */
public BulkTestSuiteMaker(final Class<? extends BulkTest> startingClass) { BulkTestSuiteMaker(final Class<? extends BulkTest> startingClass) {
this.startingClass = startingClass; this.startingClass = startingClass;
} }
@ -340,7 +340,7 @@ class BulkTestSuiteMaker {
* @param m The simple test method * @param m The simple test method
*/ */
void addTest(final BulkTest bulk, final Method m) { void addTest(final BulkTest bulk, final Method m) {
final BulkTest bulk2 = (BulkTest)bulk.clone(); final BulkTest bulk2 = (BulkTest) bulk.clone();
bulk2.setName(m.getName()); bulk2.setName(m.getName());
bulk2.verboseName = prefix + "." + m.getName(); bulk2.verboseName = prefix + "." + m.getName();
if (ignored.contains(bulk2.verboseName)) { if (ignored.contains(bulk2.verboseName)) {
@ -366,7 +366,7 @@ class BulkTestSuiteMaker {
BulkTest bulk2; BulkTest bulk2;
try { try {
bulk2 = (BulkTest)m.invoke(bulk, (Object[]) null); bulk2 = (BulkTest) m.invoke(bulk, (Object[]) null);
if (bulk2 == null) { if (bulk2 == null) {
return; return;
} }

View File

@ -652,7 +652,7 @@ public class CollectionUtilsTest extends MockTestCase {
testPredicate = equalPredicate((Number) 45); testPredicate = equalPredicate((Number) 45);
test = CollectionUtils.find(collectionA, testPredicate); test = CollectionUtils.find(collectionA, testPredicate);
assertTrue(test == null); assertTrue(test == null);
assertNull(CollectionUtils.find(null,testPredicate)); assertNull(CollectionUtils.find(null, testPredicate));
assertNull(CollectionUtils.find(collectionA, null)); assertNull(CollectionUtils.find(collectionA, null));
} }
@ -1276,7 +1276,7 @@ public class CollectionUtilsTest extends MockTestCase {
assertTrue(collection.contains(2L) && !collection.contains(1)); assertTrue(collection.contains(2L) && !collection.contains(1));
} }
Transformer<Object, Integer> TRANSFORM_TO_INTEGER = input -> Integer.valueOf(((Long)input).intValue()); Transformer<Object, Integer> TRANSFORM_TO_INTEGER = input -> Integer.valueOf(((Long) input).intValue());
@Test @Test
public void transform1() { public void transform1() {
@ -1741,27 +1741,27 @@ public class CollectionUtilsTest extends MockTestCase {
assertTrue(collectionA.contains(5)); assertTrue(collectionA.contains(5));
} }
@Test(expected=IndexOutOfBoundsException.class) @Test(expected = IndexOutOfBoundsException.class)
public void getNegative() { public void getNegative() {
CollectionUtils.get((Object)collectionA, -3); CollectionUtils.get((Object) collectionA, -3);
} }
@Test(expected=IndexOutOfBoundsException.class) @Test(expected = IndexOutOfBoundsException.class)
public void getPositiveOutOfBounds() { public void getPositiveOutOfBounds() {
CollectionUtils.get((Object)collectionA.iterator(), 30); CollectionUtils.get((Object) collectionA.iterator(), 30);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void get1() { public void get1() {
CollectionUtils.get((Object)null, 0); CollectionUtils.get((Object) null, 0);
} }
@Test @Test
public void get() { public void get() {
assertEquals(2, CollectionUtils.get((Object)collectionA, 2)); assertEquals(2, CollectionUtils.get((Object) collectionA, 2));
assertEquals(2, CollectionUtils.get((Object)collectionA.iterator(), 2)); assertEquals(2, CollectionUtils.get((Object) collectionA.iterator(), 2));
final Map<Integer, Integer> map = CollectionUtils.getCardinalityMap(collectionA); final Map<Integer, Integer> map = CollectionUtils.getCardinalityMap(collectionA);
assertEquals(map.entrySet().iterator().next(), CollectionUtils.get((Object)map, 0)); assertEquals(map.entrySet().iterator().next(), CollectionUtils.get((Object) map, 0));
} }
@Test @Test

View File

@ -272,7 +272,7 @@ public class IterableUtilsTest {
testPredicate = equalPredicate((Number) 45); testPredicate = equalPredicate((Number) 45);
test = IterableUtils.find(iterableA, testPredicate); test = IterableUtils.find(iterableA, testPredicate);
assertTrue(test == null); assertTrue(test == null);
assertNull(IterableUtils.find(null,testPredicate)); assertNull(IterableUtils.find(null, testPredicate));
try { try {
IterableUtils.find(iterableA, null); IterableUtils.find(iterableA, null);
fail("expecting NullPointerException"); fail("expecting NullPointerException");

View File

@ -117,7 +117,7 @@ public class ListUtilsTest {
two.add("a"); two.add("a");
two.add("b"); two.add("b");
two.add("b"); two.add("b");
assertEquals(ListUtils.intersection(one,two),ListUtils.intersection(two, one)); assertEquals(ListUtils.intersection(one, two), ListUtils.intersection(two, one));
} }
@Test @Test
@ -328,7 +328,7 @@ public class ListUtilsTest {
index = ListUtils.indexOf(fullList, testPredicate); index = ListUtils.indexOf(fullList, testPredicate);
assertEquals(index, -1); assertEquals(index, -1);
assertEquals(ListUtils.indexOf(null,testPredicate), -1); assertEquals(ListUtils.indexOf(null, testPredicate), -1);
assertEquals(ListUtils.indexOf(fullList, null), -1); assertEquals(ListUtils.indexOf(fullList, null), -1);
} }

View File

@ -53,7 +53,6 @@ import org.junit.Test;
/** /**
* Tests for MapUtils. * Tests for MapUtils.
*
*/ */
@SuppressWarnings("boxing") @SuppressWarnings("boxing")
public class MapUtilsTest extends AbstractAvailableLocalesTest { public class MapUtilsTest extends AbstractAvailableLocalesTest {
@ -276,7 +275,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
@Test @Test
public void testConvertResourceBundle() { public void testConvertResourceBundle() {
final Map<String, String> in = new HashMap<>( 5 , 1 ); final Map<String, String> in = new HashMap<>(5, 1);
in.put("1", "A"); in.put("1", "A");
in.put("2", "B"); in.put("2", "B");
in.put("3", "C"); in.put("3", "C");
@ -352,7 +351,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final String INDENT = " "; final String INDENT = " ";
final Map<Integer, String> map = new TreeMap<>(); // treeMap guarantees order across JDKs for test final Map<Integer, String> map = new TreeMap<>(); // treeMap guarantees order across JDKs for test
map.put(2, "B"); map.put(2, "B");
map.put(3, "C"); map.put(3, "C");
map.put(4, null); map.put(4, null);
@ -376,7 +375,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final String INDENT = " "; final String INDENT = " ";
final Map<Integer, String> map = new TreeMap<>(); // treeMap guarantees order across JDKs for test final Map<Integer, String> map = new TreeMap<>(); // treeMap guarantees order across JDKs for test
map.put(2, "B"); map.put(2, "B");
map.put(3, "C"); map.put(3, "C");
map.put(4, null); map.put(4, null);
@ -590,7 +589,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
out.reset(); out.reset();
final Map<Integer, String> inner = new TreeMap<>(); // treeMap guarantees order across JDKs for test final Map<Integer, String> inner = new TreeMap<>(); // treeMap guarantees order across JDKs for test
inner.put(2, "B"); inner.put(2, "B");
inner.put(3, "C"); inner.put(3, "C");
@ -626,7 +625,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
out.reset(); out.reset();
final Map<Integer, String> inner = new TreeMap<>(); // treeMap guarantees order across JDKs for test final Map<Integer, String> inner = new TreeMap<>(); // treeMap guarantees order across JDKs for test
inner.put(2, "B"); inner.put(2, "B");
inner.put(3, "C"); inner.put(3, "C");
@ -647,7 +646,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final String LABEL = "Print Map"; final String LABEL = "Print Map";
final String INDENT = " "; final String INDENT = " ";
final Map<Integer, Object> grandfather = new TreeMap<>();// treeMap guarantees order across JDKs for test final Map<Integer, Object> grandfather = new TreeMap<>(); // treeMap guarantees order across JDKs for test
final Map<Integer, Object> father = new TreeMap<>(); final Map<Integer, Object> father = new TreeMap<>();
final Map<Integer, Object> son = new TreeMap<>(); final Map<Integer, Object> son = new TreeMap<>();
@ -694,7 +693,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final String LABEL = "Print Map"; final String LABEL = "Print Map";
final String INDENT = " "; final String INDENT = " ";
final Map<Integer, Object> grandfather = new TreeMap<>();// treeMap guarantees order across JDKs for test final Map<Integer, Object> grandfather = new TreeMap<>(); // treeMap guarantees order across JDKs for test
final Map<Integer, Object> father = new TreeMap<>(); final Map<Integer, Object> father = new TreeMap<>();
final Map<Integer, Object> son = new TreeMap<>(); final Map<Integer, Object> son = new TreeMap<>();
@ -821,11 +820,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
/** /**
* Test class for populateMap(MultiMap). * Test class for populateMap(MultiMap).
*/ */
public static class X implements Comparable<X> { static class X implements Comparable<X> {
int key; int key;
String name; String name;
public X(final int key, final String name) { X(final int key, final String name) {
this.key = key; this.key = key;
this.name = name; this.name = name;
} }
@ -834,7 +833,6 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
public int compareTo(final X o) { public int compareTo(final X o) {
return key - o.key | name.compareTo(o.name); return key - o.key | name.compareTo(o.name);
} }
} }
@Test @Test
@ -849,7 +847,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
// Now test key transform population // Now test key transform population
final MultiValueMap<Integer, X> map = MultiValueMap.multiValueMap(new TreeMap<Integer, Collection<X>>()); final MultiValueMap<Integer, X> map = MultiValueMap.multiValueMap(new TreeMap<Integer, Collection<X>>());
MapUtils.populateMap(map, list, (Transformer<X, Integer>) input -> input.key, TransformerUtils.<X> nopTransformer()); MapUtils.populateMap(map, list, (Transformer<X, Integer>) input -> input.key, TransformerUtils.<X>nopTransformer());
assertEquals(list.size(), map.totalSize()); assertEquals(list.size(), map.totalSize());
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
@ -938,18 +936,18 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Double> in = new HashMap<>(); final Map<String, Double> in = new HashMap<>();
in.put("key", 2.0); in.put("key", 2.0);
assertEquals(2.0, MapUtils.getDoubleValue(in,"key", 0.0), 0); assertEquals(2.0, MapUtils.getDoubleValue(in, "key", 0.0), 0);
assertEquals(2.0, MapUtils.getDoubleValue(in,"key"), 0); assertEquals(2.0, MapUtils.getDoubleValue(in, "key"), 0);
assertEquals(1.0, MapUtils.getDoubleValue(in,"noKey", 1.0), 0); assertEquals(1.0, MapUtils.getDoubleValue(in, "noKey", 1.0), 0);
assertEquals(5.0, MapUtils.getDoubleValue(in,"noKey", (key)->{ assertEquals(5.0, MapUtils.getDoubleValue(in, "noKey", (key)->{
//sometimes the default value need to be calculated,such as System.currentTimeMillis() //sometimes the default value need to be calculated,such as System.currentTimeMillis()
return 5.0D; return 5.0D;
}),0); }),0);
assertEquals(0, MapUtils.getDoubleValue(in,"noKey"), 0); assertEquals(0, MapUtils.getDoubleValue(in, "noKey"), 0);
assertEquals(2.0, MapUtils.getDouble(in,"key", 0.0), 0); assertEquals(2.0, MapUtils.getDouble(in, "key", 0.0), 0);
assertEquals(1.0, MapUtils.getDouble(in,"noKey", 1.0), 0); assertEquals(1.0, MapUtils.getDouble(in, "noKey", 1.0), 0);
assertEquals(1.0, MapUtils.getDouble(in,"noKey", (key)->{ assertEquals(1.0, MapUtils.getDouble(in, "noKey", (key)->{
return 1.0; return 1.0;
}), 0); }), 0);
@ -958,7 +956,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final char decimalSeparator = getDecimalSeparator(); final char decimalSeparator = getDecimalSeparator();
inStr.put("str1", "2" + decimalSeparator + "0"); inStr.put("str1", "2" + decimalSeparator + "0");
assertEquals(MapUtils.getDoubleValue(inStr,"str1", 0.0), 2.0, 0); assertEquals(MapUtils.getDoubleValue(inStr, "str1", 0.0), 2.0, 0);
} }
@Test @Test
@ -966,16 +964,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Float> in = new HashMap<>(); final Map<String, Float> in = new HashMap<>();
in.put("key", 2.0f); in.put("key", 2.0f);
assertEquals(2.0, MapUtils.getFloatValue(in,"key", 0.0f), 0); assertEquals(2.0, MapUtils.getFloatValue(in, "key", 0.0f), 0);
assertEquals(2.0, MapUtils.getFloatValue(in,"key"), 0); assertEquals(2.0, MapUtils.getFloatValue(in, "key"), 0);
assertEquals(1.0, MapUtils.getFloatValue(in,"noKey", 1.0f), 0); assertEquals(1.0, MapUtils.getFloatValue(in, "noKey", 1.0f), 0);
assertEquals(1.0, MapUtils.getFloatValue(in,"noKey", (key)->{ assertEquals(1.0, MapUtils.getFloatValue(in, "noKey", (key) -> {
return 1.0F; return 1.0F;
}), 0); }), 0);
assertEquals(0, MapUtils.getFloatValue(in,"noKey"), 0); assertEquals(0, MapUtils.getFloatValue(in, "noKey"), 0);
assertEquals(2.0, MapUtils.getFloat(in,"key", 0.0f), 0); assertEquals(2.0, MapUtils.getFloat(in, "key", 0.0f), 0);
assertEquals(1.0, MapUtils.getFloat(in,"noKey", 1.0f), 0); assertEquals(1.0, MapUtils.getFloat(in, "noKey", 1.0f), 0);
assertEquals(1.0, MapUtils.getFloat(in,"noKey", (key)->{ assertEquals(1.0, MapUtils.getFloat(in, "noKey", (key) -> {
return 1.0F; return 1.0F;
}), 0); }), 0);
@ -983,7 +981,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final char decimalSeparator = getDecimalSeparator(); final char decimalSeparator = getDecimalSeparator();
inStr.put("str1", "2" + decimalSeparator + "0"); inStr.put("str1", "2" + decimalSeparator + "0");
assertEquals(MapUtils.getFloatValue(inStr,"str1", 0.0f), 2.0, 0); assertEquals(MapUtils.getFloatValue(inStr, "str1", 0.0f), 2.0, 0);
} }
@Test @Test
@ -991,23 +989,23 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Long> in = new HashMap<>(); final Map<String, Long> in = new HashMap<>();
in.put("key", 2L); in.put("key", 2L);
assertEquals(2.0, MapUtils.getLongValue(in,"key", 0L), 0); assertEquals(2.0, MapUtils.getLongValue(in, "key", 0L), 0);
assertEquals(2.0, MapUtils.getLongValue(in,"key"), 0); assertEquals(2.0, MapUtils.getLongValue(in, "key"), 0);
assertEquals(1, MapUtils.getLongValue(in,"noKey", 1L), 0); assertEquals(1, MapUtils.getLongValue(in, "noKey", 1L), 0);
assertEquals(1, MapUtils.getLongValue(in,"noKey", (key)->{ assertEquals(1, MapUtils.getLongValue(in, "noKey", (key) -> {
return 1L; return 1L;
}), 0); }), 0);
assertEquals(0, MapUtils.getLongValue(in,"noKey"), 0); assertEquals(0, MapUtils.getLongValue(in, "noKey"), 0);
assertEquals(2.0, MapUtils.getLong(in,"key", 0L), 0); assertEquals(2.0, MapUtils.getLong(in, "key", 0L), 0);
assertEquals(1, MapUtils.getLong(in,"noKey", 1L), 0); assertEquals(1, MapUtils.getLong(in, "noKey", 1L), 0);
assertEquals(1, MapUtils.getLong(in,"noKey", (key)->{ assertEquals(1, MapUtils.getLong(in, "noKey", (key) -> {
return 1L; return 1L;
}), 0); }), 0);
final Map<String, String> inStr = new HashMap<>(); final Map<String, String> inStr = new HashMap<>();
inStr.put("str1", "2"); inStr.put("str1", "2");
assertEquals(MapUtils.getLongValue(inStr,"str1", 0L), 2, 0); assertEquals(MapUtils.getLongValue(inStr, "str1", 0L), 2, 0);
assertEquals(MapUtils.getLong(inStr, "str1", 1L), 2, 0); assertEquals(MapUtils.getLong(inStr, "str1", 1L), 2, 0);
} }
@ -1017,23 +1015,23 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Integer> in = new HashMap<>(); final Map<String, Integer> in = new HashMap<>();
in.put("key", 2); in.put("key", 2);
assertEquals(2, MapUtils.getIntValue(in,"key", 0), 0); assertEquals(2, MapUtils.getIntValue(in, "key", 0), 0);
assertEquals(2, MapUtils.getIntValue(in,"key"), 0); assertEquals(2, MapUtils.getIntValue(in, "key"), 0);
assertEquals(0, MapUtils.getIntValue(in,"noKey", 0), 0); assertEquals(0, MapUtils.getIntValue(in, "noKey", 0), 0);
assertEquals(0, MapUtils.getIntValue(in,"noKey", (key)->{ assertEquals(0, MapUtils.getIntValue(in, "noKey", (key)->{
return 0; return 0;
}), 0); }), 0);
assertEquals(0, MapUtils.getIntValue(in,"noKey"), 0); assertEquals(0, MapUtils.getIntValue(in, "noKey"), 0);
assertEquals(2, MapUtils.getInteger(in,"key", 0), 0); assertEquals(2, MapUtils.getInteger(in, "key", 0), 0);
assertEquals(0, MapUtils.getInteger(in,"noKey", 0), 0); assertEquals(0, MapUtils.getInteger(in, "noKey", 0), 0);
assertEquals(0, MapUtils.getInteger(in,"noKey", (key)->{ assertEquals(0, MapUtils.getInteger(in, "noKey", (key)->{
return 0; return 0;
}), 0); }), 0);
final Map<String, String> inStr = new HashMap<>(); final Map<String, String> inStr = new HashMap<>();
inStr.put("str1", "2"); inStr.put("str1", "2");
assertEquals(MapUtils.getIntValue(inStr,"str1", 0), 2, 0); assertEquals(MapUtils.getIntValue(inStr, "str1", 0), 2, 0);
} }
@Test @Test
@ -1042,23 +1040,23 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final short val = 10; final short val = 10;
in.put("key", val); in.put("key", val);
assertEquals(val, MapUtils.getShortValue(in,"key", val), 0); assertEquals(val, MapUtils.getShortValue(in, "key", val), 0);
assertEquals(val, MapUtils.getShortValue(in,"key"), 0); assertEquals(val, MapUtils.getShortValue(in, "key"), 0);
assertEquals(val, MapUtils.getShortValue(in,"noKey", val), 0); assertEquals(val, MapUtils.getShortValue(in, "noKey", val), 0);
assertEquals(val, MapUtils.getShortValue(in,"noKey", (key)->{ assertEquals(val, MapUtils.getShortValue(in, "noKey", (key)->{
return val; return val;
}), 0); }), 0);
assertEquals(0, MapUtils.getShortValue(in,"noKey"), 0); assertEquals(0, MapUtils.getShortValue(in, "noKey"), 0);
assertEquals(val, MapUtils.getShort(in,"key", val), 0); assertEquals(val, MapUtils.getShort(in, "key", val), 0);
assertEquals(val,MapUtils.getShort(in,"noKey", val), 0); assertEquals(val, MapUtils.getShort(in, "noKey", val), 0);
assertEquals(val,MapUtils.getShort(in,"noKey", (key)->{ assertEquals(val, MapUtils.getShort(in, "noKey", (key)->{
return val; return val;
}), 0); }), 0);
final Map<String, String> inStr = new HashMap<>(); final Map<String, String> inStr = new HashMap<>();
inStr.put("str1", "10"); inStr.put("str1", "10");
assertEquals(MapUtils.getShortValue(inStr,"str1", val), val, 0); assertEquals(MapUtils.getShortValue(inStr, "str1", val), val, 0);
} }
@Test @Test
@ -1067,16 +1065,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final byte val = 100; final byte val = 100;
in.put("key", val); in.put("key", val);
assertEquals(val, MapUtils.getByteValue(in,"key", val), 0); assertEquals(val, MapUtils.getByteValue(in, "key", val), 0);
assertEquals(val, MapUtils.getByteValue(in,"key"), 0); assertEquals(val, MapUtils.getByteValue(in, "key"), 0);
assertEquals(val, MapUtils.getByteValue(in,"noKey", val), 0); assertEquals(val, MapUtils.getByteValue(in, "noKey", val), 0);
assertEquals(val, MapUtils.getByteValue(in,"noKey", (key)->{ assertEquals(val, MapUtils.getByteValue(in, "noKey", (key) -> {
return (byte)100; return (byte) 100;
}), 0); }), 0);
assertEquals(0, MapUtils.getByteValue(in,"noKey"), 0); assertEquals(0, MapUtils.getByteValue(in, "noKey"), 0);
assertEquals(val, MapUtils.getByte(in,"key", val), 0); assertEquals(val, MapUtils.getByte(in, "key", val), 0);
assertEquals(val, MapUtils.getByte(in,"noKey", val), 0); assertEquals(val, MapUtils.getByte(in, "noKey", val), 0);
assertEquals(val, MapUtils.getByte(in,"noKey", (key)->{ assertEquals(val, MapUtils.getByte(in, "noKey", (key)->{
return val; return val;
}), 0); }), 0);
@ -1084,7 +1082,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, String> inStr = new HashMap<>(); final Map<String, String> inStr = new HashMap<>();
inStr.put("str1", "100"); inStr.put("str1", "100");
assertEquals(MapUtils.getByteValue(inStr,"str1", val), val, 0); assertEquals(MapUtils.getByteValue(inStr, "str1", val), val, 0);
} }
@Test @Test
@ -1093,9 +1091,9 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Number val = 1000; final Number val = 1000;
in.put("key", val); in.put("key", val);
assertEquals(val.intValue(), MapUtils.getNumber(in,"key", val).intValue(), 0); assertEquals(val.intValue(), MapUtils.getNumber(in, "key", val).intValue(), 0);
assertEquals(val.intValue(), MapUtils.getNumber(in,"noKey", val).intValue(), 0); assertEquals(val.intValue(), MapUtils.getNumber(in, "noKey", val).intValue(), 0);
assertEquals(val.intValue(), MapUtils.getNumber(in,"noKey", (key)->{ assertEquals(val.intValue(), MapUtils.getNumber(in, "noKey", (key) -> {
if (true) { if (true) {
return val; return val;
} else { } else {
@ -1110,18 +1108,18 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, String> in = new HashMap<>(); final Map<String, String> in = new HashMap<>();
in.put("key", "str"); in.put("key", "str");
assertEquals("str", MapUtils.getString(in,"key", "defualt")); assertEquals("str", MapUtils.getString(in, "key", "defualt"));
assertEquals("str", MapUtils.getString(in,"key")); assertEquals("str", MapUtils.getString(in, "key"));
assertEquals(null, MapUtils.getString(null,"key")); assertEquals(null, MapUtils.getString(null, "key"));
assertEquals("default", MapUtils.getString(in,"noKey", "default")); assertEquals("default", MapUtils.getString(in, "noKey", "default"));
assertEquals("default", MapUtils.getString(in,"noKey", (key)->{ assertEquals("default", MapUtils.getString(in, "noKey", (key)->{
if ("noKey".equals(key)) { if ("noKey".equals(key)) {
return "default"; return "default";
} else { } else {
return ""; return "";
} }
})); }));
assertEquals("default", MapUtils.getString(null,"noKey", "default")); assertEquals("default", MapUtils.getString(null, "noKey", "default"));
} }
@ -1130,11 +1128,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Object> in = new HashMap<>(); final Map<String, Object> in = new HashMap<>();
in.put("key", "str"); in.put("key", "str");
assertEquals("str", MapUtils.getObject(in,"key", "defualt")); assertEquals("str", MapUtils.getObject(in, "key", "defualt"));
assertEquals("str", MapUtils.getObject(in,"key")); assertEquals("str", MapUtils.getObject(in, "key"));
assertEquals(null, MapUtils.getObject(null,"key")); assertEquals(null, MapUtils.getObject(null, "key"));
assertEquals("default", MapUtils.getObject(in,"noKey", "default")); assertEquals("default", MapUtils.getObject(in, "noKey", "default"));
assertEquals("default", MapUtils.getObject(null,"noKey", "default")); assertEquals("default", MapUtils.getObject(null, "noKey", "default"));
} }
@Test @Test
@ -1148,16 +1146,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertFalse(MapUtils.getBooleanValue(null, "keyString", null)); assertFalse(MapUtils.getBooleanValue(null, "keyString", null));
assertFalse(MapUtils.getBooleanValue(in, null, null)); assertFalse(MapUtils.getBooleanValue(in, null, null));
assertFalse(MapUtils.getBooleanValue(null, null, null)); assertFalse(MapUtils.getBooleanValue(null, null, null));
assertTrue(MapUtils.getBooleanValue(in,"key", true)); assertTrue(MapUtils.getBooleanValue(in, "key", true));
assertTrue(MapUtils.getBooleanValue(in,"key")); assertTrue(MapUtils.getBooleanValue(in, "key"));
assertTrue(MapUtils.getBooleanValue(in,"noKey", true)); assertTrue(MapUtils.getBooleanValue(in, "noKey", true));
assertTrue(MapUtils.getBooleanValue(in,"noKey", (key)->{ assertTrue(MapUtils.getBooleanValue(in, "noKey", (key) -> {
return true; return true;
})); }));
assertTrue(!MapUtils.getBooleanValue(in,"noKey")); assertTrue(!MapUtils.getBooleanValue(in, "noKey"));
assertTrue(MapUtils.getBoolean(in,"key", true)); assertTrue(MapUtils.getBoolean(in, "key", true));
assertTrue(MapUtils.getBoolean(in,"noKey", true)); assertTrue(MapUtils.getBoolean(in, "noKey", true));
assertTrue(MapUtils.getBoolean(in,"noKey", (key)->{ assertTrue(MapUtils.getBoolean(in, "noKey", (key)->{
if (System.currentTimeMillis() > 0) { if (System.currentTimeMillis() > 0) {
return true; return true;
} }
@ -1169,7 +1167,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertFalse(MapUtils.getBooleanValue(in, "noKey", (key) -> { assertFalse(MapUtils.getBooleanValue(in, "noKey", (key) -> {
return null; return null;
})); }));
assertEquals(null, MapUtils.getBoolean(null,"noKey")); assertEquals(null, MapUtils.getBoolean(null, "noKey"));
// Values are Numbers // Values are Numbers
assertFalse(MapUtils.getBoolean(in, "keyNumberFalse")); assertFalse(MapUtils.getBoolean(in, "keyNumberFalse"));
assertTrue(MapUtils.getBoolean(in, "keyNumberTrue")); assertTrue(MapUtils.getBoolean(in, "keyNumberTrue"));
@ -1181,17 +1179,17 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, String> inStr = new HashMap<>(); final Map<String, String> inStr = new HashMap<>();
inStr.put("str1", "true"); inStr.put("str1", "true");
assertTrue(MapUtils.getBooleanValue(inStr,"str1", true)); assertTrue(MapUtils.getBooleanValue(inStr, "str1", true));
assertTrue(MapUtils.getBoolean(inStr,"str1", true)); assertTrue(MapUtils.getBoolean(inStr, "str1", true));
} }
@Test @Test
public void testgetMap() { public void testgetMap() {
final Map<String, Map<String,String>> in = new HashMap<>(); final Map<String, Map<String, String>> in = new HashMap<>();
final Map<String, String> valMap = new HashMap<>(); final Map<String, String> valMap = new HashMap<>();
valMap.put("key1", "value1"); valMap.put("key1", "value1");
in.put("key1", valMap); in.put("key1", valMap);
final Map<?, ?> outValue = MapUtils.getMap(in,"key1", (Map<?, ?>) null); final Map<?, ?> outValue = MapUtils.getMap(in, "key1", (Map<?, ?>) null);
assertEquals("value1", outValue.get("key1")); assertEquals("value1", outValue.get("key1"));
assertEquals(null, outValue.get("key2")); assertEquals(null, outValue.get("key2"));
@ -1204,8 +1202,8 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Object> inMap = new HashMap<>(); final Map<String, Object> inMap = new HashMap<>();
MapUtils.safeAddToMap(inMap,"key1", "value1"); MapUtils.safeAddToMap(inMap, "key1", "value1");
MapUtils.safeAddToMap(inMap,"key2", null); MapUtils.safeAddToMap(inMap, "key2", null);
assertEquals("value1", inMap.get("key1")); assertEquals("value1", inMap.get("key1"));
assertEquals("", inMap.get("key2")); assertEquals("", inMap.get("key2"));
} }
@ -1226,6 +1224,4 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
} }
return '.'; return '.';
} }
} }

View File

@ -187,8 +187,7 @@ public class SetUtilsTest {
} }
@Test @Test
public void testHashSet() public void testHashSet() {
{
final Set<?> set1 = SetUtils.unmodifiableSet(); final Set<?> set1 = SetUtils.unmodifiableSet();
assertTrue("set is empty", set1.isEmpty()); assertTrue("set is empty", set1.isEmpty());
@ -249,8 +248,7 @@ public class SetUtilsTest {
} }
@Test @Test
public void testUnmodifiableSet() public void testUnmodifiableSet() {
{
final Set<?> set1 = SetUtils.unmodifiableSet(); final Set<?> set1 = SetUtils.unmodifiableSet();
assertTrue("set is empty", set1.isEmpty()); assertTrue("set is empty", set1.isEmpty());
@ -275,8 +273,7 @@ public class SetUtilsTest {
} }
@Test @Test
public void testUnmodifiableSetWrap() public void testUnmodifiableSetWrap() {
{
final Set<Integer> set1 = SetUtils.unmodifiableSet(1, 2, 2, 3); final Set<Integer> set1 = SetUtils.unmodifiableSet(1, 2, 2, 3);
final Set<Integer> set2 = SetUtils.unmodifiableSet(set1); final Set<Integer> set2 = SetUtils.unmodifiableSet(set1);
assertSame(set1, set2); assertSame(set1, set2);

View File

@ -46,7 +46,7 @@ public class SplitMapUtilsTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
backingMap = new HashMap<>(); backingMap = new HashMap<>();
transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer.<String> nopTransformer(), transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer.<String>nopTransformer(),
stringToInt); stringToInt);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
transformedMap.put(String.valueOf(i), String.valueOf(i)); transformedMap.put(String.valueOf(i), String.valueOf(i));

View File

@ -96,7 +96,7 @@ public class CollectionBagTest<T> extends AbstractCollectionTest<T> {
final Bag<T> bag = makeObject(); final Bag<T> bag = makeObject();
if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) { if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
final Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag)); final Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
assertTrue("Bag is empty",bag2.size() == 0); assertTrue("Bag is empty", bag2.size() == 0);
assertEquals(bag, bag2); assertEquals(bag, bag2);
} }
} }

View File

@ -136,7 +136,7 @@ public class CollectionSortedBagTest<T> extends AbstractCollectionTest<T> {
final Bag<T> bag = makeObject(); final Bag<T> bag = makeObject();
if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) { if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
final Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag)); final Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
assertTrue("Bag is empty",bag2.size() == 0); assertTrue("Bag is empty", bag2.size() == 0);
assertEquals(bag, bag2); assertEquals(bag, bag2);
} }
} }

View File

@ -75,7 +75,7 @@ public class PredicatedBagTest<T> extends AbstractBagTest<T> {
assertEquals(true, bag.contains(els[i])); assertEquals(true, bag.contains(els[i]));
} }
Set<T> set = ((PredicatedBag<T>) bag).uniqueSet(); Set<T> set = ((PredicatedBag<T>) bag).uniqueSet();
assertTrue("Unique set contains the first element",set.contains(els[0])); assertTrue("Unique set contains the first element", set.contains(els[0]));
assertEquals(true, bag.remove(els[0])); assertEquals(true, bag.remove(els[0]));
set = ((PredicatedBag<T>) bag).uniqueSet(); set = ((PredicatedBag<T>) bag).uniqueSet();
assertTrue("Unique set now does not contain the first element", assertTrue("Unique set now does not contain the first element",

View File

@ -69,11 +69,11 @@ public class AbstractOrderedBidiMapDecoratorTest<K, V>
private TestOrderedBidiMap<V, K> inverse = null; private TestOrderedBidiMap<V, K> inverse = null;
public TestOrderedBidiMap() { TestOrderedBidiMap() {
super(new DualTreeBidiMap<K, V>()); super(new DualTreeBidiMap<K, V>());
} }
public TestOrderedBidiMap(final OrderedBidiMap<K, V> map) { TestOrderedBidiMap(final OrderedBidiMap<K, V> map) {
super(map); super(map);
} }

View File

@ -53,7 +53,7 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
sortedValues.addAll(map.values()); sortedValues.addAll(map.values());
sortedValues = Collections.unmodifiableList(sortedValues); sortedValues = Collections.unmodifiableList(sortedValues);
sortedNewValues.addAll(this.<V> getAsList(getNewSampleValues())); sortedNewValues.addAll(this.<V>getAsList(getNewSampleValues()));
} }
// public AbstractTestSortedBidiMap() { // public AbstractTestSortedBidiMap() {

View File

@ -52,8 +52,8 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
@Override @Override
public DualTreeBidiMap<K, V> makeObject() { public DualTreeBidiMap<K, V> makeObject() {
return new DualTreeBidiMap<>( return new DualTreeBidiMap<>(
new ReverseComparator<>(ComparableComparator.<K> comparableComparator()), new ReverseComparator<>(ComparableComparator.<K>comparableComparator()),
new ReverseComparator<>(ComparableComparator.<V> comparableComparator())); new ReverseComparator<>(ComparableComparator.<V>comparableComparator()));
} }
@Override @Override
@ -90,7 +90,7 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
final Object dest = in.readObject(); final Object dest = in.readObject();
in.close(); in.close();
final SortedBidiMap<?,?> bidi = (SortedBidiMap<?,?>) dest; final SortedBidiMap<?, ?> bidi = (SortedBidiMap<?, ?>) dest;
assertNotNull(obj.comparator()); assertNotNull(obj.comparator());
assertNotNull(bidi.comparator()); assertNotNull(bidi.comparator());
assertTrue(bidi.comparator() instanceof ReverseComparator); assertTrue(bidi.comparator() instanceof ReverseComparator);

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,13 +1,12 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more
* or more contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file distributed with
* distributed with this work for additional information * this work for additional information regarding copyright ownership.
* regarding copyright ownership. The ASF licenses this file * The ASF licenses this file to You under the Apache License, Version 2.0
* to you under the Apache License, Version 2.0 (the * (the "License"); you may not use this file except in compliance with
* "License"); you may not use this file except in compliance * the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,

Some files were not shown because too many files have changed in this diff Show More