CPD Results
The following document contains the results of PMD's CPD 6.55.0.
Duplications
File |
Line |
org/apache/commons/collections4/bag/CollectionBag.java |
65 |
org/apache/commons/collections4/bag/CollectionSortedBag.java |
56 |
public CollectionBag(final Bag<E> bag) {
super(bag);
}
/**
* <i>(Change)</i>
* Adds one copy of the specified object to the Bag.
* <p>
* Since this method always increases the size of the bag, it
* will always return {@code true}.
*
* @param object the object to add
* @return {@code true}, always
*/
@Override
public boolean add(final E object) {
return add(object, 1);
}
/**
* <i>(Change)</i>
* Adds {@code count} copies of the specified object to the Bag.
* <p>
* Since this method always increases the size of the bag, it
* will always return {@code true}.
*
* @param object the object to add
* @param count the number of copies to add
* @return {@code true}, always
*/
@Override
public boolean add(final E object, final int count) {
decorated().add(object, count);
return true;
}
// Collection interface
@Override
public boolean addAll(final Collection<? extends E> coll) {
boolean changed = false;
for (final E current : coll) {
final boolean added = add(current, 1);
changed = changed || added;
}
return changed;
}
/**
* <i>(Change)</i>
* Returns {@code true} if the bag contains all elements in
* the given collection, <b>not</b> respecting cardinality. That is,
* if the given collection {@code coll} contains at least one of
* every object contained in this object.
*
* @param coll the collection to check against
* @return {@code true} if the Bag contains at least one of every object in the collection
*/
@Override
public boolean containsAll(final Collection<?> coll) {
return coll.stream().allMatch(this::contains);
}
/**
* Read the collection in using a custom routine.
*
* @param in the input stream
* @throws IOException if an error occurs while reading from the stream
* @throws ClassNotFoundException if an object read from the stream can not be loaded
* @throws ClassCastException if deserialized object has wrong type
*/
@SuppressWarnings("unchecked") // will throw CCE, see Javadoc
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
setCollection((Collection<E>) in.readObject());
}
/**
* <i>(Change)</i>
* Removes the first occurrence of the given object from the bag.
* <p>
* This will also remove the object from the {@link #uniqueSet()} if the
* bag contains no occurrence anymore of the object after this operation.
*
* @param object the object to remove
* @return {@code true} if this call changed the collection
*/
@Override
public boolean remove(final Object object) {
return remove(object, 1);
}
/**
* <i>(Change)</i>
* Remove all elements represented in the given collection,
* <b>not</b> respecting cardinality. That is, remove <i>all</i>
* occurrences of every object contained in the given collection.
*
* @param coll the collection to remove
* @return {@code true} if this call changed the collection
*/
@Override
public boolean removeAll(final Collection<?> coll) {
if (coll != null) {
boolean result = false;
for (final Object obj : coll) {
final boolean changed = remove(obj, getCount(obj));
result = result || changed;
}
return result;
}
// let the decorated bag handle the case of null argument
return decorated().removeAll(null);
}
/**
* <i>(Change)</i>
* Remove any members of the bag that are not in the given collection,
* <i>not</i> respecting cardinality. That is, any object in the given
* collection {@code coll} will be retained in the bag with the same
* number of copies prior to this operation. All other objects will be
* completely removed from this bag.
* <p>
* This implementation iterates over the elements of this bag, checking
* each element in turn to see if it's contained in {@code coll}.
* If it's not contained, it's removed from this bag. As a consequence,
* it is advised to use a collection type for {@code coll} that provides
* a fast (e.g. O(1)) implementation of {@link Collection#contains(Object)}.
*
* @param coll the collection to retain
* @return {@code true} if this call changed the collection
*/
@Override
public boolean retainAll(final Collection<?> coll) {
if (coll != null) {
boolean modified = false;
final Iterator<E> e = iterator();
while (e.hasNext()) {
if (!coll.contains(e.next())) {
e.remove();
modified = true;
}
}
return modified;
}
// let the decorated bag handle the case of null argument
return decorated().retainAll(null);
}
// Bag interface
/**
* Write the collection out using a custom routine.
*
* @param out the output stream
* @throws IOException if an error occurs while writing to the stream
*/
private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(decorated());
}
} |
File |
Line |
org/apache/commons/collections4/collection/CompositeCollection.java |
446 |
org/apache/commons/collections4/set/CompositeSet.java |
468 |
for (final Collection<E> item : all) {
size += item.size();
}
return size;
}
/**
* Returns an array containing all of the elements in this composite.
*
* @return an object array of all the elements in the collection
*/
@Override
public Object[] toArray() {
final Object[] result = new Object[size()];
int i = 0;
for (final Iterator<E> it = iterator(); it.hasNext(); i++) {
result[i] = it.next();
}
return result;
}
/**
* Returns an object array, populating the supplied array if possible.
* See {@code Collection} interface for full details.
*
* @param <T> the type of the elements in the collection
* @param array the array to use, populating if possible
* @return an array of all the elements in the collection
*/
@Override
@SuppressWarnings("unchecked")
public <T> T[] toArray(final T[] array) {
final int size = size();
Object[] result = null;
if (array.length >= size) {
result = array;
} else {
result = (Object[]) Array.newInstance(array.getClass().getComponentType(), size);
}
int offset = 0;
for (final Collection<E> item : all) {
for (final E e : item) {
result[offset++] = e;
}
}
if (result.length > size) {
result[size] = null;
}
return (T[]) result;
}
/**
* Returns a new collection containing all of the elements
*
* @return A new ArrayList containing all of the elements in this composite.
* The new collection is <i>not</i> backed by this composite.
*/
public Collection<E> toCollection() { |
File |
Line |
org/apache/commons/collections4/bag/AbstractMapBag.java |
64 |
org/apache/commons/collections4/multiset/AbstractMapMultiSet.java |
109 |
BagIterator(final AbstractMapBag<E> parent) {
this.parent = parent;
this.entryIterator = parent.map.entrySet().iterator();
this.current = null;
this.mods = parent.modCount;
this.canRemove = false;
}
/** {@inheritDoc} */
@Override
public boolean hasNext() {
return itemCount > 0 || entryIterator.hasNext();
}
/** {@inheritDoc} */
@Override
public E next() {
if (parent.modCount != mods) {
throw new ConcurrentModificationException();
}
if (itemCount == 0) {
current = entryIterator.next();
itemCount = current.getValue().value;
}
canRemove = true;
itemCount--;
return current.getKey();
}
/** {@inheritDoc} */
@Override
public void remove() {
if (parent.modCount != mods) {
throw new ConcurrentModificationException();
}
if (!canRemove) {
throw new IllegalStateException();
}
final MutableInteger mut = current.getValue();
if (mut.value > 1) {
mut.value--;
} else {
entryIterator.remove();
}
parent.size--;
canRemove = false;
}
}
/**
* Mutable integer class for storing the data.
*/
protected static class MutableInteger { |
File |
Line |
org/apache/commons/collections4/map/AbstractMapDecorator.java |
67 |
org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java |
53 |
decorated().clear();
}
@Override
public boolean containsKey(final Object key) {
return decorated().containsKey(key);
}
@Override
public boolean containsValue(final Object value) {
return decorated().containsValue(value);
}
/**
* Gets the map being decorated.
*
* @return the decorated map
*/
protected Map<K, V> decorated() {
return map;
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
return decorated().entrySet();
}
@Override
public boolean equals(final Object object) {
if (object == this) {
return true;
}
return decorated().equals(object);
}
@Override
public V get(final Object key) {
return decorated().get(key);
}
@Override
public int hashCode() {
return decorated().hashCode();
}
@Override
public boolean isEmpty() {
return decorated().isEmpty();
}
@Override
public Set<K> keySet() {
return decorated().keySet();
}
@Override
public V put(final K key, final V value) { |
File |
Line |
org/apache/commons/collections4/bag/UnmodifiableBag.java |
103 |
org/apache/commons/collections4/bag/UnmodifiableSortedBag.java |
100 |
return UnmodifiableIterator.<E>unmodifiableIterator(decorated().iterator());
}
/**
* Read the collection in using a custom routine.
*
* @param in the input stream
* @throws IOException if an error occurs while reading from the stream
* @throws ClassNotFoundException if an object read from the stream can not be loaded
* @throws ClassCastException if deserialized object has wrong type
*/
@SuppressWarnings("unchecked") // will throw CCE, see Javadoc
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
setCollection((Collection<E>) in.readObject());
}
@Override
public boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
@Override
public boolean remove(final Object object, final int count) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(final Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public Set<E> uniqueSet() {
final Set<E> set = decorated().uniqueSet();
return UnmodifiableSet.<E>unmodifiableSet(set); |
File |
Line |
org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java |
101 |
org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMap.java |
99 |
inverse = new UnmodifiableOrderedBidiMap<>(decorated().inverseBidiMap());
inverse.inverse = this;
}
return inverse;
}
@Override
public Set<K> keySet() {
final Set<K> set = super.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public OrderedMapIterator<K, V> mapIterator() {
final OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
}
@Override
public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
@Override
public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public K removeValue(final Object value) {
throw new UnsupportedOperationException();
}
@Override
public Set<V> values() { |
File |
Line |
org/apache/commons/collections4/map/UnmodifiableMap.java |
109 |
org/apache/commons/collections4/map/UnmodifiableOrderedMap.java |
103 |
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
}
@Override
public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
/**
* Read the map in using a custom routine.
*
* @param in the input stream
* @throws IOException if an error occurs while reading from the stream
* @throws ClassNotFoundException if an object read from the stream can not be loaded
* @since 3.1
*/
@SuppressWarnings("unchecked")
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
map = (Map<K, V>) in.readObject();
}
@Override
public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public Collection<V> values() {
final Collection<V> coll = super.values();
return UnmodifiableCollection.unmodifiableCollection(coll);
}
/**
* Write the map out using a custom routine.
*
* @param out the output stream
* @throws IOException if an error occurs while writing to the stream
* @since 3.1
*/
private void writeObject(final ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(map);
}
} |
File |
Line |
org/apache/commons/collections4/collection/UnmodifiableCollection.java |
73 |
org/apache/commons/collections4/set/UnmodifiableSet.java |
72 |
super((Collection<E>) coll);
}
@Override
public boolean add(final E object) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(final Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@Override
public boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(final Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
} |
File |
Line |
org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java |
780 |
org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java |
135 |
return it.hasNext() && CollectionUtils.addAll(get(key), it);
}
/**
* Copies all of the mappings from the specified map to this map. The effect
* of this call is equivalent to that of calling {@link #put(Object,Object)
* put(k, v)} on this map once for each mapping from key {@code k} to value
* {@code v} in the specified map. The behavior of this operation is
* undefined if the specified map is modified while the operation is in
* progress.
*
* @param map mappings to be stored in this map, may not be null
* @return true if the map changed as a result of this operation
* @throws NullPointerException if map is null
*/
@Override
public boolean putAll(final Map<? extends K, ? extends V> map) {
Objects.requireNonNull(map, "map");
boolean changed = false;
for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
changed |= put(entry.getKey(), entry.getValue());
}
return changed;
}
/**
* Copies all of the mappings from the specified MultiValuedMap to this map.
* The effect of this call is equivalent to that of calling
* {@link #put(Object,Object) put(k, v)} on this map once for each mapping
* from key {@code k} to value {@code v} in the specified map. The
* behavior of this operation is undefined if the specified map is modified
* while the operation is in progress.
*
* @param map mappings to be stored in this map, may not be null
* @return true if the map changed as a result of this operation
* @throws NullPointerException if map is null
*/
@Override
public boolean putAll(final MultiValuedMap<? extends K, ? extends V> map) {
Objects.requireNonNull(map, "map");
boolean changed = false;
for (final Map.Entry<? extends K, ? extends V> entry : map.entries()) {
changed |= put(entry.getKey(), entry.getValue());
}
return changed;
} |
File |
Line |
org/apache/commons/collections4/list/AbstractListDecorator.java |
64 |
org/apache/commons/collections4/list/PredicatedList.java |
126 |
return decorated().addAll(index, coll);
}
/**
* Gets the list being decorated.
*
* @return the decorated list
*/
@Override
protected List<E> decorated() {
return (List<E>) super.decorated();
}
@Override
public boolean equals(final Object object) {
return object == this || decorated().equals(object);
}
@Override
public E get(final int index) {
return decorated().get(index);
}
@Override
public int hashCode() {
return decorated().hashCode();
}
@Override
public int indexOf(final Object object) {
return decorated().indexOf(object);
}
@Override
public int lastIndexOf(final Object object) {
return decorated().lastIndexOf(object);
}
@Override
public ListIterator<E> listIterator() {
return decorated().listIterator(); |
File |
Line |
org/apache/commons/collections4/bag/AbstractBagDecorator.java |
58 |
org/apache/commons/collections4/bag/PredicatedBag.java |
87 |
return decorated().add(object, count);
}
/**
* Gets the bag being decorated.
*
* @return the decorated bag
*/
@Override
protected Bag<E> decorated() {
return (Bag<E>) super.decorated();
}
@Override
public boolean equals(final Object object) {
return object == this || decorated().equals(object);
}
@Override
public int getCount(final Object object) {
return decorated().getCount(object);
}
@Override
public int hashCode() {
return decorated().hashCode();
}
@Override
public boolean remove(final Object object, final int count) {
return decorated().remove(object, count);
}
@Override
public Set<E> uniqueSet() {
return decorated().uniqueSet();
}
} |
File |
Line |
org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java |
75 |
org/apache/commons/collections4/iterators/EntrySetMapIterator.java |
55 |
this.iterator = parent.normalMap.entrySet().iterator();
}
@Override
public K getKey() {
if (last == null) {
throw new IllegalStateException(
"Iterator getKey() can only be called after next() and before remove()");
}
return last.getKey();
}
@Override
public V getValue() {
if (last == null) {
throw new IllegalStateException(
"Iterator getValue() can only be called after next() and before remove()");
}
return last.getValue();
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public K next() {
last = iterator.next();
canRemove = true;
return last.getKey();
}
@Override
public void remove() {
if (!canRemove) {
throw new IllegalStateException("Iterator remove() can only be called once after next()");
} |
File |
Line |
org/apache/commons/collections4/set/PredicatedNavigableSet.java |
116 |
org/apache/commons/collections4/set/TransformedNavigableSet.java |
136 |
return predicatedNavigableSet(head, predicate);
}
@Override
public E higher(final E e) {
return decorated().higher(e);
}
@Override
public E lower(final E e) {
return decorated().lower(e);
}
@Override
public E pollFirst() {
return decorated().pollFirst();
}
@Override
public E pollLast() {
return decorated().pollLast();
}
@Override
public NavigableSet<E> subSet(final E fromElement, final boolean fromInclusive, final E toElement,
final boolean toInclusive) {
final NavigableSet<E> sub = decorated().subSet(fromElement, fromInclusive, toElement, toInclusive);
return predicatedNavigableSet(sub, predicate); |
File |
Line |
org/apache/commons/collections4/multiset/AbstractMultiSetDecorator.java |
71 |
org/apache/commons/collections4/multiset/PredicatedMultiSet.java |
101 |
public Set<Entry<E>> entrySet() {
return decorated().entrySet();
}
@Override
public boolean equals(final Object object) {
return object == this || decorated().equals(object);
}
@Override
public int getCount(final Object object) {
return decorated().getCount(object);
}
@Override
public int hashCode() {
return decorated().hashCode();
}
@Override
public int remove(final Object object, final int count) {
return decorated().remove(object, count);
}
@Override
public int setCount(final E object, final int count) { |
File |
Line |
org/apache/commons/collections4/set/UnmodifiableNavigableSet.java |
128 |
org/apache/commons/collections4/set/UnmodifiableSortedSet.java |
98 |
throw new UnsupportedOperationException();
}
/**
* Read the collection in using a custom routine.
*
* @param in the input stream
* @throws IOException if an error occurs while reading from the stream
* @throws ClassNotFoundException if an object read from the stream can not be loaded
*/
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
setCollection((Collection<E>) in.readObject()); // (1)
}
@Override
public boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(final Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public NavigableSet<E> subSet(final E fromElement, final boolean fromInclusive, final E toElement, |
File |
Line |
org/apache/commons/collections4/bag/AbstractMapBag.java |
317 |
org/apache/commons/collections4/multiset/AbstractMapMultiSet.java |
376 |
final Bag<?> other = (Bag<?>) object;
if (other.size() != size()) {
return false;
}
for (final E element : map.keySet()) {
if (other.getCount(element) != getCount(element)) {
return false;
}
}
return true;
}
/**
* Returns the number of occurrence of the given element in this bag by
* looking up its count in the underlying map.
*
* @param object the object to search for
* @return the number of occurrences of the object, zero if not found
*/
@Override
public int getCount(final Object object) {
final MutableInteger count = map.get(object);
if (count != null) {
return count.value;
}
return 0;
}
/**
* Utility method for implementations to access the map that backs this bag.
* Not intended for interactive use outside of subclasses.
*
* @return the map being used by the Bag
*/
protected Map<E, MutableInteger> getMap() {
return map;
}
/**
* Gets a hash code for the Bag compatible with the definition of equals.
* The hash code is defined as the sum total of a hash code for each
* element. The per element hash code is defined as
* {@code (e==null ? 0 : e.hashCode()) ^ noOccurrences)}. This hash code
* is compatible with the Set interface.
*
* @return the hash code of the Bag
*/
@Override
public int hashCode() {
int total = 0;
for (final Entry<E, MutableInteger> entry : map.entrySet()) { |
File |
Line |
org/apache/commons/collections4/keyvalue/AbstractMapEntry.java |
39 |
org/apache/commons/collections4/map/AbstractHashedMap.java |
158 |
}
/**
* Compares this {@code Map.Entry} with another {@code Map.Entry}.
* <p>
* Implemented per API documentation of {@link java.util.Map.Entry#equals(Object)}
*
* @param obj the object to compare to
* @return true if equal key and value
*/
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Map.Entry)) {
return false;
}
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return
(getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) &&
(getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
}
/**
* Gets a hashCode compatible with the equals method.
* <p>
* Implemented per API documentation of {@link java.util.Map.Entry#hashCode()}
*
* @return a suitable hash code
*/
@Override |
File |
Line |
org/apache/commons/collections4/bidimap/UnmodifiableBidiMap.java |
106 |
org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java |
116 |
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
}
@Override
public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
@Override
public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public K removeValue(final Object value) {
throw new UnsupportedOperationException();
}
@Override
public Set<V> values() {
final Set<V> set = super.values();
return UnmodifiableSet.unmodifiableSet(set);
}
} |
File |
Line |
org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java |
105 |
org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMap.java |
103 |
org/apache/commons/collections4/map/UnmodifiableOrderedMap.java |
92 |
}
@Override
public Set<K> keySet() {
final Set<K> set = super.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public OrderedMapIterator<K, V> mapIterator() {
final OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
}
@Override
public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
@Override |
File |
Line |
org/apache/commons/collections4/list/AbstractLinkedList.java |
366 |
org/apache/commons/collections4/list/CursorableLinkedList.java |
253 |
super(sub.parent, startIndex + sub.offset);
this.sub = sub;
}
@Override
public void add(final E obj) {
super.add(obj);
sub.expectedModCount = parent.modCount;
sub.size++;
}
@Override
public boolean hasNext() {
return nextIndex() < sub.size;
}
@Override
public boolean hasPrevious() {
return previousIndex() >= 0;
}
@Override
public int nextIndex() {
return super.nextIndex() - sub.offset;
}
@Override
public void remove() {
super.remove();
sub.expectedModCount = parent.modCount;
sub.size--;
}
} |
File |
Line |
org/apache/commons/collections4/keyvalue/AbstractMapEntry.java |
57 |
org/apache/commons/collections4/keyvalue/DefaultKeyValue.java |
92 |
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return
(getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) &&
(getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
}
/**
* Gets a hashCode compatible with the equals method.
* <p>
* Implemented per API documentation of {@link java.util.Map.Entry#hashCode()}
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode());
}
/**
* Sets the value stored in this {@code Map.Entry}.
* <p>
* This {@code Map.Entry} is not connected to a Map, so only the
* local data is changed.
*
* @param value the new value
* @return the previous value
*/
@Override
public V setValue(final V value) { // NOPMD |
File |
Line |
org/apache/commons/collections4/map/AbstractHashedMap.java |
296 |
org/apache/commons/collections4/map/AbstractReferenceMap.java |
460 |
protected HashMapIterator(final AbstractHashedMap<K, V> parent) {
super(parent);
}
@Override
public K getKey() {
final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
}
return current.getKey();
}
@Override
public V getValue() {
final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
}
return current.getValue();
}
@Override
public K next() {
return super.nextEntry().getKey(); |
File |
Line |
org/apache/commons/collections4/map/MultiKeyMap.java |
230 |
org/apache/commons/collections4/map/MultiKeyMap.java |
325 |
public boolean containsKey(final Object key1, final Object key2, final Object key3,
final Object key4, final Object key5) {
final int hashCode = hash(key1, key2, key3, key4, key5);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
return true; |
File |
Line |
org/apache/commons/collections4/map/MultiKeyMap.java |
500 |
org/apache/commons/collections4/map/MultiKeyMap.java |
522 |
multi.size() == 4 &&
(key1 == multi.getKey(0) || key1 != null && key1.equals(multi.getKey(0))) &&
(key2 == multi.getKey(1) || key2 != null && key2.equals(multi.getKey(1))) &&
(key3 == multi.getKey(2) || key3 != null && key3.equals(multi.getKey(2))) &&
(key4 == multi.getKey(3) || key4 != null && key4.equals(multi.getKey(3))); |
File |
Line |
org/apache/commons/collections4/map/UnmodifiableMap.java |
109 |
org/apache/commons/collections4/map/UnmodifiableOrderedMap.java |
103 |
org/apache/commons/collections4/map/UnmodifiableSortedMap.java |
115 |
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
}
@Override
public V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(final Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException();
}
/**
* Read the map in using a custom routine.
*
* @param in the input stream
* @throws IOException if an error occurs while reading from the stream
* @throws ClassNotFoundException if an object read from the stream can not be loaded
* @since 3.1
*/
@SuppressWarnings("unchecked")
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
map = (Map<K, V>) in.readObject();
}
@Override
public V remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
public Collection<V> values() { |
File |
Line |
org/apache/commons/collections4/set/AbstractNavigableSetDecorator.java |
86 |
org/apache/commons/collections4/set/PredicatedNavigableSet.java |
116 |
org/apache/commons/collections4/set/TransformedNavigableSet.java |
136 |
return decorated().headSet(toElement, inclusive);
}
@Override
public E higher(final E e) {
return decorated().higher(e);
}
@Override
public E lower(final E e) {
return decorated().lower(e);
}
@Override
public E pollFirst() {
return decorated().pollFirst();
}
@Override
public E pollLast() {
return decorated().pollLast();
}
@Override
public NavigableSet<E> subSet(final E fromElement, final boolean fromInclusive, final E toElement,
final boolean toInclusive) { |
File |
Line |
org/apache/commons/collections4/map/UnmodifiableMap.java |
82 |
org/apache/commons/collections4/map/UnmodifiableOrderedMap.java |
80 |
super((Map<K, V>) map);
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
final Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
}
@Override
public Set<K> keySet() {
final Set<K> set = super.keySet();
return UnmodifiableSet.unmodifiableSet(set);
}
@Override
public MapIterator<K, V> mapIterator() { |
File |
Line |
org/apache/commons/collections4/map/MultiKeyMap.java |
207 |
org/apache/commons/collections4/map/MultiKeyMap.java |
302 |
public boolean containsKey(final Object key1, final Object key2, final Object key3, final Object key4) {
final int hashCode = hash(key1, key2, key3, key4);
AbstractHashedMap.HashEntry<MultiKey<? extends K>, V> entry =
decorated().data[decorated().hashIndex(hashCode, decorated().data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
return true; |
|