CPD Results
The following document contains the results of PMD's CPD 6.13.0.
Duplications
File |
Line |
org\apache\commons\collections4\bag\CollectionBag.java |
66 |
org\apache\commons\collections4\bag\CollectionSortedBag.java |
57 |
public CollectionBag(final Bag<E> bag) {
super(bag);
}
//-----------------------------------------------------------------------
/**
* 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());
}
/**
* 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 deserialised 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());
}
//-----------------------------------------------------------------------
// Collection interface
//-----------------------------------------------------------------------
/**
* <i>(Change)</i>
* Returns <code>true</code> if the bag contains all elements in
* the given collection, <b>not</b> respecting cardinality. That is,
* if the given collection <code>coll</code> contains at least one of
* every object contained in this object.
*
* @param coll the collection to check against
* @return <code>true</code> if the Bag contains at least one of every object in the collection
*/
@Override
public boolean containsAll(final Collection<?> coll) {
final Iterator<?> e = coll.iterator();
while (e.hasNext()) {
if(!contains(e.next())) {
return false;
}
}
return true;
}
/**
* <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</code>.
*
* @param object the object to add
* @return <code>true</code>, always
*/
@Override
public boolean add(final E object) {
return add(object, 1);
}
@Override
public boolean addAll(final Collection<? extends E> coll) {
boolean changed = false;
final Iterator<? extends E> i = coll.iterator();
while (i.hasNext()) {
final boolean added = add(i.next(), 1);
changed = changed || added;
}
return changed;
}
/**
* <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</code> 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</code> if this call changed the collection
*/
@Override
public boolean removeAll(final Collection<?> coll) {
if (coll != null) {
boolean result = false;
final Iterator<?> i = coll.iterator();
while (i.hasNext()) {
final Object obj = i.next();
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</code> 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</code>.
* 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</code> that provides
* a fast (e.g. O(1)) implementation of {@link Collection#contains(Object)}.
*
* @param coll the collection to retain
* @return <code>true</code> 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
//-----------------------------------------------------------------------
/**
* <i>(Change)</i>
* Adds <code>count</code> 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</code>.
*
* @param object the object to add
* @param count the number of copies to add
* @return <code>true</code>, always
*/
@Override
public boolean add(final E object, final int count) {
decorated().add(object, count);
return true;
}
} |
File |
Line |
org\apache\commons\collections4\collection\CompositeCollection.java |
161 |
org\apache\commons\collections4\set\CompositeSet.java |
159 |
for (final Collection<E> item : all) {
chain.addIterator(item.iterator());
}
return chain;
}
/**
* 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</code> 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;
}
/**
* Adds an object to the collection, throwing UnsupportedOperationException
* unless a CollectionMutator strategy is specified.
*
* @param obj the object to add
* @return {@code true} if the collection was modified
* @throws UnsupportedOperationException if CollectionMutator hasn't been set
* @throws UnsupportedOperationException if add is unsupported
* @throws ClassCastException if the object cannot be added due to its type
* @throws NullPointerException if the object cannot be added because its null
* @throws IllegalArgumentException if the object cannot be added
*/
@Override
public boolean add(final E obj) {
if (mutator == null) {
throw new UnsupportedOperationException( |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableBag.java |
79 |
org\apache\commons\collections4\multiset\UnmodifiableMultiSet.java |
75 |
super((Bag<E>) bag);
}
//-----------------------------------------------------------------------
/**
* 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());
}
/**
* 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 deserialised 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 Iterator<E> iterator() {
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) { |
File |
Line |
org\apache\commons\collections4\bidimap\UnmodifiableBidiMap.java |
75 |
org\apache\commons\collections4\bidimap\UnmodifiableOrderedBidiMap.java |
76 |
org\apache\commons\collections4\bidimap\UnmodifiableSortedBidiMap.java |
77 |
super((BidiMap<K, V>) map);
}
//-----------------------------------------------------------------------
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@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 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 Set<V> values() {
final Set<V> set = super.values();
return UnmodifiableSet.unmodifiableSet(set);
}
//-----------------------------------------------------------------------
@Override
public K removeValue(final Object value) {
throw new UnsupportedOperationException();
}
@Override
public MapIterator<K, V> mapIterator() { |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableBag.java |
111 |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
108 |
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) {
throw new UnsupportedOperationException();
}
@Override
public boolean remove(final Object object, final int count) {
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\set\UnmodifiableNavigableSet.java |
69 |
org\apache\commons\collections4\set\UnmodifiableSortedSet.java |
72 |
private UnmodifiableNavigableSet(final NavigableSet<E> set) {
super(set);
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
// SortedSet
//-----------------------------------------------------------------------
@Override
public SortedSet<E> subSet(final E fromElement, final E toElement) {
final SortedSet<E> sub = decorated().subSet(fromElement, toElement);
return UnmodifiableSortedSet.unmodifiableSortedSet(sub); |
File |
Line |
org\apache\commons\collections4\bag\AbstractMapBag.java |
194 |
org\apache\commons\collections4\multiset\AbstractMapMultiSet.java |
168 |
public 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 == false) {
throw new IllegalStateException();
}
final MutableInteger mut = current.getValue();
if (mut.value > 1) {
mut.value--;
} else {
entryIterator.remove();
}
parent.size--;
canRemove = false;
}
}
//-----------------------------------------------------------------------
/**
* Adds a new element to the bag, incrementing its count in the underlying map.
*
* @param object the object to add
* @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
*/
@Override
public boolean add(final E object) { |
File |
Line |
org\apache\commons\collections4\multimap\AbstractMultiValuedMap.java |
268 |
org\apache\commons\collections4\multimap\TransformedMultiValuedMap.java |
167 |
return coll.add(value);
}
/**
* 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) {
if (map == null) {
throw new NullPointerException("Map must not be null.");
}
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) {
if (map == null) {
throw new NullPointerException("Map must not be null.");
}
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\collection\UnmodifiableBoundedCollection.java |
116 |
org\apache\commons\collections4\collection\UnmodifiableCollection.java |
74 |
super((BoundedCollection<E>) coll);
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(final Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
} |
File |
Line |
org\apache\commons\collections4\keyvalue\AbstractMapEntry.java |
55 |
org\apache\commons\collections4\map\AbstractHashedMap.java |
1112 |
}
/**
* Compares this <code>Map.Entry</code> with another <code>Map.Entry</code>.
* <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 == false) {
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
public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode());
} |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
102 |
org\apache\commons\collections4\set\UnmodifiableNavigableSet.java |
70 |
org\apache\commons\collections4\set\UnmodifiableSortedSet.java |
73 |
setCollection((Collection<E>) in.readObject());
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) { |
File |
Line |
org\apache\commons\collections4\list\UnmodifiableList.java |
74 |
org\apache\commons\collections4\queue\UnmodifiableQueue.java |
99 |
super((List<E>) list);
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@Override
public boolean add(final Object 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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public ListIterator<E> listIterator() { |
File |
Line |
org\apache\commons\collections4\bidimap\UnmodifiableBidiMap.java |
75 |
org\apache\commons\collections4\bidimap\UnmodifiableOrderedBidiMap.java |
76 |
org\apache\commons\collections4\bidimap\UnmodifiableSortedBidiMap.java |
77 |
org\apache\commons\collections4\map\UnmodifiableOrderedMap.java |
115 |
super((BidiMap<K, V>) map);
}
//-----------------------------------------------------------------------
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@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 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 Set<V> values() { |
File |
Line |
org\apache\commons\collections4\set\UnmodifiableNavigableSet.java |
70 |
org\apache\commons\collections4\set\UnmodifiableSet.java |
73 |
org\apache\commons\collections4\set\UnmodifiableSortedSet.java |
73 |
super(set);
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
} |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
102 |
org\apache\commons\collections4\set\UnmodifiableSet.java |
73 |
setCollection((Collection<E>) in.readObject());
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
} |
File |
Line |
org\apache\commons\collections4\set\AbstractNavigableSetDecorator.java |
52 |
org\apache\commons\collections4\set\PredicatedNavigableSet.java |
81 |
org\apache\commons\collections4\set\TransformedNavigableSet.java |
101 |
super(set);
}
/**
* Gets the set being decorated.
*
* @return the decorated set
*/
@Override
protected NavigableSet<E> decorated() {
return (NavigableSet<E>) super.decorated();
}
//-----------------------------------------------------------------------
@Override
public E lower(final E e) {
return decorated().lower(e);
}
@Override
public E floor(final E e) {
return decorated().floor(e);
}
@Override
public E ceiling(final E e) {
return decorated().ceiling(e);
}
@Override
public E higher(final E e) {
return decorated().higher(e);
}
@Override
public E pollFirst() {
return decorated().pollFirst();
}
@Override
public E pollLast() {
return decorated().pollLast();
}
@Override
public NavigableSet<E> descendingSet() {
return decorated().descendingSet(); |
File |
Line |
org\apache\commons\collections4\map\UnmodifiableMap.java |
83 |
org\apache\commons\collections4\map\UnmodifiableSortedMap.java |
81 |
super((Map<K, V>) map);
}
//-----------------------------------------------------------------------
/**
* 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);
}
/**
* 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 void clear() {
throw new UnsupportedOperationException();
}
@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 MapIterator<K, V> mapIterator() { |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableBag.java |
111 |
org\apache\commons\collections4\set\UnmodifiableNavigableSet.java |
76 |
org\apache\commons\collections4\set\UnmodifiableSortedSet.java |
79 |
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) { |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
108 |
org\apache\commons\collections4\multiset\UnmodifiableMultiSet.java |
107 |
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) { |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableBag.java |
111 |
org\apache\commons\collections4\multiset\UnmodifiableMultiSet.java |
107 |
org\apache\commons\collections4\set\UnmodifiableSet.java |
79 |
return UnmodifiableIterator.<E> unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
} |
File |
Line |
org\apache\commons\collections4\map\AbstractHashedMap.java |
775 |
org\apache\commons\collections4\map\AbstractReferenceMap.java |
937 |
return super.nextEntry().getKey();
}
@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 V setValue(final V value) {
final HashEntry<K, V> current = currentEntry();
if (current == null) {
throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
}
return current.setValue(value);
}
} |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableBag.java |
115 |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
112 |
org\apache\commons\collections4\queue\UnmodifiableQueue.java |
109 |
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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) { |
File |
Line |
org\apache\commons\collections4\map\FixedSizeMap.java |
90 |
org\apache\commons\collections4\map\FixedSizeSortedMap.java |
101 |
}
//-----------------------------------------------------------------------
/**
* 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);
}
/**
* 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") // (1) should only fail if input stream is incorrect
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
map = (Map<K, V>) in.readObject(); // (1)
}
//-----------------------------------------------------------------------
@Override
public V put(final K key, final V value) {
if (map.containsKey(key) == false) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
}
return map.put(key, value);
}
@Override
public void putAll(final Map<? extends K, ? extends V> mapToCopy) { |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableBag.java |
115 |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
112 |
org\apache\commons\collections4\list\UnmodifiableList.java |
84 |
org\apache\commons\collections4\multiset\UnmodifiableMultiSet.java |
111 |
org\apache\commons\collections4\queue\UnmodifiableQueue.java |
109 |
org\apache\commons\collections4\set\UnmodifiableNavigableSet.java |
80 |
org\apache\commons\collections4\set\UnmodifiableSortedSet.java |
83 |
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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
@Override
public boolean add(final E object, final int count) { |
File |
Line |
org\apache\commons\collections4\list\UnmodifiableList.java |
84 |
org\apache\commons\collections4\queue\UnmodifiableQueue.java |
109 |
org\apache\commons\collections4\set\UnmodifiableSet.java |
83 |
public boolean add(final Object 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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException();
} |
File |
Line |
org\apache\commons\collections4\map\LazySortedMap.java |
123 |
org\apache\commons\collections4\map\PredicatedSortedMap.java |
92 |
org\apache\commons\collections4\map\TransformedSortedMap.java |
122 |
super(map, factory);
}
//-----------------------------------------------------------------------
/**
* Gets the map being decorated.
*
* @return the decorated map
*/
protected SortedMap<K,V> getSortedMap() {
return (SortedMap<K,V>) map;
}
//-----------------------------------------------------------------------
@Override
public K firstKey() {
return getSortedMap().firstKey();
}
@Override
public K lastKey() {
return getSortedMap().lastKey();
}
@Override
public Comparator<? super K> comparator() {
return getSortedMap().comparator();
}
@Override
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); |
File |
Line |
org\apache\commons\collections4\bidimap\AbstractDualBidiMap.java |
781 |
org\apache\commons\collections4\bidimap\DualTreeBidiMap.java |
350 |
}
@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 V setValue(final V value) {
if (last == null) {
throw new IllegalStateException(
"Iterator setValue() can only be called after next() and before remove()");
}
if (parent.reverseMap.containsKey(value) &&
parent.reverseMap.get(value) != last.getKey()) {
throw new IllegalArgumentException(
"Cannot use setValue() when the object being set is already in the map");
} |
File |
Line |
org\apache\commons\collections4\bidimap\TreeBidiMap.java |
1468 |
org\apache\commons\collections4\trie\AbstractPatriciaTrie.java |
2430 |
final int size = stream.readInt();
for(int i = 0; i < size; i++){
final K k =(K) stream.readObject();
final V v =(V) stream.readObject();
put(k, v);
}
}
/**
* Writes the content to the stream for serialization.
*
* @param stream the output stream
* @throws IOException if an error occurs while writing to the stream
*/
private void writeObject(final ObjectOutputStream stream) throws IOException{
stream.defaultWriteObject();
stream.writeInt(this.size());
for (final Entry<K, V> entry : entrySet()) {
stream.writeObject(entry.getKey());
stream.writeObject(entry.getValue());
}
} |
File |
Line |
org\apache\commons\collections4\list\AbstractLinkedList.java |
932 |
org\apache\commons\collections4\list\CursorableLinkedList.java |
596 |
super(sub.parent, startIndex + sub.offset);
this.sub = sub;
}
@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 add(final E obj) {
super.add(obj);
sub.expectedModCount = parent.modCount;
sub.size++;
}
@Override
public void remove() {
super.remove();
sub.expectedModCount = parent.modCount;
sub.size--;
}
} |
File |
Line |
org\apache\commons\collections4\keyvalue\AbstractMapEntry.java |
73 |
org\apache\commons\collections4\keyvalue\DefaultKeyValue.java |
136 |
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());
}
} |
File |
Line |
org\apache\commons\collections4\keyvalue\DefaultKeyValue.java |
136 |
org\apache\commons\collections4\map\AbstractHashedMap.java |
1122 |
final DefaultKeyValue<?, ?> other = (DefaultKeyValue<?, ?>) 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()},
* however subclasses may override this.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode());
} |
File |
Line |
org\apache\commons\collections4\map\UnmodifiableMap.java |
141 |
org\apache\commons\collections4\map\UnmodifiableOrderedMap.java |
135 |
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
}
@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 Collection<V> values() {
final Collection<V> coll = super.values();
return UnmodifiableCollection.unmodifiableCollection(coll);
}
} |
File |
Line |
org\apache\commons\collections4\map\MultiKeyMap.java |
546 |
org\apache\commons\collections4\map\MultiKeyMap.java |
706 |
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\MultiKeyMap.java |
564 |
org\apache\commons\collections4\map\MultiKeyMap.java |
587 |
public V get(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 entry.getValue(); |
File |
Line |
org\apache\commons\collections4\map\AbstractHashedMap.java |
937 |
org\apache\commons\collections4\map\Flat3Map.java |
992 |
protected KeySet(final AbstractHashedMap<K, ?> parent) {
super();
this.parent = parent;
}
@Override
public int size() {
return parent.size();
}
@Override
public void clear() {
parent.clear();
}
@Override
public boolean contains(final Object key) {
return parent.containsKey(key);
}
@Override
public boolean remove(final Object key) {
final boolean result = parent.containsKey(key);
parent.remove(key);
return result;
}
@Override
public Iterator<K> iterator() { |
File |
Line |
org\apache\commons\collections4\bag\UnmodifiableSortedBag.java |
102 |
org\apache\commons\collections4\collection\UnmodifiableBoundedCollection.java |
116 |
org\apache\commons\collections4\collection\UnmodifiableCollection.java |
74 |
org\apache\commons\collections4\set\UnmodifiableNavigableSet.java |
70 |
org\apache\commons\collections4\set\UnmodifiableSet.java |
73 |
org\apache\commons\collections4\set\UnmodifiableSortedSet.java |
73 |
setCollection((Collection<E>) in.readObject());
}
//-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() {
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
}
@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 boolean remove(final Object object) {
throw new UnsupportedOperationException();
}
/**
* @since 4.4
*/
@Override
public boolean removeIf(Predicate<? super E> filter) { |
File |
Line |
org\apache\commons\collections4\iterators\AbstractListIteratorDecorator.java |
54 |
org\apache\commons\collections4\iterators\UnmodifiableListIterator.java |
65 |
return iterator;
}
//-----------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public boolean hasNext() {
return iterator.hasNext();
}
/** {@inheritDoc} */
@Override
public E next() {
return iterator.next();
}
/** {@inheritDoc} */
@Override
public int nextIndex() {
return iterator.nextIndex();
}
/** {@inheritDoc} */
@Override
public boolean hasPrevious() {
return iterator.hasPrevious();
}
/** {@inheritDoc} */
@Override
public E previous() {
return iterator.previous();
}
/** {@inheritDoc} */
@Override
public int previousIndex() {
return iterator.previousIndex();
}
/** {@inheritDoc} */
@Override
public void remove() { |
File |
Line |
org\apache\commons\collections4\map\MultiKeyMap.java |
414 |
org\apache\commons\collections4\map\MultiKeyMap.java |
436 |
public V get(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 entry.getValue(); |
|