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:
Sebastian Bazley 2010-07-21 17:39:49 +00:00
parent 9601875f69
commit 5cabc0f86f
206 changed files with 1129 additions and 0 deletions

View File

@ -413,6 +413,7 @@ public class ExtendedProperties extends Hashtable {
* *
* @return True if the object has more tokens. * @return True if the object has more tokens.
*/ */
@Override
public boolean hasMoreTokens() { public boolean hasMoreTokens() {
return super.hasMoreTokens(); return super.hasMoreTokens();
} }
@ -422,6 +423,7 @@ public class ExtendedProperties extends Hashtable {
* *
* @return A String. * @return A String.
*/ */
@Override
public String nextToken() { public String nextToken() {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
@ -1708,6 +1710,7 @@ public class ExtendedProperties extends Hashtable {
* @param value for the property * @param value for the property
* @return old value of the property * @return old value of the property
*/ */
@Override
public Object put(Object key, Object value) { public Object put(Object key, Object value) {
String strKey = String.valueOf(key); String strKey = String.valueOf(key);
Object ret = getProperty(strKey); Object ret = getProperty(strKey);
@ -1722,6 +1725,7 @@ public class ExtendedProperties extends Hashtable {
* *
* @param map full of key/value pair data * @param map full of key/value pair data
*/ */
@Override
public void putAll(Map map) { public void putAll(Map map) {
if (map instanceof ExtendedProperties) { if (map instanceof ExtendedProperties) {
for (Iterator it = ((ExtendedProperties) map).getKeys(); it.hasNext(); ) { for (Iterator it = ((ExtendedProperties) map).getKeys(); it.hasNext(); ) {
@ -1744,6 +1748,7 @@ public class ExtendedProperties extends Hashtable {
* @param key specifying the property * @param key specifying the property
* @return old value of the property * @return old value of the property
*/ */
@Override
public Object remove(Object key) { public Object remove(Object key) {
String strKey = String.valueOf(key); String strKey = String.valueOf(key);
Object ret = getProperty(strKey); Object ret = getProperty(strKey);

View File

@ -60,6 +60,7 @@ public abstract class AbstractBagDecorator<E>
* *
* @return the decorated bag * @return the decorated bag
*/ */
@Override
protected Bag<E> decorated() { protected Bag<E> decorated() {
return (Bag<E>) super.decorated(); return (Bag<E>) super.decorated();
} }

View File

@ -417,6 +417,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
this.value = value; this.value = value;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof MutableInteger == false) { if (obj instanceof MutableInteger == false) {
return false; return false;
@ -424,6 +425,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
return ((MutableInteger) obj).value == value; return ((MutableInteger) obj).value == value;
} }
@Override
public int hashCode() { public int hashCode() {
return value; return value;
} }
@ -530,6 +532,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
* @param object the Bag to compare to * @param object the Bag to compare to
* @return true if equal * @return true if equal
*/ */
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (object == this) { if (object == this) {
return true; return true;
@ -559,6 +562,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
* *
* @return the hash code of the Bag * @return the hash code of the Bag
*/ */
@Override
public int hashCode() { public int hashCode() {
int total = 0; int total = 0;
for (Iterator<Map.Entry<E, MutableInteger>> it = map.entrySet().iterator(); it.hasNext();) { 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 * @return a debugging toString
*/ */
@Override
public String toString() { public String toString() {
if (size() == 0) { if (size() == 0) {
return "[]"; return "[]";

View File

@ -59,6 +59,7 @@ public abstract class AbstractSortedBagDecorator<E>
* *
* @return the decorated bag * @return the decorated bag
*/ */
@Override
protected SortedBag<E> decorated() { protected SortedBag<E> decorated() {
return (SortedBag<E>) super.decorated(); return (SortedBag<E>) super.decorated();
} }

View File

@ -84,6 +84,7 @@ public class PredicatedBag<E>
* *
* @return the decorated bag * @return the decorated bag
*/ */
@Override
protected Bag<E> decorated() { protected Bag<E> decorated() {
return (Bag<E>) super.decorated(); return (Bag<E>) super.decorated();
} }

View File

@ -83,6 +83,7 @@ public class PredicatedSortedBag<E>
* *
* @return the decorated bag * @return the decorated bag
*/ */
@Override
protected SortedBag<E> decorated() { protected SortedBag<E> decorated() {
return (SortedBag<E>) super.decorated(); return (SortedBag<E>) super.decorated();
} }

View File

@ -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? // TODO: Generics - should this be E<? extends Comparable> or some such?
@Override
public boolean add(E object) { public boolean add(E object) {
if(comparator() == null && !(object instanceof Comparable)) { if(comparator() == null && !(object instanceof Comparable)) {
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " + throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +

View File

@ -100,43 +100,53 @@ public final class UnmodifiableBag<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.<E>decorate(decorated().iterator()); return UnmodifiableIterator.<E>decorate(decorated().iterator());
} }
@Override
public boolean add(E object) { public boolean add(E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public boolean add(E object, int count) { public boolean add(E object, int count) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object, int count) { public boolean remove(Object object, int count) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<E> uniqueSet() { public Set<E> uniqueSet() {
Set<E> set = decorated().uniqueSet(); Set<E> set = decorated().uniqueSet();
return UnmodifiableSet.<E>decorate(set); return UnmodifiableSet.<E>decorate(set);

View File

@ -100,43 +100,53 @@ public final class UnmodifiableSortedBag<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator()); return UnmodifiableIterator.decorate(decorated().iterator());
} }
@Override
public boolean add(E object) { public boolean add(E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public boolean add(E object, int count) { public boolean add(E object, int count) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object, int count) { public boolean remove(Object object, int count) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<E> uniqueSet() { public Set<E> uniqueSet() {
Set<E> set = decorated().uniqueSet(); Set<E> set = decorated().uniqueSet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);

View File

@ -55,11 +55,13 @@ public abstract class AbstractBidiMapDecorator<K, V> extends AbstractMapDecorato
* *
* @return the decorated map * @return the decorated map
*/ */
@Override
protected BidiMap<K, V> decorated() { protected BidiMap<K, V> decorated() {
return (BidiMap<K, V>) super.decorated(); return (BidiMap<K, V>) super.decorated();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public MapIterator<K, V> mapIterator() { public MapIterator<K, V> mapIterator() {
return decorated().mapIterator(); return decorated().mapIterator();
} }

View File

@ -56,6 +56,7 @@ public abstract class AbstractSortedBidiMapDecorator<K, V> extends
* *
* @return the decorated map * @return the decorated map
*/ */
@Override
protected SortedBidiMap<K, V> decorated() { protected SortedBidiMap<K, V> decorated() {
return (SortedBidiMap<K, V>) super.decorated(); return (SortedBidiMap<K, V>) super.decorated();
} }

View File

@ -121,6 +121,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
* @param inverseMap the inverse BidiMap * @param inverseMap the inverse BidiMap
* @return new bidi map * @return new bidi map
*/ */
@Override
protected DualTreeBidiMap<V, K> createBidiMap(Map<V, K> normalMap, Map<K, V> reverseMap, BidiMap<K, V> inverseMap) { 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); 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 * @return a new ordered map iterator
*/ */
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
return new BidiOrderedMapIterator<K, V>(this); 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(); this.bidi = (DualTreeBidiMap<K, V>) decorated();
} }
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
// override as default implementation uses reverseMap // override as default implementation uses reverseMap
return decorated().normalMap.containsValue(value); return decorated().normalMap.containsValue(value);
} }
@Override
public void clear() { public void clear() {
// override as default implementation uses reverseMap // override as default implementation uses reverseMap
for (Iterator<K> it = keySet().iterator(); it.hasNext();) { 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) { public SortedMap<K, V> headMap(K toKey) {
return new ViewMap<K, V>(decorated(), super.headMap(toKey)); return new ViewMap<K, V>(decorated(), super.headMap(toKey));
} }
@Override
public SortedMap<K, V> tailMap(K fromKey) { public SortedMap<K, V> tailMap(K fromKey) {
return new ViewMap<K, V>(decorated(), super.tailMap(fromKey)); return new ViewMap<K, V>(decorated(), super.tailMap(fromKey));
} }
@Override
public SortedMap<K, V> subMap(K fromKey, K toKey) { public SortedMap<K, V> subMap(K fromKey, K toKey) {
return new ViewMap<K, V>(decorated(), super.subMap(fromKey, 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(); return (DualTreeBidiMap<K, V>) super.decorated();
} }
@Override
public K previousKey(K key) { public K previousKey(K key) {
return decorated().previousKey(key); return decorated().previousKey(key);
}; };
@Override
public K nextKey(K key) { public K nextKey(K key) {
return decorated().nextKey(key); return decorated().nextKey(key);
}; };
@ -358,6 +367,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
last = null; last = null;
} }
@Override
public String toString() { public String toString() {
if (last != null) { if (last != null) {
return "MapIterator[" + getKey() + "=" + getValue() + "]"; return "MapIterator[" + getKey() + "=" + getValue() + "]";

View File

@ -447,6 +447,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
* @param obj the object to compare to * @param obj the object to compare to
* @return true if equal * @return true if equal
*/ */
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return this.doEquals(obj, KEY); 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 * @return the hash code value for this map
*/ */
@Override
public int hashCode() { public int hashCode() {
return this.doHashCode(KEY); 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 * @return a standard format string version of the map
*/ */
@Override
public String toString() { public String toString() {
return this.doToString(KEY); return this.doToString(KEY);
} }
@ -1423,10 +1426,12 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
this.orderType = orderType; this.orderType = orderType;
} }
@Override
public int size() { public int size() {
return TreeBidiMap.this.size(); return TreeBidiMap.this.size();
} }
@Override
public void clear() { public void clear() {
TreeBidiMap.this.clear(); TreeBidiMap.this.clear();
} }
@ -1495,6 +1500,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
super(KEY); super(KEY);
} }
@Override
public boolean contains(Object obj) { public boolean contains(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return 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); return node != null && node.getValue().equals(value);
} }
@Override
public boolean remove(Object obj) { public boolean remove(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return false; return false;
@ -1534,6 +1541,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
super(VALUE); super(VALUE);
} }
@Override
public boolean contains(Object obj) { public boolean contains(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return 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); return node != null && node.getKey().equals(value);
} }
@Override
public boolean remove(Object obj) { public boolean remove(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return 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. * @param obj the object to be compared for equality with this entry.
* @return true if the specified object is equal to this entry. * @return true if the specified object is equal to this entry.
*/ */
@Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj == this) { if (obj == this) {
return true; 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. * @return the hash code value for this map entry.
*/ */
@Override
public int hashCode() { public int hashCode() {
if (!calculatedHashCode) { if (!calculatedHashCode) {
hashcodeValue = getKey().hashCode() ^ getValue().hashCode(); hashcodeValue = getKey().hashCode() ^ getValue().hashCode();
@ -2108,14 +2119,17 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
return TreeBidiMap.this; return TreeBidiMap.this;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return TreeBidiMap.this.doEquals(obj, DataElement.VALUE); return TreeBidiMap.this.doEquals(obj, DataElement.VALUE);
} }
@Override
public int hashCode() { public int hashCode() {
return TreeBidiMap.this.doHashCode(DataElement.VALUE); return TreeBidiMap.this.doHashCode(DataElement.VALUE);
} }
@Override
public String toString() { public String toString() {
return TreeBidiMap.this.doToString(DataElement.VALUE); return TreeBidiMap.this.doToString(DataElement.VALUE);
} }

View File

@ -72,47 +72,57 @@ public final class UnmodifiableBidiMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V put(K key, V value) { public V put(K key, V value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = super.entrySet(); Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.decorate(set); return UnmodifiableEntrySet.decorate(set);
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
Set<K> set = super.keySet(); Set<K> set = super.keySet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Collection<V> values() { public Collection<V> values() {
Collection<V> coll = super.values(); Collection<V> coll = super.values();
return UnmodifiableCollection.decorate(coll); return UnmodifiableCollection.decorate(coll);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public K removeValue(Object value) { public K removeValue(Object value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public MapIterator<K, V> mapIterator() { public MapIterator<K, V> mapIterator() {
MapIterator<K, V> it = decorated().mapIterator(); MapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableMapIterator.decorate(it); return UnmodifiableMapIterator.decorate(it);
} }
@Override
public synchronized BidiMap<V, K> inverseBidiMap() { public synchronized BidiMap<V, K> inverseBidiMap() {
if (inverse == null) { if (inverse == null) {
inverse = new UnmodifiableBidiMap<V, K>(decorated().inverseBidiMap()); inverse = new UnmodifiableBidiMap<V, K>(decorated().inverseBidiMap());

View File

@ -72,47 +72,57 @@ public final class UnmodifiableOrderedBidiMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V put(K key, V value) { public V put(K key, V value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = super.entrySet(); Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.decorate(set); return UnmodifiableEntrySet.decorate(set);
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
Set<K> set = super.keySet(); Set<K> set = super.keySet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Collection<V> values() { public Collection<V> values() {
Collection<V> coll = super.values(); Collection<V> coll = super.values();
return UnmodifiableCollection.decorate(coll); return UnmodifiableCollection.decorate(coll);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public K removeValue(Object value) { public K removeValue(Object value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public OrderedBidiMap<V, K> inverseBidiMap() { public OrderedBidiMap<V, K> inverseBidiMap() {
return inverseOrderedBidiMap(); return inverseOrderedBidiMap();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
OrderedMapIterator<K, V> it = decorated().mapIterator(); OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.decorate(it); return UnmodifiableOrderedMapIterator.decorate(it);

View File

@ -74,49 +74,59 @@ public final class UnmodifiableSortedBidiMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V put(K key, V value) { public V put(K key, V value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = super.entrySet(); Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.decorate(set); return UnmodifiableEntrySet.decorate(set);
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
Set<K> set = super.keySet(); Set<K> set = super.keySet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Collection<V> values() { public Collection<V> values() {
Collection<V> coll = super.values(); Collection<V> coll = super.values();
return UnmodifiableCollection.decorate(coll); return UnmodifiableCollection.decorate(coll);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public K removeValue(Object value) { public K removeValue(Object value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
OrderedMapIterator<K, V> it = decorated().mapIterator(); OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.decorate(it); return UnmodifiableOrderedMapIterator.decorate(it);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public SortedBidiMap<V, K> inverseBidiMap() { public SortedBidiMap<V, K> inverseBidiMap() {
if (inverse == null) { if (inverse == null) {
inverse = new UnmodifiableSortedBidiMap<V, K>(decorated().inverseBidiMap()); inverse = new UnmodifiableSortedBidiMap<V, K>(decorated().inverseBidiMap());
@ -125,16 +135,19 @@ public final class UnmodifiableSortedBidiMap<K, V>
return inverse; return inverse;
} }
@Override
public SortedMap<K, V> subMap(K fromKey, K toKey) { public SortedMap<K, V> subMap(K fromKey, K toKey) {
SortedMap<K, V> sm = decorated().subMap(fromKey, toKey); SortedMap<K, V> sm = decorated().subMap(fromKey, toKey);
return UnmodifiableSortedMap.decorate(sm); return UnmodifiableSortedMap.decorate(sm);
} }
@Override
public SortedMap<K, V> headMap(K toKey) { public SortedMap<K, V> headMap(K toKey) {
SortedMap<K, V> sm = decorated().headMap(toKey); SortedMap<K, V> sm = decorated().headMap(toKey);
return UnmodifiableSortedMap.decorate(sm); return UnmodifiableSortedMap.decorate(sm);
} }
@Override
public SortedMap<K, V> tailMap(K fromKey) { public SortedMap<K, V> tailMap(K fromKey) {
SortedMap<K, V> sm = decorated().tailMap(fromKey); SortedMap<K, V> sm = decorated().tailMap(fromKey);
return UnmodifiableSortedMap.decorate(sm); return UnmodifiableSortedMap.decorate(sm);

View File

@ -59,6 +59,7 @@ public abstract class AbstractBufferDecorator<E> extends AbstractCollectionDecor
* *
* @return the decorated buffer * @return the decorated buffer
*/ */
@Override
protected Buffer<E> decorated() { protected Buffer<E> decorated() {
return (Buffer<E>) super.decorated(); return (Buffer<E>) super.decorated();
} }

View File

@ -108,6 +108,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public boolean add(E o) { public boolean add(E o) {
synchronized (lock) { synchronized (lock) {
boolean result = collection.add(o); boolean result = collection.add(o);
@ -116,6 +117,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
} }
} }
@Override
public boolean addAll(Collection<? extends E> c) { public boolean addAll(Collection<? extends E> c) {
synchronized (lock) { synchronized (lock) {
boolean result = collection.addAll(c); boolean result = collection.addAll(c);
@ -131,6 +133,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
* *
* @throws BufferUnderflowException if an interrupt is received * @throws BufferUnderflowException if an interrupt is received
*/ */
@Override
public E get() { public E get() {
synchronized (lock) { synchronized (lock) {
while (collection.isEmpty()) { while (collection.isEmpty()) {
@ -187,6 +190,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
* *
* @throws BufferUnderflowException if an interrupt is received * @throws BufferUnderflowException if an interrupt is received
*/ */
@Override
public E remove() { public E remove() {
synchronized (lock) { synchronized (lock) {
while (collection.isEmpty()) { while (collection.isEmpty()) {

View File

@ -107,6 +107,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public E remove() { public E remove() {
synchronized (lock) { synchronized (lock) {
E returnValue = decorated().remove(); E returnValue = decorated().remove();
@ -115,6 +116,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
} }
} }
@Override
public boolean add(E o) { public boolean add(E o) {
synchronized (lock) { synchronized (lock) {
timeoutWait(1); timeoutWait(1);
@ -122,6 +124,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
} }
} }
@Override
public boolean addAll(final Collection<? extends E> c) { public boolean addAll(final Collection<? extends E> c) {
synchronized (lock) { synchronized (lock) {
timeoutWait(c.size()); timeoutWait(c.size());
@ -129,6 +132,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
} }
} }
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new NotifyingIterator(collection.iterator()); return new NotifyingIterator(collection.iterator());
} }
@ -184,6 +188,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
super(it); super(it);
} }
@Override
public void remove() { public void remove() {
synchronized (lock) { synchronized (lock) {
iterator.remove(); iterator.remove();

View File

@ -171,6 +171,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
* *
* @return this buffer's size * @return this buffer's size
*/ */
@Override
public int size() { public int size() {
int size = 0; int size = 0;
@ -190,6 +191,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
* *
* @return true if this buffer is empty * @return true if this buffer is empty
*/ */
@Override
public boolean isEmpty() { public boolean isEmpty() {
return size() == 0; return size() == 0;
} }
@ -215,6 +217,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
/** /**
* Clears this buffer. * Clears this buffer.
*/ */
@Override
public void clear() { public void clear() {
full = false; full = false;
start = 0; start = 0;
@ -230,6 +233,7 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
* @throws NullPointerException if the given element is null * @throws NullPointerException if the given element is null
* @throws BufferOverflowException if this buffer is full * @throws BufferOverflowException if this buffer is full
*/ */
@Override
public boolean add(E element) { public boolean add(E element) {
if (null == element) { if (null == element) {
throw new NullPointerException("Attempted to add null object to buffer"); 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 * @return an iterator over this buffer's elements
*/ */
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new Iterator<E>() { return new Iterator<E>() {

View File

@ -86,6 +86,7 @@ public class CircularFifoBuffer<E> extends BoundedFifoBuffer<E> {
* @param element the element to add * @param element the element to add
* @return true, always * @return true, always
*/ */
@Override
public boolean add(E element) { public boolean add(E element) {
if (isFull()) { if (isFull()) {
remove(); remove();

View File

@ -81,6 +81,7 @@ public class PredicatedBuffer<E> extends PredicatedCollection<E> implements Buff
* *
* @return the decorated buffer * @return the decorated buffer
*/ */
@Override
protected Buffer<E> decorated() { protected Buffer<E> decorated() {
return (Buffer<E>) super.decorated(); return (Buffer<E>) super.decorated();
} }

View File

@ -224,6 +224,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
* *
* @return the number of elements in this buffer * @return the number of elements in this buffer
*/ */
@Override
public int size() { public int size() {
return size; return size;
} }
@ -231,6 +232,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
/** /**
* Clears all elements from the buffer. * Clears all elements from the buffer.
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void clear() { public void clear() {
elements = (E[]) new Object[elements.length]; // for gc 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 * @param element the element to be added
* @return true always * @return true always
*/ */
@Override
public boolean add(E element) { public boolean add(E element) {
if (isAtCapacity()) { if (isAtCapacity()) {
grow(); grow();
@ -467,6 +470,7 @@ public class PriorityBuffer<E> extends AbstractCollection<E> implements Buffer<E
* *
* @return an iterator over this heap's elements * @return an iterator over this heap's elements
*/ */
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new Iterator<E>() { 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 * @return a string representation of this heap
*/ */
@Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View File

@ -79,6 +79,7 @@ public class SynchronizedBuffer<E>
* *
* @return the decorated buffer * @return the decorated buffer
*/ */
@Override
protected Buffer<E> decorated() { protected Buffer<E> decorated() {
return (Buffer<E>) super.decorated(); return (Buffer<E>) super.decorated();
} }

View File

@ -150,6 +150,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
* *
* @return this buffer's size * @return this buffer's size
*/ */
@Override
public int size() { public int size() {
int size = 0; int size = 0;
@ -167,6 +168,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
* *
* @return true if this buffer is empty * @return true if this buffer is empty
*/ */
@Override
public boolean isEmpty() { public boolean isEmpty() {
return (size() == 0); return (size() == 0);
} }
@ -178,6 +180,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
* @return true, always * @return true, always
* @throws NullPointerException if the given element is null * @throws NullPointerException if the given element is null
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean add(final E obj) { public boolean add(final E obj) {
if (obj == null) { if (obj == null) {
@ -272,6 +275,7 @@ public class UnboundedFifoBuffer<E> extends AbstractCollection<E> implements Buf
* *
* @return an iterator over this buffer's elements * @return an iterator over this buffer's elements
*/ */
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new Iterator<E>() { return new Iterator<E>() {

View File

@ -99,35 +99,43 @@ public final class UnmodifiableBuffer<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator()); return UnmodifiableIterator.decorate(decorated().iterator());
} }
@Override
public boolean add(Object object) { public boolean add(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public E remove() { public E remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -135,14 +135,17 @@ public abstract class AbstractCollectionDecorator<E>
return decorated().retainAll(coll); return decorated().retainAll(coll);
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
return object == this || decorated().equals(object); return object == this || decorated().equals(object);
} }
@Override
public int hashCode() { public int hashCode() {
return decorated().hashCode(); return decorated().hashCode();
} }
@Override
public String toString() { public String toString() {
return decorated().toString(); return decorated().toString();
} }

View File

@ -110,14 +110,17 @@ public abstract class AbstractUntypedCollectionDecorator<E, D> implements Collec
return decorated().retainAll(coll); return decorated().retainAll(coll);
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
return object == this || decorated().equals(object); return object == this || decorated().equals(object);
} }
@Override
public int hashCode() { public int hashCode() {
return decorated().hashCode(); return decorated().hashCode();
} }
@Override
public String toString() { public String toString() {
return decorated().toString(); return decorated().toString();
} }

View File

@ -112,6 +112,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
* @return the result of adding to the underlying collection * @return the result of adding to the underlying collection
* @throws IllegalArgumentException if the add is invalid * @throws IllegalArgumentException if the add is invalid
*/ */
@Override
public boolean add(E object) { public boolean add(E object) {
validate(object); validate(object);
return decorated().add(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 * @return the result of adding to the underlying collection
* @throws IllegalArgumentException if the add is invalid * @throws IllegalArgumentException if the add is invalid
*/ */
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
for (E item : coll) { for (E item : coll) {
validate(item); validate(item);

View File

@ -188,6 +188,7 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
} }
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
synchronized (lock) { synchronized (lock) {
if (object == this) { if (object == this) {
@ -197,12 +198,14 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
} }
} }
@Override
public int hashCode() { public int hashCode() {
synchronized (lock) { synchronized (lock) {
return decorated().hashCode(); return decorated().hashCode();
} }
} }
@Override
public String toString() { public String toString() {
synchronized (lock) { synchronized (lock) {
return decorated().toString(); return decorated().toString();

View File

@ -137,10 +137,12 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public boolean add(E object) { public boolean add(E object) {
return decorated().add(transform(object)); return decorated().add(transform(object));
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
return decorated().addAll(transform(coll)); return decorated().addAll(transform(coll));
} }

View File

@ -103,30 +103,37 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator()); return UnmodifiableIterator.decorate(decorated().iterator());
} }
@Override
public boolean add(E object) { public boolean add(E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -71,30 +71,37 @@ public final class UnmodifiableCollection<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator()); return UnmodifiableIterator.decorate(decorated().iterator());
} }
@Override
public boolean add(E object) { public boolean add(E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -149,6 +149,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
* *
* @return a hash code for this comparator. * @return a hash code for this comparator.
*/ */
@Override
public int hashCode() { public int hashCode() {
int hash = "BooleanComparator".hashCode(); int hash = "BooleanComparator".hashCode();
return trueFirst ? -1 * hash : hash; return trueFirst ? -1 * hash : hash;
@ -166,6 +167,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
* @param object the object to compare to * @param object the object to compare to
* @return true if equal * @return true if equal
*/ */
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
return (this == object) || return (this == object) ||
((object instanceof BooleanComparator) && ((object instanceof BooleanComparator) &&

View File

@ -100,6 +100,7 @@ public class ComparableComparator<E extends Comparable<? super E>> implements Co
* @return a hash code for this comparator. * @return a hash code for this comparator.
* @since Commons Collections 3.0 * @since Commons Collections 3.0
*/ */
@Override
public int hashCode() { public int hashCode() {
return "ComparableComparator".hashCode(); return "ComparableComparator".hashCode();
} }
@ -119,6 +120,7 @@ public class ComparableComparator<E extends Comparable<? super E>> implements Co
* @return true if equal * @return true if equal
* @since Commons Collections 3.0 * @since Commons Collections 3.0
*/ */
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
return (this == object) || return (this == object) ||
((null != object) && (object.getClass().equals(this.getClass()))); ((null != object) && (object.getClass().equals(this.getClass())));

View File

@ -299,6 +299,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
* @return a suitable hash code * @return a suitable hash code
* @since Commons Collections 3.0 * @since Commons Collections 3.0
*/ */
@Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
if (null != comparatorChain) { if (null != comparatorChain) {
@ -326,6 +327,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
* @return true if equal * @return true if equal
* @since Commons Collections 3.0 * @since Commons Collections 3.0
*/ */
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (this == object) { if (this == object) {
return true; return true;

View File

@ -151,6 +151,7 @@ public class NullComparator<E> implements Comparator<E>, Serializable {
* *
* @return a hash code for this comparator. * @return a hash code for this comparator.
**/ **/
@Override
public int hashCode() { public int hashCode() {
return (nullsAreHigh ? -1 : 1) * nonNullComparator.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 * (i.e. <code>null</code> high or low) and with equivalent underlying
* non-<code>null</code> object comparators. * non-<code>null</code> object comparators.
**/ **/
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(obj == null) { return false; } if(obj == null) { return false; }
if(obj == this) { return true; } if(obj == this) { return true; }

View File

@ -87,6 +87,7 @@ public class ReverseComparator<E> implements Comparator<E>, Serializable {
* @return a suitable hash code * @return a suitable hash code
* @since Commons Collections 3.0 * @since Commons Collections 3.0
*/ */
@Override
public int hashCode() { public int hashCode() {
return "ReverseComparator".hashCode() ^ comparator.hashCode(); return "ReverseComparator".hashCode() ^ comparator.hashCode();
} }
@ -107,6 +108,7 @@ public class ReverseComparator<E> implements Comparator<E>, Serializable {
* @return true if equal * @return true if equal
* @since Commons Collections 3.0 * @since Commons Collections 3.0
*/ */
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (this == object) { if (this == object) {
return true; return true;

View File

@ -144,6 +144,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
* @return the next element * @return the next element
* @throws NoSuchElementException if there is no next element * @throws NoSuchElementException if there is no next element
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public E next() { public E next() {
if (hasNext() == false) { if (hasNext() == false) {
@ -208,6 +209,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
/** /**
* Resets the iterator back to the start index. * Resets the iterator back to the start index.
*/ */
@Override
public void reset() { public void reset() {
super.reset(); super.reset();
this.lastItemIndex = -1; this.lastItemIndex = -1;

View File

@ -160,6 +160,7 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
* *
* @return a string version of the iterator * @return a string version of the iterator
*/ */
@Override
public String toString() { public String toString() {
if (last != null) { if (last != null) {
return "MapIterator[" + getKey() + "=" + getValue() + "]"; return "MapIterator[" + getKey() + "=" + getValue() + "]";

View File

@ -133,6 +133,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
* @return the next element * @return the next element
* @throws NoSuchElementException if there is no next element * @throws NoSuchElementException if there is no next element
*/ */
@Override
public E next() { public E next() {
if (hasNext() == false) { if (hasNext() == false) {
throw new NoSuchElementException(); throw new NoSuchElementException();
@ -198,6 +199,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
/** /**
* Resets the iterator back to the start index. * Resets the iterator back to the start index.
*/ */
@Override
public void reset() { public void reset() {
super.reset(); super.reset();
this.lastItemIndex = -1; this.lastItemIndex = -1;

View File

@ -72,6 +72,7 @@ public abstract class AbstractKeyValue<K, V> implements KeyValue<K, V> {
* *
* @return a String view of the entry * @return a String view of the entry
*/ */
@Override
public String toString() { public String toString() {
return new StringBuilder() return new StringBuilder()
.append(getKey()) .append(getKey())

View File

@ -67,6 +67,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
* @param obj the object to compare to * @param obj the object to compare to
* @return true if equal key and value * @return true if equal key and value
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
@ -88,6 +89,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
* *
* @return a suitable hash code * @return a suitable hash code
*/ */
@Override
public int hashCode() { public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^ return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode()); (getValue() == null ? 0 : getValue().hashCode());

View File

@ -69,6 +69,7 @@ public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>
return entry.setValue(object); return entry.setValue(object);
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (object == this) { if (object == this) {
return true; return true;
@ -76,10 +77,12 @@ public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>
return entry.equals(object); return entry.equals(object);
} }
@Override
public int hashCode() { public int hashCode() {
return entry.hashCode(); return entry.hashCode();
} }
@Override
public String toString() { public String toString() {
return entry.toString(); return entry.toString();
} }

View File

@ -129,6 +129,7 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
* @param obj the object to compare to * @param obj the object to compare to
* @return true if equal key and value * @return true if equal key and value
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj == this) { if (obj == this) {
@ -152,6 +153,7 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
* *
* @return a suitable hash code * @return a suitable hash code
*/ */
@Override
public int hashCode() { public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^ return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode()); (getValue() == null ? 0 : getValue().hashCode());

View File

@ -219,6 +219,7 @@ public class MultiKey<K> implements Serializable {
* @param other the other object to compare to * @param other the other object to compare to
* @return true if equal * @return true if equal
*/ */
@Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == this) { if (other == this) {
return true; return true;
@ -240,6 +241,7 @@ public class MultiKey<K> implements Serializable {
* *
* @return the hash code * @return the hash code
*/ */
@Override
public int hashCode() { public int hashCode() {
return hashCode; return hashCode;
} }
@ -249,6 +251,7 @@ public class MultiKey<K> implements Serializable {
* *
* @return a debugging string * @return a debugging string
*/ */
@Override
public String toString() { public String toString() {
return "MultiKey" + Arrays.asList(keys).toString(); return "MultiKey" + Arrays.asList(keys).toString();
} }

View File

@ -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 * @param obj the object to compare to
* @return true if equal key and value * @return true if equal key and value
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { 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 * @return a suitable hash code
*/ */
@Override
public int hashCode() { public int hashCode() {
Object value = getValue(); Object value = getValue();
return (getKey() == null ? 0 : getKey().hashCode()) ^ 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 * @return entry as a string
*/ */
@Override
public String toString() { public String toString() {
return getKey() + "=" + getValue(); return getKey() + "=" + getValue();
} }

View File

@ -69,6 +69,7 @@ public final class UnmodifiableMapEntry<K, V> extends AbstractMapEntry<K, V> imp
* @return the previous value * @return the previous value
* @throws UnsupportedOperationException always * @throws UnsupportedOperationException always
*/ */
@Override
public V setValue(V value) { public V setValue(V value) {
throw new UnsupportedOperationException("setValue() is not supported"); throw new UnsupportedOperationException("setValue() is not supported");
} }

View File

@ -325,6 +325,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
@ -348,6 +349,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return !(it1.hasNext() || it2.hasNext()); return !(it1.hasNext() || it2.hasNext());
} }
@Override
public int hashCode() { public int hashCode() {
int hashCode = 1; int hashCode = 1;
for (E e : this) { for (E e : this) {
@ -356,6 +358,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return hashCode; return hashCode;
} }
@Override
public String toString() { public String toString() {
if (size() == 0) { if (size() == 0) {
return "[]"; return "[]";
@ -863,24 +866,29 @@ public abstract class AbstractLinkedList<E> implements List<E> {
this.sub = sub; this.sub = sub;
} }
@Override
public boolean hasNext() { public boolean hasNext() {
return (nextIndex() < sub.size); return (nextIndex() < sub.size);
} }
@Override
public boolean hasPrevious() { public boolean hasPrevious() {
return (previousIndex() >= 0); return (previousIndex() >= 0);
} }
@Override
public int nextIndex() { public int nextIndex() {
return (super.nextIndex() - sub.offset); return (super.nextIndex() - sub.offset);
} }
@Override
public void add(E obj) { public void add(E obj) {
super.add(obj); super.add(obj);
sub.expectedModCount = parent.modCount; sub.expectedModCount = parent.modCount;
sub.size++; sub.size++;
} }
@Override
public void remove() { public void remove() {
super.remove(); super.remove();
sub.expectedModCount = parent.modCount; sub.expectedModCount = parent.modCount;
@ -918,17 +926,20 @@ public abstract class AbstractLinkedList<E> implements List<E> {
this.expectedModCount = parent.modCount; this.expectedModCount = parent.modCount;
} }
@Override
public int size() { public int size() {
checkModCount(); checkModCount();
return size; return size;
} }
@Override
public E get(int index) { public E get(int index) {
rangeCheck(index, size); rangeCheck(index, size);
checkModCount(); checkModCount();
return parent.get(index + offset); return parent.get(index + offset);
} }
@Override
public void add(int index, E obj) { public void add(int index, E obj) {
rangeCheck(index, size + 1); rangeCheck(index, size + 1);
checkModCount(); checkModCount();
@ -938,6 +949,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
LinkedSubList.this.modCount++; LinkedSubList.this.modCount++;
} }
@Override
public E remove(int index) { public E remove(int index) {
rangeCheck(index, size); rangeCheck(index, size);
checkModCount(); checkModCount();
@ -948,10 +960,12 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return result; return result;
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
return addAll(size, coll); return addAll(size, coll);
} }
@Override
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
rangeCheck(index, size + 1); rangeCheck(index, size + 1);
int cSize = coll.size(); int cSize = coll.size();
@ -967,12 +981,14 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return true; return true;
} }
@Override
public E set(int index, E obj) { public E set(int index, E obj) {
rangeCheck(index, size); rangeCheck(index, size);
checkModCount(); checkModCount();
return parent.set(index + offset, obj); return parent.set(index + offset, obj);
} }
@Override
public void clear() { public void clear() {
checkModCount(); checkModCount();
Iterator<E> it = iterator(); Iterator<E> it = iterator();
@ -982,17 +998,20 @@ public abstract class AbstractLinkedList<E> implements List<E> {
} }
} }
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
checkModCount(); checkModCount();
return parent.createSubListIterator(this); return parent.createSubListIterator(this);
} }
@Override
public ListIterator<E> listIterator(final int index) { public ListIterator<E> listIterator(final int index) {
rangeCheck(index, size + 1); rangeCheck(index, size + 1);
checkModCount(); checkModCount();
return parent.createSubListListIterator(this, index); return parent.createSubListListIterator(this, index);
} }
@Override
public List<E> subList(int fromIndexInclusive, int toIndexExclusive) { public List<E> subList(int fromIndexInclusive, int toIndexExclusive) {
return new LinkedSubList<E>(parent, fromIndexInclusive + offset, toIndexExclusive + offset); return new LinkedSubList<E>(parent, fromIndexInclusive + offset, toIndexExclusive + offset);
} }

View File

@ -62,6 +62,7 @@ public abstract class AbstractListDecorator<E> extends AbstractCollectionDecorat
* *
* @return the decorated list * @return the decorated list
*/ */
@Override
protected List<E> decorated() { protected List<E> decorated() {
return (List<E>) super.decorated(); return (List<E>) super.decorated();
} }

View File

@ -117,6 +117,7 @@ public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
* @throws ClassCastException if the underlying list rejects the element * @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element * @throws IllegalArgumentException if the underlying list rejects the element
*/ */
@Override
public void add(int index, E element) { public void add(int index, E element) {
int size = decorated().size(); int size = decorated().size();
if (index > 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 ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException 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) { public boolean addAll(int index, Collection<? extends E> coll) {
int size = decorated().size(); int size = decorated().size();
boolean result = false; boolean result = false;
@ -175,6 +177,7 @@ public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
* @throws ClassCastException if the underlying list rejects the element * @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element * @throws IllegalArgumentException if the underlying list rejects the element
*/ */
@Override
public E set(int index, E element) { public E set(int index, E element) {
int size = decorated().size(); int size = decorated().size();
if (index >= size) { if (index >= size) {

View File

@ -107,6 +107,7 @@ public class LazyList<E> extends AbstractSerializableListDecorator<E> {
* *
* @param index the index to retrieve * @param index the index to retrieve
*/ */
@Override
public E get(int index) { public E get(int index) {
int size = decorated().size(); int size = decorated().size();
if (index < size) { if (index < size) {
@ -131,6 +132,7 @@ public class LazyList<E> extends AbstractSerializableListDecorator<E> {
return object; return object;
} }
@Override
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
List<E> sub = decorated().subList(fromIndex, toIndex); List<E> sub = decorated().subList(fromIndex, toIndex);
return new LazyList<E>(sub, factory); return new LazyList<E>(sub, factory);

View File

@ -186,6 +186,7 @@ public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements S
* @param value value of the new node * @param value value of the new node
* @return the newly created node * @return the newly created node
*/ */
@Override
protected Node<E> createNode(E value) { protected Node<E> createNode(E value) {
Node<E> cachedNode = getNodeFromCache(); Node<E> cachedNode = getNodeFromCache();
if (cachedNode == null) { if (cachedNode == null) {
@ -201,6 +202,7 @@ public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements S
* *
* @param node the node to remove * @param node the node to remove
*/ */
@Override
protected void removeNode(Node<E> node) { protected void removeNode(Node<E> node) {
super.removeNode(node); super.removeNode(node);
addNodeToCache(node); addNodeToCache(node);
@ -211,6 +213,7 @@ public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements S
* cache for reuse. * cache for reuse.
* *
*/ */
@Override
protected void removeAllNodes() { protected void removeAllNodes() {
// Add the removed nodes to the cache, then remove the rest. // Add the removed nodes to the cache, then remove the rest.
// We can add them to the cache before removing them, since // We can add them to the cache before removing them, since

View File

@ -124,6 +124,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
* @param object the object to add * @param object the object to add
* @return true if object was added * @return true if object was added
*/ */
@Override
public boolean add(E object) { public boolean add(E object) {
// gets initial size // gets initial size
final int sizeBefore = size(); final int sizeBefore = size();
@ -145,6 +146,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
* @param index the index to insert at * @param index the index to insert at
* @param object the object to add * @param object the object to add
*/ */
@Override
public void add(int index, E object) { public void add(int index, E object) {
// adds element if it is not contained already // adds element if it is not contained already
if (set.contains(object) == false) { 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 * @param coll the collection to add in iterator order
* @return true if this collection changed * @return true if this collection changed
*/ */
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
return addAll(size(), 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 * @param coll the collection to add in iterator order
* @return true if this collection changed * @return true if this collection changed
*/ */
@Override
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
HashSet<E> temp = new HashSet<E>(coll); HashSet<E> temp = new HashSet<E>(coll);
temp.removeAll(set); temp.removeAll(set);
@ -213,6 +217,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
* @param object the object to set * @param object the object to set
* @return the previous object * @return the previous object
*/ */
@Override
public E set(int index, E object) { public E set(int index, E object) {
int pos = indexOf(object); int pos = indexOf(object);
E removed = super.set(index, 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 return removed; // return the item deleted by the set
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
boolean result = super.remove(object); boolean result = super.remove(object);
set.remove(object); set.remove(object);
return result; return result;
} }
@Override
public E remove(int index) { public E remove(int index) {
E result = super.remove(index); E result = super.remove(index);
set.remove(result); set.remove(result);
return result; return result;
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
boolean result = super.removeAll(coll); boolean result = super.removeAll(coll);
set.removeAll(coll); set.removeAll(coll);
return result; return result;
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
boolean result = super.retainAll(coll); boolean result = super.retainAll(coll);
set.retainAll(coll); set.retainAll(coll);
return result; return result;
} }
@Override
public void clear() { public void clear() {
super.clear(); super.clear();
set.clear(); set.clear();
} }
@Override
public boolean contains(Object object) { public boolean contains(Object object) {
return set.contains(object); return set.contains(object);
} }
@Override
public boolean containsAll(Collection<?> coll) { public boolean containsAll(Collection<?> coll) {
return set.containsAll(coll); return set.containsAll(coll);
} }
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new SetListIterator<E>(super.iterator(), set); return new SetListIterator<E>(super.iterator(), set);
} }
@Override
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
return new SetListListIterator<E>(super.listIterator(), set); return new SetListListIterator<E>(super.listIterator(), set);
} }
@Override
public ListIterator<E> listIterator(int index) { public ListIterator<E> listIterator(int index) {
return new SetListListIterator<E>(super.listIterator(index), set); return new SetListListIterator<E>(super.listIterator(index), set);
} }
@Override
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
List<E> superSubList = super.subList(fromIndex, toIndex); List<E> superSubList = super.subList(fromIndex, toIndex);
Set<E> subSet = createSetBasedOnList(set, superSubList); Set<E> subSet = createSetBasedOnList(set, superSubList);
@ -316,11 +332,13 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
this.set = set; this.set = set;
} }
@Override
public E next() { public E next() {
last = super.next(); last = super.next();
return last; return last;
} }
@Override
public void remove() { public void remove() {
super.remove(); super.remove();
set.remove(last); set.remove(last);
@ -341,22 +359,26 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
this.set = set; this.set = set;
} }
@Override
public E next() { public E next() {
last = super.next(); last = super.next();
return last; return last;
} }
@Override
public E previous() { public E previous() {
last = super.previous(); last = super.previous();
return last; return last;
} }
@Override
public void remove() { public void remove() {
super.remove(); super.remove();
set.remove(last); set.remove(last);
last = null; last = null;
} }
@Override
public void add(E object) { public void add(E object) {
if (set.contains(object) == false) { if (set.contains(object) == false) {
super.add(object); super.add(object);
@ -364,6 +386,7 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
} }
} }
@Override
public void set(E object) { public void set(E object) {
throw new UnsupportedOperationException("ListIterator does not support set"); throw new UnsupportedOperationException("ListIterator does not support set");
} }

View File

@ -165,11 +165,13 @@ public class TransformedList<E> extends TransformedCollection<E> implements List
super(iterator); super(iterator);
} }
@Override
public void add(E object) { public void add(E object) {
object = transform(object); object = transform(object);
iterator.add(object); iterator.add(object);
} }
@Override
public void set(E object) { public void set(E object) {
object = transform(object); object = transform(object);
iterator.set(object); iterator.set(object);

View File

@ -94,6 +94,7 @@ public class TreeList<E> extends AbstractList<E> {
* @param index the index to retrieve * @param index the index to retrieve
* @return the element at the specified index * @return the element at the specified index
*/ */
@Override
public E get(int index) { public E get(int index) {
checkInterval(index, 0, size() - 1); checkInterval(index, 0, size() - 1);
return root.get(index).getValue(); return root.get(index).getValue();
@ -104,6 +105,7 @@ public class TreeList<E> extends AbstractList<E> {
* *
* @return the current size * @return the current size
*/ */
@Override
public int size() { public int size() {
return size; return size;
} }
@ -113,6 +115,7 @@ public class TreeList<E> extends AbstractList<E> {
* *
* @return an iterator over the list * @return an iterator over the list
*/ */
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
// override to go 75% faster // override to go 75% faster
return listIterator(0); return listIterator(0);
@ -123,6 +126,7 @@ public class TreeList<E> extends AbstractList<E> {
* *
* @return the new iterator * @return the new iterator
*/ */
@Override
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
// override to go 75% faster // override to go 75% faster
return listIterator(0); return listIterator(0);
@ -134,6 +138,7 @@ public class TreeList<E> extends AbstractList<E> {
* @param fromIndex the index to start from * @param fromIndex the index to start from
* @return the new iterator * @return the new iterator
*/ */
@Override
public ListIterator<E> listIterator(int fromIndex) { public ListIterator<E> listIterator(int fromIndex) {
// override to go 75% faster // override to go 75% faster
// cannot use EmptyIterator as iterator.add() must work // 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 * @return the index of the object, -1 if not found
*/ */
@Override
public int indexOf(Object object) { public int indexOf(Object object) {
// override to go 75% faster // override to go 75% faster
if (root == null) { if (root == null) {
@ -159,6 +165,7 @@ public class TreeList<E> extends AbstractList<E> {
* *
* @return true if the object is found * @return true if the object is found
*/ */
@Override
public boolean contains(Object object) { public boolean contains(Object object) {
return (indexOf(object) >= 0); return (indexOf(object) >= 0);
} }
@ -168,6 +175,7 @@ public class TreeList<E> extends AbstractList<E> {
* *
* @return the list as an array * @return the list as an array
*/ */
@Override
public Object[] toArray() { public Object[] toArray() {
// override to go 20% faster // override to go 20% faster
Object[] array = new Object[size()]; Object[] array = new Object[size()];
@ -184,6 +192,7 @@ public class TreeList<E> extends AbstractList<E> {
* @param index the index to add before * @param index the index to add before
* @param obj the element to add * @param obj the element to add
*/ */
@Override
public void add(int index, E obj) { public void add(int index, E obj) {
modCount++; modCount++;
checkInterval(index, 0, size()); checkInterval(index, 0, size());
@ -203,6 +212,7 @@ public class TreeList<E> extends AbstractList<E> {
* @return the previous object at that index * @return the previous object at that index
* @throws IndexOutOfBoundsException if the index is invalid * @throws IndexOutOfBoundsException if the index is invalid
*/ */
@Override
public E set(int index, E obj) { public E set(int index, E obj) {
checkInterval(index, 0, size() - 1); checkInterval(index, 0, size() - 1);
AVLNode<E> node = root.get(index); AVLNode<E> node = root.get(index);
@ -217,6 +227,7 @@ public class TreeList<E> extends AbstractList<E> {
* @param index the index to remove * @param index the index to remove
* @return the previous object at that index * @return the previous object at that index
*/ */
@Override
public E remove(int index) { public E remove(int index) {
modCount++; modCount++;
checkInterval(index, 0, size() - 1); checkInterval(index, 0, size() - 1);
@ -229,6 +240,7 @@ public class TreeList<E> extends AbstractList<E> {
/** /**
* Clears the list, removing all entries. * Clears the list, removing all entries.
*/ */
@Override
public void clear() { public void clear() {
modCount++; modCount++;
root = null; root = null;
@ -763,6 +775,7 @@ public class TreeList<E> extends AbstractList<E> {
/** /**
* Used for debugging. * Used for debugging.
*/ */
@Override
public String toString() { public String toString() {
return "AVLNode(" + relativePosition + "," + (left != null) + "," + value + return "AVLNode(" + relativePosition + "," + (left != null) + "," + value +
"," + (getRightSubTree() != null) + ", faedelung " + rightIsNext + " )"; "," + (getRightSubTree() != null) + ", faedelung " + rightIsNext + " )";

View File

@ -70,59 +70,73 @@ public final class UnmodifiableList<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator()); return UnmodifiableIterator.decorate(decorated().iterator());
} }
@Override
public boolean add(Object object) { public boolean add(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public ListIterator<E> listIterator() { public ListIterator<E> listIterator() {
return UnmodifiableListIterator.decorate(decorated().listIterator()); return UnmodifiableListIterator.decorate(decorated().listIterator());
} }
@Override
public ListIterator<E> listIterator(int index) { public ListIterator<E> listIterator(int index) {
return UnmodifiableListIterator.decorate(decorated().listIterator(index)); return UnmodifiableListIterator.decorate(decorated().listIterator(index));
} }
@Override
public void add(int index, E object) { public void add(int index, E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(int index, Collection<? extends E> coll) { public boolean addAll(int index, Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public E remove(int index) { public E remove(int index) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public E set(int index, E object) { public E set(int index, E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
List<E> sub = decorated().subList(fromIndex, toIndex); List<E> sub = decorated().subList(fromIndex, toIndex);
return new UnmodifiableList<E>(sub); return new UnmodifiableList<E>(sub);

View File

@ -179,6 +179,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* @param key the key * @param key the key
* @return the mapped value, null if no match * @return the mapped value, null if no match
*/ */
@Override
public V get(Object key) { public V get(Object key) {
key = convertKey(key); key = convertKey(key);
int hashCode = hash(key); int hashCode = hash(key);
@ -197,6 +198,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* *
* @return the size * @return the size
*/ */
@Override
public int size() { public int size() {
return 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 * @return true if the map is currently size zero
*/ */
@Override
public boolean isEmpty() { public boolean isEmpty() {
return (size == 0); 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 * @param key the key to search for
* @return true if the map contains the key * @return true if the map contains the key
*/ */
@Override
public boolean containsKey(Object key) { public boolean containsKey(Object key) {
key = convertKey(key); key = convertKey(key);
int hashCode = hash(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 * @param value the value to search for
* @return true if the map contains the value * @return true if the map contains the value
*/ */
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
if (value == null) { if (value == null) {
for (int i = 0, isize = data.length; i < isize; i++) { 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 * @param value the value to add
* @return the value previously mapped to this key, null if none * @return the value previously mapped to this key, null if none
*/ */
@Override
public V put(K key, V value) { public V put(K key, V value) {
Object convertedKey = convertKey(key); Object convertedKey = convertKey(key);
int hashCode = hash(convertedKey); 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 * @param map the map to add
* @throws NullPointerException if the map is null * @throws NullPointerException if the map is null
*/ */
@Override
public void putAll(Map<? extends K, ? extends V> map) { public void putAll(Map<? extends K, ? extends V> map) {
_putAll(map); _putAll(map);
} }
@ -330,6 +337,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* @param key the mapping to remove * @param key the mapping to remove
* @return the value mapped to the removed key, null if key not in map * @return the value mapped to the removed key, null if key not in map
*/ */
@Override
public V remove(Object key) { public V remove(Object key) {
key = convertKey(key); key = convertKey(key);
int hashCode = hash(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 * Clears the map, resetting the size to zero and nullifying references
* to avoid garbage collection issues. * to avoid garbage collection issues.
*/ */
@Override
public void clear() { public void clear() {
modCount++; modCount++;
HashEntry<K, V>[] data = this.data; 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 * @return the entrySet view
*/ */
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
if (entrySet == null) { if (entrySet == null) {
entrySet = new EntrySet<K, V>(this); entrySet = new EntrySet<K, V>(this);
@ -831,14 +841,17 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public void clear() { public void clear() {
parent.clear(); parent.clear();
} }
@Override
public boolean contains(Object entry) { public boolean contains(Object entry) {
if (entry instanceof Map.Entry) { if (entry instanceof Map.Entry) {
Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry; Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry;
@ -848,6 +861,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
return false; return false;
} }
@Override
public boolean remove(Object obj) { public boolean remove(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return false; return false;
@ -860,6 +874,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
return true; return true;
} }
@Override
public Iterator<Map.Entry<K, V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
return parent.createEntrySetIterator(); return parent.createEntrySetIterator();
} }
@ -887,6 +902,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* *
* @return the keySet view * @return the keySet view
*/ */
@Override
public Set<K> keySet() { public Set<K> keySet() {
if (keySet == null) { if (keySet == null) {
keySet = new KeySet<K>(this); keySet = new KeySet<K>(this);
@ -919,24 +935,29 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public void clear() { public void clear() {
parent.clear(); parent.clear();
} }
@Override
public boolean contains(Object key) { public boolean contains(Object key) {
return parent.containsKey(key); return parent.containsKey(key);
} }
@Override
public boolean remove(Object key) { public boolean remove(Object key) {
boolean result = parent.containsKey(key); boolean result = parent.containsKey(key);
parent.remove(key); parent.remove(key);
return result; return result;
} }
@Override
public Iterator<K> iterator() { public Iterator<K> iterator() {
return parent.createKeySetIterator(); return parent.createKeySetIterator();
} }
@ -965,6 +986,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* *
* @return the values view * @return the values view
*/ */
@Override
public Collection<V> values() { public Collection<V> values() {
if (values == null) { if (values == null) {
values = new Values<V>(this); values = new Values<V>(this);
@ -997,18 +1019,22 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public void clear() { public void clear() {
parent.clear(); parent.clear();
} }
@Override
public boolean contains(Object value) { public boolean contains(Object value) {
return parent.containsValue(value); return parent.containsValue(value);
} }
@Override
public Iterator<V> iterator() { public Iterator<V> iterator() {
return parent.createValuesIterator(); return parent.createValuesIterator();
} }
@ -1076,6 +1102,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
return (V) old; return (V) old;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; 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())); (getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
} }
@Override
public int hashCode() { public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^ return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode()); (getValue() == null ? 0 : getValue().hashCode());
} }
@Override
public String toString() { public String toString() {
return new StringBuilder().append(getKey()).append('=').append(getValue()).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; expectedModCount = parent.modCount;
} }
@Override
public String toString() { public String toString() {
if (last != null) { if (last != null) {
return "Iterator[" + last.getKey() + "=" + last.getValue() + "]"; 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 * @return a shallow clone
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected AbstractHashedMap<K, V> clone() { protected AbstractHashedMap<K, V> clone() {
try { try {
@ -1273,6 +1304,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
* @param obj the object to compare to * @param obj the object to compare to
* @return true if equal * @return true if equal
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { 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 * @return the hash code defined in the Map interface
*/ */
@Override
public int hashCode() { public int hashCode() {
int total = 0; int total = 0;
Iterator<Map.Entry<K, V>> it = createEntrySetIterator(); 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 * @return a string version of the map
*/ */
@Override
public String toString() { public String toString() {
if (size() == 0) { if (size() == 0) {
return "{}"; return "{}";

View File

@ -96,6 +96,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
if (isSetValueChecking()) { if (isSetValueChecking()) {
return new EntrySet(map.entrySet(), this); return new EntrySet(map.entrySet(), this);
@ -118,10 +119,12 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
this.parent = parent; this.parent = parent;
} }
@Override
public Iterator<Map.Entry<K, V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
return new EntrySetIterator(collection.iterator(), parent); return new EntrySetIterator(collection.iterator(), parent);
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object[] toArray() { public Object[] toArray() {
Object[] array = collection.toArray(); Object[] array = collection.toArray();
@ -131,6 +134,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
return array; return array;
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] array) { public <T> T[] toArray(T[] array) {
Object[] result = array; Object[] result = array;
@ -171,6 +175,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
this.parent = parent; this.parent = parent;
} }
@Override
public Map.Entry<K, V> next() { public Map.Entry<K, V> next() {
Map.Entry<K, V> entry = iterator.next(); Map.Entry<K, V> entry = iterator.next();
return new MapEntry(entry, parent); return new MapEntry(entry, parent);
@ -190,6 +195,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
this.parent = parent; this.parent = parent;
} }
@Override
public V setValue(V value) { public V setValue(V value) {
value = parent.checkSetValue(value); value = parent.checkSetValue(value);
return entry.setValue(value); return entry.setValue(value);

View File

@ -125,6 +125,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
* {@link #createEntry(HashEntry, int, Object, Object)} to create * {@link #createEntry(HashEntry, int, Object, Object)} to create
* the map entry object. * the map entry object.
*/ */
@Override
protected void init() { protected void init() {
header = createEntry(null, -1, null, null); header = createEntry(null, -1, null, null);
header.before = header.after = header; 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 * @param value the value to search for
* @return true if the map contains the value * @return true if the map contains the value
*/ */
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
// override uses faster iterator // override uses faster iterator
if (value == null) { 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 * Clears the map, resetting the size to zero and nullifying references
* to avoid garbage collection issues. * to avoid garbage collection issues.
*/ */
@Override
public void clear() { public void clear() {
// override to reset the linked list // override to reset the linked list
super.clear(); 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()); return (entry == null || entry.after == header ? null : entry.after.getKey());
} }
@Override
protected LinkEntry<K, V> getEntry(Object key) { protected LinkEntry<K, V> getEntry(Object key) {
return (LinkEntry<K, V>) super.getEntry(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 link the entry to add
* @param hashIndex the index into the data array to store at * @param hashIndex the index into the data array to store at
*/ */
@Override
protected void addEntry(HashEntry<K, V> entry, int hashIndex) { protected void addEntry(HashEntry<K, V> entry, int hashIndex) {
LinkEntry<K, V> link = (LinkEntry<K, V>) entry; LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
link.after = header; link.after = header;
@ -277,6 +282,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
* @param value the value to store * @param value the value to store
* @return the newly created entry * @return the newly created entry
*/ */
@Override
protected LinkEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) { 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); 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 hashIndex the index into the data structure
* @param previous the previous entry in the chain * @param previous the previous entry in the chain
*/ */
@Override
protected void removeEntry(HashEntry<K, V> entry, int hashIndex, HashEntry<K, V> previous) { protected void removeEntry(HashEntry<K, V> entry, int hashIndex, HashEntry<K, V> previous) {
LinkEntry<K, V> link = (LinkEntry<K, V>) entry; LinkEntry<K, V> link = (LinkEntry<K, V>) entry;
link.before.after = link.after; link.before.after = link.after;
@ -331,6 +338,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
if (size == 0) { if (size == 0) {
return EmptyOrderedMapIterator.<K, V>getInstance(); return EmptyOrderedMapIterator.<K, V>getInstance();
@ -388,6 +396,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
* *
* @return the entrySet iterator * @return the entrySet iterator
*/ */
@Override
protected Iterator<Map.Entry<K, V>> createEntrySetIterator() { protected Iterator<Map.Entry<K, V>> createEntrySetIterator() {
if (size() == 0) { if (size() == 0) {
return EmptyOrderedIterator.<Map.Entry<K, V>>getInstance(); 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 * @return the keySet iterator
*/ */
@Override
protected Iterator<K> createKeySetIterator() { protected Iterator<K> createKeySetIterator() {
if (size() == 0) { if (size() == 0) {
return EmptyOrderedIterator.<K>getInstance(); return EmptyOrderedIterator.<K>getInstance();
@ -455,6 +465,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
* *
* @return the values iterator * @return the values iterator
*/ */
@Override
protected Iterator<V> createValuesIterator() { protected Iterator<V> createValuesIterator() {
if (size() == 0) { if (size() == 0) {
return EmptyOrderedIterator.<V>getInstance(); return EmptyOrderedIterator.<V>getInstance();
@ -585,6 +596,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
next = parent.header.after; next = parent.header.after;
} }
@Override
public String toString() { public String toString() {
if (last != null) { if (last != null) {
return "Iterator[" + last.getKey() + "=" + last.getValue() + "]"; return "Iterator[" + last.getKey() + "=" + last.getValue() + "]";

View File

@ -125,6 +125,7 @@ public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K,
return decorated().values(); return decorated().values();
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (object == this) { if (object == this) {
return true; return true;
@ -132,10 +133,12 @@ public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K,
return decorated().equals(object); return decorated().equals(object);
} }
@Override
public int hashCode() { public int hashCode() {
return decorated().hashCode(); return decorated().hashCode();
} }
@Override
public String toString() { public String toString() {
return decorated().toString(); return decorated().toString();
} }

View File

@ -62,6 +62,7 @@ public abstract class AbstractOrderedMapDecorator<K, V> extends AbstractMapDecor
* *
* @return the decorated map * @return the decorated map
*/ */
@Override
protected OrderedMap<K, V> decorated() { protected OrderedMap<K, V> decorated() {
return (OrderedMap<K, V>) super.decorated(); return (OrderedMap<K, V>) super.decorated();
} }
@ -83,6 +84,7 @@ public abstract class AbstractOrderedMapDecorator<K, V> extends AbstractMapDecor
return decorated().previousKey(key); return decorated().previousKey(key);
} }
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
return decorated().mapIterator(); return decorated().mapIterator();
} }

View File

@ -172,6 +172,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
/** /**
* Initialise this subclass during construction, cloning or deserialization. * Initialise this subclass during construction, cloning or deserialization.
*/ */
@Override
protected void init() { protected void init() {
queue = new ReferenceQueue<Object>(); queue = new ReferenceQueue<Object>();
} }
@ -182,6 +183,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* *
* @return the size * @return the size
*/ */
@Override
public int size() { public int size() {
purgeBeforeRead(); purgeBeforeRead();
return super.size(); 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 * @return true if the map is currently size zero
*/ */
@Override
public boolean isEmpty() { public boolean isEmpty() {
purgeBeforeRead(); purgeBeforeRead();
return super.isEmpty(); return super.isEmpty();
@ -203,6 +206,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* @param key the key to search for * @param key the key to search for
* @return true if the map contains the key * @return true if the map contains the key
*/ */
@Override
public boolean containsKey(Object key) { public boolean containsKey(Object key) {
purgeBeforeRead(); purgeBeforeRead();
Entry<K, V> entry = getEntry(key); 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 * @param value the value to search for
* @return true if the map contains the value * @return true if the map contains the value
*/ */
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
purgeBeforeRead(); purgeBeforeRead();
if (value == null) { if (value == null) {
@ -232,6 +237,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* @param key the key * @param key the key
* @return the mapped value, null if no match * @return the mapped value, null if no match
*/ */
@Override
public V get(Object key) { public V get(Object key) {
purgeBeforeRead(); purgeBeforeRead();
Entry<K, V> entry = getEntry(key); 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 * @return the value previously mapped to this key, null if none
* @throws NullPointerException if either the key or value is null * @throws NullPointerException if either the key or value is null
*/ */
@Override
public V put(K key, V value) { public V put(K key, V value) {
if (key == null) { if (key == null) {
throw new NullPointerException("null keys not allowed"); 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 * @param key the mapping to remove
* @return the value mapped to the removed key, null if key not in map * @return the value mapped to the removed key, null if key not in map
*/ */
@Override
public V remove(Object key) { public V remove(Object key) {
if (key == null) { if (key == null) {
return null; return null;
@ -280,6 +288,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
/** /**
* Clears this map. * Clears this map.
*/ */
@Override
public void clear() { public void clear() {
super.clear(); super.clear();
while (queue.poll() != null) {} // drain the queue 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 * @return a map iterator
*/ */
@Override
public MapIterator<K, V> mapIterator() { public MapIterator<K, V> mapIterator() {
return new ReferenceMapIterator<K, V>(this); 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 * @return a set view of this map's entries
*/ */
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
if (entrySet == null) { if (entrySet == null) {
entrySet = new ReferenceEntrySet<K, V>(this); 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 * @return a set view of this map's keys
*/ */
@Override
public Set<K> keySet() { public Set<K> keySet() {
if (keySet == null) { if (keySet == null) {
keySet = new ReferenceKeySet<K>(this); 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 * @return a set view of this map's values
*/ */
@Override
public Collection<V> values() { public Collection<V> values() {
if (values == null) { if (values == null) {
values = new ReferenceValues<V>(this); values = new ReferenceValues<V>(this);
@ -405,6 +418,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* @param key the key * @param key the key
* @return the entry, null if no match * @return the entry, null if no match
*/ */
@Override
protected HashEntry<K, V> getEntry(Object key) { protected HashEntry<K, V> getEntry(Object key) {
if (key == null) { if (key == null) {
return 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> * @param key2 the second key extracted from the entry via <code>entry.key</code>
* @return true if equal * @return true if equal
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected boolean isEqualKey(Object key1, Object key2) { protected boolean isEqualKey(Object key1, Object key2) {
key2 = (keyType == ReferenceStrength.HARD ? key2 : ((Reference<K>) key2).get()); 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 * @param value the value to store
* @return the newly created entry * @return the newly created entry
*/ */
@Override
protected ReferenceEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) { 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); 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 * @return the entrySet iterator
*/ */
@Override
protected Iterator<Map.Entry<K, V>> createEntrySetIterator() { protected Iterator<Map.Entry<K, V>> createEntrySetIterator() {
return new ReferenceEntrySetIterator<K, V>(this); return new ReferenceEntrySetIterator<K, V>(this);
} }
@ -468,6 +485,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* *
* @return the keySet iterator * @return the keySet iterator
*/ */
@Override
protected Iterator<K> createKeySetIterator() { protected Iterator<K> createKeySetIterator() {
return new ReferenceKeySetIterator<K>(this); return new ReferenceKeySetIterator<K>(this);
} }
@ -477,6 +495,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* *
* @return the values iterator * @return the values iterator
*/ */
@Override
protected Iterator<V> createValuesIterator() { protected Iterator<V> createValuesIterator() {
return new ReferenceValuesIterator<V>(this); return new ReferenceValuesIterator<V>(this);
} }
@ -491,10 +510,12 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
super(parent); super(parent);
} }
@Override
public Object[] toArray() { public Object[] toArray() {
return toArray(new Object[0]); return toArray(new Object[0]);
} }
@Override
public <T> T[] toArray(T[] arr) { public <T> T[] toArray(T[] arr) {
// special implementation to handle disappearing entries // special implementation to handle disappearing entries
ArrayList<Map.Entry<K, V>> list = new ArrayList<Map.Entry<K, V>>(); 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); super(parent);
} }
@Override
public Object[] toArray() { public Object[] toArray() {
return toArray(new Object[0]); return toArray(new Object[0]);
} }
@Override
public <T> T[] toArray(T[] arr) { public <T> T[] toArray(T[] arr) {
// special implementation to handle disappearing keys // special implementation to handle disappearing keys
List<K> list = new ArrayList<K>(parent.size()); List<K> list = new ArrayList<K>(parent.size());
@ -539,10 +562,12 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
super(parent); super(parent);
} }
@Override
public Object[] toArray() { public Object[] toArray() {
return toArray(new Object[0]); return toArray(new Object[0]);
} }
@Override
public <T> T[] toArray(T[] arr) { public <T> T[] toArray(T[] arr) {
// special implementation to handle disappearing values // special implementation to handle disappearing values
List<V> list = new ArrayList<V>(parent.size()); 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 * @return the key, which may be null if it was garbage collected
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public K getKey() { public K getKey() {
return (K) ((parent.keyType == ReferenceStrength.HARD) ? key : ((Reference<K>) key).get()); 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 * @return the value, which may be null if it was garbage collected
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public V getValue() { public V getValue() {
return (V) ((parent.valueType == ReferenceStrength.HARD) ? value : ((Reference<V>) value).get()); 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 * @param obj the object to store
* @return the previous value * @return the previous value
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public V setValue(V obj) { public V setValue(V obj) {
V old = getValue(); 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 * @param obj the other map entry to compare to
* @return true if equal, false if not * @return true if equal, false if not
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
@ -657,6 +686,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* *
* @return the hashcode of the entry * @return the hashcode of the entry
*/ */
@Override
public int hashCode() { public int hashCode() {
return parent.hashEntry(getKey(), getValue()); return parent.hashEntry(getKey(), getValue());
} }
@ -912,6 +942,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
this.hash = hash; this.hash = hash;
} }
@Override
public int hashCode() { public int hashCode() {
return hash; return hash;
} }
@ -929,6 +960,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
this.hash = hash; this.hash = hash;
} }
@Override
public int hashCode() { public int hashCode() {
return hash; return hash;
} }
@ -953,6 +985,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* *
* @param out the output stream * @param out the output stream
*/ */
@Override
protected void doWriteObject(ObjectOutputStream out) throws IOException { protected void doWriteObject(ObjectOutputStream out) throws IOException {
out.writeInt(keyType.value); out.writeInt(keyType.value);
out.writeInt(valueType.value); out.writeInt(valueType.value);
@ -984,6 +1017,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* *
* @param in the input stream * @param in the input stream
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException { protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
this.keyType = ReferenceStrength.resolve(in.readInt()); this.keyType = ReferenceStrength.resolve(in.readInt());

View File

@ -72,6 +72,7 @@ public abstract class AbstractSortedMapDecorator<K, V> extends AbstractMapDecora
* *
* @return the decorated map * @return the decorated map
*/ */
@Override
protected SortedMap<K, V> decorated() { protected SortedMap<K, V> decorated() {
return (SortedMap<K, V>) super.decorated(); return (SortedMap<K, V>) super.decorated();
} }

View File

@ -116,6 +116,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
* @param key the key convert * @param key the key convert
* @return the converted key * @return the converted key
*/ */
@Override
protected Object convertKey(Object key) { protected Object convertKey(Object key) {
if (key != null) { if (key != null) {
char[] chars = key.toString().toCharArray(); char[] chars = key.toString().toCharArray();
@ -133,6 +134,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
public CaseInsensitiveMap<K, V> clone() { public CaseInsensitiveMap<K, V> clone() {
return (CaseInsensitiveMap<K, V>) super.clone(); return (CaseInsensitiveMap<K, V>) super.clone();
} }

View File

@ -463,6 +463,7 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> implements Ser
* @param obj the object to compare to * @param obj the object to compare to
* @return true if the maps are equal * @return true if the maps are equal
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Map) { 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. * Gets a hash code for the Map as per the Map specification.
*/ */
@Override
public int hashCode() { public int hashCode() {
int code = 0; int code = 0;
for (Map.Entry<K, V> entry : entrySet()) { for (Map.Entry<K, V> entry : entrySet()) {

View File

@ -183,6 +183,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public V get(Object key) { public V get(Object key) {
// create value for key if key is not currently in the map // create value for key if key is not currently in the map

View File

@ -112,6 +112,7 @@ public class FixedSizeMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public V put(K key, V value) { public V put(K key, V value) {
if (map.containsKey(key) == false) { if (map.containsKey(key) == false) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size"); 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); return map.put(key, value);
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
for (K key : mapToCopy.keySet()) { for (K key : mapToCopy.keySet()) {
if (!containsKey(key)) { if (!containsKey(key)) {
@ -128,25 +130,30 @@ public class FixedSizeMap<K, V>
map.putAll(mapToCopy); map.putAll(mapToCopy);
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException("Map is fixed size"); throw new UnsupportedOperationException("Map is fixed size");
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException("Map is fixed size"); throw new UnsupportedOperationException("Map is fixed size");
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = map.entrySet(); Set<Map.Entry<K, V>> set = map.entrySet();
// unmodifiable set will still allow modification via Map.Entry objects // unmodifiable set will still allow modification via Map.Entry objects
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
Set<K> set = map.keySet(); Set<K> set = map.keySet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Collection<V> values() { public Collection<V> values() {
Collection<V> coll = map.values(); Collection<V> coll = map.values();
return UnmodifiableCollection.decorate(coll); return UnmodifiableCollection.decorate(coll);

View File

@ -113,6 +113,7 @@ public class FixedSizeSortedMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public V put(K key, V value) { public V put(K key, V value) {
if (map.containsKey(key) == false) { if (map.containsKey(key) == false) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size"); 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); return map.put(key, value);
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
if (CollectionUtils.isSubCollection(mapToCopy.keySet(), keySet())) { if (CollectionUtils.isSubCollection(mapToCopy.keySet(), keySet())) {
throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size"); 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); map.putAll(mapToCopy);
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException("Map is fixed size"); throw new UnsupportedOperationException("Map is fixed size");
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException("Map is fixed size"); throw new UnsupportedOperationException("Map is fixed size");
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
return UnmodifiableSet.decorate(map.entrySet()); return UnmodifiableSet.decorate(map.entrySet());
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
return UnmodifiableSet.decorate(map.keySet()); return UnmodifiableSet.decorate(map.keySet());
} }
@Override
public Collection<V> values() { public Collection<V> values() {
return UnmodifiableCollection.decorate(map.values()); return UnmodifiableCollection.decorate(map.values());
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public SortedMap<K, V> subMap(K fromKey, K toKey) { public SortedMap<K, V> subMap(K fromKey, K toKey) {
return new FixedSizeSortedMap<K, V>(getSortedMap().subMap(fromKey, toKey)); return new FixedSizeSortedMap<K, V>(getSortedMap().subMap(fromKey, toKey));
} }
@Override
public SortedMap<K, V> headMap(K toKey) { public SortedMap<K, V> headMap(K toKey) {
return new FixedSizeSortedMap<K, V>(getSortedMap().headMap(toKey)); return new FixedSizeSortedMap<K, V>(getSortedMap().headMap(toKey));
} }
@Override
public SortedMap<K, V> tailMap(K fromKey) { public SortedMap<K, V> tailMap(K fromKey) {
return new FixedSizeSortedMap<K, V>(getSortedMap().tailMap(fromKey)); return new FixedSizeSortedMap<K, V>(getSortedMap().tailMap(fromKey));
} }

View File

@ -667,6 +667,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
canRemove = false; canRemove = false;
} }
@Override
public String toString() { public String toString() {
if (canRemove) { if (canRemove) {
return "Iterator[" + getKey() + "=" + getValue() + "]"; return "Iterator[" + getKey() + "=" + getValue() + "]";
@ -702,14 +703,17 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public void clear() { public void clear() {
parent.clear(); parent.clear();
} }
@Override
public boolean remove(Object obj) { public boolean remove(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
return false; return false;
@ -721,6 +725,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
return result; return result;
} }
@Override
public Iterator<Map.Entry<K, V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
if (parent.delegateMap != null) { if (parent.delegateMap != null) {
return parent.delegateMap.entrySet().iterator(); return parent.delegateMap.entrySet().iterator();
@ -829,6 +834,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
return nextEntry(); return nextEntry();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (canRemove == false) { if (canRemove == false) {
return 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())); (value == null ? other.getValue() == null : value.equals(other.getValue()));
} }
@Override
public int hashCode() { public int hashCode() {
if (canRemove == false) { if (canRemove == false) {
return 0; return 0;
@ -853,6 +860,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
(value == null ? 0 : value.hashCode()); (value == null ? 0 : value.hashCode());
} }
@Override
public String toString() { public String toString() {
if (canRemove) { if (canRemove) {
return getKey() + "=" + getValue(); return getKey() + "=" + getValue();
@ -886,24 +894,29 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public void clear() { public void clear() {
parent.clear(); parent.clear();
} }
@Override
public boolean contains(Object key) { public boolean contains(Object key) {
return parent.containsKey(key); return parent.containsKey(key);
} }
@Override
public boolean remove(Object key) { public boolean remove(Object key) {
boolean result = parent.containsKey(key); boolean result = parent.containsKey(key);
parent.remove(key); parent.remove(key);
return result; return result;
} }
@Override
public Iterator<K> iterator() { public Iterator<K> iterator() {
if (parent.delegateMap != null) { if (parent.delegateMap != null) {
return parent.delegateMap.keySet().iterator(); return parent.delegateMap.keySet().iterator();
@ -956,18 +969,22 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public void clear() { public void clear() {
parent.clear(); parent.clear();
} }
@Override
public boolean contains(Object value) { public boolean contains(Object value) {
return parent.containsValue(value); return parent.containsValue(value);
} }
@Override
public Iterator<V> iterator() { public Iterator<V> iterator() {
if (parent.delegateMap != null) { if (parent.delegateMap != null) {
return parent.delegateMap.values().iterator(); return parent.delegateMap.values().iterator();
@ -1030,6 +1047,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
* @return a shallow clone * @return a shallow clone
* @since Commons Collections 3.1 * @since Commons Collections 3.1
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Flat3Map<K, V> clone() { public Flat3Map<K, V> clone() {
try { try {
@ -1049,6 +1067,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
* @param obj the object to compare to * @param obj the object to compare to
* @return true if equal * @return true if equal
*/ */
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; 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 * @return the hash code defined in the Map interface
*/ */
@Override
public int hashCode() { public int hashCode() {
if (delegateMap != null) { if (delegateMap != null) {
return delegateMap.hashCode(); 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 * @return a string version of the map
*/ */
@Override
public String toString() { public String toString() {
if (delegateMap != null) { if (delegateMap != null) {
return delegateMap.toString(); return delegateMap.toString();

View File

@ -93,6 +93,7 @@ public class HashedMap<K, V>
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
public HashedMap<K, V> clone() { public HashedMap<K, V> clone() {
return (HashedMap<K, V>) super.clone(); return (HashedMap<K, V>) super.clone();
} }

View File

@ -95,6 +95,7 @@ public class IdentityMap<K, V>
* @param key the key to get a hash code for * @param key the key to get a hash code for
* @return the hash code * @return the hash code
*/ */
@Override
protected int hash(Object key) { protected int hash(Object key) {
return System.identityHashCode(key); return System.identityHashCode(key);
} }
@ -107,6 +108,7 @@ public class IdentityMap<K, V>
* @param key2 the second key to compare * @param key2 the second key to compare
* @return true if equal by identity * @return true if equal by identity
*/ */
@Override
protected boolean isEqualKey(Object key1, Object key2) { protected boolean isEqualKey(Object key1, Object key2) {
return (key1 == key2); return (key1 == key2);
} }
@ -119,6 +121,7 @@ public class IdentityMap<K, V>
* @param value2 the second value to compare * @param value2 the second value to compare
* @return true if equal by identity * @return true if equal by identity
*/ */
@Override
protected boolean isEqualValue(Object value1, Object value2) { protected boolean isEqualValue(Object value1, Object value2) {
return (value1 == value2); return (value1 == value2);
} }
@ -133,6 +136,7 @@ public class IdentityMap<K, V>
* @param value the value to store * @param value the value to store
* @return the newly created entry * @return the newly created entry
*/ */
@Override
protected IdentityEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) { protected IdentityEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) {
return new IdentityEntry<K, V>(next, hashCode, key, value); return new IdentityEntry<K, V>(next, hashCode, key, value);
} }
@ -147,6 +151,7 @@ public class IdentityMap<K, V>
super(next, hashCode, key, value); super(next, hashCode, key, value);
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; return true;
@ -160,6 +165,7 @@ public class IdentityMap<K, V>
(getValue() == other.getValue()); (getValue() == other.getValue());
} }
@Override
public int hashCode() { public int hashCode() {
return System.identityHashCode(getKey()) ^ return System.identityHashCode(getKey()) ^
System.identityHashCode(getValue()); System.identityHashCode(getValue());
@ -172,6 +178,7 @@ public class IdentityMap<K, V>
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
public IdentityMap<K, V> clone() { public IdentityMap<K, V> clone() {
return (IdentityMap<K, V>) super.clone(); return (IdentityMap<K, V>) super.clone();
} }

View File

@ -170,6 +170,7 @@ public class LRUMap<K, V>
* @param key the key * @param key the key
* @return the mapped value, null if no match * @return the mapped value, null if no match
*/ */
@Override
public V get(Object key) { public V get(Object key) {
LinkEntry<K, V> entry = getEntry(key); LinkEntry<K, V> entry = getEntry(key);
if (entry == null) { if (entry == null) {
@ -218,6 +219,7 @@ public class LRUMap<K, V>
* @param entry the entry to update * @param entry the entry to update
* @param newValue the new value to store * @param newValue the new value to store
*/ */
@Override
protected void updateEntry(HashEntry<K, V> entry, V newValue) { protected void updateEntry(HashEntry<K, V> entry, V newValue) {
moveToMRU((LinkEntry<K, V>) entry); // handles modCount moveToMRU((LinkEntry<K, V>) entry); // handles modCount
entry.setValue(newValue); entry.setValue(newValue);
@ -238,6 +240,7 @@ public class LRUMap<K, V>
* @param key the key to add * @param key the key to add
* @param value the value to add * @param value the value to add
*/ */
@Override
protected void addMapping(int hashIndex, int hashCode, K key, V value) { protected void addMapping(int hashIndex, int hashCode, K key, V value) {
if (isFull()) { if (isFull()) {
LinkEntry<K, V> reuse = header.after; LinkEntry<K, V> reuse = header.after;
@ -397,6 +400,7 @@ public class LRUMap<K, V>
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
public LRUMap<K, V> clone() { public LRUMap<K, V> clone() {
return (LRUMap<K, V>) super.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. * Writes the data necessary for <code>put()</code> to work in deserialization.
*/ */
@Override
protected void doWriteObject(ObjectOutputStream out) throws IOException { protected void doWriteObject(ObjectOutputStream out) throws IOException {
out.writeInt(maxSize); out.writeInt(maxSize);
super.doWriteObject(out); 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. * Reads the data necessary for <code>put()</code> to work in the superclass.
*/ */
@Override
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException { protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
maxSize = in.readInt(); maxSize = in.readInt();
super.doReadObject(in); super.doReadObject(in);

View File

@ -113,6 +113,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
public LinkedMap<K, V> clone() { public LinkedMap<K, V> clone() {
return (LinkedMap<K, V>) super.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; this.parent = parent;
} }
@Override
public int size() { public int size() {
return parent.size(); return parent.size();
} }
@Override
public K get(int index) { public K get(int index) {
return parent.get(index); return parent.get(index);
} }
@Override
public boolean contains(Object obj) { public boolean contains(Object obj) {
return parent.containsKey(obj); return parent.containsKey(obj);
} }
@Override
public int indexOf(Object obj) { public int indexOf(Object obj) {
return parent.indexOf(obj); return parent.indexOf(obj);
} }
@Override
public int lastIndexOf(Object obj) { public int lastIndexOf(Object obj) {
return parent.indexOf(obj); return parent.indexOf(obj);
} }
@Override
public boolean containsAll(Collection<?> coll) { public boolean containsAll(Collection<?> coll) {
return parent.keySet().containsAll(coll); return parent.keySet().containsAll(coll);
} }
@Override
public K remove(int index) { public K remove(int index) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object obj) { public boolean remove(Object obj) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Object[] toArray() { public Object[] toArray() {
return parent.keySet().toArray(); return parent.keySet().toArray();
} }
@Override
public <T> T[] toArray(T[] array) { public <T> T[] toArray(T[] array) {
return parent.keySet().toArray(array); return parent.keySet().toArray(array);
} }
@Override
public Iterator<K> iterator() { public Iterator<K> iterator() {
return UnmodifiableIterator.decorate(parent.keySet().iterator()); return UnmodifiableIterator.decorate(parent.keySet().iterator());
} }
@Override
public ListIterator<K> listIterator() { public ListIterator<K> listIterator() {
return UnmodifiableListIterator.decorate(super.listIterator()); return UnmodifiableListIterator.decorate(super.listIterator());
} }
@Override
public ListIterator<K> listIterator(int fromIndex) { public ListIterator<K> listIterator(int fromIndex) {
return UnmodifiableListIterator.decorate(super.listIterator(fromIndex)); return UnmodifiableListIterator.decorate(super.listIterator(fromIndex));
} }
@Override
public List<K> subList(int fromIndexInclusive, int toIndexExclusive) { public List<K> subList(int fromIndexInclusive, int toIndexExclusive) {
return UnmodifiableList.decorate(super.subList(fromIndexInclusive, toIndexExclusive)); return UnmodifiableList.decorate(super.subList(fromIndexInclusive, toIndexExclusive));
} }

View File

@ -140,6 +140,7 @@ public class ListOrderedMap<K, V>
// Implement OrderedMap // Implement OrderedMap
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
return new ListOrderedMapIterator<K, V>(this); return new ListOrderedMapIterator<K, V>(this);
} }
@ -201,6 +202,7 @@ public class ListOrderedMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public V put(K key, V value) { public V put(K key, V value) {
if (decorated().containsKey(key)) { if (decorated().containsKey(key)) {
// re-adding doesn't change order // 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) { public void putAll(Map<? extends K, ? extends V> map) {
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
put(entry.getKey(), entry.getValue()); put(entry.getKey(), entry.getValue());
@ -233,12 +236,14 @@ public class ListOrderedMap<K, V>
} }
} }
@Override
public V remove(Object key) { public V remove(Object key) {
V result = decorated().remove(key); V result = decorated().remove(key);
insertOrder.remove(key); insertOrder.remove(key);
return result; return result;
} }
@Override
public void clear() { public void clear() {
decorated().clear(); decorated().clear();
insertOrder.clear(); insertOrder.clear();
@ -253,6 +258,7 @@ public class ListOrderedMap<K, V>
* @see #keyList() * @see #keyList()
* @return the fully modifiable collection view over the keys * @return the fully modifiable collection view over the keys
*/ */
@Override
public Set<K> keySet() { public Set<K> keySet() {
return new KeySetView<K>(this); return new KeySetView<K>(this);
} }
@ -282,6 +288,7 @@ public class ListOrderedMap<K, V>
* @see #valueList() * @see #valueList()
* @return the fully modifiable collection view over the values * @return the fully modifiable collection view over the values
*/ */
@Override
public Collection<V> values() { public Collection<V> values() {
return new ValuesView<V>(this); return new ValuesView<V>(this);
} }
@ -307,6 +314,7 @@ public class ListOrderedMap<K, V>
* *
* @return the fully modifiable set view over the entries * @return the fully modifiable set view over the entries
*/ */
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
return new EntrySetView<K, V>(this, this.insertOrder); return new EntrySetView<K, V>(this, this.insertOrder);
} }
@ -317,6 +325,7 @@ public class ListOrderedMap<K, V>
* *
* @return the Map as a String * @return the Map as a String
*/ */
@Override
public String toString() { public String toString() {
if (isEmpty()) { if (isEmpty()) {
return "{}"; return "{}";
@ -466,18 +475,22 @@ public class ListOrderedMap<K, V>
this.parent = (ListOrderedMap<Object, V>) parent; this.parent = (ListOrderedMap<Object, V>) parent;
} }
@Override
public int size() { public int size() {
return this.parent.size(); return this.parent.size();
} }
@Override
public boolean contains(Object value) { public boolean contains(Object value) {
return this.parent.containsValue(value); return this.parent.containsValue(value);
} }
@Override
public void clear() { public void clear() {
this.parent.clear(); this.parent.clear();
} }
@Override
public Iterator<V> iterator() { public Iterator<V> iterator() {
return new AbstractUntypedIteratorDecorator<Map.Entry<Object, V>, V>(parent.entrySet().iterator()) { return new AbstractUntypedIteratorDecorator<Map.Entry<Object, V>, V>(parent.entrySet().iterator()) {
public V next() { public V next() {
@ -486,14 +499,17 @@ public class ListOrderedMap<K, V>
}; };
} }
@Override
public V get(int index) { public V get(int index) {
return this.parent.getValue(index); return this.parent.getValue(index);
} }
@Override
public V set(int index, V value) { public V set(int index, V value) {
return this.parent.setValue(index, value); return this.parent.setValue(index, value);
} }
@Override
public V remove(int index) { public V remove(int index) {
return this.parent.remove(index); return this.parent.remove(index);
} }
@ -509,18 +525,22 @@ public class ListOrderedMap<K, V>
this.parent = (ListOrderedMap<K, Object>) parent; this.parent = (ListOrderedMap<K, Object>) parent;
} }
@Override
public int size() { public int size() {
return this.parent.size(); return this.parent.size();
} }
@Override
public boolean contains(Object value) { public boolean contains(Object value) {
return this.parent.containsKey(value); return this.parent.containsKey(value);
} }
@Override
public void clear() { public void clear() {
this.parent.clear(); this.parent.clear();
} }
@Override
public Iterator<K> iterator() { public Iterator<K> iterator() {
return new AbstractUntypedIteratorDecorator<Map.Entry<K, Object>, K>(parent.entrySet().iterator()) { return new AbstractUntypedIteratorDecorator<Map.Entry<K, Object>, K>(parent.entrySet().iterator()) {
public K next() { public K next() {
@ -549,21 +569,26 @@ public class ListOrderedMap<K, V>
return entrySet; return entrySet;
} }
@Override
public int size() { public int size() {
return this.parent.size(); return this.parent.size();
} }
@Override
public boolean isEmpty() { public boolean isEmpty() {
return this.parent.isEmpty(); return this.parent.isEmpty();
} }
@Override
public boolean contains(Object obj) { public boolean contains(Object obj) {
return getEntrySet().contains(obj); return getEntrySet().contains(obj);
} }
@Override
public boolean containsAll(Collection<?> coll) { public boolean containsAll(Collection<?> coll) {
return getEntrySet().containsAll(coll); return getEntrySet().containsAll(coll);
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean remove(Object obj) { public boolean remove(Object obj) {
if (obj instanceof Map.Entry == false) { if (obj instanceof Map.Entry == false) {
@ -577,10 +602,12 @@ public class ListOrderedMap<K, V>
return false; return false;
} }
@Override
public void clear() { public void clear() {
this.parent.clear(); this.parent.clear();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; return true;
@ -588,14 +615,17 @@ public class ListOrderedMap<K, V>
return getEntrySet().equals(obj); return getEntrySet().equals(obj);
} }
@Override
public int hashCode() { public int hashCode() {
return getEntrySet().hashCode(); return getEntrySet().hashCode();
} }
@Override
public String toString() { public String toString() {
return getEntrySet().toString(); return getEntrySet().toString();
} }
@Override
public Iterator<Map.Entry<K, V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
return new ListOrderedIterator<K, V>(parent, insertOrder); return new ListOrderedIterator<K, V>(parent, insertOrder);
} }
@ -616,6 +646,7 @@ public class ListOrderedMap<K, V>
return new ListOrderedMapEntry<K, V>(parent, last); return new ListOrderedMapEntry<K, V>(parent, last);
} }
@Override
public void remove() { public void remove() {
super.remove(); super.remove();
parent.decorated().remove(last); parent.decorated().remove(last);
@ -631,10 +662,12 @@ public class ListOrderedMap<K, V>
this.parent = parent; this.parent = parent;
} }
@Override
public V getValue() { public V getValue() {
return parent.get(key); return parent.get(key);
} }
@Override
public V setValue(V value) { public V setValue(V value) {
return parent.decorated().put(key, value); return parent.decorated().put(key, value);
} }
@ -709,6 +742,7 @@ public class ListOrderedMap<K, V>
readable = false; readable = false;
} }
@Override
public String toString() { public String toString() {
if (readable == true) { if (readable == true) {
return "Iterator[" + getKey() + "=" + getValue() + "]"; return "Iterator[" + getKey() + "=" + getValue() + "]";

View File

@ -807,6 +807,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
public MultiKeyMap<K, V> clone() { public MultiKeyMap<K, V> clone() {
return new MultiKeyMap<K, V>(decorated().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 NullPointerException if the key is null
* @throws ClassCastException if the key is not a MultiKey * @throws ClassCastException if the key is not a MultiKey
*/ */
@Override
public V put(MultiKey<? extends K> key, V value) { public V put(MultiKey<? extends K> key, V value) {
checkKey(key); checkKey(key);
return super.put(key, value); 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() { public MapIterator<MultiKey<? extends K>, V> mapIterator() {
return decorated().mapIterator(); return decorated().mapIterator();
} }

View File

@ -166,6 +166,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
/** /**
* Clear the map. * Clear the map.
*/ */
@Override
public void clear() { public void clear() {
// If you believe that you have GC issues here, try uncommenting this code // If you believe that you have GC issues here, try uncommenting this code
// Set pairs = getMap().entrySet(); // 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 * @param value the value to search for
* @return true if the map contains the value * @return true if the map contains the value
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
Set<Map.Entry<K, Object>> pairs = decorated().entrySet(); 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 * @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 * @return the value added if the map changed and null if the map did not change
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object put(K key, Object value) { public Object put(K key, Object value) {
boolean result = false; 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) * @param map the map to copy (either a normal or multi map)
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void putAll(Map<? extends K, ?> map) { public void putAll(Map<? extends K, ?> map) {
if (map instanceof MultiMap) { 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 * @return a collection view of the values contained in this map
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Collection<Object> values() { public Collection<Object> values() {
Collection<V> vs = valuesView; 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. * Inner class that provides the values view.
*/ */
private class Values extends AbstractCollection<V> { private class Values extends AbstractCollection<V> {
@Override
public Iterator<V> iterator() { public Iterator<V> iterator() {
final IteratorChain<V> chain = new IteratorChain<V>(); final IteratorChain<V> chain = new IteratorChain<V>();
for (Iterator<K> it = keySet().iterator(); it.hasNext();) { for (Iterator<K> it = keySet().iterator(); it.hasNext();) {
@ -414,10 +420,12 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
return chain; return chain;
} }
@Override
public int size() { public int size() {
return totalSize(); return totalSize();
} }
@Override
public void clear() { public void clear() {
MultiValueMap.this.clear(); MultiValueMap.this.clear();
} }

View File

@ -151,6 +151,7 @@ public class PredicatedMap<K, V>
* @throws IllegalArgumentException if invalid * @throws IllegalArgumentException if invalid
* @since Commons Collections 3.1 * @since Commons Collections 3.1
*/ */
@Override
protected V checkSetValue(V value) { protected V checkSetValue(V value) {
if (valuePredicate.evaluate(value) == false) { if (valuePredicate.evaluate(value) == false) {
throw new IllegalArgumentException("Cannot set value - Predicate rejected it"); 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 * @return true if a value predicate is in use
* @since Commons Collections 3.1 * @since Commons Collections 3.1
*/ */
@Override
protected boolean isSetValueChecking() { protected boolean isSetValueChecking() {
return (valuePredicate != null); return (valuePredicate != null);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public V put(K key, V value) { public V put(K key, V value) {
validate(key, value); validate(key, value);
return map.put(key, value); return map.put(key, value);
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
for (Map.Entry<? extends K, ? extends V> entry : mapToCopy.entrySet()) { for (Map.Entry<? extends K, ? extends V> entry : mapToCopy.entrySet()) {
validate(entry.getKey(), entry.getValue()); validate(entry.getKey(), entry.getValue());

View File

@ -156,6 +156,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
* @param key the key to get a hash code for * @param key the key to get a hash code for
* @return the hash code * @return the hash code
*/ */
@Override
protected int hash(Object key) { protected int hash(Object key) {
return System.identityHashCode(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 * @param value the value to get a hash code for, may be null
* @return the hash code, as per the MapEntry specification * @return the hash code, as per the MapEntry specification
*/ */
@Override
protected int hashEntry(Object key, Object value) { protected int hashEntry(Object key, Object value) {
return System.identityHashCode(key) ^ return System.identityHashCode(key) ^
System.identityHashCode(value); 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> * @param key2 the second key extracted from the entry via <code>entry.key</code>
* @return true if equal by identity * @return true if equal by identity
*/ */
@Override
protected boolean isEqualKey(Object key1, Object key2) { protected boolean isEqualKey(Object key1, Object key2) {
key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference<?>) key2).get(); key2 = keyType == ReferenceStrength.HARD ? key2 : ((Reference<?>) key2).get();
return key1 == key2; 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> * @param value2 the second value extracted from the entry via <code>getValue()</code>
* @return true if equal by identity * @return true if equal by identity
*/ */
@Override
protected boolean isEqualValue(Object value1, Object value2) { protected boolean isEqualValue(Object value1, Object value2) {
return value1 == value2; return value1 == value2;
} }

View File

@ -466,6 +466,7 @@ public class SingletonMap<K, V>
hasNext = true; hasNext = true;
} }
@Override
public String toString() { public String toString() {
if (hasNext) { if (hasNext) {
return "Iterator[]"; return "Iterator[]";
@ -487,18 +488,23 @@ public class SingletonMap<K, V>
this.parent = parent; this.parent = parent;
} }
@Override
public int size() { public int size() {
return 1; return 1;
} }
@Override
public boolean isEmpty() { public boolean isEmpty() {
return false; return false;
} }
@Override
public boolean contains(Object object) { public boolean contains(Object object) {
return parent.containsValue(object); return parent.containsValue(object);
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Iterator<V> iterator() { public Iterator<V> iterator() {
return new SingletonIterator<V>(parent.getValue(), false); return new SingletonIterator<V>(parent.getValue(), false);
} }
@ -510,6 +516,7 @@ public class SingletonMap<K, V>
* *
* @return a shallow clone * @return a shallow clone
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public SingletonMap<K, V> clone() { public SingletonMap<K, V> clone() {
try { try {
@ -525,6 +532,7 @@ public class SingletonMap<K, V>
* @param obj the object to compare to * @param obj the object to compare to
* @return true if equal * @return true if equal
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
@ -546,6 +554,7 @@ public class SingletonMap<K, V>
* *
* @return the hash code defined in the Map interface * @return the hash code defined in the Map interface
*/ */
@Override
public int hashCode() { public int hashCode() {
return (getKey() == null ? 0 : getKey().hashCode()) ^ return (getKey() == null ? 0 : getKey().hashCode()) ^
(getValue() == null ? 0 : getValue().hashCode()); (getValue() == null ? 0 : getValue().hashCode());
@ -556,6 +565,7 @@ public class SingletonMap<K, V>
* *
* @return a string version of the map * @return a string version of the map
*/ */
@Override
public String toString() { public String toString() {
return new StringBuilder(128) return new StringBuilder(128)
.append('{') .append('{')

View File

@ -209,6 +209,7 @@ public class TransformedMap<K, V>
* @return the transformed value * @return the transformed value
* @since Commons Collections 3.1 * @since Commons Collections 3.1
*/ */
@Override
protected V checkSetValue(V value) { protected V checkSetValue(V value) {
return valueTransformer.transform(value); return valueTransformer.transform(value);
} }
@ -219,17 +220,20 @@ public class TransformedMap<K, V>
* @return true if a value transformer is in use * @return true if a value transformer is in use
* @since Commons Collections 3.1 * @since Commons Collections 3.1
*/ */
@Override
protected boolean isSetValueChecking() { protected boolean isSetValueChecking() {
return (valueTransformer != null); return (valueTransformer != null);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public V put(K key, V value) { public V put(K key, V value) {
key = transformKey(key); key = transformKey(key);
value = transformValue(value); value = transformValue(value);
return decorated().put(key, value); return decorated().put(key, value);
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
mapToCopy = transformMap(mapToCopy); mapToCopy = transformMap(mapToCopy);
decorated().putAll(mapToCopy); decorated().putAll(mapToCopy);

View File

@ -68,35 +68,43 @@ public final class UnmodifiableEntrySet<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public boolean add(Map.Entry<K, V> object) { public boolean add(Map.Entry<K, V> object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) { public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<Map.Entry<K, V>> iterator() { public Iterator<Map.Entry<K, V>> iterator() {
return new UnmodifiableEntrySetIterator(collection.iterator()); return new UnmodifiableEntrySetIterator(collection.iterator());
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object[] toArray() { public Object[] toArray() {
Object[] array = collection.toArray(); Object[] array = collection.toArray();
@ -106,6 +114,7 @@ public final class UnmodifiableEntrySet<K, V>
return array; return array;
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] array) { public <T> T[] toArray(T[] array) {
Object[] result = array; Object[] result = array;
@ -142,10 +151,12 @@ public final class UnmodifiableEntrySet<K, V>
super(iterator); super(iterator);
} }
@Override
public Map.Entry<K, V> next() { public Map.Entry<K, V> next() {
return new UnmodifiableEntry(iterator.next()); return new UnmodifiableEntry(iterator.next());
} }
@Override
public void remove() { public void remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -161,6 +172,7 @@ public final class UnmodifiableEntrySet<K, V>
super(entry); super(entry);
} }
@Override
public V setValue(V obj) { public V setValue(V obj) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -103,22 +103,27 @@ public final class UnmodifiableMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V put(K key, V value) { public V put(K key, V value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public MapIterator<K, V> mapIterator() { public MapIterator<K, V> mapIterator() {
if (map instanceof IterableMap) { if (map instanceof IterableMap) {
MapIterator<K, V> it = ((IterableMap<K, V>) map).mapIterator(); MapIterator<K, V> it = ((IterableMap<K, V>) map).mapIterator();
@ -128,16 +133,19 @@ public final class UnmodifiableMap<K, V>
return UnmodifiableMapIterator.decorate(it); return UnmodifiableMapIterator.decorate(it);
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = super.entrySet(); Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.decorate(set); return UnmodifiableEntrySet.decorate(set);
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
Set<K> set = super.keySet(); Set<K> set = super.keySet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Collection<V> values() { public Collection<V> values() {
Collection<V> coll = super.values(); Collection<V> coll = super.values();
return UnmodifiableCollection.decorate(coll); return UnmodifiableCollection.decorate(coll);

View File

@ -101,37 +101,45 @@ public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecora
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public OrderedMapIterator<K, V> mapIterator() { public OrderedMapIterator<K, V> mapIterator() {
OrderedMapIterator<K, V> it = decorated().mapIterator(); OrderedMapIterator<K, V> it = decorated().mapIterator();
return UnmodifiableOrderedMapIterator.decorate(it); return UnmodifiableOrderedMapIterator.decorate(it);
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V put(K key, V value) { public V put(K key, V value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = super.entrySet(); Set<Map.Entry<K, V>> set = super.entrySet();
return UnmodifiableEntrySet.decorate(set); return UnmodifiableEntrySet.decorate(set);
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
Set<K> set = super.keySet(); Set<K> set = super.keySet();
return UnmodifiableSet.decorate(set); return UnmodifiableSet.decorate(set);
} }
@Override
public Collection<V> values() { public Collection<V> values() {
Collection<V> coll = super.values(); Collection<V> coll = super.values();
return UnmodifiableCollection.decorate(coll); return UnmodifiableCollection.decorate(coll);

View File

@ -101,55 +101,68 @@ public final class UnmodifiableSortedMap<K, V>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V put(K key, V value) { public V put(K key, V value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopy) { public void putAll(Map<? extends K, ? extends V> mapToCopy) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public V remove(Object key) { public V remove(Object key) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Set<Map.Entry<K, V>> entrySet() { public Set<Map.Entry<K, V>> entrySet() {
return UnmodifiableEntrySet.decorate(super.entrySet()); return UnmodifiableEntrySet.decorate(super.entrySet());
} }
@Override
public Set<K> keySet() { public Set<K> keySet() {
return UnmodifiableSet.decorate(super.keySet()); return UnmodifiableSet.decorate(super.keySet());
} }
@Override
public Collection<V> values() { public Collection<V> values() {
return UnmodifiableCollection.decorate(super.values()); return UnmodifiableCollection.decorate(super.values());
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public K firstKey() { public K firstKey() {
return decorated().firstKey(); return decorated().firstKey();
} }
@Override
public K lastKey() { public K lastKey() {
return decorated().lastKey(); return decorated().lastKey();
} }
@Override
public Comparator<? super K> comparator() { public Comparator<? super K> comparator() {
return decorated().comparator(); return decorated().comparator();
} }
@Override
public SortedMap<K, V> subMap(K fromKey, K toKey) { public SortedMap<K, V> subMap(K fromKey, K toKey) {
return new UnmodifiableSortedMap<K, V>(decorated().subMap(fromKey, toKey)); return new UnmodifiableSortedMap<K, V>(decorated().subMap(fromKey, toKey));
} }
@Override
public SortedMap<K, V> headMap(K toKey) { public SortedMap<K, V> headMap(K toKey) {
return new UnmodifiableSortedMap<K, V>(decorated().headMap(toKey)); return new UnmodifiableSortedMap<K, V>(decorated().headMap(toKey));
} }
@Override
public SortedMap<K, V> tailMap(K fromKey) { public SortedMap<K, V> tailMap(K fromKey) {
return new UnmodifiableSortedMap<K, V>(decorated().tailMap(fromKey)); return new UnmodifiableSortedMap<K, V>(decorated().tailMap(fromKey));
} }

View File

@ -60,6 +60,7 @@ public abstract class AbstractSetDecorator<E> extends AbstractCollectionDecorato
* *
* @return the decorated set * @return the decorated set
*/ */
@Override
protected Set<E> decorated() { protected Set<E> decorated() {
return (Set<E>) super.decorated(); return (Set<E>) super.decorated();
} }

View File

@ -61,6 +61,7 @@ public abstract class AbstractSortedSetDecorator<E>
* *
* @return the decorated set * @return the decorated set
*/ */
@Override
protected SortedSet<E> decorated() { protected SortedSet<E> decorated() {
return (SortedSet<E>) super.decorated(); return (SortedSet<E>) super.decorated();
} }

View File

@ -70,6 +70,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
* @see org.apache.commons.collections.collection.CompositeCollection.CollectionMutator * @see org.apache.commons.collections.collection.CompositeCollection.CollectionMutator
* @see SetMutator * @see SetMutator
*/ */
@Override
public synchronized void addComposited(Collection<E> c) { public synchronized void addComposited(Collection<E> c) {
if (!(c instanceof Set)) { if (!(c instanceof Set)) {
throw new IllegalArgumentException("Collections added must implement java.util.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 * @throws IllegalArgumentException if c or d does not implement java.util.Set
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void addComposited(Collection<E> c, Collection<E> d) { public synchronized void addComposited(Collection<E> c, Collection<E> d) {
if (!(c instanceof Set)) throw new IllegalArgumentException("Argument must implement java.util.Set"); 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 * @param comps
* @throws IllegalArgumentException if any of the collections in comps do not implement Set * @throws IllegalArgumentException if any of the collections in comps do not implement Set
*/ */
@Override
public synchronized void addComposited(Collection<E>[] comps) { public synchronized void addComposited(Collection<E>[] comps) {
for (int i = comps.length - 1; i >= 0; --i) { for (int i = comps.length - 1; i >= 0; --i) {
this.addComposited(comps[i]); this.addComposited(comps[i]);
@ -135,6 +138,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
* composited sets will throw IllegalArgumentException * composited sets will throw IllegalArgumentException
* <p> * <p>
*/ */
@Override
public void setMutator(CollectionMutator<E> mutator) { public void setMutator(CollectionMutator<E> mutator) {
super.setMutator(mutator); super.setMutator(mutator);
} }
@ -148,6 +152,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
* @param obj Object to be removed * @param obj Object to be removed
* @return true if the object is removed, false otherwise * @return true if the object is removed, false otherwise
*/ */
@Override
public boolean remove(Object obj) { public boolean remove(Object obj) {
for (Set<? extends E> set : getCollections()) { for (Set<? extends E> set : getCollections()) {
if (set.contains(obj)) return set.remove(obj); 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 * @see Set#equals
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Set) { if (obj instanceof Set) {
@ -170,6 +176,7 @@ public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
/** /**
* @see Set#hashCode * @see Set#hashCode
*/ */
@Override
public int hashCode() { public int hashCode() {
int code = 0; int code = 0;
for (E e : this) { for (E e : this) {

View File

@ -168,15 +168,18 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public void clear() { public void clear() {
collection.clear(); collection.clear();
setOrder.clear(); setOrder.clear();
} }
@Override
public OrderedIterator<E> iterator() { public OrderedIterator<E> iterator() {
return new OrderedSetIterator<E>(setOrder.listIterator(), collection); return new OrderedSetIterator<E>(setOrder.listIterator(), collection);
} }
@Override
public boolean add(E object) { public boolean add(E object) {
if (collection.add(object)) { if (collection.add(object)) {
setOrder.add(object); setOrder.add(object);
@ -185,6 +188,7 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
return false; return false;
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
boolean result = false; boolean result = false;
for (E e : coll) { for (E e : coll) {
@ -193,12 +197,14 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
return result; return result;
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
boolean result = collection.remove(object); boolean result = collection.remove(object);
setOrder.remove(object); setOrder.remove(object);
return result; return result;
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
boolean result = false; boolean result = false;
for (Iterator<?> it = coll.iterator(); it.hasNext();) { for (Iterator<?> it = coll.iterator(); it.hasNext();) {
@ -207,6 +213,7 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
return result; return result;
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
boolean result = collection.retainAll(coll); boolean result = collection.retainAll(coll);
if (result == false) { if (result == false) {
@ -224,10 +231,12 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
return result; return result;
} }
@Override
public Object[] toArray() { public Object[] toArray() {
return setOrder.toArray(); return setOrder.toArray();
} }
@Override
public <T> T[] toArray(T a[]) { public <T> T[] toArray(T a[]) {
return setOrder.toArray(a); return setOrder.toArray(a);
} }
@ -273,6 +282,7 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
* any custom toStrings will be ignored. * any custom toStrings will be ignored.
*/ */
// Fortunately List.toString and Set.toString look the same // Fortunately List.toString and Set.toString look the same
@Override
public String toString() { public String toString() {
return setOrder.toString(); return setOrder.toString();
} }
@ -294,11 +304,13 @@ public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> imple
this.set = set; this.set = set;
} }
@Override
public E next() { public E next() {
last = iterator.next(); last = iterator.next();
return last; return last;
} }
@Override
public void remove() { public void remove() {
set.remove(last); set.remove(last);
iterator.remove(); iterator.remove();

View File

@ -147,10 +147,12 @@ public final class MapBackedSet<E, V> implements Set<E>, Serializable {
return map.keySet().toArray(array); return map.keySet().toArray(array);
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return map.keySet().equals(obj); return map.keySet().equals(obj);
} }
@Override
public int hashCode() { public int hashCode() {
return map.keySet().hashCode(); return map.keySet().hashCode();
} }

View File

@ -82,6 +82,7 @@ public class PredicatedSet<E> extends PredicatedCollection<E> implements Set<E>
* *
* @return the decorated set * @return the decorated set
*/ */
@Override
protected Set<E> decorated() { protected Set<E> decorated() {
return (Set<E>) super.decorated(); return (Set<E>) super.decorated();
} }

View File

@ -82,6 +82,7 @@ public class PredicatedSortedSet<E> extends PredicatedSet<E> implements SortedSe
* *
* @return the decorated sorted set * @return the decorated sorted set
*/ */
@Override
protected SortedSet<E> decorated() { protected SortedSet<E> decorated() {
return (SortedSet<E>) super.decorated(); return (SortedSet<E>) super.decorated();
} }

View File

@ -67,30 +67,37 @@ public final class UnmodifiableSet<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.<E>decorate(decorated().iterator()); return UnmodifiableIterator.<E>decorate(decorated().iterator());
} }
@Override
public boolean add(E object) { public boolean add(E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -96,45 +96,55 @@ public final class UnmodifiableSortedSet<E>
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator()); return UnmodifiableIterator.decorate(decorated().iterator());
} }
@Override
public boolean add(E object) { public boolean add(E object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean addAll(Collection<? extends E> coll) { public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void clear() { public void clear() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean remove(Object object) { public boolean remove(Object object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean retainAll(Collection<?> coll) { public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override
public SortedSet<E> subSet(E fromElement, E toElement) { public SortedSet<E> subSet(E fromElement, E toElement) {
SortedSet<E> sub = decorated().subSet(fromElement, toElement); SortedSet<E> sub = decorated().subSet(fromElement, toElement);
return new UnmodifiableSortedSet<E>(sub); return new UnmodifiableSortedSet<E>(sub);
} }
@Override
public SortedSet<E> headSet(E toElement) { public SortedSet<E> headSet(E toElement) {
SortedSet<E> sub = decorated().headSet(toElement); SortedSet<E> sub = decorated().headSet(toElement);
return new UnmodifiableSortedSet<E>(sub); return new UnmodifiableSortedSet<E>(sub);
} }
@Override
public SortedSet<E> tailSet(E fromElement) { public SortedSet<E> tailSet(E fromElement) {
SortedSet<E> sub = decorated().tailSet(fromElement); SortedSet<E> sub = decorated().tailSet(fromElement);
return new UnmodifiableSortedSet<E>(sub); return new UnmodifiableSortedSet<E>(sub);

View File

@ -130,6 +130,7 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (object == this) { if (object == this) {
return true; return true;
@ -140,6 +141,7 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int hashCode() { public int hashCode() {
return decorated().hashCode(); return decorated().hashCode();
} }
@ -147,6 +149,7 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String toString() { public String toString() {
return decorated().toString(); return decorated().toString();
} }

View File

@ -174,6 +174,7 @@ public class BulkTest extends TestCase implements Cloneable {
* *
* @return a clone of this <code>BulkTest</code> * @return a clone of this <code>BulkTest</code>
*/ */
@Override
public Object clone() { public Object clone() {
try { try {
return super.clone(); return super.clone();
@ -226,6 +227,7 @@ public class BulkTest extends TestCase implements Cloneable {
* *
* @return the display name of this <code>BulkTest</code> * @return the display name of this <code>BulkTest</code>
*/ */
@Override
public String toString() { public String toString() {
return getName() + "(" + verboseName + ") "; return getName() + "(" + verboseName + ") ";
} }

View File

@ -96,6 +96,7 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
* *
* @return true if equal * @return true if equal
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean equals(Object o) { public boolean equals(Object o) {
@ -116,6 +117,7 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
/** /**
* @return hash code * @return hash code
*/ */
@Override
public int hashCode() { public int hashCode() {
return getKey().hashCode() ^ getValue().hashCode(); return getKey().hashCode() ^ getValue().hashCode();
} }

View File

@ -42,6 +42,7 @@ public class TestArrayStack<E> extends TestArrayList<E> {
junit.textui.TestRunner.main(testCaseName); junit.textui.TestRunner.main(testCaseName);
} }
@Override
public ArrayStack<E> makeObject() { public ArrayStack<E> makeObject() {
return new ArrayStack<E>(); return new ArrayStack<E>();
} }
@ -97,6 +98,7 @@ public class TestArrayStack<E> extends TestArrayList<E> {
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testSearch() { public void testSearch() {
ArrayStack<E> stack = makeObject(); ArrayStack<E> stack = makeObject();

View File

@ -69,12 +69,14 @@ public class TestClosureUtils extends junit.framework.TestCase {
/** /**
* Set up instance variables required by this test case. * Set up instance variables required by this test case.
*/ */
@Override
public void setUp() { public void setUp() {
} }
/** /**
* Tear down instance variables required by this test case. * Tear down instance variables required by this test case.
*/ */
@Override
public void tearDown() { public void tearDown() {
} }

View File

@ -50,12 +50,14 @@ public class TestFactoryUtils extends junit.framework.TestCase {
/** /**
* Set up instance variables required by this test case. * Set up instance variables required by this test case.
*/ */
@Override
public void setUp() { public void setUp() {
} }
/** /**
* Tear down instance variables required by this test case. * Tear down instance variables required by this test case.
*/ */
@Override
public void tearDown() { public void tearDown() {
} }
@ -205,6 +207,7 @@ public class TestFactoryUtils extends junit.framework.TestCase {
public Mock1(Mock1 mock) { public Mock1(Mock1 mock) {
iVal = mock.iVal; iVal = mock.iVal;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Mock1) { if (obj instanceof Mock1) {
if (iVal == ((Mock1) obj).iVal) { if (iVal == ((Mock1) obj).iVal) {
@ -221,6 +224,7 @@ public class TestFactoryUtils extends junit.framework.TestCase {
public Mock2(Object val) { public Mock2(Object val) {
iVal = val; iVal = val;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Mock2) { if (obj instanceof Mock2) {
if (iVal == ((Mock2) obj).iVal) { if (iVal == ((Mock2) obj).iVal) {

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