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:
parent
72f45156d3
commit
4797acefba
|
@ -20,7 +20,7 @@ limitations under the License.
|
|||
"-//Puppy Crawl//DTD Check Configuration 1.1//EN"
|
||||
"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">
|
||||
<property name="localeLanguage" value="en"/>
|
||||
<module name="JavadocPackage"/>
|
||||
|
|
|
@ -73,7 +73,7 @@ public class CollectionUtils {
|
|||
* @param a the first 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);
|
||||
cardinalityB = CollectionUtils.<O>getCardinalityMap(b);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class CollectionUtils {
|
|||
* @param a the first 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);
|
||||
elements = new HashSet<>();
|
||||
addAll(elements, a);
|
||||
|
@ -555,15 +555,15 @@ public class CollectionUtils {
|
|||
* @return {@code true} iff the collections contain the same elements with the same cardinalities.
|
||||
*/
|
||||
public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b) {
|
||||
if(a.size() != b.size()) {
|
||||
if (a.size() != b.size()) {
|
||||
return false;
|
||||
}
|
||||
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b);
|
||||
if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
|
||||
if (helper.cardinalityA.size() != helper.cardinalityB.size()) {
|
||||
return false;
|
||||
}
|
||||
for( final Object obj : helper.cardinalityA.keySet()) {
|
||||
if(helper.freqA(obj) != helper.freqB(obj)) {
|
||||
for (final Object obj : helper.cardinalityA.keySet()) {
|
||||
if (helper.freqA(obj) != helper.freqB(obj)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ public class CollectionUtils {
|
|||
final Equator<? super E> equator) {
|
||||
Objects.requireNonNull(equator, "equator");
|
||||
|
||||
if(a.size() != b.size()) {
|
||||
if (a.size() != b.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ public class CollectionUtils {
|
|||
private final Equator<? super O> equator;
|
||||
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.object = object;
|
||||
}
|
||||
|
@ -1318,7 +1318,7 @@ public class CollectionUtils {
|
|||
if (i < 0) {
|
||||
throw new IndexOutOfBoundsException("Index cannot be negative: " + i);
|
||||
}
|
||||
if (object instanceof Map<?,?>) {
|
||||
if (object instanceof Map<?, ?>) {
|
||||
final Map<?, ?> map = (Map<?, ?>) object;
|
||||
final Iterator<?> iterator = map.entrySet().iterator();
|
||||
return IteratorUtils.get(iterator, i);
|
||||
|
@ -1355,7 +1355,7 @@ public class CollectionUtils {
|
|||
* @return the object at the specified index
|
||||
* @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);
|
||||
return get(map.entrySet(), index);
|
||||
}
|
||||
|
@ -1383,7 +1383,7 @@ public class CollectionUtils {
|
|||
return 0;
|
||||
}
|
||||
int total = 0;
|
||||
if (object instanceof Map<?,?>) {
|
||||
if (object instanceof Map<?, ?>) {
|
||||
total = ((Map<?, ?>) object).size();
|
||||
} else if (object instanceof Collection<?>) {
|
||||
total = ((Collection<?>) object).size();
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. 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 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 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.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 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 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;
|
||||
|
||||
|
|
|
@ -478,7 +478,7 @@ public class IterableUtils {
|
|||
private static final class UnmodifiableIterable<E> extends FluentIterable<E> {
|
||||
private final Iterable<E> unmodifiable;
|
||||
|
||||
public UnmodifiableIterable(final Iterable<E> iterable) {
|
||||
UnmodifiableIterable(final Iterable<E> iterable) {
|
||||
super();
|
||||
this.unmodifiable = iterable;
|
||||
}
|
||||
|
|
|
@ -808,7 +808,7 @@ public class IteratorUtils {
|
|||
* Convenience method, allows easy iteration over NodeLists:
|
||||
* <pre>
|
||||
* Iterator<Node> iterator = IteratorUtils.nodeListIterator(node);
|
||||
* for(Node childNode : IteratorUtils.asIterable(iterator)) {
|
||||
* for (Node childNode : IteratorUtils.asIterable(iterator)) {
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -1247,7 +1247,7 @@ public class IteratorUtils {
|
|||
Objects.requireNonNull(predicate, "predicate");
|
||||
|
||||
if (iterator != null) {
|
||||
for(int index = 0; iterator.hasNext(); index++) {
|
||||
for (int index = 0; iterator.hasNext(); index++) {
|
||||
final E element = iterator.next();
|
||||
if (predicate.evaluate(element)) {
|
||||
return index;
|
||||
|
@ -1469,7 +1469,7 @@ public class IteratorUtils {
|
|||
stringBuilder.append(transformer.transform(element));
|
||||
stringBuilder.append(delimiter);
|
||||
}
|
||||
if(stringBuilder.length() > prefix.length()) {
|
||||
if (stringBuilder.length() > prefix.length()) {
|
||||
stringBuilder.setLength(stringBuilder.length() - delimiter.length());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ public class ListUtils {
|
|||
private static final class LcsVisitor<E> implements CommandVisitor<E> {
|
||||
private final ArrayList<E> sequence;
|
||||
|
||||
public LcsVisitor() {
|
||||
LcsVisitor() {
|
||||
sequence = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -639,23 +639,21 @@ public class ListUtils {
|
|||
* A simple wrapper to use a CharSequence as List.
|
||||
*/
|
||||
private static final class CharSequenceAsList extends AbstractList<Character> {
|
||||
|
||||
private final CharSequence sequence;
|
||||
|
||||
public CharSequenceAsList(final CharSequence sequence) {
|
||||
CharSequenceAsList(final CharSequence sequence) {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character get( final int index ) {
|
||||
return Character.valueOf(sequence.charAt( index ));
|
||||
public Character get(final int index) {
|
||||
return Character.valueOf(sequence.charAt(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return sequence.length();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SetUtils {
|
|||
* @param <E> the element type
|
||||
* @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.
|
||||
|
|
|
@ -191,7 +191,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
*
|
||||
* @param parent the parent bag
|
||||
*/
|
||||
public BagIterator(final AbstractMapBag<E> parent) {
|
||||
BagIterator(final AbstractMapBag<E> parent) {
|
||||
this.parent = parent;
|
||||
this.entryIterator = parent.map.entrySet().iterator();
|
||||
this.current = null;
|
||||
|
@ -507,7 +507,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
@Override
|
||||
public Set<E> uniqueSet() {
|
||||
if (uniqueSet == null) {
|
||||
uniqueSet = UnmodifiableSet.<E> unmodifiableSet(map.keySet());
|
||||
uniqueSet = UnmodifiableSet.<E>unmodifiableSet(map.keySet());
|
||||
}
|
||||
return uniqueSet;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public final class CollectionBag<E> extends AbstractBagDecorator<E> {
|
|||
public boolean containsAll(final Collection<?> coll) {
|
||||
final Iterator<?> e = coll.iterator();
|
||||
while (e.hasNext()) {
|
||||
if(!contains(e.next())) {
|
||||
if (!contains(e.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public final class CollectionSortedBag<E> extends AbstractSortedBagDecorator<E>
|
|||
public boolean containsAll(final Collection<?> coll) {
|
||||
final Iterator<?> e = coll.iterator();
|
||||
while (e.hasNext()) {
|
||||
if(!contains(e.next())) {
|
||||
if (!contains(e.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
|
|||
*/
|
||||
@Override
|
||||
public boolean add(final E object) {
|
||||
if(comparator() == null && !(object instanceof Comparable)) {
|
||||
if (comparator() == null && !(object instanceof Comparable)) {
|
||||
Objects.requireNonNull(object, "object");
|
||||
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
|
||||
"a naturally ordered TreeBag as it does not implement Comparable");
|
||||
|
|
|
@ -108,7 +108,7 @@ public final class UnmodifiableBag<E>
|
|||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator());
|
||||
return UnmodifiableIterator.<E>unmodifiableIterator(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,7 +163,7 @@ public final class UnmodifiableBag<E>
|
|||
@Override
|
||||
public Set<E> uniqueSet() {
|
||||
final Set<E> set = decorated().uniqueSet();
|
||||
return UnmodifiableSet.<E> unmodifiableSet(set);
|
||||
return UnmodifiableSet.<E>unmodifiableSet(set);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -344,7 +344,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
/**
|
||||
* 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. */
|
||||
private static final long serialVersionUID = 4621510560119690639L;
|
||||
|
|
|
@ -1465,7 +1465,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
stream.defaultReadObject();
|
||||
rootNode = new Node[2];
|
||||
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 V v =(V) stream.readObject();
|
||||
put(k, v);
|
||||
|
@ -1521,7 +1521,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
/**
|
||||
* Create a new TreeBidiMap.KeyView.
|
||||
*/
|
||||
public KeyView(final DataElement orderType) {
|
||||
KeyView(final DataElement orderType) {
|
||||
super(orderType);
|
||||
}
|
||||
|
||||
|
@ -1548,7 +1548,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
/**
|
||||
* Create a new TreeBidiMap.ValueView.
|
||||
*/
|
||||
public ValueView(final DataElement orderType) {
|
||||
ValueView(final DataElement orderType) {
|
||||
super(orderType);
|
||||
}
|
||||
|
||||
|
@ -1792,7 +1792,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
/**
|
||||
* Create a new TreeBidiMap.InverseViewMapIterator.
|
||||
*/
|
||||
public InverseViewMapIterator(final DataElement orderType) {
|
||||
InverseViewMapIterator(final DataElement orderType) {
|
||||
super(orderType);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -168,7 +167,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* @param other the other Bloom filter.
|
||||
*/
|
||||
@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
|
||||
|
@ -179,7 +178,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* this filter, or if the hasher is not the specified one
|
||||
*/
|
||||
@Override
|
||||
abstract public void merge(Hasher hasher);
|
||||
public abstract void merge(Hasher hasher);
|
||||
|
||||
@Override
|
||||
public int orCardinality(final BloomFilter other) {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -64,7 +63,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
if (other instanceof BitSetBloomFilter) {
|
||||
verifyShape(other);
|
||||
final BitSet result = (BitSet) bitSet.clone();
|
||||
result.and(((BitSetBloomFilter)other).bitSet);
|
||||
result.and(((BitSetBloomFilter) other).bitSet);
|
||||
return result.cardinality();
|
||||
}
|
||||
return super.andCardinality(other);
|
||||
|
@ -101,7 +100,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
public void merge(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
if (other instanceof BitSetBloomFilter) {
|
||||
bitSet.or(((BitSetBloomFilter)other).bitSet);
|
||||
bitSet.or(((BitSetBloomFilter) other).bitSet);
|
||||
} else {
|
||||
bitSet.or(BitSet.valueOf(other.getBits()));
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
if (other instanceof BitSetBloomFilter) {
|
||||
verifyShape(other);
|
||||
final BitSet result = (BitSet) bitSet.clone();
|
||||
result.or(((BitSetBloomFilter)other).bitSet);
|
||||
result.or(((BitSetBloomFilter) other).bitSet);
|
||||
return result.cardinality();
|
||||
}
|
||||
return super.orCardinality(other);
|
||||
|
@ -134,7 +133,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
if (other instanceof BitSetBloomFilter) {
|
||||
verifyShape(other);
|
||||
final BitSet result = (BitSet) bitSet.clone();
|
||||
result.xor(((BitSetBloomFilter)other).bitSet);
|
||||
result.xor(((BitSetBloomFilter) other).bitSet);
|
||||
return result.cardinality();
|
||||
}
|
||||
return super.xorCardinality(other);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -105,7 +104,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
public int andCardinality(final BloomFilter other) {
|
||||
if (other instanceof CountingBloomFilter) {
|
||||
final Set<Integer> result = new HashSet<>(counts.keySet());
|
||||
result.retainAll(((CountingBloomFilter)other).counts.keySet());
|
||||
result.retainAll(((CountingBloomFilter) other).counts.keySet());
|
||||
return result.size();
|
||||
}
|
||||
return super.andCardinality(other);
|
||||
|
@ -229,7 +228,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
public void remove(final Hasher hasher) {
|
||||
verifyHasher(hasher);
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -35,7 +34,7 @@ public final class SetOperations {
|
|||
* @return the jaccard distance.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public static long estimateIntersectionSize(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
verifyShape(first, second);
|
||||
// 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.
|
||||
*/
|
||||
public static long estimateUnionSize(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
verifyShape(first, second);
|
||||
final Shape shape = first.getShape();
|
||||
final double estimate = -(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.
|
||||
*/
|
||||
public static int hammingDistance(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
verifyShape(first, second);
|
||||
return first.xorCardinality(second);
|
||||
}
|
||||
|
||||
|
@ -123,7 +122,7 @@ public final class SetOperations {
|
|||
* @return the Jaccard distance.
|
||||
*/
|
||||
public static double jaccardDistance(final BloomFilter first, final BloomFilter second) {
|
||||
return 1.0 - jaccardSimilarity(first,second);
|
||||
return 1.0 - jaccardSimilarity(first, second);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -291,7 +290,7 @@ public class Shape {
|
|||
* @return the number of bytes in the Bloom filter.
|
||||
*/
|
||||
public int getNumberOfBytes() {
|
||||
return Double.valueOf(Math.ceil(numberOfBits / (double)Byte.SIZE )).intValue();
|
||||
return Double.valueOf(Math.ceil(numberOfBits / (double) Byte.SIZE )).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -15,9 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementations of org.apache.commons.collections4.bloomfilter.hasher.HasherFunction
|
||||
* interface.
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
package org.apache.commons.collections4.bloomfilter.hasher.function;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -15,9 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementations of org.apache.commons.collections4.bloomfilter.Hasher
|
||||
* interface.
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
package org.apache.commons.collections4.bloomfilter.hasher;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -15,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A collection of extensible Bloom filter classes and interfaces.
|
||||
*
|
||||
|
|
|
@ -173,7 +173,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
|
|||
public boolean equals(final Object object) {
|
||||
return (this == object) ||
|
||||
((object instanceof BooleanComparator) &&
|
||||
(this.trueFirst == ((BooleanComparator)object).trueFirst));
|
||||
(this.trueFirst == ((BooleanComparator) object).trueFirst));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -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) {
|
||||
checkLocked();
|
||||
|
||||
comparatorChain.set(index,comparator);
|
||||
comparatorChain.set(index, comparator);
|
||||
if (reverse == true) {
|
||||
orderingBits.set(index);
|
||||
} else {
|
||||
|
@ -278,7 +278,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
|
|||
for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) {
|
||||
|
||||
final Comparator<? super E> comparator = comparators.next();
|
||||
int retval = comparator.compare(o1,o2);
|
||||
int retval = comparator.compare(o1, o2);
|
||||
if (retval != 0) {
|
||||
// invert the order if it is a reverse sort
|
||||
if (orderingBits.get(comparatorIndex) == true) {
|
||||
|
|
|
@ -132,9 +132,15 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
|
|||
**/
|
||||
@Override
|
||||
public int compare(final E o1, final E o2) {
|
||||
if(o1 == o2) { return 0; }
|
||||
if(o1 == null) { return this.nullsAreHigh ? 1 : -1; }
|
||||
if(o2 == null) { return this.nullsAreHigh ? -1 : 1; }
|
||||
if (o1 == o2) {
|
||||
return 0;
|
||||
}
|
||||
if (o1 == null) {
|
||||
return this.nullsAreHigh ? 1 : -1;
|
||||
}
|
||||
if (o2 == null) {
|
||||
return this.nullsAreHigh ? -1 : 1;
|
||||
}
|
||||
return this.nonNullComparator.compare(o1, o2);
|
||||
}
|
||||
|
||||
|
@ -163,14 +169,19 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
|
|||
**/
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if(obj == null) { return false; }
|
||||
if(obj == this) { return true; }
|
||||
if(!obj.getClass().equals(this.getClass())) { return false; }
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!obj.getClass().equals(this.getClass())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NullComparator<?> other = (NullComparator<?>) obj;
|
||||
|
||||
return this.nullsAreHigh == other.nullsAreHigh &&
|
||||
this.nonNullComparator.equals(other.nonNullComparator);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public O transform(final I input) {
|
||||
if(iPredicate.evaluate(input)){
|
||||
if (iPredicate.evaluate(input)){
|
||||
return iTrueTransformer.transform(input);
|
||||
}
|
||||
return iFalseTransformer.transform(input);
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. 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 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
|
||||
* 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.
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 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 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;
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
protected void updateCurrentIterator() {
|
||||
if (currentIterator == null) {
|
||||
if (iteratorChain.isEmpty()) {
|
||||
currentIterator = EmptyIterator.<E> emptyIterator();
|
||||
currentIterator = EmptyIterator.<E>emptyIterator();
|
||||
} else {
|
||||
currentIterator = iteratorChain.remove();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. 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 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
|
||||
* 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.
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 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 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;
|
||||
|
||||
|
@ -129,7 +132,7 @@ public class IteratorIterable<E> implements Iterable<E> {
|
|||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
if (iterator instanceof ResettableIterator) {
|
||||
((ResettableIterator<? extends E>)iterator).reset();
|
||||
((ResettableIterator<? extends E>) iterator).reset();
|
||||
}
|
||||
return typeSafeIterator;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/*
|
||||
* Copyright 2013 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -137,7 +137,7 @@ public class SingletonListIterator<E> implements ResettableListIterator<E> {
|
|||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
if(!nextCalled || removed) {
|
||||
if (!nextCalled || removed) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
object = null;
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. 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 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
|
||||
* 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.
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 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 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;
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ZippingIterator<E> implements Iterator<E> {
|
|||
return true;
|
||||
}
|
||||
|
||||
while(iterators.hasNext()) {
|
||||
while (iterators.hasNext()) {
|
||||
final Iterator<? extends E> childIterator = iterators.next();
|
||||
if (childIterator.hasNext()) {
|
||||
nextIterator = childIterator;
|
||||
|
|
|
@ -227,8 +227,7 @@ public class MultiKey<K> implements Serializable {
|
|||
* Calculate the hash code of the instance using the provided keys.
|
||||
* @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;
|
||||
for (final Object key : keys) {
|
||||
if (key != null) {
|
||||
|
|
|
@ -108,7 +108,7 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
|
|||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
}
|
||||
final Map.Entry<?,?> other = (Map.Entry<?,?>) obj;
|
||||
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
|
||||
final Object value = getValue();
|
||||
return
|
||||
(key == null ? other.getKey() == null : key.equals(other.getKey())) &&
|
||||
|
|
|
@ -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 <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 */
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
final Map<?,?> map = (Map<?,?>) obj;
|
||||
final Map<?, ?> map = (Map<?, ?>) obj;
|
||||
if (map.size() != size()) {
|
||||
return false;
|
||||
}
|
||||
final MapIterator<?,?> it = mapIterator();
|
||||
final MapIterator<?, ?> it = mapIterator();
|
||||
try {
|
||||
while (it.hasNext()) {
|
||||
final Object key = it.next();
|
||||
|
|
|
@ -543,7 +543,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
/**
|
||||
* Base Iterator that iterates in link order.
|
||||
*/
|
||||
protected static abstract class LinkIterator<K, V> {
|
||||
protected abstract static class LinkIterator<K, V> {
|
||||
|
||||
/** The parent map */
|
||||
protected final AbstractLinkedMap<K, V> parent;
|
||||
|
|
|
@ -679,7 +679,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
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 entryValue = entry.getValue(); // convert to hard reference
|
||||
if (entryKey == null || entryValue == null) {
|
||||
|
@ -794,7 +794,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
|
||||
int expectedModCount;
|
||||
|
||||
public ReferenceBaseIterator(final AbstractReferenceMap<K, V> parent) {
|
||||
ReferenceBaseIterator(final AbstractReferenceMap<K, V> parent) {
|
||||
super();
|
||||
this.parent = parent;
|
||||
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>
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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) */
|
||||
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);
|
||||
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) */
|
||||
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);
|
||||
this.hash = hash;
|
||||
}
|
||||
|
|
|
@ -809,7 +809,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
private final int index;
|
||||
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.index = index;
|
||||
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 int nextIndex = 0;
|
||||
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.
|
||||
*/
|
||||
public EntryIterator(final Flat3Map<K, V> parent) {
|
||||
EntryIterator(final Flat3Map<K, V> parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
/**
|
||||
* 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")
|
||||
KeySetIterator(final Flat3Map<K, ?> parent) {
|
||||
|
|
|
@ -269,7 +269,7 @@ public class LRUMap<K, V>
|
|||
if (entry.after != header) {
|
||||
modCount++;
|
||||
// remove
|
||||
if(entry.before == null) {
|
||||
if (entry.before == null) {
|
||||
throw new IllegalStateException("Entry.before is null." +
|
||||
" This should not occur if your keys are immutable, and you have used synchronization properly.");
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Seriali
|
|||
* @throws NullPointerException if map or factory is null
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* @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);
|
||||
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
|
||||
* @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);
|
||||
this.factory = Objects.requireNonNull(factory, "factory");
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ import org.apache.commons.collections4.Transformer;
|
|||
* @param <V> the type of the values in this map
|
||||
* @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 */
|
||||
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
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,8 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
|||
*
|
||||
* @return the decorated map
|
||||
*/
|
||||
protected SortedMap<K,V> getSortedMap() {
|
||||
return (SortedMap<K,V>) map;
|
||||
protected SortedMap<K, V> getSortedMap() {
|
||||
return (SortedMap<K, V>) map;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -150,20 +150,20 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K,V> subMap(final K fromKey, final K toKey) {
|
||||
final SortedMap<K,V> map = getSortedMap().subMap(fromKey, toKey);
|
||||
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
||||
final SortedMap<K, V> map = getSortedMap().subMap(fromKey, toKey);
|
||||
return new LazySortedMap<>(map, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K,V> headMap(final K toKey) {
|
||||
final SortedMap<K,V> map = getSortedMap().headMap(toKey);
|
||||
public SortedMap<K, V> headMap(final K toKey) {
|
||||
final SortedMap<K, V> map = getSortedMap().headMap(toKey);
|
||||
return new LazySortedMap<>(map, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K,V> tailMap(final K fromKey) {
|
||||
final SortedMap<K,V> map = getSortedMap().tailMap(fromKey);
|
||||
public SortedMap<K, V> tailMap(final K fromKey) {
|
||||
final SortedMap<K, V> map = getSortedMap().tailMap(fromKey);
|
||||
return new LazySortedMap<>(map, factory);
|
||||
}
|
||||
|
||||
|
|
|
@ -600,7 +600,7 @@ public class ListOrderedMap<K, V>
|
|||
private final List<K> insertOrder;
|
||||
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();
|
||||
this.parent = parent;
|
||||
this.insertOrder = insertOrder;
|
||||
|
|
|
@ -91,7 +91,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
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 Iterator<V> iterator;
|
||||
|
||||
public ValuesIterator(final Object key) {
|
||||
ValuesIterator(final Object key) {
|
||||
this.key = key;
|
||||
this.values = getCollection(key);
|
||||
this.iterator = values.iterator();
|
||||
|
@ -552,7 +552,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
|
||||
private final Class<T> clazz;
|
||||
|
||||
public ReflectionFactory(final Class<T> clazz) {
|
||||
ReflectionFactory(final Class<T> clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
|
|
@ -572,11 +572,11 @@ public class SingletonMap<K, V>
|
|||
if (obj instanceof Map == false) {
|
||||
return false;
|
||||
}
|
||||
final Map<?,?> other = (Map<?,?>) obj;
|
||||
final Map<?, ?> other = (Map<?, ?>) obj;
|
||||
if (other.size() != 1) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
private final static class Lock {
|
||||
private static final class Lock {
|
||||
public int size;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public abstract class AbstractListValuedMap<K, V> extends AbstractMultiValuedMap
|
|||
*/
|
||||
private class WrappedList extends WrappedCollection implements List<V> {
|
||||
|
||||
public WrappedList(final K key) {
|
||||
WrappedList(final K key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
|
@ -220,13 +220,13 @@ public abstract class AbstractListValuedMap<K, V> extends AbstractMultiValuedMap
|
|||
private List<V> values;
|
||||
private ListIterator<V> iterator;
|
||||
|
||||
public ValuesListIterator(final K key) {
|
||||
ValuesListIterator(final K key) {
|
||||
this.key = key;
|
||||
this.values = ListUtils.emptyIfNull(getMap().get(key));
|
||||
this.iterator = values.listIterator();
|
||||
}
|
||||
|
||||
public ValuesListIterator(final K key, final int index) {
|
||||
ValuesListIterator(final K key, final int index) {
|
||||
this.key = key;
|
||||
this.values = ListUtils.emptyIfNull(getMap().get(key));
|
||||
this.iterator = values.listIterator(index);
|
||||
|
|
|
@ -398,7 +398,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
|
|||
|
||||
protected final K key;
|
||||
|
||||
public WrappedCollection(final K key) {
|
||||
WrappedCollection(final K key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
|
|||
|
||||
private Entry<K, V> current = null;
|
||||
|
||||
public MultiValuedMapIterator() {
|
||||
MultiValuedMapIterator() {
|
||||
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 Iterator<V> iterator;
|
||||
|
||||
public ValuesIterator(final Object key) {
|
||||
ValuesIterator(final Object key) {
|
||||
this.key = key;
|
||||
this.values = getMap().get(key);
|
||||
this.iterator = values.iterator();
|
||||
|
|
|
@ -109,7 +109,7 @@ public abstract class AbstractSetValuedMap<K, V> extends AbstractMultiValuedMap<
|
|||
*/
|
||||
private class WrappedSet extends WrappedCollection implements Set<V> {
|
||||
|
||||
public WrappedSet(final K key) {
|
||||
WrappedSet(final K key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
|
@ -133,5 +133,4 @@ public abstract class AbstractSetValuedMap<K, V> extends AbstractMultiValuedMap<
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> {
|
|||
*
|
||||
* @param parent the parent multiset
|
||||
*/
|
||||
public MapBasedMultiSetIterator(final AbstractMapMultiSet<E> parent) {
|
||||
MapBasedMultiSetIterator(final AbstractMapMultiSet<E> parent) {
|
||||
this.parent = parent;
|
||||
this.entryIterator = parent.map.entrySet().iterator();
|
||||
this.current = null;
|
||||
|
|
|
@ -138,7 +138,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
|
|||
*
|
||||
* @param parent the parent multiset
|
||||
*/
|
||||
public MultiSetIterator(final AbstractMultiSet<E> parent) {
|
||||
MultiSetIterator(final AbstractMultiSet<E> parent) {
|
||||
this.parent = parent;
|
||||
this.entryIterator = parent.entrySet().iterator();
|
||||
this.current = null;
|
||||
|
@ -404,7 +404,7 @@ public abstract class AbstractMultiSet<E> extends AbstractCollection<E> implemen
|
|||
/**
|
||||
* Inner class AbstractEntry.
|
||||
*/
|
||||
protected static abstract class AbstractEntry<E> implements Entry<E> {
|
||||
protected abstract static class AbstractEntry<E> implements Entry<E> {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
|
|
|
@ -104,7 +104,7 @@ public final class UnmodifiableMultiSet<E>
|
|||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator());
|
||||
return UnmodifiableIterator.<E>unmodifiableIterator(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
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 obtain a copy of the License at
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
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 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 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.
|
||||
-->
|
||||
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.
|
||||
-->
|
||||
<body>
|
||||
<p>
|
||||
Commons-Collections contains implementations, enhancements and utilities
|
||||
|
|
|
@ -82,7 +82,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
|
|||
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
|
|||
* the file.
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
|
|||
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
|
|||
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public abstract class AbstractPropertiesFactory<T extends Properties> {
|
|||
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class SequencesComparator<T> {
|
|||
vDown[1+offset] = start1;
|
||||
vUp[1+offset] = end1 + 1;
|
||||
|
||||
for (int d = 0; d <= offset ; ++d) {
|
||||
for (int d = 0; d <= offset; ++d) {
|
||||
// Down
|
||||
for (int k = -d; k <= d; k += 2) {
|
||||
// First step
|
||||
|
@ -314,7 +314,7 @@ public class SequencesComparator<T> {
|
|||
* @param end end index of the snake
|
||||
* @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.end = end;
|
||||
this.diag = diag;
|
||||
|
|
|
@ -150,11 +150,11 @@ public abstract class AbstractBitwiseTrie<K, V> extends AbstractMap<K, V>
|
|||
|
||||
protected V value;
|
||||
|
||||
public BasicEntry(final K key) {
|
||||
BasicEntry(final K key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public BasicEntry(final K key, final V value) {
|
||||
BasicEntry(final K key, final V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public abstract class AbstractBitwiseTrie<K, V> extends AbstractMap<K, V>
|
|||
return false;
|
||||
}
|
||||
|
||||
final Map.Entry<?, ?> other = (Map.Entry<?, ?>)o;
|
||||
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) o;
|
||||
if (compare(key, other.getKey())
|
||||
&& compare(value, other.getValue())) {
|
||||
return true;
|
||||
|
|
|
@ -55,7 +55,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
*/
|
||||
private transient volatile Set<K> keySet;
|
||||
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}. */
|
||||
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> current = root.left;
|
||||
TrieEntry<K, V> path = root;
|
||||
while(true) {
|
||||
while (true) {
|
||||
if (current.bitIndex >= entry.bitIndex
|
||||
|| current.bitIndex <= path.bitIndex) {
|
||||
entry.predecessor = entry;
|
||||
|
@ -247,14 +247,14 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
* <p>
|
||||
* 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);
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K,V>> entrySet() {
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
if (entrySet == null) {
|
||||
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> current = root.left;
|
||||
TrieEntry<K, V> path = root;
|
||||
while(true) {
|
||||
while (true) {
|
||||
if (current.bitIndex <= path.bitIndex) {
|
||||
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.
|
||||
*/
|
||||
TrieEntry<K, V> followLeft(TrieEntry<K, V> node) {
|
||||
while(true) {
|
||||
while (true) {
|
||||
TrieEntry<K, V> child = node.left;
|
||||
// if we hit root and it didn't have a node, go right instead.
|
||||
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,
|
||||
* 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
|
||||
// tree. (We do it here because there are other well-defined
|
||||
// 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
|
||||
* 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:
|
||||
// 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
|
||||
* 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:
|
||||
// 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
|
||||
* 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
|
||||
// tree. (We do it here because there are other well-defined
|
||||
// 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> current = root.left;
|
||||
TrieEntry<K, V> path = root;
|
||||
while(true) {
|
||||
while (true) {
|
||||
if (current.bitIndex <= path.bitIndex || lengthInBits <= current.bitIndex) {
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
|
||||
|
@ -1272,16 +1272,16 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
protected int bitIndex;
|
||||
|
||||
/** The parent of this entry. */
|
||||
protected TrieEntry<K,V> parent;
|
||||
protected TrieEntry<K, V> parent;
|
||||
|
||||
/** The left child of this entry. */
|
||||
protected TrieEntry<K,V> left;
|
||||
protected TrieEntry<K, V> left;
|
||||
|
||||
/** The right child of this entry. */
|
||||
protected TrieEntry<K,V> right;
|
||||
protected TrieEntry<K, V> right;
|
||||
|
||||
/** 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) {
|
||||
super(key, value);
|
||||
|
@ -1365,7 +1365,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
buffer.append(", ");
|
||||
|
||||
if (predecessor != null) {
|
||||
if(predecessor.bitIndex == -1) {
|
||||
if (predecessor.bitIndex == -1) {
|
||||
buffer.append("predecessor=").append("ROOT");
|
||||
} else {
|
||||
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()}.
|
||||
*/
|
||||
private class EntrySet extends AbstractSet<Map.Entry<K,V>> {
|
||||
private class EntrySet extends AbstractSet<Map.Entry<K, V>> {
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<K,V>> iterator() {
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return new EntryIterator();
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -1425,9 +1425,9 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
/**
|
||||
* 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
|
||||
public Map.Entry<K,V> next() {
|
||||
public Map.Entry<K, V> next() {
|
||||
return nextEntry();
|
||||
}
|
||||
}
|
||||
|
@ -1552,12 +1552,12 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
/**
|
||||
* Returns the next {@link TrieEntry}.
|
||||
*/
|
||||
protected TrieEntry<K,V> nextEntry() {
|
||||
protected TrieEntry<K, V> nextEntry() {
|
||||
if (expectedModCount != AbstractPatriciaTrie.this.modCount) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
final TrieEntry<K,V> e = next;
|
||||
final TrieEntry<K, V> e = next;
|
||||
if (e == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
@ -1650,12 +1650,12 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
return nextEntry;
|
||||
}
|
||||
|
||||
protected TrieEntry<K,V> previousEntry() {
|
||||
protected TrieEntry<K, V> previousEntry() {
|
||||
if (expectedModCount != AbstractPatriciaTrie.this.modCount) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
final TrieEntry<K,V> e = previous;
|
||||
final TrieEntry<K, V> e = previous;
|
||||
if (e == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
@ -1881,7 +1881,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
|
||||
@Override
|
||||
public K firstKey() {
|
||||
Map.Entry<K,V> e = null;
|
||||
Map.Entry<K, V> e = null;
|
||||
if (fromKey == null) {
|
||||
e = firstEntry();
|
||||
} else {
|
||||
|
@ -1901,7 +1901,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
|
||||
@Override
|
||||
public K lastKey() {
|
||||
Map.Entry<K,V> e;
|
||||
Map.Entry<K, V> e;
|
||||
if (toKey == null) {
|
||||
e = lastEntry();
|
||||
} else {
|
||||
|
@ -1965,7 +1965,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
/**
|
||||
* Creates a {@link RangeEntrySet}.
|
||||
*/
|
||||
public RangeEntrySet(final RangeMap delegate) {
|
||||
RangeEntrySet(final RangeMap 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.
|
||||
*/
|
||||
private final class EntryIterator extends TrieIterator<Map.Entry<K,V>> {
|
||||
private final class EntryIterator extends TrieIterator<Map.Entry<K, V>> {
|
||||
|
||||
private final K excludedKey;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
this.excludedKey = last != null ? last.getKey() : null;
|
||||
}
|
||||
|
@ -2067,7 +2067,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map.Entry<K,V> next() {
|
||||
public Map.Entry<K, V> next() {
|
||||
if (next == null || compare(next.key, excludedKey)) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
@ -2124,7 +2124,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
|
||||
fromKey = entry == null ? null : entry.getKey();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -2138,7 +2138,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
toKey = entry == null ? null : entry.getKey();
|
||||
|
||||
if (toKey != null) {
|
||||
entry = nextEntry((TrieEntry<K, V>)entry);
|
||||
entry = nextEntry((TrieEntry<K, V>) entry);
|
||||
toKey = entry == null ? null : entry.getKey();
|
||||
}
|
||||
|
||||
|
@ -2152,7 +2152,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
public K firstKey() {
|
||||
fixup();
|
||||
|
||||
Map.Entry<K,V> e = null;
|
||||
Map.Entry<K, V> e = null;
|
||||
if (fromKey == null) {
|
||||
e = firstEntry();
|
||||
} else {
|
||||
|
@ -2171,7 +2171,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
public K lastKey() {
|
||||
fixup();
|
||||
|
||||
Map.Entry<K,V> e = null;
|
||||
Map.Entry<K, V> e = null;
|
||||
if (toKey == null) {
|
||||
e = lastEntry();
|
||||
} else {
|
||||
|
@ -2275,7 +2275,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
/**
|
||||
* Creates a {@link PrefixRangeEntrySet}.
|
||||
*/
|
||||
public PrefixRangeEntrySet(final PrefixRangeMap delegate) {
|
||||
PrefixRangeEntrySet(final PrefixRangeMap delegate) {
|
||||
super(delegate);
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
@ -2286,14 +2286,14 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<K,V>> iterator() {
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
if (AbstractPatriciaTrie.this.modCount != expectedModCount) {
|
||||
prefixStart = subtree(delegate.prefix, delegate.offsetInBits, delegate.lengthInBits);
|
||||
expectedModCount = AbstractPatriciaTrie.this.modCount;
|
||||
}
|
||||
|
||||
if (prefixStart == null) {
|
||||
final Set<Map.Entry<K,V>> empty = Collections.emptySet();
|
||||
final Set<Map.Entry<K, V>> empty = Collections.emptySet();
|
||||
return empty.iterator();
|
||||
} else if (delegate.lengthInBits > prefixStart.bitIndex) {
|
||||
return new SingletonIterator(prefixStart);
|
||||
|
@ -2311,7 +2311,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
|
||||
private int hit = 0;
|
||||
|
||||
public SingletonIterator(final TrieEntry<K, V> entry) {
|
||||
SingletonIterator(final TrieEntry<K, V> entry) {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
|
@ -2368,7 +2368,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map.Entry<K,V> next() {
|
||||
public Map.Entry<K, V> next() {
|
||||
final Map.Entry<K, V> entry = nextEntry();
|
||||
if (lastOne) {
|
||||
next = null;
|
||||
|
@ -2419,7 +2419,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
|
|||
stream.defaultReadObject();
|
||||
root = new TrieEntry<>(null, null, -1);
|
||||
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 V v = (V) stream.readObject();
|
||||
put(k, v);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class StringKeyAnalyzer extends KeyAnalyzer<String> {
|
|||
// then figure out which bit makes the difference
|
||||
// and return it.
|
||||
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 index2 = beginIndex2 + i;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class BagUtilsTest {
|
|||
assertTrue("Returned object should be a PredicatedBag.",
|
||||
bag instanceof PredicatedBag);
|
||||
try {
|
||||
BagUtils.predicatedBag(null,truePredicate);
|
||||
BagUtils.predicatedBag(null, truePredicate);
|
||||
fail("Expecting NullPointerException for null bag.");
|
||||
} catch (final NullPointerException ex) {
|
||||
// expected
|
||||
|
|
|
@ -287,7 +287,7 @@ class BulkTestSuiteMaker {
|
|||
*
|
||||
* @param startingClass the starting class
|
||||
*/
|
||||
public BulkTestSuiteMaker(final Class<? extends BulkTest> startingClass) {
|
||||
BulkTestSuiteMaker(final Class<? extends BulkTest> startingClass) {
|
||||
this.startingClass = startingClass;
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ class BulkTestSuiteMaker {
|
|||
* @param m The simple test method
|
||||
*/
|
||||
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.verboseName = prefix + "." + m.getName();
|
||||
if (ignored.contains(bulk2.verboseName)) {
|
||||
|
@ -366,7 +366,7 @@ class BulkTestSuiteMaker {
|
|||
|
||||
BulkTest bulk2;
|
||||
try {
|
||||
bulk2 = (BulkTest)m.invoke(bulk, (Object[]) null);
|
||||
bulk2 = (BulkTest) m.invoke(bulk, (Object[]) null);
|
||||
if (bulk2 == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -652,7 +652,7 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
testPredicate = equalPredicate((Number) 45);
|
||||
test = CollectionUtils.find(collectionA, testPredicate);
|
||||
assertTrue(test == null);
|
||||
assertNull(CollectionUtils.find(null,testPredicate));
|
||||
assertNull(CollectionUtils.find(null, testPredicate));
|
||||
assertNull(CollectionUtils.find(collectionA, null));
|
||||
}
|
||||
|
||||
|
@ -1276,7 +1276,7 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
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
|
||||
public void transform1() {
|
||||
|
@ -1741,27 +1741,27 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
assertTrue(collectionA.contains(5));
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void getNegative() {
|
||||
CollectionUtils.get((Object)collectionA, -3);
|
||||
CollectionUtils.get((Object) collectionA, -3);
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
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() {
|
||||
CollectionUtils.get((Object)null, 0);
|
||||
CollectionUtils.get((Object) null, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get() {
|
||||
assertEquals(2, CollectionUtils.get((Object)collectionA, 2));
|
||||
assertEquals(2, CollectionUtils.get((Object)collectionA.iterator(), 2));
|
||||
assertEquals(2, CollectionUtils.get((Object) collectionA, 2));
|
||||
assertEquals(2, CollectionUtils.get((Object) collectionA.iterator(), 2));
|
||||
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
|
||||
|
|
|
@ -272,7 +272,7 @@ public class IterableUtilsTest {
|
|||
testPredicate = equalPredicate((Number) 45);
|
||||
test = IterableUtils.find(iterableA, testPredicate);
|
||||
assertTrue(test == null);
|
||||
assertNull(IterableUtils.find(null,testPredicate));
|
||||
assertNull(IterableUtils.find(null, testPredicate));
|
||||
try {
|
||||
IterableUtils.find(iterableA, null);
|
||||
fail("expecting NullPointerException");
|
||||
|
|
|
@ -117,7 +117,7 @@ public class ListUtilsTest {
|
|||
two.add("a");
|
||||
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
|
||||
|
@ -328,7 +328,7 @@ public class ListUtilsTest {
|
|||
index = ListUtils.indexOf(fullList, testPredicate);
|
||||
assertEquals(index, -1);
|
||||
|
||||
assertEquals(ListUtils.indexOf(null,testPredicate), -1);
|
||||
assertEquals(ListUtils.indexOf(null, testPredicate), -1);
|
||||
assertEquals(ListUtils.indexOf(fullList, null), -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ import org.junit.Test;
|
|||
|
||||
/**
|
||||
* Tests for MapUtils.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("boxing")
|
||||
public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
||||
|
@ -276,7 +275,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
|
||||
@Test
|
||||
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("2", "B");
|
||||
in.put("3", "C");
|
||||
|
@ -647,7 +646,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final String LABEL = "Print Map";
|
||||
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> son = new TreeMap<>();
|
||||
|
||||
|
@ -694,7 +693,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final String LABEL = "Print Map";
|
||||
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> son = new TreeMap<>();
|
||||
|
||||
|
@ -821,11 +820,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
/**
|
||||
* Test class for populateMap(MultiMap).
|
||||
*/
|
||||
public static class X implements Comparable<X> {
|
||||
static class X implements Comparable<X> {
|
||||
int key;
|
||||
String name;
|
||||
|
||||
public X(final int key, final String name) {
|
||||
X(final int key, final String name) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -834,7 +833,6 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
public int compareTo(final X o) {
|
||||
return key - o.key | name.compareTo(o.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -849,7 +847,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
|
||||
// Now test key transform population
|
||||
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());
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
@ -938,18 +936,18 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, Double> in = new HashMap<>();
|
||||
in.put("key", 2.0);
|
||||
|
||||
assertEquals(2.0, MapUtils.getDoubleValue(in,"key", 0.0), 0);
|
||||
assertEquals(2.0, MapUtils.getDoubleValue(in,"key"), 0);
|
||||
assertEquals(1.0, MapUtils.getDoubleValue(in,"noKey", 1.0), 0);
|
||||
assertEquals(5.0, MapUtils.getDoubleValue(in,"noKey", (key)->{
|
||||
assertEquals(2.0, MapUtils.getDoubleValue(in, "key", 0.0), 0);
|
||||
assertEquals(2.0, MapUtils.getDoubleValue(in, "key"), 0);
|
||||
assertEquals(1.0, MapUtils.getDoubleValue(in, "noKey", 1.0), 0);
|
||||
assertEquals(5.0, MapUtils.getDoubleValue(in, "noKey", (key)->{
|
||||
//sometimes the default value need to be calculated,such as System.currentTimeMillis()
|
||||
return 5.0D;
|
||||
}),0);
|
||||
|
||||
assertEquals(0, MapUtils.getDoubleValue(in,"noKey"), 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", (key)->{
|
||||
assertEquals(0, MapUtils.getDoubleValue(in, "noKey"), 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", (key)->{
|
||||
return 1.0;
|
||||
}), 0);
|
||||
|
||||
|
@ -958,7 +956,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final char decimalSeparator = getDecimalSeparator();
|
||||
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
|
||||
|
@ -966,16 +964,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, Float> in = new HashMap<>();
|
||||
in.put("key", 2.0f);
|
||||
|
||||
assertEquals(2.0, MapUtils.getFloatValue(in,"key", 0.0f), 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", (key)->{
|
||||
assertEquals(2.0, MapUtils.getFloatValue(in, "key", 0.0f), 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", (key) -> {
|
||||
return 1.0F;
|
||||
}), 0);
|
||||
assertEquals(0, MapUtils.getFloatValue(in,"noKey"), 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", (key)->{
|
||||
assertEquals(0, MapUtils.getFloatValue(in, "noKey"), 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", (key) -> {
|
||||
return 1.0F;
|
||||
}), 0);
|
||||
|
||||
|
@ -983,7 +981,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final char decimalSeparator = getDecimalSeparator();
|
||||
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
|
||||
|
@ -991,23 +989,23 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, Long> in = new HashMap<>();
|
||||
in.put("key", 2L);
|
||||
|
||||
assertEquals(2.0, MapUtils.getLongValue(in,"key", 0L), 0);
|
||||
assertEquals(2.0, MapUtils.getLongValue(in,"key"), 0);
|
||||
assertEquals(1, MapUtils.getLongValue(in,"noKey", 1L), 0);
|
||||
assertEquals(1, MapUtils.getLongValue(in,"noKey", (key)->{
|
||||
assertEquals(2.0, MapUtils.getLongValue(in, "key", 0L), 0);
|
||||
assertEquals(2.0, MapUtils.getLongValue(in, "key"), 0);
|
||||
assertEquals(1, MapUtils.getLongValue(in, "noKey", 1L), 0);
|
||||
assertEquals(1, MapUtils.getLongValue(in, "noKey", (key) -> {
|
||||
return 1L;
|
||||
}), 0);
|
||||
assertEquals(0, MapUtils.getLongValue(in,"noKey"), 0);
|
||||
assertEquals(2.0, MapUtils.getLong(in,"key", 0L), 0);
|
||||
assertEquals(1, MapUtils.getLong(in,"noKey", 1L), 0);
|
||||
assertEquals(1, MapUtils.getLong(in,"noKey", (key)->{
|
||||
assertEquals(0, MapUtils.getLongValue(in, "noKey"), 0);
|
||||
assertEquals(2.0, MapUtils.getLong(in, "key", 0L), 0);
|
||||
assertEquals(1, MapUtils.getLong(in, "noKey", 1L), 0);
|
||||
assertEquals(1, MapUtils.getLong(in, "noKey", (key) -> {
|
||||
return 1L;
|
||||
}), 0);
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -1017,23 +1015,23 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, Integer> in = new HashMap<>();
|
||||
in.put("key", 2);
|
||||
|
||||
assertEquals(2, MapUtils.getIntValue(in,"key", 0), 0);
|
||||
assertEquals(2, MapUtils.getIntValue(in,"key"), 0);
|
||||
assertEquals(0, MapUtils.getIntValue(in,"noKey", 0), 0);
|
||||
assertEquals(0, MapUtils.getIntValue(in,"noKey", (key)->{
|
||||
assertEquals(2, MapUtils.getIntValue(in, "key", 0), 0);
|
||||
assertEquals(2, MapUtils.getIntValue(in, "key"), 0);
|
||||
assertEquals(0, MapUtils.getIntValue(in, "noKey", 0), 0);
|
||||
assertEquals(0, MapUtils.getIntValue(in, "noKey", (key)->{
|
||||
return 0;
|
||||
}), 0);
|
||||
assertEquals(0, MapUtils.getIntValue(in,"noKey"), 0);
|
||||
assertEquals(2, MapUtils.getInteger(in,"key", 0), 0);
|
||||
assertEquals(0, MapUtils.getInteger(in,"noKey", 0), 0);
|
||||
assertEquals(0, MapUtils.getInteger(in,"noKey", (key)->{
|
||||
assertEquals(0, MapUtils.getIntValue(in, "noKey"), 0);
|
||||
assertEquals(2, MapUtils.getInteger(in, "key", 0), 0);
|
||||
assertEquals(0, MapUtils.getInteger(in, "noKey", 0), 0);
|
||||
assertEquals(0, MapUtils.getInteger(in, "noKey", (key)->{
|
||||
return 0;
|
||||
}), 0);
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "2");
|
||||
|
||||
assertEquals(MapUtils.getIntValue(inStr,"str1", 0), 2, 0);
|
||||
assertEquals(MapUtils.getIntValue(inStr, "str1", 0), 2, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1042,23 +1040,23 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final short val = 10;
|
||||
in.put("key", val);
|
||||
|
||||
assertEquals(val, MapUtils.getShortValue(in,"key", val), 0);
|
||||
assertEquals(val, MapUtils.getShortValue(in,"key"), 0);
|
||||
assertEquals(val, MapUtils.getShortValue(in,"noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getShortValue(in,"noKey", (key)->{
|
||||
assertEquals(val, MapUtils.getShortValue(in, "key", val), 0);
|
||||
assertEquals(val, MapUtils.getShortValue(in, "key"), 0);
|
||||
assertEquals(val, MapUtils.getShortValue(in, "noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getShortValue(in, "noKey", (key)->{
|
||||
return val;
|
||||
}), 0);
|
||||
assertEquals(0, MapUtils.getShortValue(in,"noKey"), 0);
|
||||
assertEquals(val, MapUtils.getShort(in,"key", val), 0);
|
||||
assertEquals(val,MapUtils.getShort(in,"noKey", val), 0);
|
||||
assertEquals(val,MapUtils.getShort(in,"noKey", (key)->{
|
||||
assertEquals(0, MapUtils.getShortValue(in, "noKey"), 0);
|
||||
assertEquals(val, MapUtils.getShort(in, "key", val), 0);
|
||||
assertEquals(val, MapUtils.getShort(in, "noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getShort(in, "noKey", (key)->{
|
||||
return val;
|
||||
}), 0);
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "10");
|
||||
|
||||
assertEquals(MapUtils.getShortValue(inStr,"str1", val), val, 0);
|
||||
assertEquals(MapUtils.getShortValue(inStr, "str1", val), val, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1067,16 +1065,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final byte val = 100;
|
||||
in.put("key", val);
|
||||
|
||||
assertEquals(val, MapUtils.getByteValue(in,"key", val), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in,"key"), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in,"noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in,"noKey", (key)->{
|
||||
return (byte)100;
|
||||
assertEquals(val, MapUtils.getByteValue(in, "key", val), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in, "key"), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in, "noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in, "noKey", (key) -> {
|
||||
return (byte) 100;
|
||||
}), 0);
|
||||
assertEquals(0, MapUtils.getByteValue(in,"noKey"), 0);
|
||||
assertEquals(val, MapUtils.getByte(in,"key", val), 0);
|
||||
assertEquals(val, MapUtils.getByte(in,"noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getByte(in,"noKey", (key)->{
|
||||
assertEquals(0, MapUtils.getByteValue(in, "noKey"), 0);
|
||||
assertEquals(val, MapUtils.getByte(in, "key", val), 0);
|
||||
assertEquals(val, MapUtils.getByte(in, "noKey", val), 0);
|
||||
assertEquals(val, MapUtils.getByte(in, "noKey", (key)->{
|
||||
return val;
|
||||
}), 0);
|
||||
|
||||
|
@ -1084,7 +1082,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "100");
|
||||
|
||||
assertEquals(MapUtils.getByteValue(inStr,"str1", val), val, 0);
|
||||
assertEquals(MapUtils.getByteValue(inStr, "str1", val), val, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1093,9 +1091,9 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Number val = 1000;
|
||||
in.put("key", val);
|
||||
|
||||
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", (key)->{
|
||||
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", (key) -> {
|
||||
if (true) {
|
||||
return val;
|
||||
} else {
|
||||
|
@ -1110,18 +1108,18 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, String> in = new HashMap<>();
|
||||
in.put("key", "str");
|
||||
|
||||
assertEquals("str", MapUtils.getString(in,"key", "defualt"));
|
||||
assertEquals("str", MapUtils.getString(in,"key"));
|
||||
assertEquals(null, MapUtils.getString(null,"key"));
|
||||
assertEquals("default", MapUtils.getString(in,"noKey", "default"));
|
||||
assertEquals("default", MapUtils.getString(in,"noKey", (key)->{
|
||||
assertEquals("str", MapUtils.getString(in, "key", "defualt"));
|
||||
assertEquals("str", MapUtils.getString(in, "key"));
|
||||
assertEquals(null, MapUtils.getString(null, "key"));
|
||||
assertEquals("default", MapUtils.getString(in, "noKey", "default"));
|
||||
assertEquals("default", MapUtils.getString(in, "noKey", (key)->{
|
||||
if ("noKey".equals(key)) {
|
||||
return "default";
|
||||
} else {
|
||||
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<>();
|
||||
in.put("key", "str");
|
||||
|
||||
assertEquals("str", MapUtils.getObject(in,"key", "defualt"));
|
||||
assertEquals("str", MapUtils.getObject(in,"key"));
|
||||
assertEquals(null, MapUtils.getObject(null,"key"));
|
||||
assertEquals("default", MapUtils.getObject(in,"noKey", "default"));
|
||||
assertEquals("default", MapUtils.getObject(null,"noKey", "default"));
|
||||
assertEquals("str", MapUtils.getObject(in, "key", "defualt"));
|
||||
assertEquals("str", MapUtils.getObject(in, "key"));
|
||||
assertEquals(null, MapUtils.getObject(null, "key"));
|
||||
assertEquals("default", MapUtils.getObject(in, "noKey", "default"));
|
||||
assertEquals("default", MapUtils.getObject(null, "noKey", "default"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1148,16 +1146,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertFalse(MapUtils.getBooleanValue(null, "keyString", null));
|
||||
assertFalse(MapUtils.getBooleanValue(in, null, null));
|
||||
assertFalse(MapUtils.getBooleanValue(null, null, null));
|
||||
assertTrue(MapUtils.getBooleanValue(in,"key", true));
|
||||
assertTrue(MapUtils.getBooleanValue(in,"key"));
|
||||
assertTrue(MapUtils.getBooleanValue(in,"noKey", true));
|
||||
assertTrue(MapUtils.getBooleanValue(in,"noKey", (key)->{
|
||||
assertTrue(MapUtils.getBooleanValue(in, "key", true));
|
||||
assertTrue(MapUtils.getBooleanValue(in, "key"));
|
||||
assertTrue(MapUtils.getBooleanValue(in, "noKey", true));
|
||||
assertTrue(MapUtils.getBooleanValue(in, "noKey", (key) -> {
|
||||
return true;
|
||||
}));
|
||||
assertTrue(!MapUtils.getBooleanValue(in,"noKey"));
|
||||
assertTrue(MapUtils.getBoolean(in,"key", true));
|
||||
assertTrue(MapUtils.getBoolean(in,"noKey", true));
|
||||
assertTrue(MapUtils.getBoolean(in,"noKey", (key)->{
|
||||
assertTrue(!MapUtils.getBooleanValue(in, "noKey"));
|
||||
assertTrue(MapUtils.getBoolean(in, "key", true));
|
||||
assertTrue(MapUtils.getBoolean(in, "noKey", true));
|
||||
assertTrue(MapUtils.getBoolean(in, "noKey", (key)->{
|
||||
if (System.currentTimeMillis() > 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1169,7 +1167,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertFalse(MapUtils.getBooleanValue(in, "noKey", (key) -> {
|
||||
return null;
|
||||
}));
|
||||
assertEquals(null, MapUtils.getBoolean(null,"noKey"));
|
||||
assertEquals(null, MapUtils.getBoolean(null, "noKey"));
|
||||
// Values are Numbers
|
||||
assertFalse(MapUtils.getBoolean(in, "keyNumberFalse"));
|
||||
assertTrue(MapUtils.getBoolean(in, "keyNumberTrue"));
|
||||
|
@ -1181,17 +1179,17 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "true");
|
||||
|
||||
assertTrue(MapUtils.getBooleanValue(inStr,"str1", true));
|
||||
assertTrue(MapUtils.getBoolean(inStr,"str1", true));
|
||||
assertTrue(MapUtils.getBooleanValue(inStr, "str1", true));
|
||||
assertTrue(MapUtils.getBoolean(inStr, "str1", true));
|
||||
}
|
||||
|
||||
@Test
|
||||
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<>();
|
||||
valMap.put("key1", "value1");
|
||||
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(null, outValue.get("key2"));
|
||||
|
@ -1204,8 +1202,8 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
|
||||
final Map<String, Object> inMap = new HashMap<>();
|
||||
|
||||
MapUtils.safeAddToMap(inMap,"key1", "value1");
|
||||
MapUtils.safeAddToMap(inMap,"key2", null);
|
||||
MapUtils.safeAddToMap(inMap, "key1", "value1");
|
||||
MapUtils.safeAddToMap(inMap, "key2", null);
|
||||
assertEquals("value1", inMap.get("key1"));
|
||||
assertEquals("", inMap.get("key2"));
|
||||
}
|
||||
|
@ -1226,6 +1224,4 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
}
|
||||
return '.';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -187,8 +187,7 @@ public class SetUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHashSet()
|
||||
{
|
||||
public void testHashSet() {
|
||||
final Set<?> set1 = SetUtils.unmodifiableSet();
|
||||
assertTrue("set is empty", set1.isEmpty());
|
||||
|
||||
|
@ -249,8 +248,7 @@ public class SetUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUnmodifiableSet()
|
||||
{
|
||||
public void testUnmodifiableSet() {
|
||||
final Set<?> set1 = SetUtils.unmodifiableSet();
|
||||
assertTrue("set is empty", set1.isEmpty());
|
||||
|
||||
|
@ -275,8 +273,7 @@ public class SetUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUnmodifiableSetWrap()
|
||||
{
|
||||
public void testUnmodifiableSetWrap() {
|
||||
final Set<Integer> set1 = SetUtils.unmodifiableSet(1, 2, 2, 3);
|
||||
final Set<Integer> set2 = SetUtils.unmodifiableSet(set1);
|
||||
assertSame(set1, set2);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class SplitMapUtilsTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
backingMap = new HashMap<>();
|
||||
transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer.<String> nopTransformer(),
|
||||
transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer.<String>nopTransformer(),
|
||||
stringToInt);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
transformedMap.put(String.valueOf(i), String.valueOf(i));
|
||||
|
|
|
@ -96,7 +96,7 @@ public class CollectionBagTest<T> extends AbstractCollectionTest<T> {
|
|||
final Bag<T> bag = makeObject();
|
||||
if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
|
||||
final Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
|
||||
assertTrue("Bag is empty",bag2.size() == 0);
|
||||
assertTrue("Bag is empty", bag2.size() == 0);
|
||||
assertEquals(bag, bag2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class CollectionSortedBagTest<T> extends AbstractCollectionTest<T> {
|
|||
final Bag<T> bag = makeObject();
|
||||
if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
|
||||
final Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
|
||||
assertTrue("Bag is empty",bag2.size() == 0);
|
||||
assertTrue("Bag is empty", bag2.size() == 0);
|
||||
assertEquals(bag, bag2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class PredicatedBagTest<T> extends AbstractBagTest<T> {
|
|||
assertEquals(true, bag.contains(els[i]));
|
||||
}
|
||||
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]));
|
||||
set = ((PredicatedBag<T>) bag).uniqueSet();
|
||||
assertTrue("Unique set now does not contain the first element",
|
||||
|
|
|
@ -69,11 +69,11 @@ public class AbstractOrderedBidiMapDecoratorTest<K, V>
|
|||
|
||||
private TestOrderedBidiMap<V, K> inverse = null;
|
||||
|
||||
public TestOrderedBidiMap() {
|
||||
TestOrderedBidiMap() {
|
||||
super(new DualTreeBidiMap<K, V>());
|
||||
}
|
||||
|
||||
public TestOrderedBidiMap(final OrderedBidiMap<K, V> map) {
|
||||
TestOrderedBidiMap(final OrderedBidiMap<K, V> map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
|
|||
sortedValues.addAll(map.values());
|
||||
sortedValues = Collections.unmodifiableList(sortedValues);
|
||||
|
||||
sortedNewValues.addAll(this.<V> getAsList(getNewSampleValues()));
|
||||
sortedNewValues.addAll(this.<V>getAsList(getNewSampleValues()));
|
||||
}
|
||||
|
||||
// public AbstractTestSortedBidiMap() {
|
||||
|
|
|
@ -52,8 +52,8 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
|
|||
@Override
|
||||
public DualTreeBidiMap<K, V> makeObject() {
|
||||
return new DualTreeBidiMap<>(
|
||||
new ReverseComparator<>(ComparableComparator.<K> comparableComparator()),
|
||||
new ReverseComparator<>(ComparableComparator.<V> comparableComparator()));
|
||||
new ReverseComparator<>(ComparableComparator.<K>comparableComparator()),
|
||||
new ReverseComparator<>(ComparableComparator.<V>comparableComparator()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +90,7 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
|
|||
final Object dest = in.readObject();
|
||||
in.close();
|
||||
|
||||
final SortedBidiMap<?,?> bidi = (SortedBidiMap<?,?>) dest;
|
||||
final SortedBidiMap<?, ?> bidi = (SortedBidiMap<?, ?>) dest;
|
||||
assertNotNull(obj.comparator());
|
||||
assertNotNull(bidi.comparator());
|
||||
assertTrue(bidi.comparator() instanceof ReverseComparator);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -25,7 +24,6 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.apache.commons.collections4.bloomfilter.hasher.Hasher;
|
||||
import org.apache.commons.collections4.bloomfilter.hasher.Shape;
|
||||
|
@ -147,11 +145,11 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
final int[] c1 = {1, 10, 100, 0};
|
||||
final int[] c2 = {4, 0, 7, 2};
|
||||
|
||||
final Map<Integer,Integer> map1 = new HashMap<>();
|
||||
final Map<Integer, Integer> map1 = new HashMap<>();
|
||||
for (int i = 0; i < c1.length; i++) {
|
||||
map1.put(i, c1[i]);
|
||||
}
|
||||
final Map<Integer,Integer> map2 = new HashMap<>();
|
||||
final Map<Integer, Integer> map2 = new HashMap<>();
|
||||
for (int i = 0; i < c2.length; i++) {
|
||||
map2.put(i, c2[i]);
|
||||
}
|
||||
|
@ -182,7 +180,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0
|
||||
};
|
||||
final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
|
||||
final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
final Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
final CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
|
@ -288,11 +286,11 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
// for (0 - 2). Fix this but the underflow behaviour is subject to change.
|
||||
c2[c2.length - 1] = 0;
|
||||
|
||||
final Map<Integer,Integer> map1 = new HashMap<>();
|
||||
final Map<Integer, Integer> map1 = new HashMap<>();
|
||||
for (int i = 0; i < c1.length; i++) {
|
||||
map1.put(i, c1[i]);
|
||||
}
|
||||
final Map<Integer,Integer> map2 = new HashMap<>();
|
||||
final Map<Integer, Integer> map2 = new HashMap<>();
|
||||
for (int i = 0; i < c2.length; i++) {
|
||||
map2.put(i, c2[i]);
|
||||
}
|
||||
|
@ -324,7 +322,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer, Integer> map = new HashMap<>();
|
||||
for (int i = 1; i < values.length; i++) {
|
||||
map.put(i, values[i]);
|
||||
}
|
||||
|
@ -355,7 +353,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer, Integer> map = new HashMap<>();
|
||||
for (int i = 1; i < values.length; i++) {
|
||||
map.put(i, values[i]);
|
||||
}
|
||||
|
@ -414,7 +412,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void testToString() {
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer, Integer> map = new HashMap<>();
|
||||
CountingBloomFilter bf = new CountingBloomFilter(map, shape);
|
||||
Assert.assertEquals("{}", bf.toString());
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -46,7 +45,7 @@ public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
|||
* @param hasher the Hasher to use.
|
||||
* @param shape the desired shape of the filter.
|
||||
*/
|
||||
public BF(final Hasher hasher, final Shape shape) {
|
||||
BF(final Hasher hasher, final Shape shape) {
|
||||
this(shape);
|
||||
verifyHasher(hasher);
|
||||
hasher.getBits(shape).forEachRemaining((IntConsumer) bitSet::set);
|
||||
|
@ -57,7 +56,7 @@ public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
|||
*
|
||||
* @param shape the desired shape of the filter.
|
||||
*/
|
||||
public BF(final Shape shape) {
|
||||
BF(final Shape shape) {
|
||||
super(shape);
|
||||
this.bitSet = new BitSet();
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -52,7 +51,7 @@ public class HashFunctionIdentityImplTest {
|
|||
|
||||
@Override
|
||||
public long getSignature() {
|
||||
return -1l;
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +65,7 @@ public class HashFunctionIdentityImplTest {
|
|||
assertEquals("Provider", impl.getProvider());
|
||||
assertEquals(Signedness.SIGNED, impl.getSignedness());
|
||||
assertEquals(ProcessType.CYCLIC, impl.getProcessType());
|
||||
assertEquals(-1l, impl.getSignature());
|
||||
assertEquals(-1L, impl.getSignature());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,11 +74,11 @@ public class HashFunctionIdentityImplTest {
|
|||
@Test
|
||||
public void valuesConstructorTest() {
|
||||
final HashFunctionIdentityImpl impl = new HashFunctionIdentityImpl("Provider", "NAME", Signedness.UNSIGNED,
|
||||
ProcessType.ITERATIVE, -2l);
|
||||
ProcessType.ITERATIVE, -2L);
|
||||
assertEquals("NAME", impl.getName());
|
||||
assertEquals("Provider", impl.getProvider());
|
||||
assertEquals(Signedness.UNSIGNED, impl.getSignedness());
|
||||
assertEquals(ProcessType.ITERATIVE, impl.getProcessType());
|
||||
assertEquals(-2l, impl.getSignature());
|
||||
assertEquals(-2L, impl.getSignature());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -23,8 +22,6 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity;
|
||||
import org.apache.commons.collections4.bloomfilter.hasher.Shape;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -132,7 +131,9 @@ public class StaticHasherTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() { return false; }
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
final StaticHasher hasher = new StaticHasher(testHasher, shape);
|
||||
|
@ -164,7 +165,9 @@ public class StaticHasherTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() { return false; }
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. 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 obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* 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 obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
|
@ -22,7 +21,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue