Add missing @Override markers
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@966327 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9601875f69
commit
5cabc0f86f
|
@ -413,6 +413,7 @@ public class ExtendedProperties extends Hashtable {
|
|||
*
|
||||
* @return True if the object has more tokens.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMoreTokens() {
|
||||
return super.hasMoreTokens();
|
||||
}
|
||||
|
@ -422,6 +423,7 @@ public class ExtendedProperties extends Hashtable {
|
|||
*
|
||||
* @return A String.
|
||||
*/
|
||||
@Override
|
||||
public String nextToken() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
|
@ -1708,6 +1710,7 @@ public class ExtendedProperties extends Hashtable {
|
|||
* @param value for the property
|
||||
* @return old value of the property
|
||||
*/
|
||||
@Override
|
||||
public Object put(Object key, Object value) {
|
||||
String strKey = String.valueOf(key);
|
||||
Object ret = getProperty(strKey);
|
||||
|
@ -1722,6 +1725,7 @@ public class ExtendedProperties extends Hashtable {
|
|||
*
|
||||
* @param map full of key/value pair data
|
||||
*/
|
||||
@Override
|
||||
public void putAll(Map map) {
|
||||
if (map instanceof ExtendedProperties) {
|
||||
for (Iterator it = ((ExtendedProperties) map).getKeys(); it.hasNext(); ) {
|
||||
|
@ -1744,6 +1748,7 @@ public class ExtendedProperties extends Hashtable {
|
|||
* @param key specifying the property
|
||||
* @return old value of the property
|
||||
*/
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
String strKey = String.valueOf(key);
|
||||
Object ret = getProperty(strKey);
|
||||
|
|
|
@ -60,6 +60,7 @@ public abstract class AbstractBagDecorator<E>
|
|||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
protected Bag<E> decorated() {
|
||||
return (Bag<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -417,6 +417,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MutableInteger == false) {
|
||||
return false;
|
||||
|
@ -424,6 +425,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
return ((MutableInteger) obj).value == value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value;
|
||||
}
|
||||
|
@ -530,6 +532,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
* @param object the Bag to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
|
@ -559,6 +562,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
*
|
||||
* @return the hash code of the Bag
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int total = 0;
|
||||
for (Iterator<Map.Entry<E, MutableInteger>> it = map.entrySet().iterator(); it.hasNext();) {
|
||||
|
@ -575,6 +579,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
*
|
||||
* @return a debugging toString
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (size() == 0) {
|
||||
return "[]";
|
||||
|
|
|
@ -59,6 +59,7 @@ public abstract class AbstractSortedBagDecorator<E>
|
|||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
protected SortedBag<E> decorated() {
|
||||
return (SortedBag<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ public class PredicatedBag<E>
|
|||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
protected Bag<E> decorated() {
|
||||
return (Bag<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ public class PredicatedSortedBag<E>
|
|||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
protected SortedBag<E> decorated() {
|
||||
return (SortedBag<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
// TODO: Generics - should this be E<? extends Comparable> or some such?
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
if(comparator() == null && !(object instanceof Comparable)) {
|
||||
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
|
||||
|
|
|
@ -100,43 +100,53 @@ public final class UnmodifiableBag<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.<E>decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean add(E object, int count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object, int count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> uniqueSet() {
|
||||
Set<E> set = decorated().uniqueSet();
|
||||
return UnmodifiableSet.<E>decorate(set);
|
||||
|
|
|
@ -100,43 +100,53 @@ public final class UnmodifiableSortedBag<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean add(E object, int count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object, int count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> uniqueSet() {
|
||||
Set<E> set = decorated().uniqueSet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
|
|
|
@ -55,11 +55,13 @@ public abstract class AbstractBidiMapDecorator<K, V> extends AbstractMapDecorato
|
|||
*
|
||||
* @return the decorated map
|
||||
*/
|
||||
@Override
|
||||
protected BidiMap<K, V> decorated() {
|
||||
return (BidiMap<K, V>) super.decorated();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public MapIterator<K, V> mapIterator() {
|
||||
return decorated().mapIterator();
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public abstract class AbstractSortedBidiMapDecorator<K, V> extends
|
|||
*
|
||||
* @return the decorated map
|
||||
*/
|
||||
@Override
|
||||
protected SortedBidiMap<K, V> decorated() {
|
||||
return (SortedBidiMap<K, V>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
* @param inverseMap the inverse BidiMap
|
||||
* @return new bidi map
|
||||
*/
|
||||
@Override
|
||||
protected DualTreeBidiMap<V, K> createBidiMap(Map<V, K> normalMap, Map<K, V> reverseMap, BidiMap<K, V> inverseMap) {
|
||||
return new DualTreeBidiMap<V, K>(normalMap, reverseMap, inverseMap);
|
||||
}
|
||||
|
@ -183,6 +184,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
*
|
||||
* @return a new ordered map iterator
|
||||
*/
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
return new BidiOrderedMapIterator<K, V>(this);
|
||||
}
|
||||
|
@ -240,11 +242,13 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
this.bidi = (DualTreeBidiMap<K, V>) decorated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
// override as default implementation uses reverseMap
|
||||
return decorated().normalMap.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
// override as default implementation uses reverseMap
|
||||
for (Iterator<K> it = keySet().iterator(); it.hasNext();) {
|
||||
|
@ -253,14 +257,17 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> headMap(K toKey) {
|
||||
return new ViewMap<K, V>(decorated(), super.headMap(toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> tailMap(K fromKey) {
|
||||
return new ViewMap<K, V>(decorated(), super.tailMap(fromKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> subMap(K fromKey, K toKey) {
|
||||
return new ViewMap<K, V>(decorated(), super.subMap(fromKey, toKey));
|
||||
}
|
||||
|
@ -270,10 +277,12 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
return (DualTreeBidiMap<K, V>) super.decorated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public K previousKey(K key) {
|
||||
return decorated().previousKey(key);
|
||||
};
|
||||
|
||||
@Override
|
||||
public K nextKey(K key) {
|
||||
return decorated().nextKey(key);
|
||||
};
|
||||
|
@ -358,6 +367,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
last = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (last != null) {
|
||||
return "MapIterator[" + getKey() + "=" + getValue() + "]";
|
||||
|
|
|
@ -447,6 +447,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this.doEquals(obj, KEY);
|
||||
}
|
||||
|
@ -456,6 +457,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
*
|
||||
* @return the hash code value for this map
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.doHashCode(KEY);
|
||||
}
|
||||
|
@ -465,6 +467,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
*
|
||||
* @return a standard format string version of the map
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.doToString(KEY);
|
||||
}
|
||||
|
@ -1423,10 +1426,12 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
this.orderType = orderType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return TreeBidiMap.this.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
TreeBidiMap.this.clear();
|
||||
}
|
||||
|
@ -1495,6 +1500,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
super(KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
|
@ -1505,6 +1511,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
return node != null && node.getValue().equals(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
|
@ -1534,6 +1541,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
super(VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
|
@ -1544,6 +1552,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
return node != null && node.getKey().equals(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
|
@ -1966,6 +1975,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
* @param obj the object to be compared for equality with this entry.
|
||||
* @return true if the specified object is equal to this entry.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
@ -1980,6 +1990,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
/**
|
||||
* @return the hash code value for this map entry.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (!calculatedHashCode) {
|
||||
hashcodeValue = getKey().hashCode() ^ getValue().hashCode();
|
||||
|
@ -2108,14 +2119,17 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
|||
return TreeBidiMap.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return TreeBidiMap.this.doEquals(obj, DataElement.VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return TreeBidiMap.this.doHashCode(DataElement.VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return TreeBidiMap.this.doToString(DataElement.VALUE);
|
||||
}
|
||||
|
|
|
@ -72,47 +72,57 @@ public final class UnmodifiableBidiMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||
return UnmodifiableEntrySet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = super.keySet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Collection<V> coll = super.values();
|
||||
return UnmodifiableCollection.decorate(coll);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public K removeValue(Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapIterator<K, V> mapIterator() {
|
||||
MapIterator<K, V> it = decorated().mapIterator();
|
||||
return UnmodifiableMapIterator.decorate(it);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized BidiMap<V, K> inverseBidiMap() {
|
||||
if (inverse == null) {
|
||||
inverse = new UnmodifiableBidiMap<V, K>(decorated().inverseBidiMap());
|
||||
|
|
|
@ -72,47 +72,57 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||
return UnmodifiableEntrySet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = super.keySet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Collection<V> coll = super.values();
|
||||
return UnmodifiableCollection.decorate(coll);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public K removeValue(Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderedBidiMap<V, K> inverseBidiMap() {
|
||||
return inverseOrderedBidiMap();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
||||
|
|
|
@ -74,49 +74,59 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||
return UnmodifiableEntrySet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = super.keySet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Collection<V> coll = super.values();
|
||||
return UnmodifiableCollection.decorate(coll);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public K removeValue(Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public SortedBidiMap<V, K> inverseBidiMap() {
|
||||
if (inverse == null) {
|
||||
inverse = new UnmodifiableSortedBidiMap<V, K>(decorated().inverseBidiMap());
|
||||
|
@ -125,16 +135,19 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
|||
return inverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> subMap(K fromKey, K toKey) {
|
||||
SortedMap<K, V> sm = decorated().subMap(fromKey, toKey);
|
||||
return UnmodifiableSortedMap.decorate(sm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> headMap(K toKey) {
|
||||
SortedMap<K, V> sm = decorated().headMap(toKey);
|
||||
return UnmodifiableSortedMap.decorate(sm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> tailMap(K fromKey) {
|
||||
SortedMap<K, V> sm = decorated().tailMap(fromKey);
|
||||
return UnmodifiableSortedMap.decorate(sm);
|
||||
|
|
|
@ -59,6 +59,7 @@ public abstract class AbstractBufferDecorator<E> extends AbstractCollectionDecor
|
|||
*
|
||||
* @return the decorated buffer
|
||||
*/
|
||||
@Override
|
||||
protected Buffer<E> decorated() {
|
||||
return (Buffer<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean add(E o) {
|
||||
synchronized (lock) {
|
||||
boolean result = collection.add(o);
|
||||
|
@ -116,6 +117,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
synchronized (lock) {
|
||||
boolean result = collection.addAll(c);
|
||||
|
@ -131,6 +133,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
|||
*
|
||||
* @throws BufferUnderflowException if an interrupt is received
|
||||
*/
|
||||
@Override
|
||||
public E get() {
|
||||
synchronized (lock) {
|
||||
while (collection.isEmpty()) {
|
||||
|
@ -187,6 +190,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
|||
*
|
||||
* @throws BufferUnderflowException if an interrupt is received
|
||||
*/
|
||||
@Override
|
||||
public E remove() {
|
||||
synchronized (lock) {
|
||||
while (collection.isEmpty()) {
|
||||
|
|
|
@ -107,6 +107,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public E remove() {
|
||||
synchronized (lock) {
|
||||
E returnValue = decorated().remove();
|
||||
|
@ -115,6 +116,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E o) {
|
||||
synchronized (lock) {
|
||||
timeoutWait(1);
|
||||
|
@ -122,6 +124,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final Collection<? extends E> c) {
|
||||
synchronized (lock) {
|
||||
timeoutWait(c.size());
|
||||
|
@ -129,6 +132,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new NotifyingIterator(collection.iterator());
|
||||
}
|
||||
|
@ -184,6 +188,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
|||
super(it);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
synchronized (lock) {
|
||||
iterator.remove();
|
||||
|
|
|
@ -171,6 +171,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
*
|
||||
* @return this buffer's size
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
int size = 0;
|
||||
|
||||
|
@ -190,6 +191,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
*
|
||||
* @return true if this buffer is empty
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
@ -215,6 +217,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
/**
|
||||
* Clears this buffer.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
full = false;
|
||||
start = 0;
|
||||
|
@ -230,6 +233,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
* @throws NullPointerException if the given element is null
|
||||
* @throws BufferOverflowException if this buffer is full
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E element) {
|
||||
if (null == element) {
|
||||
throw new NullPointerException("Attempted to add null object to buffer");
|
||||
|
@ -322,6 +326,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
*
|
||||
* @return an iterator over this buffer's elements
|
||||
*/
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new Iterator<E>() {
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public class CircularFifoBuffer<E> extends BoundedFifoBuffer<E> {
|
|||
* @param element the element to add
|
||||
* @return true, always
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E element) {
|
||||
if (isFull()) {
|
||||
remove();
|
||||
|
|
|
@ -81,6 +81,7 @@ public class PredicatedBuffer<E> extends PredicatedCollection<E> implements Buff
|
|||
*
|
||||
* @return the decorated buffer
|
||||
*/
|
||||
@Override
|
||||
protected Buffer<E> decorated() {
|
||||
return (Buffer<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -224,6 +224,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
*
|
||||
* @return the number of elements in this buffer
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
@ -231,6 +232,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
/**
|
||||
* Clears all elements from the buffer.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void clear() {
|
||||
elements = (E[]) new Object[elements.length]; // for gc
|
||||
|
@ -245,6 +247,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
* @param element the element to be added
|
||||
* @return true always
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E element) {
|
||||
if (isAtCapacity()) {
|
||||
grow();
|
||||
|
@ -467,6 +470,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
*
|
||||
* @return an iterator over this heap's elements
|
||||
*/
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new Iterator<E>() {
|
||||
|
||||
|
@ -526,6 +530,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
|
|||
*
|
||||
* @return a string representation of this heap
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public class SynchronizedBuffer<E>
|
|||
*
|
||||
* @return the decorated buffer
|
||||
*/
|
||||
@Override
|
||||
protected Buffer<E> decorated() {
|
||||
return (Buffer<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
|
|||
*
|
||||
* @return this buffer's size
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
int size = 0;
|
||||
|
||||
|
@ -167,6 +168,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
|
|||
*
|
||||
* @return true if this buffer is empty
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (size() == 0);
|
||||
}
|
||||
|
@ -178,6 +180,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
|
|||
* @return true, always
|
||||
* @throws NullPointerException if the given element is null
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean add(final E obj) {
|
||||
if (obj == null) {
|
||||
|
@ -272,6 +275,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
|
|||
*
|
||||
* @return an iterator over this buffer's elements
|
||||
*/
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new Iterator<E>() {
|
||||
|
||||
|
|
|
@ -99,35 +99,43 @@ public final class UnmodifiableBuffer<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public E remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -135,14 +135,17 @@ public abstract class AbstractCollectionDecorator<E>
|
|||
return decorated().retainAll(coll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object == this || decorated().equals(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return decorated().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return decorated().toString();
|
||||
}
|
||||
|
|
|
@ -110,14 +110,17 @@ public abstract class AbstractUntypedCollectionDecorator<E, D> implements Collec
|
|||
return decorated().retainAll(coll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object == this || decorated().equals(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return decorated().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return decorated().toString();
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
* @return the result of adding to the underlying collection
|
||||
* @throws IllegalArgumentException if the add is invalid
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
validate(object);
|
||||
return decorated().add(object);
|
||||
|
@ -126,6 +127,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
* @return the result of adding to the underlying collection
|
||||
* @throws IllegalArgumentException if the add is invalid
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
for (E item : coll) {
|
||||
validate(item);
|
||||
|
|
|
@ -188,6 +188,7 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
synchronized (lock) {
|
||||
if (object == this) {
|
||||
|
@ -197,12 +198,14 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
synchronized (lock) {
|
||||
return decorated().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
synchronized (lock) {
|
||||
return decorated().toString();
|
||||
|
|
|
@ -137,10 +137,12 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
return decorated().add(transform(object));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
return decorated().addAll(transform(coll));
|
||||
}
|
||||
|
|
|
@ -103,30 +103,37 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -71,30 +71,37 @@ public final class UnmodifiableCollection<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
|
|||
*
|
||||
* @return a hash code for this comparator.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = "BooleanComparator".hashCode();
|
||||
return trueFirst ? -1 * hash : hash;
|
||||
|
@ -166,6 +167,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
|
|||
* @param object the object to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return (this == object) ||
|
||||
((object instanceof BooleanComparator) &&
|
||||
|
|
|
@ -100,6 +100,7 @@ public class ComparableComparator<E extends Comparable<? super E>> implements Co
|
|||
* @return a hash code for this comparator.
|
||||
* @since Commons Collections 3.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return "ComparableComparator".hashCode();
|
||||
}
|
||||
|
@ -119,6 +120,7 @@ public class ComparableComparator<E extends Comparable<? super E>> implements Co
|
|||
* @return true if equal
|
||||
* @since Commons Collections 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return (this == object) ||
|
||||
((null != object) && (object.getClass().equals(this.getClass())));
|
||||
|
|
|
@ -299,6 +299,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
|
|||
* @return a suitable hash code
|
||||
* @since Commons Collections 3.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
if (null != comparatorChain) {
|
||||
|
@ -326,6 +327,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
|
|||
* @return true if equal
|
||||
* @since Commons Collections 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
|
|
|
@ -151,6 +151,7 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
|
|||
*
|
||||
* @return a hash code for this comparator.
|
||||
**/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (nullsAreHigh ? -1 : 1) * nonNullComparator.hashCode();
|
||||
}
|
||||
|
@ -166,6 +167,7 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
|
|||
* (i.e. <code>null</code> high or low) and with equivalent underlying
|
||||
* non-<code>null</code> object comparators.
|
||||
**/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == null) { return false; }
|
||||
if(obj == this) { return true; }
|
||||
|
|
|
@ -87,6 +87,7 @@ public class ReverseComparator<E> implements Comparator<E>, Serializable {
|
|||
* @return a suitable hash code
|
||||
* @since Commons Collections 3.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return "ReverseComparator".hashCode() ^ comparator.hashCode();
|
||||
}
|
||||
|
@ -107,6 +108,7 @@ public class ReverseComparator<E> implements Comparator<E>, Serializable {
|
|||
* @return true if equal
|
||||
* @since Commons Collections 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
|
|
|
@ -144,6 +144,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
* @return the next element
|
||||
* @throws NoSuchElementException if there is no next element
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public E next() {
|
||||
if (hasNext() == false) {
|
||||
|
@ -208,6 +209,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
/**
|
||||
* Resets the iterator back to the start index.
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
this.lastItemIndex = -1;
|
||||
|
|
|
@ -160,6 +160,7 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
|
|||
*
|
||||
* @return a string version of the iterator
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (last != null) {
|
||||
return "MapIterator[" + getKey() + "=" + getValue() + "]";
|
||||
|
|
|
@ -133,6 +133,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
* @return the next element
|
||||
* @throws NoSuchElementException if there is no next element
|
||||
*/
|
||||
@Override
|
||||
public E next() {
|
||||
if (hasNext() == false) {
|
||||
throw new NoSuchElementException();
|
||||
|
@ -198,6 +199,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
/**
|
||||
* Resets the iterator back to the start index.
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
this.lastItemIndex = -1;
|
||||
|
|
|
@ -72,6 +72,7 @@ public abstract class AbstractKeyValue<K, V> implements KeyValue<K, V> {
|
|||
*
|
||||
* @return a String view of the entry
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
.append(getKey())
|
||||
|
|
|
@ -67,6 +67,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal key and value
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -88,6 +89,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
|
|||
*
|
||||
* @return a suitable hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getKey() == null ? 0 : getKey().hashCode()) ^
|
||||
(getValue() == null ? 0 : getValue().hashCode());
|
||||
|
|
|
@ -69,6 +69,7 @@ public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>
|
|||
return entry.setValue(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
|
@ -76,10 +77,12 @@ public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>
|
|||
return entry.equals(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return entry.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return entry.toString();
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal key and value
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -152,6 +153,7 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
|
|||
*
|
||||
* @return a suitable hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getKey() == null ? 0 : getKey().hashCode()) ^
|
||||
(getValue() == null ? 0 : getValue().hashCode());
|
||||
|
|
|
@ -219,6 +219,7 @@ public class MultiKey<K> implements Serializable {
|
|||
* @param other the other object to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
|
@ -240,6 +241,7 @@ public class MultiKey<K> implements Serializable {
|
|||
*
|
||||
* @return the hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
@ -249,6 +251,7 @@ public class MultiKey<K> implements Serializable {
|
|||
*
|
||||
* @return a debugging string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MultiKey" + Arrays.asList(keys).toString();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal key and value
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -119,6 +120,7 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
|
|||
*
|
||||
* @return a suitable hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Object value = getValue();
|
||||
return (getKey() == null ? 0 : getKey().hashCode()) ^
|
||||
|
@ -130,6 +132,7 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
|
|||
*
|
||||
* @return entry as a string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getKey() + "=" + getValue();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public final class UnmodifiableMapEntry<K, V> extends AbstractMapEntry<K, V> imp
|
|||
* @return the previous value
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
throw new UnsupportedOperationException("setValue() is not supported");
|
||||
}
|
||||
|
|
|
@ -325,6 +325,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -348,6 +349,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
return !(it1.hasNext() || it2.hasNext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
||||
for (E e : this) {
|
||||
|
@ -356,6 +358,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (size() == 0) {
|
||||
return "[]";
|
||||
|
@ -863,24 +866,29 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
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(E obj) {
|
||||
super.add(obj);
|
||||
sub.expectedModCount = parent.modCount;
|
||||
sub.size++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
sub.expectedModCount = parent.modCount;
|
||||
|
@ -918,17 +926,20 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
this.expectedModCount = parent.modCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
checkModCount();
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
rangeCheck(index, size);
|
||||
checkModCount();
|
||||
return parent.get(index + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E obj) {
|
||||
rangeCheck(index, size + 1);
|
||||
checkModCount();
|
||||
|
@ -938,6 +949,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
LinkedSubList.this.modCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
rangeCheck(index, size);
|
||||
checkModCount();
|
||||
|
@ -948,10 +960,12 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
return addAll(size, coll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> coll) {
|
||||
rangeCheck(index, size + 1);
|
||||
int cSize = coll.size();
|
||||
|
@ -967,12 +981,14 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E obj) {
|
||||
rangeCheck(index, size);
|
||||
checkModCount();
|
||||
return parent.set(index + offset, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
checkModCount();
|
||||
Iterator<E> it = iterator();
|
||||
|
@ -982,17 +998,20 @@ public abstract class AbstractLinkedList<E> implements List<E> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
checkModCount();
|
||||
return parent.createSubListIterator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(final int index) {
|
||||
rangeCheck(index, size + 1);
|
||||
checkModCount();
|
||||
return parent.createSubListListIterator(this, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndexInclusive, int toIndexExclusive) {
|
||||
return new LinkedSubList<E>(parent, fromIndexInclusive + offset, toIndexExclusive + offset);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public abstract class AbstractListDecorator<E> extends AbstractCollectionDecorat
|
|||
*
|
||||
* @return the decorated list
|
||||
*/
|
||||
@Override
|
||||
protected List<E> decorated() {
|
||||
return (List<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @throws ClassCastException if the underlying list rejects the element
|
||||
* @throws IllegalArgumentException if the underlying list rejects the element
|
||||
*/
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
int size = decorated().size();
|
||||
if (index > size) {
|
||||
|
@ -145,6 +146,7 @@ public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @throws ClassCastException if the underlying list rejects the element
|
||||
* @throws IllegalArgumentException if the underlying list rejects the element
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> coll) {
|
||||
int size = decorated().size();
|
||||
boolean result = false;
|
||||
|
@ -175,6 +177,7 @@ public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @throws ClassCastException if the underlying list rejects the element
|
||||
* @throws IllegalArgumentException if the underlying list rejects the element
|
||||
*/
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
int size = decorated().size();
|
||||
if (index >= size) {
|
||||
|
|
|
@ -107,6 +107,7 @@ public class LazyList<E> extends AbstractSerializableListDecorator<E> {
|
|||
*
|
||||
* @param index the index to retrieve
|
||||
*/
|
||||
@Override
|
||||
public E get(int index) {
|
||||
int size = decorated().size();
|
||||
if (index < size) {
|
||||
|
@ -131,6 +132,7 @@ public class LazyList<E> extends AbstractSerializableListDecorator<E> {
|
|||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
List<E> sub = decorated().subList(fromIndex, toIndex);
|
||||
return new LazyList<E>(sub, factory);
|
||||
|
|
|
@ -186,6 +186,7 @@ public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements S
|
|||
* @param value value of the new node
|
||||
* @return the newly created node
|
||||
*/
|
||||
@Override
|
||||
protected Node<E> createNode(E value) {
|
||||
Node<E> cachedNode = getNodeFromCache();
|
||||
if (cachedNode == null) {
|
||||
|
@ -201,6 +202,7 @@ public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements S
|
|||
*
|
||||
* @param node the node to remove
|
||||
*/
|
||||
@Override
|
||||
protected void removeNode(Node<E> node) {
|
||||
super.removeNode(node);
|
||||
addNodeToCache(node);
|
||||
|
@ -211,6 +213,7 @@ public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements S
|
|||
* cache for reuse.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected void removeAllNodes() {
|
||||
// Add the removed nodes to the cache, then remove the rest.
|
||||
// We can add them to the cache before removing them, since
|
||||
|
|
|
@ -124,6 +124,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @param object the object to add
|
||||
* @return true if object was added
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
// gets initial size
|
||||
final int sizeBefore = size();
|
||||
|
@ -145,6 +146,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @param index the index to insert at
|
||||
* @param object the object to add
|
||||
*/
|
||||
@Override
|
||||
public void add(int index, E object) {
|
||||
// adds element if it is not contained already
|
||||
if (set.contains(object) == false) {
|
||||
|
@ -166,6 +168,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @param coll the collection to add in iterator order
|
||||
* @return true if this collection changed
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
return addAll(size(), coll);
|
||||
}
|
||||
|
@ -185,6 +188,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @param coll the collection to add in iterator order
|
||||
* @return true if this collection changed
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> coll) {
|
||||
HashSet<E> temp = new HashSet<E>(coll);
|
||||
temp.removeAll(set);
|
||||
|
@ -213,6 +217,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @param object the object to set
|
||||
* @return the previous object
|
||||
*/
|
||||
@Override
|
||||
public E set(int index, E object) {
|
||||
int pos = indexOf(object);
|
||||
E removed = super.set(index, object);
|
||||
|
@ -229,55 +234,66 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
return removed; // return the item deleted by the set
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
boolean result = super.remove(object);
|
||||
set.remove(object);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
E result = super.remove(index);
|
||||
set.remove(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
boolean result = super.removeAll(coll);
|
||||
set.removeAll(coll);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
boolean result = super.retainAll(coll);
|
||||
set.retainAll(coll);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
set.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object object) {
|
||||
return set.contains(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> coll) {
|
||||
return set.containsAll(coll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new SetListIterator<E>(super.iterator(), set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return new SetListListIterator<E>(super.listIterator(), set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
return new SetListListIterator<E>(super.listIterator(index), set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
List<E> superSubList = super.subList(fromIndex, toIndex);
|
||||
Set<E> subSet = createSetBasedOnList(set, superSubList);
|
||||
|
@ -316,11 +332,13 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
last = super.next();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
set.remove(last);
|
||||
|
@ -341,22 +359,26 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
last = super.next();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E previous() {
|
||||
last = super.previous();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
set.remove(last);
|
||||
last = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(E object) {
|
||||
if (set.contains(object) == false) {
|
||||
super.add(object);
|
||||
|
@ -364,6 +386,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(E object) {
|
||||
throw new UnsupportedOperationException("ListIterator does not support set");
|
||||
}
|
||||
|
|
|
@ -165,11 +165,13 @@ public class TransformedList<E> extends TransformedCollection<E> implements List
|
|||
super(iterator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(E object) {
|
||||
object = transform(object);
|
||||
iterator.add(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(E object) {
|
||||
object = transform(object);
|
||||
iterator.set(object);
|
||||
|
|
|
@ -94,6 +94,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @param index the index to retrieve
|
||||
* @return the element at the specified index
|
||||
*/
|
||||
@Override
|
||||
public E get(int index) {
|
||||
checkInterval(index, 0, size() - 1);
|
||||
return root.get(index).getValue();
|
||||
|
@ -104,6 +105,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*
|
||||
* @return the current size
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
@ -113,6 +115,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*
|
||||
* @return an iterator over the list
|
||||
*/
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
// override to go 75% faster
|
||||
return listIterator(0);
|
||||
|
@ -123,6 +126,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*
|
||||
* @return the new iterator
|
||||
*/
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
// override to go 75% faster
|
||||
return listIterator(0);
|
||||
|
@ -134,6 +138,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @param fromIndex the index to start from
|
||||
* @return the new iterator
|
||||
*/
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int fromIndex) {
|
||||
// override to go 75% faster
|
||||
// cannot use EmptyIterator as iterator.add() must work
|
||||
|
@ -146,6 +151,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*
|
||||
* @return the index of the object, -1 if not found
|
||||
*/
|
||||
@Override
|
||||
public int indexOf(Object object) {
|
||||
// override to go 75% faster
|
||||
if (root == null) {
|
||||
|
@ -159,6 +165,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*
|
||||
* @return true if the object is found
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object object) {
|
||||
return (indexOf(object) >= 0);
|
||||
}
|
||||
|
@ -168,6 +175,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
*
|
||||
* @return the list as an array
|
||||
*/
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
// override to go 20% faster
|
||||
Object[] array = new Object[size()];
|
||||
|
@ -184,6 +192,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @param index the index to add before
|
||||
* @param obj the element to add
|
||||
*/
|
||||
@Override
|
||||
public void add(int index, E obj) {
|
||||
modCount++;
|
||||
checkInterval(index, 0, size());
|
||||
|
@ -203,6 +212,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @return the previous object at that index
|
||||
* @throws IndexOutOfBoundsException if the index is invalid
|
||||
*/
|
||||
@Override
|
||||
public E set(int index, E obj) {
|
||||
checkInterval(index, 0, size() - 1);
|
||||
AVLNode<E> node = root.get(index);
|
||||
|
@ -217,6 +227,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
* @param index the index to remove
|
||||
* @return the previous object at that index
|
||||
*/
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
modCount++;
|
||||
checkInterval(index, 0, size() - 1);
|
||||
|
@ -229,6 +240,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
/**
|
||||
* Clears the list, removing all entries.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
modCount++;
|
||||
root = null;
|
||||
|
@ -763,6 +775,7 @@ public class TreeList<E> extends AbstractList<E> {
|
|||
/**
|
||||
* Used for debugging.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AVLNode(" + relativePosition + "," + (left != null) + "," + value +
|
||||
"," + (getRightSubTree() != null) + ", faedelung " + rightIsNext + " )";
|
||||
|
|
|
@ -70,59 +70,73 @@ public final class UnmodifiableList<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return UnmodifiableListIterator.decorate(decorated().listIterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
return UnmodifiableListIterator.decorate(decorated().listIterator(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
List<E> sub = decorated().subList(fromIndex, toIndex);
|
||||
return new UnmodifiableList<E>(sub);
|
||||
|
|
|
@ -179,6 +179,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param key the key
|
||||
* @return the mapped value, null if no match
|
||||
*/
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
key = convertKey(key);
|
||||
int hashCode = hash(key);
|
||||
|
@ -197,6 +198,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return the size
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
@ -206,6 +208,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return true if the map is currently size zero
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (size == 0);
|
||||
}
|
||||
|
@ -217,6 +220,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param key the key to search for
|
||||
* @return true if the map contains the key
|
||||
*/
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
key = convertKey(key);
|
||||
int hashCode = hash(key);
|
||||
|
@ -236,6 +240,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param value the value to search for
|
||||
* @return true if the map contains the value
|
||||
*/
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
if (value == null) {
|
||||
for (int i = 0, isize = data.length; i < isize; i++) {
|
||||
|
@ -269,6 +274,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param value the value to add
|
||||
* @return the value previously mapped to this key, null if none
|
||||
*/
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
Object convertedKey = convertKey(key);
|
||||
int hashCode = hash(convertedKey);
|
||||
|
@ -296,6 +302,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param map the map to add
|
||||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> map) {
|
||||
_putAll(map);
|
||||
}
|
||||
|
@ -330,6 +337,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param key the mapping to remove
|
||||
* @return the value mapped to the removed key, null if key not in map
|
||||
*/
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
key = convertKey(key);
|
||||
int hashCode = hash(key);
|
||||
|
@ -352,6 +360,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* Clears the map, resetting the size to zero and nullifying references
|
||||
* to avoid garbage collection issues.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
modCount++;
|
||||
HashEntry<K, V>[] data = this.data;
|
||||
|
@ -799,6 +808,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return the entrySet view
|
||||
*/
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
if (entrySet == null) {
|
||||
entrySet = new EntrySet<K, V>(this);
|
||||
|
@ -831,14 +841,17 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object entry) {
|
||||
if (entry instanceof Map.Entry) {
|
||||
Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry;
|
||||
|
@ -848,6 +861,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
|
@ -860,6 +874,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return parent.createEntrySetIterator();
|
||||
}
|
||||
|
@ -887,6 +902,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return the keySet view
|
||||
*/
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
if (keySet == null) {
|
||||
keySet = new KeySet<K>(this);
|
||||
|
@ -919,24 +935,29 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object key) {
|
||||
return parent.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key) {
|
||||
boolean result = parent.containsKey(key);
|
||||
parent.remove(key);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<K> iterator() {
|
||||
return parent.createKeySetIterator();
|
||||
}
|
||||
|
@ -965,6 +986,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return the values view
|
||||
*/
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
if (values == null) {
|
||||
values = new Values<V>(this);
|
||||
|
@ -997,18 +1019,22 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object value) {
|
||||
return parent.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator() {
|
||||
return parent.createValuesIterator();
|
||||
}
|
||||
|
@ -1076,6 +1102,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
return (V) old;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
@ -1089,11 +1116,13 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
(getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getKey() == null ? 0 : getKey().hashCode()) ^
|
||||
(getValue() == null ? 0 : getValue().hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder().append(getKey()).append('=').append(getValue()).toString();
|
||||
}
|
||||
|
@ -1169,6 +1198,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
expectedModCount = parent.modCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (last != null) {
|
||||
return "Iterator[" + last.getKey() + "=" + last.getValue() + "]";
|
||||
|
@ -1249,6 +1279,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected AbstractHashedMap<K, V> clone() {
|
||||
try {
|
||||
|
@ -1273,6 +1304,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -1313,6 +1345,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return the hash code defined in the Map interface
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int total = 0;
|
||||
Iterator<Map.Entry<K, V>> it = createEntrySetIterator();
|
||||
|
@ -1327,6 +1360,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
|||
*
|
||||
* @return a string version of the map
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (size() == 0) {
|
||||
return "{}";
|
||||
|
|
|
@ -96,6 +96,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
if (isSetValueChecking()) {
|
||||
return new EntrySet(map.entrySet(), this);
|
||||
|
@ -118,10 +119,12 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return new EntrySetIterator(collection.iterator(), parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object[] toArray() {
|
||||
Object[] array = collection.toArray();
|
||||
|
@ -131,6 +134,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
|||
return array;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] toArray(T[] array) {
|
||||
Object[] result = array;
|
||||
|
@ -171,6 +175,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map.Entry<K, V> next() {
|
||||
Map.Entry<K, V> entry = iterator.next();
|
||||
return new MapEntry(entry, parent);
|
||||
|
@ -190,6 +195,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
value = parent.checkSetValue(value);
|
||||
return entry.setValue(value);
|
||||
|
|
|
@ -125,6 +125,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
* {@link #createEntry(HashEntry, int, Object, Object)} to create
|
||||
* the map entry object.
|
||||
*/
|
||||
@Override
|
||||
protected void init() {
|
||||
header = createEntry(null, -1, null, null);
|
||||
header.before = header.after = header;
|
||||
|
@ -137,6 +138,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
* @param value the value to search for
|
||||
* @return true if the map contains the value
|
||||
*/
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
// override uses faster iterator
|
||||
if (value == null) {
|
||||
|
@ -159,6 +161,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
* Clears the map, resetting the size to zero and nullifying references
|
||||
* to avoid garbage collection issues.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
// override to reset the linked list
|
||||
super.clear();
|
||||
|
@ -201,6 +204,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
return (entry == null || entry.after == header ? null : entry.after.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinkEntry<K, V> getEntry(Object key) {
|
||||
return (LinkEntry<K, V>) super.getEntry(key);
|
||||
}
|
||||
|
@ -257,6 +261,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
* @param link the entry to add
|
||||
* @param hashIndex the index into the data array to store at
|
||||
*/
|
||||
@Override
|
||||
protected void addEntry(HashEntry<K, V> entry, int hashIndex) {
|
||||
LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
|
||||
link.after = header;
|
||||
|
@ -277,6 +282,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
* @param value the value to store
|
||||
* @return the newly created entry
|
||||
*/
|
||||
@Override
|
||||
protected LinkEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
|
||||
return new LinkEntry<K, V>(next, hashCode, convertKey(key), value);
|
||||
}
|
||||
|
@ -291,6 +297,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
* @param hashIndex the index into the data structure
|
||||
* @param previous the previous entry in the chain
|
||||
*/
|
||||
@Override
|
||||
protected void removeEntry(HashEntry<K, V> entry, int hashIndex, HashEntry<K, V> previous) {
|
||||
LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
|
||||
link.before.after = link.after;
|
||||
|
@ -331,6 +338,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
if (size == 0) {
|
||||
return EmptyOrderedMapIterator.<K, V>getInstance();
|
||||
|
@ -388,6 +396,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
*
|
||||
* @return the entrySet iterator
|
||||
*/
|
||||
@Override
|
||||
protected Iterator<Map.Entry<K, V>> createEntrySetIterator() {
|
||||
if (size() == 0) {
|
||||
return EmptyOrderedIterator.<Map.Entry<K, V>>getInstance();
|
||||
|
@ -421,6 +430,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
*
|
||||
* @return the keySet iterator
|
||||
*/
|
||||
@Override
|
||||
protected Iterator<K> createKeySetIterator() {
|
||||
if (size() == 0) {
|
||||
return EmptyOrderedIterator.<K>getInstance();
|
||||
|
@ -455,6 +465,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
*
|
||||
* @return the values iterator
|
||||
*/
|
||||
@Override
|
||||
protected Iterator<V> createValuesIterator() {
|
||||
if (size() == 0) {
|
||||
return EmptyOrderedIterator.<V>getInstance();
|
||||
|
@ -585,6 +596,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
|||
next = parent.header.after;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (last != null) {
|
||||
return "Iterator[" + last.getKey() + "=" + last.getValue() + "]";
|
||||
|
|
|
@ -125,6 +125,7 @@ public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K,
|
|||
return decorated().values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
|
@ -132,10 +133,12 @@ public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K,
|
|||
return decorated().equals(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return decorated().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return decorated().toString();
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public abstract class AbstractOrderedMapDecorator<K, V> extends AbstractMapDecor
|
|||
*
|
||||
* @return the decorated map
|
||||
*/
|
||||
@Override
|
||||
protected OrderedMap<K, V> decorated() {
|
||||
return (OrderedMap<K, V>) super.decorated();
|
||||
}
|
||||
|
@ -83,6 +84,7 @@ public abstract class AbstractOrderedMapDecorator<K, V> extends AbstractMapDecor
|
|||
return decorated().previousKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
return decorated().mapIterator();
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
/**
|
||||
* Initialise this subclass during construction, cloning or deserialization.
|
||||
*/
|
||||
@Override
|
||||
protected void init() {
|
||||
queue = new ReferenceQueue<Object>();
|
||||
}
|
||||
|
@ -182,6 +183,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the size
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
purgeBeforeRead();
|
||||
return super.size();
|
||||
|
@ -192,6 +194,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return true if the map is currently size zero
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
purgeBeforeRead();
|
||||
return super.isEmpty();
|
||||
|
@ -203,6 +206,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param key the key to search for
|
||||
* @return true if the map contains the key
|
||||
*/
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
purgeBeforeRead();
|
||||
Entry<K, V> entry = getEntry(key);
|
||||
|
@ -218,6 +222,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param value the value to search for
|
||||
* @return true if the map contains the value
|
||||
*/
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
purgeBeforeRead();
|
||||
if (value == null) {
|
||||
|
@ -232,6 +237,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param key the key
|
||||
* @return the mapped value, null if no match
|
||||
*/
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
purgeBeforeRead();
|
||||
Entry<K, V> entry = getEntry(key);
|
||||
|
@ -251,6 +257,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @return the value previously mapped to this key, null if none
|
||||
* @throws NullPointerException if either the key or value is null
|
||||
*/
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
if (key == null) {
|
||||
throw new NullPointerException("null keys not allowed");
|
||||
|
@ -269,6 +276,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param key the mapping to remove
|
||||
* @return the value mapped to the removed key, null if key not in map
|
||||
*/
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
|
@ -280,6 +288,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
/**
|
||||
* Clears this map.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
while (queue.poll() != null) {} // drain the queue
|
||||
|
@ -292,6 +301,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return a map iterator
|
||||
*/
|
||||
@Override
|
||||
public MapIterator<K, V> mapIterator() {
|
||||
return new ReferenceMapIterator<K, V>(this);
|
||||
}
|
||||
|
@ -303,6 +313,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return a set view of this map's entries
|
||||
*/
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
if (entrySet == null) {
|
||||
entrySet = new ReferenceEntrySet<K, V>(this);
|
||||
|
@ -315,6 +326,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return a set view of this map's keys
|
||||
*/
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
if (keySet == null) {
|
||||
keySet = new ReferenceKeySet<K>(this);
|
||||
|
@ -327,6 +339,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return a set view of this map's values
|
||||
*/
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
if (values == null) {
|
||||
values = new ReferenceValues<V>(this);
|
||||
|
@ -405,6 +418,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param key the key
|
||||
* @return the entry, null if no match
|
||||
*/
|
||||
@Override
|
||||
protected HashEntry<K, V> getEntry(Object key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
|
@ -435,6 +449,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param key2 the second key extracted from the entry via <code>entry.key</code>
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected boolean isEqualKey(Object key1, Object key2) {
|
||||
key2 = (keyType == ReferenceStrength.HARD ? key2 : ((Reference<K>) key2).get());
|
||||
|
@ -450,6 +465,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param value the value to store
|
||||
* @return the newly created entry
|
||||
*/
|
||||
@Override
|
||||
protected ReferenceEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
|
||||
return new ReferenceEntry<K, V>(this, next, hashCode, key, value);
|
||||
}
|
||||
|
@ -459,6 +475,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the entrySet iterator
|
||||
*/
|
||||
@Override
|
||||
protected Iterator<Map.Entry<K, V>> createEntrySetIterator() {
|
||||
return new ReferenceEntrySetIterator<K, V>(this);
|
||||
}
|
||||
|
@ -468,6 +485,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the keySet iterator
|
||||
*/
|
||||
@Override
|
||||
protected Iterator<K> createKeySetIterator() {
|
||||
return new ReferenceKeySetIterator<K>(this);
|
||||
}
|
||||
|
@ -477,6 +495,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the values iterator
|
||||
*/
|
||||
@Override
|
||||
protected Iterator<V> createValuesIterator() {
|
||||
return new ReferenceValuesIterator<V>(this);
|
||||
}
|
||||
|
@ -491,10 +510,12 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return toArray(new Object[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] arr) {
|
||||
// special implementation to handle disappearing entries
|
||||
ArrayList<Map.Entry<K, V>> list = new ArrayList<Map.Entry<K, V>>();
|
||||
|
@ -515,10 +536,12 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return toArray(new Object[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] arr) {
|
||||
// special implementation to handle disappearing keys
|
||||
List<K> list = new ArrayList<K>(parent.size());
|
||||
|
@ -539,10 +562,12 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return toArray(new Object[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] arr) {
|
||||
// special implementation to handle disappearing values
|
||||
List<V> list = new ArrayList<V>(parent.size());
|
||||
|
@ -588,6 +613,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the key, which may be null if it was garbage collected
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public K getKey() {
|
||||
return (K) ((parent.keyType == ReferenceStrength.HARD) ? key : ((Reference<K>) key).get());
|
||||
|
@ -599,6 +625,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the value, which may be null if it was garbage collected
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public V getValue() {
|
||||
return (V) ((parent.valueType == ReferenceStrength.HARD) ? value : ((Reference<V>) value).get());
|
||||
|
@ -610,6 +637,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param obj the object to store
|
||||
* @return the previous value
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public V setValue(V obj) {
|
||||
V old = getValue();
|
||||
|
@ -629,6 +657,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
* @param obj the other map entry to compare to
|
||||
* @return true if equal, false if not
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -657,6 +686,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @return the hashcode of the entry
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return parent.hashEntry(getKey(), getValue());
|
||||
}
|
||||
|
@ -912,6 +942,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
this.hash = hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
@ -929,6 +960,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
this.hash = hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
@ -953,6 +985,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @param out the output stream
|
||||
*/
|
||||
@Override
|
||||
protected void doWriteObject(ObjectOutputStream out) throws IOException {
|
||||
out.writeInt(keyType.value);
|
||||
out.writeInt(valueType.value);
|
||||
|
@ -984,6 +1017,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
*
|
||||
* @param in the input stream
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
this.keyType = ReferenceStrength.resolve(in.readInt());
|
||||
|
|
|
@ -72,6 +72,7 @@ public abstract class AbstractSortedMapDecorator<K, V> extends AbstractMapDecora
|
|||
*
|
||||
* @return the decorated map
|
||||
*/
|
||||
@Override
|
||||
protected SortedMap<K, V> decorated() {
|
||||
return (SortedMap<K, V>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
|||
* @param key the key convert
|
||||
* @return the converted key
|
||||
*/
|
||||
@Override
|
||||
protected Object convertKey(Object key) {
|
||||
if (key != null) {
|
||||
char[] chars = key.toString().toCharArray();
|
||||
|
@ -133,6 +134,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
public CaseInsensitiveMap<K, V> clone() {
|
||||
return (CaseInsensitiveMap<K, V>) super.clone();
|
||||
}
|
||||
|
|
|
@ -463,6 +463,7 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> implements Ser
|
|||
* @param obj the object to compare to
|
||||
* @return true if the maps are equal
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Map) {
|
||||
|
@ -475,6 +476,7 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> implements Ser
|
|||
/**
|
||||
* Gets a hash code for the Map as per the Map specification.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 0;
|
||||
for (Map.Entry<K, V> entry : entrySet()) {
|
||||
|
|
|
@ -183,6 +183,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public V get(Object key) {
|
||||
// create value for key if key is not currently in the map
|
||||
|
|
|
@ -112,6 +112,7 @@ public class FixedSizeMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
if (map.containsKey(key) == false) {
|
||||
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
|
||||
|
@ -119,6 +120,7 @@ public class FixedSizeMap<K, V>
|
|||
return map.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
for (K key : mapToCopy.keySet()) {
|
||||
if (!containsKey(key)) {
|
||||
|
@ -128,25 +130,30 @@ public class FixedSizeMap<K, V>
|
|||
map.putAll(mapToCopy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("Map is fixed size");
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException("Map is fixed size");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = map.entrySet();
|
||||
// unmodifiable set will still allow modification via Map.Entry objects
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = map.keySet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Collection<V> coll = map.values();
|
||||
return UnmodifiableCollection.decorate(coll);
|
||||
|
|
|
@ -113,6 +113,7 @@ public class FixedSizeSortedMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
if (map.containsKey(key) == false) {
|
||||
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
|
||||
|
@ -120,6 +121,7 @@ public class FixedSizeSortedMap<K, V>
|
|||
return map.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
if (CollectionUtils.isSubCollection(mapToCopy.keySet(), keySet())) {
|
||||
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
|
||||
|
@ -127,35 +129,43 @@ public class FixedSizeSortedMap<K, V>
|
|||
map.putAll(mapToCopy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("Map is fixed size");
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException("Map is fixed size");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
return UnmodifiableSet.decorate(map.entrySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return UnmodifiableSet.decorate(map.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return UnmodifiableCollection.decorate(map.values());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public SortedMap<K, V> subMap(K fromKey, K toKey) {
|
||||
return new FixedSizeSortedMap<K, V>(getSortedMap().subMap(fromKey, toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> headMap(K toKey) {
|
||||
return new FixedSizeSortedMap<K, V>(getSortedMap().headMap(toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> tailMap(K fromKey) {
|
||||
return new FixedSizeSortedMap<K, V>(getSortedMap().tailMap(fromKey));
|
||||
}
|
||||
|
|
|
@ -667,6 +667,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
canRemove = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (canRemove) {
|
||||
return "Iterator[" + getKey() + "=" + getValue() + "]";
|
||||
|
@ -702,14 +703,17 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
return false;
|
||||
|
@ -721,6 +725,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
if (parent.delegateMap != null) {
|
||||
return parent.delegateMap.entrySet().iterator();
|
||||
|
@ -829,6 +834,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
return nextEntry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (canRemove == false) {
|
||||
return false;
|
||||
|
@ -843,6 +849,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
(value == null ? other.getValue() == null : value.equals(other.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (canRemove == false) {
|
||||
return 0;
|
||||
|
@ -853,6 +860,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
(value == null ? 0 : value.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (canRemove) {
|
||||
return getKey() + "=" + getValue();
|
||||
|
@ -886,24 +894,29 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object key) {
|
||||
return parent.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key) {
|
||||
boolean result = parent.containsKey(key);
|
||||
parent.remove(key);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<K> iterator() {
|
||||
if (parent.delegateMap != null) {
|
||||
return parent.delegateMap.keySet().iterator();
|
||||
|
@ -956,18 +969,22 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object value) {
|
||||
return parent.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator() {
|
||||
if (parent.delegateMap != null) {
|
||||
return parent.delegateMap.values().iterator();
|
||||
|
@ -1030,6 +1047,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
* @return a shallow clone
|
||||
* @since Commons Collections 3.1
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Flat3Map<K, V> clone() {
|
||||
try {
|
||||
|
@ -1049,6 +1067,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
@ -1100,6 +1119,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
*
|
||||
* @return the hash code defined in the Map interface
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (delegateMap != null) {
|
||||
return delegateMap.hashCode();
|
||||
|
@ -1121,6 +1141,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
|||
*
|
||||
* @return a string version of the map
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (delegateMap != null) {
|
||||
return delegateMap.toString();
|
||||
|
|
|
@ -93,6 +93,7 @@ public class HashedMap<K, V>
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
public HashedMap<K, V> clone() {
|
||||
return (HashedMap<K, V>) super.clone();
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ public class IdentityMap<K, V>
|
|||
* @param key the key to get a hash code for
|
||||
* @return the hash code
|
||||
*/
|
||||
@Override
|
||||
protected int hash(Object key) {
|
||||
return System.identityHashCode(key);
|
||||
}
|
||||
|
@ -107,6 +108,7 @@ public class IdentityMap<K, V>
|
|||
* @param key2 the second key to compare
|
||||
* @return true if equal by identity
|
||||
*/
|
||||
@Override
|
||||
protected boolean isEqualKey(Object key1, Object key2) {
|
||||
return (key1 == key2);
|
||||
}
|
||||
|
@ -119,6 +121,7 @@ public class IdentityMap<K, V>
|
|||
* @param value2 the second value to compare
|
||||
* @return true if equal by identity
|
||||
*/
|
||||
@Override
|
||||
protected boolean isEqualValue(Object value1, Object value2) {
|
||||
return (value1 == value2);
|
||||
}
|
||||
|
@ -133,6 +136,7 @@ public class IdentityMap<K, V>
|
|||
* @param value the value to store
|
||||
* @return the newly created entry
|
||||
*/
|
||||
@Override
|
||||
protected IdentityEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
|
||||
return new IdentityEntry<K, V>(next, hashCode, key, value);
|
||||
}
|
||||
|
@ -147,6 +151,7 @@ public class IdentityMap<K, V>
|
|||
super(next, hashCode, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
@ -160,6 +165,7 @@ public class IdentityMap<K, V>
|
|||
(getValue() == other.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(getKey()) ^
|
||||
System.identityHashCode(getValue());
|
||||
|
@ -172,6 +178,7 @@ public class IdentityMap<K, V>
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
public IdentityMap<K, V> clone() {
|
||||
return (IdentityMap<K, V>) super.clone();
|
||||
}
|
||||
|
|
|
@ -170,6 +170,7 @@ public class LRUMap<K, V>
|
|||
* @param key the key
|
||||
* @return the mapped value, null if no match
|
||||
*/
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
LinkEntry<K, V> entry = getEntry(key);
|
||||
if (entry == null) {
|
||||
|
@ -218,6 +219,7 @@ public class LRUMap<K, V>
|
|||
* @param entry the entry to update
|
||||
* @param newValue the new value to store
|
||||
*/
|
||||
@Override
|
||||
protected void updateEntry(HashEntry<K, V> entry, V newValue) {
|
||||
moveToMRU((LinkEntry<K, V>) entry); // handles modCount
|
||||
entry.setValue(newValue);
|
||||
|
@ -238,6 +240,7 @@ public class LRUMap<K, V>
|
|||
* @param key the key to add
|
||||
* @param value the value to add
|
||||
*/
|
||||
@Override
|
||||
protected void addMapping(int hashIndex, int hashCode, K key, V value) {
|
||||
if (isFull()) {
|
||||
LinkEntry<K, V> reuse = header.after;
|
||||
|
@ -397,6 +400,7 @@ public class LRUMap<K, V>
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
public LRUMap<K, V> clone() {
|
||||
return (LRUMap<K, V>) super.clone();
|
||||
}
|
||||
|
@ -420,6 +424,7 @@ public class LRUMap<K, V>
|
|||
/**
|
||||
* Writes the data necessary for <code>put()</code> to work in deserialization.
|
||||
*/
|
||||
@Override
|
||||
protected void doWriteObject(ObjectOutputStream out) throws IOException {
|
||||
out.writeInt(maxSize);
|
||||
super.doWriteObject(out);
|
||||
|
@ -428,6 +433,7 @@ public class LRUMap<K, V>
|
|||
/**
|
||||
* Reads the data necessary for <code>put()</code> to work in the superclass.
|
||||
*/
|
||||
@Override
|
||||
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
maxSize = in.readInt();
|
||||
super.doReadObject(in);
|
||||
|
|
|
@ -113,6 +113,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
public LinkedMap<K, V> clone() {
|
||||
return (LinkedMap<K, V>) super.clone();
|
||||
}
|
||||
|
@ -215,70 +216,87 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public K get(int index) {
|
||||
return parent.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object obj) {
|
||||
return parent.containsKey(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object obj) {
|
||||
return parent.indexOf(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object obj) {
|
||||
return parent.indexOf(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> coll) {
|
||||
return parent.keySet().containsAll(coll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public K remove(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return parent.keySet().toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] array) {
|
||||
return parent.keySet().toArray(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<K> iterator() {
|
||||
return UnmodifiableIterator.decorate(parent.keySet().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<K> listIterator() {
|
||||
return UnmodifiableListIterator.decorate(super.listIterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<K> listIterator(int fromIndex) {
|
||||
return UnmodifiableListIterator.decorate(super.listIterator(fromIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<K> subList(int fromIndexInclusive, int toIndexExclusive) {
|
||||
return UnmodifiableList.decorate(super.subList(fromIndexInclusive, toIndexExclusive));
|
||||
}
|
||||
|
|
|
@ -140,6 +140,7 @@ public class ListOrderedMap<K, V>
|
|||
|
||||
// Implement OrderedMap
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
return new ListOrderedMapIterator<K, V>(this);
|
||||
}
|
||||
|
@ -201,6 +202,7 @@ public class ListOrderedMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
if (decorated().containsKey(key)) {
|
||||
// re-adding doesn't change order
|
||||
|
@ -213,6 +215,7 @@ public class ListOrderedMap<K, V>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> map) {
|
||||
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
|
@ -233,12 +236,14 @@ public class ListOrderedMap<K, V>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
V result = decorated().remove(key);
|
||||
insertOrder.remove(key);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
decorated().clear();
|
||||
insertOrder.clear();
|
||||
|
@ -253,6 +258,7 @@ public class ListOrderedMap<K, V>
|
|||
* @see #keyList()
|
||||
* @return the fully modifiable collection view over the keys
|
||||
*/
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return new KeySetView<K>(this);
|
||||
}
|
||||
|
@ -282,6 +288,7 @@ public class ListOrderedMap<K, V>
|
|||
* @see #valueList()
|
||||
* @return the fully modifiable collection view over the values
|
||||
*/
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return new ValuesView<V>(this);
|
||||
}
|
||||
|
@ -307,6 +314,7 @@ public class ListOrderedMap<K, V>
|
|||
*
|
||||
* @return the fully modifiable set view over the entries
|
||||
*/
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
return new EntrySetView<K, V>(this, this.insertOrder);
|
||||
}
|
||||
|
@ -317,6 +325,7 @@ public class ListOrderedMap<K, V>
|
|||
*
|
||||
* @return the Map as a String
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isEmpty()) {
|
||||
return "{}";
|
||||
|
@ -466,18 +475,22 @@ public class ListOrderedMap<K, V>
|
|||
this.parent = (ListOrderedMap<Object, V>) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object value) {
|
||||
return this.parent.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator() {
|
||||
return new AbstractUntypedIteratorDecorator<Map.Entry<Object, V>, V>(parent.entrySet().iterator()) {
|
||||
public V next() {
|
||||
|
@ -486,14 +499,17 @@ public class ListOrderedMap<K, V>
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(int index) {
|
||||
return this.parent.getValue(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V set(int index, V value) {
|
||||
return this.parent.setValue(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(int index) {
|
||||
return this.parent.remove(index);
|
||||
}
|
||||
|
@ -509,18 +525,22 @@ public class ListOrderedMap<K, V>
|
|||
this.parent = (ListOrderedMap<K, Object>) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object value) {
|
||||
return this.parent.containsKey(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<K> iterator() {
|
||||
return new AbstractUntypedIteratorDecorator<Map.Entry<K, Object>, K>(parent.entrySet().iterator()) {
|
||||
public K next() {
|
||||
|
@ -549,21 +569,26 @@ public class ListOrderedMap<K, V>
|
|||
return entrySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.parent.size();
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.parent.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object obj) {
|
||||
return getEntrySet().contains(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> coll) {
|
||||
return getEntrySet().containsAll(coll);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean remove(Object obj) {
|
||||
if (obj instanceof Map.Entry == false) {
|
||||
|
@ -577,10 +602,12 @@ public class ListOrderedMap<K, V>
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
@ -588,14 +615,17 @@ public class ListOrderedMap<K, V>
|
|||
return getEntrySet().equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getEntrySet().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getEntrySet().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return new ListOrderedIterator<K, V>(parent, insertOrder);
|
||||
}
|
||||
|
@ -616,6 +646,7 @@ public class ListOrderedMap<K, V>
|
|||
return new ListOrderedMapEntry<K, V>(parent, last);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
parent.decorated().remove(last);
|
||||
|
@ -631,10 +662,12 @@ public class ListOrderedMap<K, V>
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getValue() {
|
||||
return parent.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
return parent.decorated().put(key, value);
|
||||
}
|
||||
|
@ -709,6 +742,7 @@ public class ListOrderedMap<K, V>
|
|||
readable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (readable == true) {
|
||||
return "Iterator[" + getKey() + "=" + getValue() + "]";
|
||||
|
|
|
@ -807,6 +807,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
public MultiKeyMap<K, V> clone() {
|
||||
return new MultiKeyMap<K, V>(decorated().clone());
|
||||
}
|
||||
|
@ -821,6 +822,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
* @throws NullPointerException if the key is null
|
||||
* @throws ClassCastException if the key is not a MultiKey
|
||||
*/
|
||||
@Override
|
||||
public V put(MultiKey<? extends K> key, V value) {
|
||||
checkKey(key);
|
||||
return super.put(key, value);
|
||||
|
@ -843,6 +845,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public MapIterator<MultiKey<? extends K>, V> mapIterator() {
|
||||
return decorated().mapIterator();
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
/**
|
||||
* Clear the map.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
// If you believe that you have GC issues here, try uncommenting this code
|
||||
// Set pairs = getMap().entrySet();
|
||||
|
@ -215,6 +216,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
* @param value the value to search for
|
||||
* @return true if the map contains the value
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean containsValue(Object value) {
|
||||
Set<Map.Entry<K, Object>> pairs = decorated().entrySet();
|
||||
|
@ -238,6 +240,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
* @param value the value to add to the collection at the key
|
||||
* @return the value added if the map changed and null if the map did not change
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object put(K key, Object value) {
|
||||
boolean result = false;
|
||||
|
@ -267,6 +270,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
*
|
||||
* @param map the map to copy (either a normal or multi map)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void putAll(Map<? extends K, ?> map) {
|
||||
if (map instanceof MultiMap) {
|
||||
|
@ -287,6 +291,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
*
|
||||
* @return a collection view of the values contained in this map
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<Object> values() {
|
||||
Collection<V> vs = valuesView;
|
||||
|
@ -406,6 +411,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
* Inner class that provides the values view.
|
||||
*/
|
||||
private class Values extends AbstractCollection<V> {
|
||||
@Override
|
||||
public Iterator<V> iterator() {
|
||||
final IteratorChain<V> chain = new IteratorChain<V>();
|
||||
for (Iterator<K> it = keySet().iterator(); it.hasNext();) {
|
||||
|
@ -414,10 +420,12 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
|||
return chain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return totalSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
MultiValueMap.this.clear();
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ public class PredicatedMap<K, V>
|
|||
* @throws IllegalArgumentException if invalid
|
||||
* @since Commons Collections 3.1
|
||||
*/
|
||||
@Override
|
||||
protected V checkSetValue(V value) {
|
||||
if (valuePredicate.evaluate(value) == false) {
|
||||
throw new IllegalArgumentException("Cannot set value - Predicate rejected it");
|
||||
|
@ -164,16 +165,19 @@ public class PredicatedMap<K, V>
|
|||
* @return true if a value predicate is in use
|
||||
* @since Commons Collections 3.1
|
||||
*/
|
||||
@Override
|
||||
protected boolean isSetValueChecking() {
|
||||
return (valuePredicate != null);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
validate(key, value);
|
||||
return map.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
for (Map.Entry<? extends K, ? extends V> entry : mapToCopy.entrySet()) {
|
||||
validate(entry.getKey(), entry.getValue());
|
||||
|
|
|
@ -156,6 +156,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
|||
* @param key the key to get a hash code for
|
||||
* @return the hash code
|
||||
*/
|
||||
@Override
|
||||
protected int hash(Object key) {
|
||||
return System.identityHashCode(key);
|
||||
}
|
||||
|
@ -169,6 +170,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
|||
* @param value the value to get a hash code for, may be null
|
||||
* @return the hash code, as per the MapEntry specification
|
||||
*/
|
||||
@Override
|
||||
protected int hashEntry(Object key, Object value) {
|
||||
return System.identityHashCode(key) ^
|
||||
System.identityHashCode(value);
|
||||
|
@ -184,6 +186,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
|||
* @param key2 the second key extracted from the entry via <code>entry.key</code>
|
||||
* @return true if equal by identity
|
||||
*/
|
||||
@Override
|
||||
protected boolean isEqualKey(Object key1, Object key2) {
|
||||
key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference<?>) key2).get();
|
||||
return key1 == key2;
|
||||
|
@ -198,6 +201,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
|||
* @param value2 the second value extracted from the entry via <code>getValue()</code>
|
||||
* @return true if equal by identity
|
||||
*/
|
||||
@Override
|
||||
protected boolean isEqualValue(Object value1, Object value2) {
|
||||
return value1 == value2;
|
||||
}
|
||||
|
|
|
@ -466,6 +466,7 @@ public class SingletonMap<K, V>
|
|||
hasNext = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (hasNext) {
|
||||
return "Iterator[]";
|
||||
|
@ -487,18 +488,23 @@ public class SingletonMap<K, V>
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(Object object) {
|
||||
return parent.containsValue(object);
|
||||
}
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@Override
|
||||
public Iterator<V> iterator() {
|
||||
return new SingletonIterator<V>(parent.getValue(), false);
|
||||
}
|
||||
|
@ -510,6 +516,7 @@ public class SingletonMap<K, V>
|
|||
*
|
||||
* @return a shallow clone
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SingletonMap<K, V> clone() {
|
||||
try {
|
||||
|
@ -525,6 +532,7 @@ public class SingletonMap<K, V>
|
|||
* @param obj the object to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
@ -546,6 +554,7 @@ public class SingletonMap<K, V>
|
|||
*
|
||||
* @return the hash code defined in the Map interface
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getKey() == null ? 0 : getKey().hashCode()) ^
|
||||
(getValue() == null ? 0 : getValue().hashCode());
|
||||
|
@ -556,6 +565,7 @@ public class SingletonMap<K, V>
|
|||
*
|
||||
* @return a string version of the map
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder(128)
|
||||
.append('{')
|
||||
|
|
|
@ -209,6 +209,7 @@ public class TransformedMap<K, V>
|
|||
* @return the transformed value
|
||||
* @since Commons Collections 3.1
|
||||
*/
|
||||
@Override
|
||||
protected V checkSetValue(V value) {
|
||||
return valueTransformer.transform(value);
|
||||
}
|
||||
|
@ -219,17 +220,20 @@ public class TransformedMap<K, V>
|
|||
* @return true if a value transformer is in use
|
||||
* @since Commons Collections 3.1
|
||||
*/
|
||||
@Override
|
||||
protected boolean isSetValueChecking() {
|
||||
return (valueTransformer != null);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
key = transformKey(key);
|
||||
value = transformValue(value);
|
||||
return decorated().put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
mapToCopy = transformMap(mapToCopy);
|
||||
decorated().putAll(mapToCopy);
|
||||
|
|
|
@ -68,35 +68,43 @@ public final class UnmodifiableEntrySet<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean add(Map.Entry<K, V> object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return new UnmodifiableEntrySetIterator(collection.iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object[] toArray() {
|
||||
Object[] array = collection.toArray();
|
||||
|
@ -106,6 +114,7 @@ public final class UnmodifiableEntrySet<K, V>
|
|||
return array;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] toArray(T[] array) {
|
||||
Object[] result = array;
|
||||
|
@ -142,10 +151,12 @@ public final class UnmodifiableEntrySet<K, V>
|
|||
super(iterator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map.Entry<K, V> next() {
|
||||
return new UnmodifiableEntry(iterator.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@ -161,6 +172,7 @@ public final class UnmodifiableEntrySet<K, V>
|
|||
super(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -103,22 +103,27 @@ public final class UnmodifiableMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapIterator<K, V> mapIterator() {
|
||||
if (map instanceof IterableMap) {
|
||||
MapIterator<K, V> it = ((IterableMap<K, V>) map).mapIterator();
|
||||
|
@ -128,16 +133,19 @@ public final class UnmodifiableMap<K, V>
|
|||
return UnmodifiableMapIterator.decorate(it);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||
return UnmodifiableEntrySet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = super.keySet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Collection<V> coll = super.values();
|
||||
return UnmodifiableCollection.decorate(coll);
|
||||
|
|
|
@ -101,37 +101,45 @@ public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecora
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||
return UnmodifiableEntrySet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = super.keySet();
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Collection<V> coll = super.values();
|
||||
return UnmodifiableCollection.decorate(coll);
|
||||
|
|
|
@ -101,55 +101,68 @@ public final class UnmodifiableSortedMap<K, V>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> mapToCopy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
return UnmodifiableEntrySet.decorate(super.entrySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return UnmodifiableSet.decorate(super.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return UnmodifiableCollection.decorate(super.values());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public K firstKey() {
|
||||
return decorated().firstKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public K lastKey() {
|
||||
return decorated().lastKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparator<? super K> comparator() {
|
||||
return decorated().comparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> subMap(K fromKey, K toKey) {
|
||||
return new UnmodifiableSortedMap<K, V>(decorated().subMap(fromKey, toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> headMap(K toKey) {
|
||||
return new UnmodifiableSortedMap<K, V>(decorated().headMap(toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> tailMap(K fromKey) {
|
||||
return new UnmodifiableSortedMap<K, V>(decorated().tailMap(fromKey));
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public abstract class AbstractSetDecorator<E> extends AbstractCollectionDecorato
|
|||
*
|
||||
* @return the decorated set
|
||||
*/
|
||||
@Override
|
||||
protected Set<E> decorated() {
|
||||
return (Set<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public abstract class AbstractSortedSetDecorator<E>
|
|||
*
|
||||
* @return the decorated set
|
||||
*/
|
||||
@Override
|
||||
protected SortedSet<E> decorated() {
|
||||
return (SortedSet<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
* @see org.apache.commons.collections.collection.CompositeCollection.CollectionMutator
|
||||
* @see SetMutator
|
||||
*/
|
||||
@Override
|
||||
public synchronized void addComposited(Collection<E> c) {
|
||||
if (!(c instanceof Set)) {
|
||||
throw new IllegalArgumentException("Collections added must implement java.util.Set");
|
||||
|
@ -110,6 +111,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
*
|
||||
* @throws IllegalArgumentException if c or d does not implement java.util.Set
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized void addComposited(Collection<E> c, Collection<E> d) {
|
||||
if (!(c instanceof Set)) throw new IllegalArgumentException("Argument must implement java.util.Set");
|
||||
|
@ -122,6 +124,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
* @param comps
|
||||
* @throws IllegalArgumentException if any of the collections in comps do not implement Set
|
||||
*/
|
||||
@Override
|
||||
public synchronized void addComposited(Collection<E>[] comps) {
|
||||
for (int i = comps.length - 1; i >= 0; --i) {
|
||||
this.addComposited(comps[i]);
|
||||
|
@ -135,6 +138,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
* composited sets will throw IllegalArgumentException
|
||||
* <p>
|
||||
*/
|
||||
@Override
|
||||
public void setMutator(CollectionMutator<E> mutator) {
|
||||
super.setMutator(mutator);
|
||||
}
|
||||
|
@ -148,6 +152,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
* @param obj Object to be removed
|
||||
* @return true if the object is removed, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(Object obj) {
|
||||
for (Set<? extends E> set : getCollections()) {
|
||||
if (set.contains(obj)) return set.remove(obj);
|
||||
|
@ -158,6 +163,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
/**
|
||||
* @see Set#equals
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Set) {
|
||||
|
@ -170,6 +176,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
|
|||
/**
|
||||
* @see Set#hashCode
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 0;
|
||||
for (E e : this) {
|
||||
|
|
|
@ -168,15 +168,18 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public void clear() {
|
||||
collection.clear();
|
||||
setOrder.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderedIterator<E> iterator() {
|
||||
return new OrderedSetIterator<E>(setOrder.listIterator(), collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
if (collection.add(object)) {
|
||||
setOrder.add(object);
|
||||
|
@ -185,6 +188,7 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
boolean result = false;
|
||||
for (E e : coll) {
|
||||
|
@ -193,12 +197,14 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
boolean result = collection.remove(object);
|
||||
setOrder.remove(object);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
boolean result = false;
|
||||
for (Iterator<?> it = coll.iterator(); it.hasNext();) {
|
||||
|
@ -207,6 +213,7 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
boolean result = collection.retainAll(coll);
|
||||
if (result == false) {
|
||||
|
@ -224,10 +231,12 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return setOrder.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T a[]) {
|
||||
return setOrder.toArray(a);
|
||||
}
|
||||
|
@ -273,6 +282,7 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
* any custom toStrings will be ignored.
|
||||
*/
|
||||
// Fortunately List.toString and Set.toString look the same
|
||||
@Override
|
||||
public String toString() {
|
||||
return setOrder.toString();
|
||||
}
|
||||
|
@ -294,11 +304,13 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
|
|||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
last = iterator.next();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
set.remove(last);
|
||||
iterator.remove();
|
||||
|
|
|
@ -147,10 +147,12 @@ public final class MapBackedSet<E, V> implements Set<E>, Serializable {
|
|||
return map.keySet().toArray(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return map.keySet().equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return map.keySet().hashCode();
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public class PredicatedSet<E> extends PredicatedCollection<E> implements Set<E>
|
|||
*
|
||||
* @return the decorated set
|
||||
*/
|
||||
@Override
|
||||
protected Set<E> decorated() {
|
||||
return (Set<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public class PredicatedSortedSet<E> extends PredicatedSet<E> implements SortedSe
|
|||
*
|
||||
* @return the decorated sorted set
|
||||
*/
|
||||
@Override
|
||||
protected SortedSet<E> decorated() {
|
||||
return (SortedSet<E>) super.decorated();
|
||||
}
|
||||
|
|
|
@ -67,30 +67,37 @@ public final class UnmodifiableSet<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.<E>decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -96,45 +96,55 @@ public final class UnmodifiableSortedSet<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public SortedSet<E> subSet(E fromElement, E toElement) {
|
||||
SortedSet<E> sub = decorated().subSet(fromElement, toElement);
|
||||
return new UnmodifiableSortedSet<E>(sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<E> headSet(E toElement) {
|
||||
SortedSet<E> sub = decorated().headSet(toElement);
|
||||
return new UnmodifiableSortedSet<E>(sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<E> tailSet(E fromElement) {
|
||||
SortedSet<E> sub = decorated().tailSet(fromElement);
|
||||
return new UnmodifiableSortedSet<E>(sub);
|
||||
|
|
|
@ -130,6 +130,7 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
|
@ -140,6 +141,7 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return decorated().hashCode();
|
||||
}
|
||||
|
@ -147,6 +149,7 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return decorated().toString();
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ public class BulkTest extends TestCase implements Cloneable {
|
|||
*
|
||||
* @return a clone of this <code>BulkTest</code>
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
|
@ -226,6 +227,7 @@ public class BulkTest extends TestCase implements Cloneable {
|
|||
*
|
||||
* @return the display name of this <code>BulkTest</code>
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + "(" + verboseName + ") ";
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
|
|||
*
|
||||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object o) {
|
||||
|
||||
|
@ -116,6 +117,7 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
|
|||
/**
|
||||
* @return hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getKey().hashCode() ^ getValue().hashCode();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class TestArrayStack<E> extends TestArrayList<E> {
|
|||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayStack<E> makeObject() {
|
||||
return new ArrayStack<E>();
|
||||
}
|
||||
|
@ -97,6 +98,7 @@ public class TestArrayStack<E> extends TestArrayList<E> {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSearch() {
|
||||
ArrayStack<E> stack = makeObject();
|
||||
|
|
|
@ -69,12 +69,14 @@ public class TestClosureUtils extends junit.framework.TestCase {
|
|||
/**
|
||||
* Set up instance variables required by this test case.
|
||||
*/
|
||||
@Override
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down instance variables required by this test case.
|
||||
*/
|
||||
@Override
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
|
|
|
@ -50,12 +50,14 @@ public class TestFactoryUtils extends junit.framework.TestCase {
|
|||
/**
|
||||
* Set up instance variables required by this test case.
|
||||
*/
|
||||
@Override
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down instance variables required by this test case.
|
||||
*/
|
||||
@Override
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
|
@ -205,6 +207,7 @@ public class TestFactoryUtils extends junit.framework.TestCase {
|
|||
public Mock1(Mock1 mock) {
|
||||
iVal = mock.iVal;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Mock1) {
|
||||
if (iVal == ((Mock1) obj).iVal) {
|
||||
|
@ -221,6 +224,7 @@ public class TestFactoryUtils extends junit.framework.TestCase {
|
|||
public Mock2(Object val) {
|
||||
iVal = val;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Mock2) {
|
||||
if (iVal == ((Mock2) obj).iVal) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue