Remove trailing spaces.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1477799 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b7a0c8d3de
commit
810250d722
|
@ -135,13 +135,13 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @param loadFactor the load factor
|
* @param loadFactor the load factor
|
||||||
* @throws IllegalArgumentException if the initial capacity is negative
|
* @throws IllegalArgumentException if the initial capacity is negative
|
||||||
* @throws IllegalArgumentException if the load factor is less than or equal to zero
|
* @throws IllegalArgumentException if the load factor is less than or equal to zero
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected AbstractHashedMap(int initialCapacity, final float loadFactor) {
|
protected AbstractHashedMap(int initialCapacity, final float loadFactor) {
|
||||||
super();
|
super();
|
||||||
if (initialCapacity < 0) {
|
if (initialCapacity < 0) {
|
||||||
throw new IllegalArgumentException("Initial capacity must be a non negative number");
|
throw new IllegalArgumentException("Initial capacity must be a non negative number");
|
||||||
}
|
}
|
||||||
if (loadFactor <= 0.0f || Float.isNaN(loadFactor)) {
|
if (loadFactor <= 0.0f || Float.isNaN(loadFactor)) {
|
||||||
throw new IllegalArgumentException("Load factor must be greater than 0");
|
throw new IllegalArgumentException("Load factor must be greater than 0");
|
||||||
|
@ -311,9 +311,9 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
|
||||||
* This implementation iterates around the specified map and
|
* This implementation iterates around the specified map and
|
||||||
* uses {@link #put(Object, Object)}.
|
* uses {@link #put(Object, Object)}.
|
||||||
* <p>
|
* <p>
|
||||||
* It is private to allow the constructor to still call it
|
* It is private to allow the constructor to still call it
|
||||||
* even when putAll is overriden.
|
* even when putAll is overriden.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,7 +54,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
||||||
* or it may transform the value into another object.
|
* or it may transform the value into another object.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation returns the input value.
|
* This implementation returns the input value.
|
||||||
*
|
*
|
||||||
* @param value the value to check
|
* @param value the value to check
|
||||||
* @throws UnsupportedOperationException if the map may not be changed by setValue
|
* @throws UnsupportedOperationException if the map may not be changed by setValue
|
||||||
* @throws IllegalArgumentException if the specified value is invalid
|
* @throws IllegalArgumentException if the specified value is invalid
|
||||||
|
@ -86,7 +86,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
||||||
* has no effect as this optimises the implementation.
|
* has no effect as this optimises the implementation.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation returns <code>true</code>.
|
* This implementation returns <code>true</code>.
|
||||||
*
|
*
|
||||||
* @return true always
|
* @return true always
|
||||||
*/
|
*/
|
||||||
protected boolean isSetValueChecking() {
|
protected boolean isSetValueChecking() {
|
||||||
|
@ -107,7 +107,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
||||||
* Implementation of an entry set that checks additions via setValue.
|
* Implementation of an entry set that checks additions via setValue.
|
||||||
*/
|
*/
|
||||||
private class EntrySet extends AbstractSetDecorator<Map.Entry<K, V>> {
|
private class EntrySet extends AbstractSetDecorator<Map.Entry<K, V>> {
|
||||||
|
|
||||||
/** Generated serial version ID. */
|
/** Generated serial version ID. */
|
||||||
private static final long serialVersionUID = 4354731610923110264L;
|
private static final long serialVersionUID = 4354731610923110264L;
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
||||||
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
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
@ -133,7 +133,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T[] toArray(final T[] array) {
|
public <T> T[] toArray(final T[] array) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ import org.apache.commons.collections4.iterators.EmptyOrderedMapIterator;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> implements OrderedMap<K, V> {
|
public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> implements OrderedMap<K, V> {
|
||||||
|
|
||||||
/** Header in the linked list */
|
/** Header in the linked list */
|
||||||
protected transient LinkEntry<K, V> header; // TODO Privatise?
|
protected transient LinkEntry<K, V> header; // TODO Privatise?
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor which performs no validation on the passed in parameters.
|
* Constructor which performs no validation on the passed in parameters.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity, must be a power of two
|
* @param initialCapacity the initial capacity, must be a power of two
|
||||||
* @param loadFactor the load factor, must be > 0.0f and generally < 1.0f
|
* @param loadFactor the load factor, must be > 0.0f and generally < 1.0f
|
||||||
* @param threshold the threshold, must be sensible
|
* @param threshold the threshold, must be sensible
|
||||||
|
@ -83,7 +83,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, empty map with the specified initial capacity.
|
* Constructs a new, empty map with the specified initial capacity.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @throws IllegalArgumentException if the initial capacity is negative
|
* @throws IllegalArgumentException if the initial capacity is negative
|
||||||
|
@ -94,7 +94,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, empty map with the specified initial capacity and
|
* Constructs a new, empty map with the specified initial capacity and
|
||||||
* load factor.
|
* load factor.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @param loadFactor the load factor
|
* @param loadFactor the load factor
|
||||||
|
@ -131,7 +131,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified value.
|
* Checks whether the map contains the specified value.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
|
@ -168,7 +168,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the first key in the map, which is the first inserted.
|
* Gets the first key in the map, which is the first inserted.
|
||||||
*
|
*
|
||||||
* @return the eldest key
|
* @return the eldest key
|
||||||
*/
|
*/
|
||||||
public K firstKey() {
|
public K firstKey() {
|
||||||
|
@ -180,7 +180,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the last key in the map, which is the most recently inserted.
|
* Gets the last key in the map, which is the most recently inserted.
|
||||||
*
|
*
|
||||||
* @return the most recently inserted key
|
* @return the most recently inserted key
|
||||||
*/
|
*/
|
||||||
public K lastKey() {
|
public K lastKey() {
|
||||||
|
@ -192,7 +192,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the next key in sequence.
|
* Gets the next key in sequence.
|
||||||
*
|
*
|
||||||
* @param key the key to get after
|
* @param key the key to get after
|
||||||
* @return the next key
|
* @return the next key
|
||||||
*/
|
*/
|
||||||
|
@ -208,7 +208,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the previous key in sequence.
|
* Gets the previous key in sequence.
|
||||||
*
|
*
|
||||||
* @param key the key to get before
|
* @param key the key to get before
|
||||||
* @return the previous key
|
* @return the previous key
|
||||||
*/
|
*/
|
||||||
|
@ -217,10 +217,10 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
return entry == null || entry.before == header ? null : entry.before.getKey();
|
return entry == null || entry.before == header ? null : entry.before.getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the key at the specified index.
|
* Gets the key at the specified index.
|
||||||
*
|
*
|
||||||
* @param index the index to retrieve
|
* @param index the index to retrieve
|
||||||
* @return the key at the specified index
|
* @return the key at the specified index
|
||||||
* @throws IndexOutOfBoundsException if the index is invalid
|
* @throws IndexOutOfBoundsException if the index is invalid
|
||||||
|
@ -248,13 +248,13 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an entry into this map, maintaining insertion order.
|
* Adds an entry into this map, maintaining insertion order.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation adds the entry to the data storage table and
|
* This implementation adds the entry to the data storage table and
|
||||||
* to the end of the linked list.
|
* to the end of the linked list.
|
||||||
*
|
*
|
||||||
* @param entry the entry to add
|
* @param entry 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
|
||||||
*/
|
*/
|
||||||
|
@ -272,7 +272,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
* Creates an entry to store the data.
|
* Creates an entry to store the data.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation creates a new LinkEntry instance.
|
* This implementation creates a new LinkEntry instance.
|
||||||
*
|
*
|
||||||
* @param next the next entry in sequence
|
* @param next the next entry in sequence
|
||||||
* @param hashCode the hash code to use
|
* @param hashCode the hash code to use
|
||||||
* @param key the key to store
|
* @param key the key to store
|
||||||
|
@ -289,7 +289,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation removes the entry from the linked list chain, then
|
* This implementation removes the entry from the linked list chain, then
|
||||||
* calls the superclass implementation.
|
* calls the superclass implementation.
|
||||||
*
|
*
|
||||||
* @param entry the entry to remove
|
* @param entry the entry to remove
|
||||||
* @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
|
||||||
|
@ -308,7 +308,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
/**
|
/**
|
||||||
* Gets the <code>before</code> field from a <code>LinkEntry</code>.
|
* Gets the <code>before</code> field from a <code>LinkEntry</code>.
|
||||||
* Used in subclasses that have no visibility of the field.
|
* Used in subclasses that have no visibility of the field.
|
||||||
*
|
*
|
||||||
* @param entry the entry to query, must not be null
|
* @param entry the entry to query, must not be null
|
||||||
* @return the <code>before</code> field of the entry
|
* @return the <code>before</code> field of the entry
|
||||||
* @throws NullPointerException if the entry is null
|
* @throws NullPointerException if the entry is null
|
||||||
|
@ -321,7 +321,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
/**
|
/**
|
||||||
* Gets the <code>after</code> field from a <code>LinkEntry</code>.
|
* Gets the <code>after</code> field from a <code>LinkEntry</code>.
|
||||||
* Used in subclasses that have no visibility of the field.
|
* Used in subclasses that have no visibility of the field.
|
||||||
*
|
*
|
||||||
* @param entry the entry to query, must not be null
|
* @param entry the entry to query, must not be null
|
||||||
* @return the <code>after</code> field of the entry
|
* @return the <code>after</code> field of the entry
|
||||||
* @throws NullPointerException if the entry is null
|
* @throws NullPointerException if the entry is null
|
||||||
|
@ -386,11 +386,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Creates an entry set iterator.
|
* Creates an entry set iterator.
|
||||||
* Subclasses can override this to return iterators with different properties.
|
* Subclasses can override this to return iterators with different properties.
|
||||||
*
|
*
|
||||||
* @return the entrySet iterator
|
* @return the entrySet iterator
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -420,11 +420,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Creates a key set iterator.
|
* Creates a key set iterator.
|
||||||
* Subclasses can override this to return iterators with different properties.
|
* Subclasses can override this to return iterators with different properties.
|
||||||
*
|
*
|
||||||
* @return the keySet iterator
|
* @return the keySet iterator
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -440,7 +440,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
*/
|
*/
|
||||||
protected static class KeySetIterator<K> extends LinkIterator<K, Object> implements
|
protected static class KeySetIterator<K> extends LinkIterator<K, Object> implements
|
||||||
OrderedIterator<K>, ResettableIterator<K> {
|
OrderedIterator<K>, ResettableIterator<K> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected KeySetIterator(final AbstractLinkedMap<K, ?> parent) {
|
protected KeySetIterator(final AbstractLinkedMap<K, ?> parent) {
|
||||||
super((AbstractLinkedMap<K, Object>) parent);
|
super((AbstractLinkedMap<K, Object>) parent);
|
||||||
|
@ -455,11 +455,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Creates a values iterator.
|
* Creates a values iterator.
|
||||||
* Subclasses can override this to return iterators with different properties.
|
* Subclasses can override this to return iterators with different properties.
|
||||||
*
|
*
|
||||||
* @return the values iterator
|
* @return the values iterator
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -507,7 +507,7 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new entry.
|
* Constructs a new entry.
|
||||||
*
|
*
|
||||||
* @param next the next entry in the hash bucket sequence
|
* @param next the next entry in the hash bucket sequence
|
||||||
* @param hashCode the hash code
|
* @param hashCode the hash code
|
||||||
* @param key the key
|
* @param key the key
|
||||||
|
|
|
@ -66,7 +66,7 @@ public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
protected Map<K, V> decorated() {
|
protected Map<K, V> decorated() {
|
||||||
|
@ -121,7 +121,7 @@ public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K,
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
return decorated().values();
|
return decorated().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object object) {
|
public boolean equals(final Object object) {
|
||||||
if (object == this) {
|
if (object == this) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.collections4.map;
|
||||||
import org.apache.commons.collections4.OrderedMap;
|
import org.apache.commons.collections4.OrderedMap;
|
||||||
import org.apache.commons.collections4.OrderedMapIterator;
|
import org.apache.commons.collections4.OrderedMapIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a base decorator that enables additional functionality to be added
|
* Provides a base decorator that enables additional functionality to be added
|
||||||
* to an OrderedMap via decoration.
|
* to an OrderedMap via decoration.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -57,7 +57,7 @@ public abstract class AbstractOrderedMapDecorator<K, V> extends AbstractMapDecor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -149,8 +149,8 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
||||||
* load factor and initial capacity.
|
* load factor and initial capacity.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link ReferenceStrength#HARD HARD},
|
* must be {@link ReferenceStrength#HARD HARD},
|
||||||
* {@link ReferenceStrength#SOFT SOFT},
|
* {@link ReferenceStrength#SOFT SOFT},
|
||||||
* {@link ReferenceStrength#WEAK WEAK}
|
* {@link ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link ReferenceStrength#HARD},
|
* must be {@link ReferenceStrength#HARD},
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.collections4.IterableSortedMap;
|
||||||
import org.apache.commons.collections4.OrderedMapIterator;
|
import org.apache.commons.collections4.OrderedMapIterator;
|
||||||
import org.apache.commons.collections4.iterators.ListIteratorWrapper;
|
import org.apache.commons.collections4.iterators.ListIteratorWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a base decorator that enables additional functionality to be added
|
* Provides a base decorator that enables additional functionality to be added
|
||||||
* to a Map via decoration.
|
* to a Map via decoration.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -67,7 +67,7 @@ public abstract class AbstractSortedMapDecorator<K, V> extends AbstractMapDecora
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
||||||
* to all lowercase in a locale-independent fashion by using information from the Unicode
|
* to all lowercase in a locale-independent fashion by using information from the Unicode
|
||||||
* data file.
|
* data file.
|
||||||
* <p>
|
* <p>
|
||||||
* Null keys are supported.
|
* Null keys are supported.
|
||||||
* <p>
|
* <p>
|
||||||
* The <code>keySet()</code> method returns all lowercase keys, or nulls.
|
* The <code>keySet()</code> method returns all lowercase keys, or nulls.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -54,7 +54,7 @@ import java.util.Map;
|
||||||
* <strong>Note that CaseInsensitiveMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that CaseInsensitiveMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
|
@ -73,7 +73,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, empty map with the specified initial capacity.
|
* Constructs a new, empty map with the specified initial capacity.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @throws IllegalArgumentException if the initial capacity is negative
|
* @throws IllegalArgumentException if the initial capacity is negative
|
||||||
|
@ -84,7 +84,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, empty map with the specified initial capacity and
|
* Constructs a new, empty map with the specified initial capacity and
|
||||||
* load factor.
|
* load factor.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @param loadFactor the load factor
|
* @param loadFactor the load factor
|
||||||
|
@ -111,11 +111,11 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Overrides convertKey() from {@link AbstractHashedMap} to convert keys to
|
* Overrides convertKey() from {@link AbstractHashedMap} to convert keys to
|
||||||
* lower case.
|
* lower case.
|
||||||
* <p>
|
* <p>
|
||||||
* Returns {@link AbstractHashedMap#NULL} if key is null.
|
* Returns {@link AbstractHashedMap#NULL} if key is null.
|
||||||
*
|
*
|
||||||
* @param key the key convert
|
* @param key the key convert
|
||||||
* @return the converted key
|
* @return the converted key
|
||||||
*/
|
*/
|
||||||
|
@ -129,7 +129,7 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
||||||
return new String(chars);
|
return new String(chars);
|
||||||
}
|
}
|
||||||
return AbstractHashedMap.NULL;
|
return AbstractHashedMap.NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -157,5 +157,5 @@ public class CaseInsensitiveMap<K, V> extends AbstractHashedMap<K, V> implements
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
doReadObject(in);
|
doReadObject(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ import org.apache.commons.collections4.functors.FactoryTransformer;
|
||||||
* <strong>Note that DefaultedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that DefaultedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
*
|
*
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
|
@ -74,7 +74,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
* Factory method to create a defaulting map.
|
* Factory method to create a defaulting map.
|
||||||
* <p>
|
* <p>
|
||||||
* The value specified is returned when a missing key is found.
|
* The value specified is returned when a missing key is found.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -91,7 +91,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
* <p>
|
* <p>
|
||||||
* The factory specified is called when a missing key is found.
|
* The factory specified is called when a missing key is found.
|
||||||
* The result will be returned as the result of the map get(key) method.
|
* The result will be returned as the result of the map get(key) method.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -112,7 +112,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
* The transformer specified is called when a missing key is found.
|
* The transformer specified is called when a missing key is found.
|
||||||
* The key is passed to the transformer as the input, and the result
|
* The key is passed to the transformer as the input, and the result
|
||||||
* will be returned as the result of the map get(key) method.
|
* will be returned as the result of the map get(key) method.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -135,7 +135,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
* <p>
|
* <p>
|
||||||
* The object passed in will be returned by the map whenever an
|
* The object passed in will be returned by the map whenever an
|
||||||
* unknown key is requested.
|
* unknown key is requested.
|
||||||
*
|
*
|
||||||
* @param defaultValue the default value to return when the key is not found
|
* @param defaultValue the default value to return when the key is not found
|
||||||
*/
|
*/
|
||||||
public DefaultedMap(final V defaultValue) {
|
public DefaultedMap(final V defaultValue) {
|
||||||
|
@ -153,7 +153,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param defaultValueTransformer the value transformer to use
|
* @param defaultValueTransformer the value transformer to use
|
||||||
* @throws IllegalArgumentException if map or transformer is null
|
* @throws IllegalArgumentException if map or transformer is null
|
||||||
|
@ -169,7 +169,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@ -180,7 +180,7 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class EntrySetToMapIteratorAdapter<K, V> implements MapIterator<K, V>, Re
|
||||||
* Get the currently active entry.
|
* Get the currently active entry.
|
||||||
* @return Map.Entry<K, V>
|
* @return Map.Entry<K, V>
|
||||||
*/
|
*/
|
||||||
protected synchronized Map.Entry<K, V> current() {
|
protected synchronized Map.Entry<K, V> current() {
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,15 +36,15 @@ import org.apache.commons.collections4.collection.UnmodifiableCollection;
|
||||||
* key however.
|
* key however.
|
||||||
* <p>
|
* <p>
|
||||||
* If trying to remove or clear the map, an UnsupportedOperationException is
|
* If trying to remove or clear the map, an UnsupportedOperationException is
|
||||||
* thrown. If trying to put a new mapping into the map, an
|
* thrown. If trying to put a new mapping into the map, an
|
||||||
* IllegalArgumentException is thrown. This is because the put method can
|
* IllegalArgumentException is thrown. This is because the put method can
|
||||||
* succeed if the mapping's key already exists in the map, so the put method
|
* succeed if the mapping's key already exists in the map, so the put method
|
||||||
* is not always unsupported.
|
* is not always unsupported.
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>Note that FixedSizeMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that FixedSizeMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -61,7 +61,7 @@ public class FixedSizeMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a fixed size map.
|
* Factory method to create a fixed size map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -75,7 +75,7 @@ public class FixedSizeMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +86,7 @@ public class FixedSizeMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -98,13 +98,13 @@ public class FixedSizeMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, V>) in.readObject(); // (1)
|
map = (Map<K, V>) in.readObject(); // (1)
|
||||||
|
|
|
@ -38,15 +38,15 @@ import org.apache.commons.collections4.collection.UnmodifiableCollection;
|
||||||
* key however.
|
* key however.
|
||||||
* <p>
|
* <p>
|
||||||
* If trying to remove or clear the map, an UnsupportedOperationException is
|
* If trying to remove or clear the map, an UnsupportedOperationException is
|
||||||
* thrown. If trying to put a new mapping into the map, an
|
* thrown. If trying to put a new mapping into the map, an
|
||||||
* IllegalArgumentException is thrown. This is because the put method can
|
* IllegalArgumentException is thrown. This is because the put method can
|
||||||
* succeed if the mapping's key already exists in the map, so the put method
|
* succeed if the mapping's key already exists in the map, so the put method
|
||||||
* is not always unsupported.
|
* is not always unsupported.
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>Note that FixedSizeSortedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that FixedSizeSortedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -63,7 +63,7 @@ public class FixedSizeSortedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a fixed size sorted map.
|
* Factory method to create a fixed size sorted map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -77,7 +77,7 @@ public class FixedSizeSortedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +87,7 @@ public class FixedSizeSortedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
protected SortedMap<K, V> getSortedMap() {
|
protected SortedMap<K, V> getSortedMap() {
|
||||||
|
@ -106,7 +106,7 @@ public class FixedSizeSortedMap<K, V>
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, V>) in.readObject(); // (1)
|
map = (Map<K, V>) in.readObject(); // (1)
|
||||||
|
|
|
@ -795,7 +795,7 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
|
||||||
* <p>
|
* <p>
|
||||||
* As a consequence, all subsequent call to {@link #getKey()},
|
* As a consequence, all subsequent call to {@link #getKey()},
|
||||||
* {@link #setValue(Object)} and {@link #getValue()} will fail.
|
* {@link #setValue(Object)} and {@link #getValue()} will fail.
|
||||||
*
|
*
|
||||||
* @param flag
|
* @param flag
|
||||||
*/
|
*/
|
||||||
void setRemoved(final boolean flag) {
|
void setRemoved(final boolean flag) {
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class LRUMap<K, V>
|
||||||
modCount++;
|
modCount++;
|
||||||
// remove
|
// remove
|
||||||
if(entry.before == null) {
|
if(entry.before == null) {
|
||||||
throw new IllegalStateException("Entry.before is null." +
|
throw new IllegalStateException("Entry.before is null." +
|
||||||
" Please check that your keys are immutable, and that you have used synchronization properly." +
|
" Please check that your keys are immutable, and that you have used synchronization properly." +
|
||||||
" If so, then please report this to dev@commons.apache.org as a bug.");
|
" If so, then please report this to dev@commons.apache.org as a bug.");
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,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.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException if an error occurs while writing to the stream
|
* @throws IOException if an error occurs while writing to the stream
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.apache.commons.collections4.functors.FactoryTransformer;
|
||||||
* <strong>Note that LazyMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that LazyMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -69,7 +69,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Map<K,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a lazily instantiated map.
|
* Factory method to create a lazily instantiated map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -83,7 +83,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Map<K,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a lazily instantiated map.
|
* Factory method to create a lazily instantiated map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -98,7 +98,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Map<K,
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param factory the factory to use, must not be null
|
* @param factory the factory to use, must not be null
|
||||||
* @throws IllegalArgumentException if map or factory is null
|
* @throws IllegalArgumentException if map or factory is null
|
||||||
|
@ -113,7 +113,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Map<K,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param factory the factory to use, must not be null
|
* @param factory the factory to use, must not be null
|
||||||
* @throws IllegalArgumentException if map or factory is null
|
* @throws IllegalArgumentException if map or factory is null
|
||||||
|
@ -129,7 +129,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Map<K,
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -141,7 +141,7 @@ public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements Map<K,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.apache.commons.collections4.Transformer;
|
||||||
* <strong>Note that LazySortedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that LazySortedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -63,7 +63,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a lazily instantiated sorted map.
|
* Factory method to create a lazily instantiated sorted map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -78,7 +78,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a lazily instantiated sorted map.
|
* Factory method to create a lazily instantiated sorted map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -94,7 +94,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param factory the factory to use, must not be null
|
* @param factory the factory to use, must not be null
|
||||||
* @throws IllegalArgumentException if map or factory is null
|
* @throws IllegalArgumentException if map or factory is null
|
||||||
|
@ -105,7 +105,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param factory the factory to use, must not be null
|
* @param factory the factory to use, must not be null
|
||||||
* @throws IllegalArgumentException if map or factory is null
|
* @throws IllegalArgumentException if map or factory is null
|
||||||
|
@ -117,7 +117,7 @@ public class LazySortedMap<K,V> extends LazyMap<K,V> implements SortedMap<K,V> {
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
protected SortedMap<K,V> getSortedMap() {
|
protected SortedMap<K,V> getSortedMap() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.commons.collections4.list.UnmodifiableList;
|
||||||
* A <code>Map</code> implementation that maintains the order of the entries.
|
* A <code>Map</code> implementation that maintains the order of the entries.
|
||||||
* In this implementation order is maintained by original insertion.
|
* In this implementation order is maintained by original insertion.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation improves on the JDK1.4 LinkedHashMap by adding the
|
* This implementation improves on the JDK1.4 LinkedHashMap by adding the
|
||||||
* {@link org.apache.commons.collections4.MapIterator MapIterator}
|
* {@link org.apache.commons.collections4.MapIterator MapIterator}
|
||||||
* functionality, additional convenience methods and allowing
|
* functionality, additional convenience methods and allowing
|
||||||
* bidirectional iteration. It also implements <code>OrderedMap</code>.
|
* bidirectional iteration. It also implements <code>OrderedMap</code>.
|
||||||
|
@ -54,7 +54,7 @@ import org.apache.commons.collections4.list.UnmodifiableList;
|
||||||
* <strong>Note that LinkedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that LinkedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
|
@ -64,7 +64,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
|
|
||||||
/** Serialisation version */
|
/** Serialisation version */
|
||||||
private static final long serialVersionUID = 9077234323521161066L;
|
private static final long serialVersionUID = 9077234323521161066L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new empty map with default size and load factor.
|
* Constructs a new empty map with default size and load factor.
|
||||||
*/
|
*/
|
||||||
|
@ -73,7 +73,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, empty map with the specified initial capacity.
|
* Constructs a new, empty map with the specified initial capacity.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @throws IllegalArgumentException if the initial capacity is negative
|
* @throws IllegalArgumentException if the initial capacity is negative
|
||||||
|
@ -84,7 +84,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, empty map with the specified initial capacity and
|
* Constructs a new, empty map with the specified initial capacity and
|
||||||
* load factor.
|
* load factor.
|
||||||
*
|
*
|
||||||
* @param initialCapacity the initial capacity
|
* @param initialCapacity the initial capacity
|
||||||
* @param loadFactor the load factor
|
* @param loadFactor the load factor
|
||||||
|
@ -115,7 +115,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
public LinkedMap<K, V> clone() {
|
public LinkedMap<K, V> clone() {
|
||||||
return (LinkedMap<K, V>) super.clone();
|
return (LinkedMap<K, V>) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*/
|
*/
|
||||||
|
@ -131,11 +131,11 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
doReadObject(in);
|
doReadObject(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the key at the specified index.
|
* Gets the key at the specified index.
|
||||||
*
|
*
|
||||||
* @param index the index to retrieve
|
* @param index the index to retrieve
|
||||||
* @return the key at the specified index
|
* @return the key at the specified index
|
||||||
* @throws IndexOutOfBoundsException if the index is invalid
|
* @throws IndexOutOfBoundsException if the index is invalid
|
||||||
|
@ -143,10 +143,10 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
public K get(final int index) {
|
public K get(final int index) {
|
||||||
return getEntry(index).getKey();
|
return getEntry(index).getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value at the specified index.
|
* Gets the value at the specified index.
|
||||||
*
|
*
|
||||||
* @param index the index to retrieve
|
* @param index the index to retrieve
|
||||||
* @return the value at the specified index
|
* @return the value at the specified index
|
||||||
* @throws IndexOutOfBoundsException if the index is invalid
|
* @throws IndexOutOfBoundsException if the index is invalid
|
||||||
|
@ -154,10 +154,10 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
public V getValue(final int index) {
|
public V getValue(final int index) {
|
||||||
return getEntry(index).getValue();
|
return getEntry(index).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index of the specified key.
|
* Gets the index of the specified key.
|
||||||
*
|
*
|
||||||
* @param key the key to find the index of
|
* @param key the key to find the index of
|
||||||
* @return the index, or -1 if not found
|
* @return the index, or -1 if not found
|
||||||
*/
|
*/
|
||||||
|
@ -197,7 +197,7 @@ public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements Serializ
|
||||||
* An alternative to this method is to use {@link #keySet()}.
|
* An alternative to this method is to use {@link #keySet()}.
|
||||||
*
|
*
|
||||||
* @see #keySet()
|
* @see #keySet()
|
||||||
* @return The ordered list of keys.
|
* @return The ordered list of keys.
|
||||||
*/
|
*/
|
||||||
public List<K> asList() {
|
public List<K> asList() {
|
||||||
return new LinkedMapList<K>(this);
|
return new LinkedMapList<K>(this);
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.apache.commons.collections4.list.UnmodifiableList;
|
||||||
* <strong>Note that ListOrderedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that ListOrderedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>Note that ListOrderedMap doesn't work with
|
* <strong>Note that ListOrderedMap doesn't work with
|
||||||
|
@ -89,7 +89,7 @@ public class ListOrderedMap<K, V>
|
||||||
* Factory method to create an ordered map.
|
* Factory method to create an ordered map.
|
||||||
* <p>
|
* <p>
|
||||||
* An <code>ArrayList</code> is used to retain order.
|
* An <code>ArrayList</code> is used to retain order.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -104,7 +104,7 @@ public class ListOrderedMap<K, V>
|
||||||
/**
|
/**
|
||||||
* Constructs a new empty <code>ListOrderedMap</code> that decorates
|
* Constructs a new empty <code>ListOrderedMap</code> that decorates
|
||||||
* a <code>HashMap</code>.
|
* a <code>HashMap</code>.
|
||||||
*
|
*
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
public ListOrderedMap() {
|
public ListOrderedMap() {
|
||||||
|
@ -113,7 +113,7 @@ public class ListOrderedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
|
@ -125,7 +125,7 @@ public class ListOrderedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -137,13 +137,13 @@ public class ListOrderedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, V>) in.readObject(); // (1)
|
map = (Map<K, V>) in.readObject(); // (1)
|
||||||
|
@ -181,11 +181,11 @@ public class ListOrderedMap<K, V>
|
||||||
}
|
}
|
||||||
return insertOrder.get(size() - 1);
|
return insertOrder.get(size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the next key to the one specified using insert order.
|
* Gets the next key to the one specified using insert order.
|
||||||
* This method performs a list search to find the key and is O(n).
|
* This method performs a list search to find the key and is O(n).
|
||||||
*
|
*
|
||||||
* @param key the key to find previous for
|
* @param key the key to find previous for
|
||||||
* @return the next key, null if no match or at start
|
* @return the next key, null if no match or at start
|
||||||
*/
|
*/
|
||||||
|
@ -200,7 +200,7 @@ public class ListOrderedMap<K, V>
|
||||||
/**
|
/**
|
||||||
* Gets the previous key to the one specified using insert order.
|
* Gets the previous key to the one specified using insert order.
|
||||||
* This method performs a list search to find the key and is O(n).
|
* This method performs a list search to find the key and is O(n).
|
||||||
*
|
*
|
||||||
* @param key the key to find previous for
|
* @param key the key to find previous for
|
||||||
* @return the previous key, null if no match or at start
|
* @return the previous key, null if no match or at start
|
||||||
*/
|
*/
|
||||||
|
@ -342,7 +342,7 @@ public class ListOrderedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Returns the Map as a string.
|
* Returns the Map as a string.
|
||||||
*
|
*
|
||||||
* @return the Map as a String
|
* @return the Map as a String
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -372,7 +372,7 @@ public class ListOrderedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the key at the specified index.
|
* Gets the key at the specified index.
|
||||||
*
|
*
|
||||||
* @param index the index to retrieve
|
* @param index the index to retrieve
|
||||||
* @return the key at the specified index
|
* @return the key at the specified index
|
||||||
* @throws IndexOutOfBoundsException if the index is invalid
|
* @throws IndexOutOfBoundsException if the index is invalid
|
||||||
|
@ -380,10 +380,10 @@ public class ListOrderedMap<K, V>
|
||||||
public K get(final int index) {
|
public K get(final int index) {
|
||||||
return insertOrder.get(index);
|
return insertOrder.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value at the specified index.
|
* Gets the value at the specified index.
|
||||||
*
|
*
|
||||||
* @param index the index to retrieve
|
* @param index the index to retrieve
|
||||||
* @return the key at the specified index
|
* @return the key at the specified index
|
||||||
* @throws IndexOutOfBoundsException if the index is invalid
|
* @throws IndexOutOfBoundsException if the index is invalid
|
||||||
|
@ -391,10 +391,10 @@ public class ListOrderedMap<K, V>
|
||||||
public V getValue(final int index) {
|
public V getValue(final int index) {
|
||||||
return get(insertOrder.get(index));
|
return get(insertOrder.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index of the specified key.
|
* Gets the index of the specified key.
|
||||||
*
|
*
|
||||||
* @param key the key to find the index of
|
* @param key the key to find the index of
|
||||||
* @return the index, or -1 if not found
|
* @return the index, or -1 if not found
|
||||||
*/
|
*/
|
||||||
|
@ -480,7 +480,7 @@ public class ListOrderedMap<K, V>
|
||||||
*
|
*
|
||||||
* @see #keyList()
|
* @see #keyList()
|
||||||
* @see #keySet()
|
* @see #keySet()
|
||||||
* @return The ordered list of keys.
|
* @return The ordered list of keys.
|
||||||
*/
|
*/
|
||||||
public List<K> asList() {
|
public List<K> asList() {
|
||||||
return keyList();
|
return keyList();
|
||||||
|
@ -571,7 +571,7 @@ public class ListOrderedMap<K, V>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
static class EntrySetView<K, V> extends AbstractSet<Map.Entry<K, V>> {
|
static class EntrySetView<K, V> extends AbstractSet<Map.Entry<K, V>> {
|
||||||
private final ListOrderedMap<K, V> parent;
|
private final ListOrderedMap<K, V> parent;
|
||||||
private final List<K> insertOrder;
|
private final List<K> insertOrder;
|
||||||
|
@ -589,7 +589,7 @@ public class ListOrderedMap<K, V>
|
||||||
}
|
}
|
||||||
return entrySet;
|
return entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return this.parent.size();
|
return this.parent.size();
|
||||||
|
@ -656,7 +656,7 @@ public class ListOrderedMap<K, V>
|
||||||
static class ListOrderedIterator<K, V> extends AbstractUntypedIteratorDecorator<K, Map.Entry<K, V>> {
|
static class ListOrderedIterator<K, V> extends AbstractUntypedIteratorDecorator<K, Map.Entry<K, V>> {
|
||||||
private final ListOrderedMap<K, V> parent;
|
private final ListOrderedMap<K, V> parent;
|
||||||
private K last = null;
|
private K last = null;
|
||||||
|
|
||||||
ListOrderedIterator(final ListOrderedMap<K, V> parent, final List<K> insertOrder) {
|
ListOrderedIterator(final ListOrderedMap<K, V> parent, final List<K> insertOrder) {
|
||||||
super(insertOrder.iterator());
|
super(insertOrder.iterator());
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
@ -716,7 +716,7 @@ public class ListOrderedMap<K, V>
|
||||||
readable = true;
|
readable = true;
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return iterator.hasPrevious();
|
return iterator.hasPrevious();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
return new MultiKeyMap<K, V>(map);
|
return new MultiKeyMap<K, V>(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructs a new MultiKeyMap that decorates a <code>HashedMap</code>.
|
* Constructs a new MultiKeyMap that decorates a <code>HashedMap</code>.
|
||||||
*/
|
*/
|
||||||
|
@ -126,7 +126,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the value mapped to the specified multi-key.
|
* Gets the value mapped to the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @return the mapped value, null if no match
|
* @return the mapped value, null if no match
|
||||||
|
@ -146,7 +146,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified multi-key.
|
* Checks whether the map contains the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @return true if the map contains the key
|
* @return true if the map contains the key
|
||||||
|
@ -166,7 +166,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the value against the specified multi-key.
|
* Stores the value against the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param value the value to store
|
* @param value the value to store
|
||||||
|
@ -190,7 +190,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified multi-key from this map.
|
* Removes the specified multi-key from this map.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @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
|
||||||
|
@ -214,7 +214,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hash code for the specified multi-key.
|
* Gets the hash code for the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @return the hash code
|
* @return the hash code
|
||||||
|
@ -236,7 +236,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the key equal to the combined key.
|
* Is the key equal to the combined key.
|
||||||
*
|
*
|
||||||
* @param entry the entry to compare to
|
* @param entry the entry to compare to
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
|
@ -254,7 +254,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the value mapped to the specified multi-key.
|
* Gets the value mapped to the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -275,7 +275,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified multi-key.
|
* Checks whether the map contains the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -296,7 +296,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the value against the specified multi-key.
|
* Stores the value against the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -321,7 +321,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified multi-key from this map.
|
* Removes the specified multi-key from this map.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -346,7 +346,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hash code for the specified multi-key.
|
* Gets the hash code for the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -372,7 +372,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the key equal to the combined key.
|
* Is the key equal to the combined key.
|
||||||
*
|
*
|
||||||
* @param entry the entry to compare to
|
* @param entry the entry to compare to
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
|
@ -392,7 +392,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the value mapped to the specified multi-key.
|
* Gets the value mapped to the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -414,7 +414,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified multi-key.
|
* Checks whether the map contains the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -436,7 +436,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the value against the specified multi-key.
|
* Stores the value against the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -462,7 +462,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified multi-key from this map.
|
* Removes the specified multi-key from this map.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -488,7 +488,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hash code for the specified multi-key.
|
* Gets the hash code for the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -518,7 +518,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the key equal to the combined key.
|
* Is the key equal to the combined key.
|
||||||
*
|
*
|
||||||
* @param entry the entry to compare to
|
* @param entry the entry to compare to
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
|
@ -540,7 +540,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the value mapped to the specified multi-key.
|
* Gets the value mapped to the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -563,7 +563,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified multi-key.
|
* Checks whether the map contains the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -587,7 +587,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the value against the specified multi-key.
|
* Stores the value against the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -614,7 +614,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified multi-key from this map.
|
* Removes the specified multi-key from this map.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -641,7 +641,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hash code for the specified multi-key.
|
* Gets the hash code for the specified multi-key.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -675,7 +675,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the key equal to the combined key.
|
* Is the key equal to the combined key.
|
||||||
*
|
*
|
||||||
* @param entry the entry to compare to
|
* @param entry the entry to compare to
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
|
@ -702,7 +702,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
* <p>
|
* <p>
|
||||||
* This method removes all the mappings where the <code>MultiKey</code>
|
* This method removes all the mappings where the <code>MultiKey</code>
|
||||||
* has one or more keys, and the first matches that specified.
|
* has one or more keys, and the first matches that specified.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @return true if any elements were removed
|
* @return true if any elements were removed
|
||||||
*/
|
*/
|
||||||
|
@ -725,7 +725,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
* <p>
|
* <p>
|
||||||
* This method removes all the mappings where the <code>MultiKey</code>
|
* This method removes all the mappings where the <code>MultiKey</code>
|
||||||
* has two or more keys, and the first two match those specified.
|
* has two or more keys, and the first two match those specified.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @return true if any elements were removed
|
* @return true if any elements were removed
|
||||||
|
@ -750,7 +750,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
* <p>
|
* <p>
|
||||||
* This method removes all the mappings where the <code>MultiKey</code>
|
* This method removes all the mappings where the <code>MultiKey</code>
|
||||||
* has three or more keys, and the first three match those specified.
|
* has three or more keys, and the first three match those specified.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -777,7 +777,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
* <p>
|
* <p>
|
||||||
* This method removes all the mappings where the <code>MultiKey</code>
|
* This method removes all the mappings where the <code>MultiKey</code>
|
||||||
* has four or more keys, and the first four match those specified.
|
* has four or more keys, and the first four match those specified.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param key3 the third key
|
* @param key3 the third key
|
||||||
|
@ -804,7 +804,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Check to ensure that input keys are valid MultiKey objects.
|
* Check to ensure that input keys are valid MultiKey objects.
|
||||||
*
|
*
|
||||||
* @param key the key to check
|
* @param key the key to check
|
||||||
*/
|
*/
|
||||||
protected void checkKey(final MultiKey<?> key) {
|
protected void checkKey(final MultiKey<?> key) {
|
||||||
|
@ -831,7 +831,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
/**
|
/**
|
||||||
* Puts the key and value into the map, where the key must be a non-null
|
* Puts the key and value into the map, where the key must be a non-null
|
||||||
* MultiKey object.
|
* MultiKey object.
|
||||||
*
|
*
|
||||||
* @param key the non-null MultiKey object
|
* @param key the non-null MultiKey object
|
||||||
* @param value the value to store
|
* @param value the value to store
|
||||||
* @return the previous value for the key
|
* @return the previous value for the key
|
||||||
|
@ -847,7 +847,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
/**
|
/**
|
||||||
* Copies all of the keys and values from the specified map to this map.
|
* Copies all of the keys and values from the specified map to this map.
|
||||||
* Each key must be non-null and a MultiKey object.
|
* Each key must be non-null and a MultiKey object.
|
||||||
*
|
*
|
||||||
* @param mapToCopy to this map
|
* @param mapToCopy to this map
|
||||||
* @throws NullPointerException if the mapToCopy or any key within is null
|
* @throws NullPointerException if the mapToCopy or any key within is null
|
||||||
* @throws ClassCastException if any key in mapToCopy is not a MultiKey
|
* @throws ClassCastException if any key in mapToCopy is not a MultiKey
|
||||||
|
@ -873,11 +873,11 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
protected AbstractHashedMap<MultiKey<? extends K>, V> decorated() {
|
protected AbstractHashedMap<MultiKey<? extends K>, V> decorated() {
|
||||||
return (AbstractHashedMap<MultiKey<? extends K>, V>) super.decorated();
|
return (AbstractHashedMap<MultiKey<? extends K>, V>) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@ -888,7 +888,7 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
|
@ -898,5 +898,5 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<MultiKey<? extends K>, V>) in.readObject();
|
map = (Map<MultiKey<? extends K>, V>) in.readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
@ -162,13 +162,13 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, Object>) in.readObject(); // (1)
|
map = (Map<K, Object>) in.readObject(); // (1)
|
||||||
|
@ -302,7 +302,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
||||||
* NOTE: the returned Entry objects will contain as value a {@link Collection}
|
* NOTE: the returned Entry objects will contain as value a {@link Collection}
|
||||||
* of all values that are mapped to the given key. To get a "flattened" version
|
* of all values that are mapped to the given key. To get a "flattened" version
|
||||||
* of all mappings contained in this map, use {@link #iterator()}.
|
* of all mappings contained in this map, use {@link #iterator()}.
|
||||||
*
|
*
|
||||||
* @see #iterator()
|
* @see #iterator()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -421,7 +421,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
|
||||||
public Iterator<Entry<K, V>> iterator() {
|
public Iterator<Entry<K, V>> iterator() {
|
||||||
final Collection<K> allKeys = new ArrayList<K>(keySet());
|
final Collection<K> allKeys = new ArrayList<K>(keySet());
|
||||||
final Iterator<K> keyIterator = allKeys.iterator();
|
final Iterator<K> keyIterator = allKeys.iterator();
|
||||||
|
|
||||||
return new LazyIteratorChain<Entry<K, V>>() {
|
return new LazyIteratorChain<Entry<K, V>>() {
|
||||||
@Override
|
@Override
|
||||||
protected Iterator<? extends Entry<K, V>> nextIterator(int count) {
|
protected Iterator<? extends Entry<K, V>> nextIterator(int count) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
* This class may throw exceptions when accessed by concurrent threads without
|
* This class may throw exceptions when accessed by concurrent threads without
|
||||||
* synchronization.
|
* synchronization.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param <K> the type of the keys in the map
|
* @param <K> the type of the keys in the map
|
||||||
* @param <V> the type of the values in the map
|
* @param <V> the type of the values in the map
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
@ -68,7 +68,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* A {@link org.apache.commons.collections4.map.PassiveExpiringMap.ExpirationPolicy ExpirationPolicy}
|
* A {@link org.apache.commons.collections4.map.PassiveExpiringMap.ExpirationPolicy ExpirationPolicy}
|
||||||
* that returns a expiration time that is a
|
* that returns a expiration time that is a
|
||||||
* constant about of time in the future from the current time.
|
* constant about of time in the future from the current time.
|
||||||
*
|
*
|
||||||
* @param <K> the type of the keys in the map
|
* @param <K> the type of the keys in the map
|
||||||
* @param <V> the type of the values in the map
|
* @param <V> the type of the values in the map
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
@ -96,7 +96,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* milliseconds. A negative time-to-live value indicates entries never
|
* milliseconds. A negative time-to-live value indicates entries never
|
||||||
* expire. A zero time-to-live value indicates entries expire (nearly)
|
* expire. A zero time-to-live value indicates entries expire (nearly)
|
||||||
* immediately.
|
* immediately.
|
||||||
*
|
*
|
||||||
* @param timeToLiveMillis the constant amount of time (in milliseconds)
|
* @param timeToLiveMillis the constant amount of time (in milliseconds)
|
||||||
* an entry is available before it expires. A negative value
|
* an entry is available before it expires. A negative value
|
||||||
* results in entries that NEVER expire. A zero value results in
|
* results in entries that NEVER expire. A zero value results in
|
||||||
|
@ -110,7 +110,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
/**
|
/**
|
||||||
* Construct a policy with the given time-to-live constant measured in
|
* Construct a policy with the given time-to-live constant measured in
|
||||||
* the given time unit of measure.
|
* the given time unit of measure.
|
||||||
*
|
*
|
||||||
* @param timeToLive the constant amount of time an entry is available
|
* @param timeToLive the constant amount of time an entry is available
|
||||||
* before it expires. A negative value results in entries that
|
* before it expires. A negative value results in entries that
|
||||||
* NEVER expire. A zero value results in entries that ALWAYS
|
* NEVER expire. A zero value results in entries that ALWAYS
|
||||||
|
@ -126,7 +126,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the expiration time for the given key-value entry.
|
* Determine the expiration time for the given key-value entry.
|
||||||
*
|
*
|
||||||
* @param key the key for the entry (ignored).
|
* @param key the key for the entry (ignored).
|
||||||
* @param value the value for the entry (ignored).
|
* @param value the value for the entry (ignored).
|
||||||
* @return if {@link #timeToLiveMillis} ≥ 0, an expiration time of
|
* @return if {@link #timeToLiveMillis} ≥ 0, an expiration time of
|
||||||
|
@ -155,7 +155,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A policy to determine the expiration time for key-value entries.
|
* A policy to determine the expiration time for key-value entries.
|
||||||
*
|
*
|
||||||
* @param <K> the key object type.
|
* @param <K> the key object type.
|
||||||
* @param <V> the value object type
|
* @param <V> the value object type
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
@ -166,7 +166,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the expiration time for the given key-value entry.
|
* Determine the expiration time for the given key-value entry.
|
||||||
*
|
*
|
||||||
* @param key the key for the entry.
|
* @param key the key for the entry.
|
||||||
* @param value the value for the entry.
|
* @param value the value for the entry.
|
||||||
* @return the expiration time value measured in milliseconds. A
|
* @return the expiration time value measured in milliseconds. A
|
||||||
|
@ -183,7 +183,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* the given time measured in the given units to the same time measured in
|
* the given time measured in the given units to the same time measured in
|
||||||
* milliseconds. If the parameters are invalid, an
|
* milliseconds. If the parameters are invalid, an
|
||||||
* {@link IllegalArgumentException} is thrown.
|
* {@link IllegalArgumentException} is thrown.
|
||||||
*
|
*
|
||||||
* @param timeToLive the constant amount of time an entry is available
|
* @param timeToLive the constant amount of time an entry is available
|
||||||
* before it expires. A negative value results in entries that NEVER
|
* before it expires. A negative value results in entries that NEVER
|
||||||
* expire. A zero value results in entries that ALWAYS expire.
|
* expire. A zero value results in entries that ALWAYS expire.
|
||||||
|
@ -216,7 +216,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
/**
|
/**
|
||||||
* Construct a map decorator using the given expiration policy to determine
|
* Construct a map decorator using the given expiration policy to determine
|
||||||
* expiration times.
|
* expiration times.
|
||||||
*
|
*
|
||||||
* @param expiringPolicy the policy used to determine expiration times of
|
* @param expiringPolicy the policy used to determine expiration times of
|
||||||
* entries as they are added.
|
* entries as they are added.
|
||||||
*/
|
*/
|
||||||
|
@ -229,7 +229,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* expiration policy to determine expiration times. If there are any
|
* expiration policy to determine expiration times. If there are any
|
||||||
* elements already in the map being decorated, they will NEVER expire
|
* elements already in the map being decorated, they will NEVER expire
|
||||||
* unless they are replaced.
|
* unless they are replaced.
|
||||||
*
|
*
|
||||||
* @param expiringPolicy the policy used to determine expiration times of
|
* @param expiringPolicy the policy used to determine expiration times of
|
||||||
* entries as they are added.
|
* entries as they are added.
|
||||||
* @param map the map to decorate, must not be null.
|
* @param map the map to decorate, must not be null.
|
||||||
|
@ -248,7 +248,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* Construct a map decorator that decorates the given map using the given
|
* Construct a map decorator that decorates the given map using the given
|
||||||
* time-to-live value measured in milliseconds to create and use a
|
* time-to-live value measured in milliseconds to create and use a
|
||||||
* {@link ConstantTimeToLiveExpirationPolicy} expiration policy.
|
* {@link ConstantTimeToLiveExpirationPolicy} expiration policy.
|
||||||
*
|
*
|
||||||
* @param timeToLiveMillis the constant amount of time (in milliseconds) an
|
* @param timeToLiveMillis the constant amount of time (in milliseconds) an
|
||||||
* entry is available before it expires. A negative value results in
|
* entry is available before it expires. A negative value results in
|
||||||
* entries that NEVER expire. A zero value results in entries that
|
* entries that NEVER expire. A zero value results in entries that
|
||||||
|
@ -265,7 +265,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* {@link ConstantTimeToLiveExpirationPolicy} expiration policy. If there
|
* {@link ConstantTimeToLiveExpirationPolicy} expiration policy. If there
|
||||||
* are any elements already in the map being decorated, they will NEVER
|
* are any elements already in the map being decorated, they will NEVER
|
||||||
* expire unless they are replaced.
|
* expire unless they are replaced.
|
||||||
*
|
*
|
||||||
* @param timeToLiveMillis the constant amount of time (in milliseconds) an
|
* @param timeToLiveMillis the constant amount of time (in milliseconds) an
|
||||||
* entry is available before it expires. A negative value results in
|
* entry is available before it expires. A negative value results in
|
||||||
* entries that NEVER expire. A zero value results in entries that
|
* entries that NEVER expire. A zero value results in entries that
|
||||||
|
@ -282,7 +282,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* Construct a map decorator using the given time-to-live value measured in
|
* Construct a map decorator using the given time-to-live value measured in
|
||||||
* the given time units of measure to create and use a
|
* the given time units of measure to create and use a
|
||||||
* {@link ConstantTimeToLiveExpirationPolicy} expiration policy.
|
* {@link ConstantTimeToLiveExpirationPolicy} expiration policy.
|
||||||
*
|
*
|
||||||
* @param timeToLive the constant amount of time an entry is available
|
* @param timeToLive the constant amount of time an entry is available
|
||||||
* before it expires. A negative value results in entries that NEVER
|
* before it expires. A negative value results in entries that NEVER
|
||||||
* expire. A zero value results in entries that ALWAYS expire.
|
* expire. A zero value results in entries that ALWAYS expire.
|
||||||
|
@ -301,7 +301,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* is used to determine expiration times. If there are any elements already
|
* is used to determine expiration times. If there are any elements already
|
||||||
* in the map being decorated, they will NEVER expire unless they are
|
* in the map being decorated, they will NEVER expire unless they are
|
||||||
* replaced.
|
* replaced.
|
||||||
*
|
*
|
||||||
* @param timeToLive the constant amount of time an entry is available
|
* @param timeToLive the constant amount of time an entry is available
|
||||||
* before it expires. A negative value results in entries that NEVER
|
* before it expires. A negative value results in entries that NEVER
|
||||||
* expire. A zero value results in entries that ALWAYS expire.
|
* expire. A zero value results in entries that ALWAYS expire.
|
||||||
|
@ -319,7 +319,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* Constructs a map decorator that decorates the given map and results in
|
* Constructs a map decorator that decorates the given map and results in
|
||||||
* entries NEVER expiring. If there are any elements already in the map
|
* entries NEVER expiring. If there are any elements already in the map
|
||||||
* being decorated, they also will NEVER expire.
|
* being decorated, they also will NEVER expire.
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null.
|
* @param map the map to decorate, must not be null.
|
||||||
* @throws IllegalArgumentException if the map is null.
|
* @throws IllegalArgumentException if the map is null.
|
||||||
*/
|
*/
|
||||||
|
@ -391,7 +391,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the given expiration time is less than <code>now</code>.
|
* Determines if the given expiration time is less than <code>now</code>.
|
||||||
*
|
*
|
||||||
* @param now the time in milliseconds used to compare against the
|
* @param now the time in milliseconds used to compare against the
|
||||||
* expiration time.
|
* expiration time.
|
||||||
* @param expirationTimeObject the expiration time value retrieved from
|
* @param expirationTimeObject the expiration time value retrieved from
|
||||||
|
@ -464,7 +464,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
* Removes all entries in the map whose expiration time is less than
|
* Removes all entries in the map whose expiration time is less than
|
||||||
* <code>now</code>. The exceptions are entries with negative expiration
|
* <code>now</code>. The exceptions are entries with negative expiration
|
||||||
* times; those entries are never removed.
|
* times; those entries are never removed.
|
||||||
*
|
*
|
||||||
* @see #isExpired(long, Long)
|
* @see #isExpired(long, Long)
|
||||||
*/
|
*/
|
||||||
private void removeAllExpired(final long now) {
|
private void removeAllExpired(final long now) {
|
||||||
|
@ -505,7 +505,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
|
@ -520,7 +520,7 @@ public class PassiveExpiringMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.commons.collections4.Predicate;
|
||||||
* <strong>Note that PredicatedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that PredicatedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -65,7 +65,7 @@ public class PredicatedMap<K, V>
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the list being decorated, they
|
* If there are any elements already in the list being decorated, they
|
||||||
* are validated.
|
* are validated.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -83,7 +83,7 @@ public class PredicatedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param keyPredicate the predicate to validate the keys, null means no check
|
* @param keyPredicate the predicate to validate the keys, null means no check
|
||||||
* @param valuePredicate the predicate to validate to values, null means no check
|
* @param valuePredicate the predicate to validate to values, null means no check
|
||||||
|
@ -94,7 +94,7 @@ public class PredicatedMap<K, V>
|
||||||
super(map);
|
super(map);
|
||||||
this.keyPredicate = keyPredicate;
|
this.keyPredicate = keyPredicate;
|
||||||
this.valuePredicate = valuePredicate;
|
this.valuePredicate = valuePredicate;
|
||||||
|
|
||||||
final Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
|
final Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
final Map.Entry<K, V> entry = it.next();
|
final Map.Entry<K, V> entry = it.next();
|
||||||
|
@ -105,7 +105,7 @@ public class PredicatedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -117,13 +117,13 @@ public class PredicatedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, V>) in.readObject(); // (1)
|
map = (Map<K, V>) in.readObject(); // (1)
|
||||||
|
@ -132,7 +132,7 @@ public class PredicatedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Validates a key value pair.
|
* Validates a key value pair.
|
||||||
*
|
*
|
||||||
* @param key the key to validate
|
* @param key the key to validate
|
||||||
* @param value the value to validate
|
* @param value the value to validate
|
||||||
* @throws IllegalArgumentException if invalid
|
* @throws IllegalArgumentException if invalid
|
||||||
|
@ -148,7 +148,7 @@ public class PredicatedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override to validate an object set into the map via <code>setValue</code>.
|
* Override to validate an object set into the map via <code>setValue</code>.
|
||||||
*
|
*
|
||||||
* @param value the value to validate
|
* @param value the value to validate
|
||||||
* @return the value itself
|
* @return the value itself
|
||||||
* @throws IllegalArgumentException if invalid
|
* @throws IllegalArgumentException if invalid
|
||||||
|
@ -164,7 +164,7 @@ public class PredicatedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override to only return true when there is a value transformer.
|
* Override to only return true when there is a value transformer.
|
||||||
*
|
*
|
||||||
* @return true if a value predicate is in use
|
* @return true if a value predicate is in use
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.commons.collections4.Predicate;
|
||||||
* <strong>Note that PredicatedSortedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that PredicatedSortedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -53,7 +53,7 @@ public class PredicatedSortedMap<K, V> extends PredicatedMap<K, V> implements So
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the list being decorated, they
|
* If there are any elements already in the list being decorated, they
|
||||||
* are validated.
|
* are validated.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -70,7 +70,7 @@ public class PredicatedSortedMap<K, V> extends PredicatedMap<K, V> implements So
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param keyPredicate the predicate to validate the keys, null means no check
|
* @param keyPredicate the predicate to validate the keys, null means no check
|
||||||
* @param valuePredicate the predicate to validate to values, null means no check
|
* @param valuePredicate the predicate to validate to values, null means no check
|
||||||
|
@ -84,7 +84,7 @@ public class PredicatedSortedMap<K, V> extends PredicatedMap<K, V> implements So
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
protected SortedMap<K, V> getSortedMap() {
|
protected SortedMap<K, V> getSortedMap() {
|
||||||
|
|
|
@ -50,7 +50,7 @@ import java.lang.ref.Reference;
|
||||||
* Attempting to add a null key or value to the map will raise a <code>NullPointerException</code>.
|
* Attempting to add a null key or value to the map will raise a <code>NullPointerException</code>.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation is not synchronized.
|
* This implementation is not synchronized.
|
||||||
* You can use {@link java.util.Collections#synchronizedMap} to
|
* You can use {@link java.util.Collections#synchronizedMap} to
|
||||||
* provide synchronized access to a <code>ReferenceIdentityMap</code>.
|
* provide synchronized access to a <code>ReferenceIdentityMap</code>.
|
||||||
* Remember that synchronization will not stop the garbage collector removing entries.
|
* Remember that synchronization will not stop the garbage collector removing entries.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -60,7 +60,7 @@ import java.lang.ref.Reference;
|
||||||
* <strong>Note that ReferenceIdentityMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that ReferenceIdentityMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
*
|
*
|
||||||
* @see java.lang.ref.Reference
|
* @see java.lang.ref.Reference
|
||||||
|
@ -87,8 +87,8 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* use the specified types of references.
|
* use the specified types of references.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
|
@ -104,15 +104,15 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* use the specified types of references.
|
* use the specified types of references.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param purgeValues should the value be automatically purged when the
|
* @param purgeValues should the value be automatically purged when the
|
||||||
* key is garbage collected
|
* key is garbage collected
|
||||||
*/
|
*/
|
||||||
public ReferenceIdentityMap(final ReferenceStrength keyType, final ReferenceStrength valueType,
|
public ReferenceIdentityMap(final ReferenceStrength keyType, final ReferenceStrength valueType,
|
||||||
final boolean purgeValues) {
|
final boolean purgeValues) {
|
||||||
|
@ -124,8 +124,8 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* specified reference types, load factor and initial capacity.
|
* specified reference types, load factor and initial capacity.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
|
@ -144,8 +144,8 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* specified reference types, load factor and initial capacity.
|
* specified reference types, load factor and initial capacity.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
|
@ -153,8 +153,8 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param capacity the initial capacity for the map
|
* @param capacity the initial capacity for the map
|
||||||
* @param loadFactor the load factor for the map
|
* @param loadFactor the load factor for the map
|
||||||
* @param purgeValues should the value be automatically purged when the
|
* @param purgeValues should the value be automatically purged when the
|
||||||
* key is garbage collected
|
* key is garbage collected
|
||||||
*/
|
*/
|
||||||
public ReferenceIdentityMap(final ReferenceStrength keyType, final ReferenceStrength valueType,
|
public ReferenceIdentityMap(final ReferenceStrength keyType, final ReferenceStrength valueType,
|
||||||
final int capacity, final float loadFactor, final boolean purgeValues) {
|
final int capacity, final float loadFactor, final boolean purgeValues) {
|
||||||
|
@ -166,7 +166,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* Gets the hash code for the key specified.
|
* Gets the hash code for the key specified.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation uses the identity hash code.
|
* This implementation uses the identity hash code.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
|
@ -179,7 +179,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* Gets the hash code for a MapEntry.
|
* Gets the hash code for a MapEntry.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation uses the identity hash code.
|
* This implementation uses the identity hash code.
|
||||||
*
|
*
|
||||||
* @param key the key to get a hash code for, may be null
|
* @param key the key to get a hash code for, may be null
|
||||||
* @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
|
||||||
|
@ -195,7 +195,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation converts the key from the entry to a real reference
|
* This implementation converts the key from the entry to a real reference
|
||||||
* before comparison and uses <code>==</code>.
|
* before comparison and uses <code>==</code>.
|
||||||
*
|
*
|
||||||
* @param key1 the first key to compare passed in from outside
|
* @param key1 the first key to compare passed in from outside
|
||||||
* @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
|
||||||
|
@ -210,7 +210,7 @@ public class ReferenceIdentityMap<K, V> extends AbstractReferenceMap<K, V> imple
|
||||||
* Compares two values for equals.
|
* Compares two values for equals.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation uses <code>==</code>.
|
* This implementation uses <code>==</code>.
|
||||||
*
|
*
|
||||||
* @param value1 the first value to compare passed in from outside
|
* @param value1 the first value to compare passed in from outside
|
||||||
* @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
|
||||||
|
|
|
@ -48,7 +48,7 @@ import java.io.Serializable;
|
||||||
* Attempting to add a null key or value to the map will raise a <code>NullPointerException</code>.
|
* Attempting to add a null key or value to the map will raise a <code>NullPointerException</code>.
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation is not synchronized.
|
* This implementation is not synchronized.
|
||||||
* You can use {@link java.util.Collections#synchronizedMap} to
|
* You can use {@link java.util.Collections#synchronizedMap} to
|
||||||
* provide synchronized access to a <code>ReferenceMap</code>.
|
* provide synchronized access to a <code>ReferenceMap</code>.
|
||||||
* Remember that synchronization will not stop the garbage collector removing entries.
|
* Remember that synchronization will not stop the garbage collector removing entries.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -58,7 +58,7 @@ import java.io.Serializable;
|
||||||
* <strong>Note that ReferenceMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that ReferenceMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedMap}. This class may throw
|
* using {@link java.util.Collections#synchronizedMap}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: As from Commons Collections 3.1 this map extends <code>AbstractReferenceMap</code>
|
* NOTE: As from Commons Collections 3.1 this map extends <code>AbstractReferenceMap</code>
|
||||||
|
@ -89,8 +89,8 @@ public class ReferenceMap<K, V> extends AbstractReferenceMap<K, V> implements Se
|
||||||
* use the specified types of references.
|
* use the specified types of references.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
|
@ -106,15 +106,15 @@ public class ReferenceMap<K, V> extends AbstractReferenceMap<K, V> implements Se
|
||||||
* use the specified types of references.
|
* use the specified types of references.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param purgeValues should the value be automatically purged when the
|
* @param purgeValues should the value be automatically purged when the
|
||||||
* key is garbage collected
|
* key is garbage collected
|
||||||
*/
|
*/
|
||||||
public ReferenceMap(final ReferenceStrength keyType, final ReferenceStrength valueType, final boolean purgeValues) {
|
public ReferenceMap(final ReferenceStrength keyType, final ReferenceStrength valueType, final boolean purgeValues) {
|
||||||
super(keyType, valueType, DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, purgeValues);
|
super(keyType, valueType, DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, purgeValues);
|
||||||
|
@ -126,8 +126,8 @@ public class ReferenceMap<K, V> extends AbstractReferenceMap<K, V> implements Se
|
||||||
* capacity.
|
* capacity.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
|
@ -147,8 +147,8 @@ public class ReferenceMap<K, V> extends AbstractReferenceMap<K, V> implements Se
|
||||||
* capacity.
|
* capacity.
|
||||||
*
|
*
|
||||||
* @param keyType the type of reference to use for keys;
|
* @param keyType the type of reference to use for keys;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
* {@link AbstractReferenceMap.ReferenceStrength#SOFT SOFT},
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param valueType the type of reference to use for values;
|
* @param valueType the type of reference to use for values;
|
||||||
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
* must be {@link AbstractReferenceMap.ReferenceStrength#HARD HARD},
|
||||||
|
@ -156,8 +156,8 @@ public class ReferenceMap<K, V> extends AbstractReferenceMap<K, V> implements Se
|
||||||
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
* {@link AbstractReferenceMap.ReferenceStrength#WEAK WEAK}
|
||||||
* @param capacity the initial capacity for the map
|
* @param capacity the initial capacity for the map
|
||||||
* @param loadFactor the load factor for the map
|
* @param loadFactor the load factor for the map
|
||||||
* @param purgeValues should the value be automatically purged when the
|
* @param purgeValues should the value be automatically purged when the
|
||||||
* key is garbage collected
|
* key is garbage collected
|
||||||
*/
|
*/
|
||||||
public ReferenceMap(final ReferenceStrength keyType, final ReferenceStrength valueType, final int capacity,
|
public ReferenceMap(final ReferenceStrength keyType, final ReferenceStrength valueType, final int capacity,
|
||||||
final float loadFactor, final boolean purgeValues) {
|
final float loadFactor, final boolean purgeValues) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.commons.collections4.keyvalue.TiedMapEntry;
|
||||||
* <p>
|
* <p>
|
||||||
* If trying to remove or clear the map, an UnsupportedOperationException is thrown.
|
* If trying to remove or clear the map, an UnsupportedOperationException is thrown.
|
||||||
* If trying to put a new mapping into the map, an IllegalArgumentException is thrown.
|
* If trying to put a new mapping into the map, an IllegalArgumentException is thrown.
|
||||||
* The put method will only suceed if the key specified is the same as the
|
* The put method will only suceed if the key specified is the same as the
|
||||||
* singleton key.
|
* singleton key.
|
||||||
* <p>
|
* <p>
|
||||||
* The key and value can be obtained by:
|
* The key and value can be obtained by:
|
||||||
|
@ -131,7 +131,7 @@ public class SingletonMap<K, V>
|
||||||
/**
|
/**
|
||||||
* Gets the key.
|
* Gets the key.
|
||||||
*
|
*
|
||||||
* @return the key
|
* @return the key
|
||||||
*/
|
*/
|
||||||
public K getKey() {
|
public K getKey() {
|
||||||
return key;
|
return key;
|
||||||
|
@ -171,7 +171,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum size of the map, always 1.
|
* Gets the maximum size of the map, always 1.
|
||||||
*
|
*
|
||||||
* @return 1 always
|
* @return 1 always
|
||||||
*/
|
*/
|
||||||
public int maxSize() {
|
public int maxSize() {
|
||||||
|
@ -182,7 +182,7 @@ public class SingletonMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the value mapped to the key specified.
|
* Gets the value mapped to the key specified.
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
* @return the mapped value, null if no match
|
* @return the mapped value, null if no match
|
||||||
*/
|
*/
|
||||||
|
@ -195,7 +195,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the size of the map, always 1.
|
* Gets the size of the map, always 1.
|
||||||
*
|
*
|
||||||
* @return the size of 1
|
* @return the size of 1
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
|
@ -204,7 +204,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map is currently empty, which it never is.
|
* Checks whether the map is currently empty, which it never is.
|
||||||
*
|
*
|
||||||
* @return false always
|
* @return false always
|
||||||
*/
|
*/
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
|
@ -214,7 +214,7 @@ public class SingletonMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified key.
|
* Checks whether the map contains the specified key.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
|
@ -224,7 +224,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the specified value.
|
* Checks whether the map contains the specified value.
|
||||||
*
|
*
|
||||||
* @param value the value to search for
|
* @param value the value to search for
|
||||||
* @return true if the map contains the key
|
* @return true if the map contains the key
|
||||||
*/
|
*/
|
||||||
|
@ -238,7 +238,7 @@ public class SingletonMap<K, V>
|
||||||
* <p>
|
* <p>
|
||||||
* An IllegalArgumentException is thrown if the key does not match as the map
|
* An IllegalArgumentException is thrown if the key does not match as the map
|
||||||
* is fixed size.
|
* is fixed size.
|
||||||
*
|
*
|
||||||
* @param key the key to set, must be the key of the map
|
* @param key the key to set, must be the key of the map
|
||||||
* @param value the value to set
|
* @param value the value to set
|
||||||
* @return the value previously mapped to this key, null if none
|
* @return the value previously mapped to this key, null if none
|
||||||
|
@ -257,7 +257,7 @@ public class SingletonMap<K, V>
|
||||||
* The map must be of size 0 or size 1.
|
* The map must be of size 0 or size 1.
|
||||||
* If it is size 1, the key must match the key of this map otherwise an
|
* If it is size 1, the key must match the key of this map otherwise an
|
||||||
* IllegalArgumentException is thrown.
|
* IllegalArgumentException is thrown.
|
||||||
*
|
*
|
||||||
* @param map the map to add, must be size 0 or 1, and the key must match
|
* @param map the map to add, must be size 0 or 1, and the key must match
|
||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
* @throws IllegalArgumentException if the key does not match
|
* @throws IllegalArgumentException if the key does not match
|
||||||
|
@ -276,10 +276,10 @@ public class SingletonMap<K, V>
|
||||||
throw new IllegalArgumentException("The map size must be 0 or 1");
|
throw new IllegalArgumentException("The map size must be 0 or 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsupported operation.
|
* Unsupported operation.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
* @throws UnsupportedOperationException always
|
* @throws UnsupportedOperationException always
|
||||||
|
@ -300,19 +300,19 @@ public class SingletonMap<K, V>
|
||||||
* Gets the entrySet view of the map.
|
* Gets the entrySet view of the map.
|
||||||
* Changes made via <code>setValue</code> affect this map.
|
* Changes made via <code>setValue</code> affect this map.
|
||||||
* To simply iterate through the entries, use {@link #mapIterator()}.
|
* To simply iterate through the entries, use {@link #mapIterator()}.
|
||||||
*
|
*
|
||||||
* @return the entrySet view
|
* @return the entrySet view
|
||||||
*/
|
*/
|
||||||
public Set<Map.Entry<K, V>> entrySet() {
|
public Set<Map.Entry<K, V>> entrySet() {
|
||||||
final Map.Entry<K, V> entry = new TiedMapEntry<K, V>(this, getKey());
|
final Map.Entry<K, V> entry = new TiedMapEntry<K, V>(this, getKey());
|
||||||
return Collections.singleton(entry);
|
return Collections.singleton(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the unmodifiable keySet view of the map.
|
* Gets the unmodifiable keySet view of the map.
|
||||||
* Changes made to the view affect this map.
|
* Changes made to the view affect this map.
|
||||||
* To simply iterate through the keys, use {@link #mapIterator()}.
|
* To simply iterate through the keys, use {@link #mapIterator()}.
|
||||||
*
|
*
|
||||||
* @return the keySet view
|
* @return the keySet view
|
||||||
*/
|
*/
|
||||||
public Set<K> keySet() {
|
public Set<K> keySet() {
|
||||||
|
@ -323,7 +323,7 @@ public class SingletonMap<K, V>
|
||||||
* Gets the unmodifiable values view of the map.
|
* Gets the unmodifiable values view of the map.
|
||||||
* Changes made to the view affect this map.
|
* Changes made to the view affect this map.
|
||||||
* To simply iterate through the values, use {@link #mapIterator()}.
|
* To simply iterate through the values, use {@link #mapIterator()}.
|
||||||
*
|
*
|
||||||
* @return the values view
|
* @return the values view
|
||||||
*/
|
*/
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
|
@ -339,7 +339,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the first (and only) key in the map.
|
* Gets the first (and only) key in the map.
|
||||||
*
|
*
|
||||||
* @return the key
|
* @return the key
|
||||||
*/
|
*/
|
||||||
public K firstKey() {
|
public K firstKey() {
|
||||||
|
@ -348,7 +348,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the last (and only) key in the map.
|
* Gets the last (and only) key in the map.
|
||||||
*
|
*
|
||||||
* @return the key
|
* @return the key
|
||||||
*/
|
*/
|
||||||
public K lastKey() {
|
public K lastKey() {
|
||||||
|
@ -357,7 +357,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the next key after the key specified, always null.
|
* Gets the next key after the key specified, always null.
|
||||||
*
|
*
|
||||||
* @param key the next key
|
* @param key the next key
|
||||||
* @return null always
|
* @return null always
|
||||||
*/
|
*/
|
||||||
|
@ -367,7 +367,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the previous key before the key specified, always null.
|
* Gets the previous key before the key specified, always null.
|
||||||
*
|
*
|
||||||
* @param key the next key
|
* @param key the next key
|
||||||
* @return null always
|
* @return null always
|
||||||
*/
|
*/
|
||||||
|
@ -378,7 +378,7 @@ public class SingletonMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Compares the specified key to the stored key.
|
* Compares the specified key to the stored key.
|
||||||
*
|
*
|
||||||
* @param key the key to compare
|
* @param key the key to compare
|
||||||
* @return true if equal
|
* @return true if equal
|
||||||
*/
|
*/
|
||||||
|
@ -388,7 +388,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the specified value to the stored value.
|
* Compares the specified value to the stored value.
|
||||||
*
|
*
|
||||||
* @param value the value to compare
|
* @param value the value to compare
|
||||||
* @return true if equal
|
* @return true if equal
|
||||||
*/
|
*/
|
||||||
|
@ -404,7 +404,7 @@ public class SingletonMap<K, V>
|
||||||
private final SingletonMap<K, V> parent;
|
private final SingletonMap<K, V> parent;
|
||||||
private boolean hasNext = true;
|
private boolean hasNext = true;
|
||||||
private boolean canGetSet = false;
|
private boolean canGetSet = false;
|
||||||
|
|
||||||
SingletonMapIterator(final SingletonMap<K, V> parent) {
|
SingletonMapIterator(final SingletonMap<K, V> parent) {
|
||||||
super();
|
super();
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
@ -459,11 +459,11 @@ public class SingletonMap<K, V>
|
||||||
}
|
}
|
||||||
return parent.setValue(value);
|
return parent.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
hasNext = true;
|
hasNext = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
|
@ -472,7 +472,7 @@ public class SingletonMap<K, V>
|
||||||
return "Iterator[" + getKey() + "=" + getValue() + "]";
|
return "Iterator[" + getKey() + "=" + getValue() + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Values implementation for the SingletonMap.
|
* Values implementation for the SingletonMap.
|
||||||
* This class is needed as values is a view that must update as the map updates.
|
* This class is needed as values is a view that must update as the map updates.
|
||||||
|
@ -507,7 +507,7 @@ public class SingletonMap<K, V>
|
||||||
return new SingletonIterator<V>(parent.getValue(), false);
|
return new SingletonIterator<V>(parent.getValue(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Clones the map without cloning the key or value.
|
* Clones the map without cloning the key or value.
|
||||||
|
@ -526,7 +526,7 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares this map with another.
|
* Compares this map with another.
|
||||||
*
|
*
|
||||||
* @param obj the object to compare to
|
* @param obj the object to compare to
|
||||||
* @return true if equal
|
* @return true if equal
|
||||||
*/
|
*/
|
||||||
|
@ -548,18 +548,18 @@ public class SingletonMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the standard Map hashCode.
|
* Gets the standard Map hashCode.
|
||||||
*
|
*
|
||||||
* @return the hash code defined in the Map interface
|
* @return the hash code defined in the Map interface
|
||||||
*/
|
*/
|
||||||
@Override
|
@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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map as a String.
|
* Gets the map as a String.
|
||||||
*
|
*
|
||||||
* @return a string version of the map
|
* @return a string version of the map
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.collections4.KeyValue;
|
||||||
* A StaticBucketMap is an efficient, thread-safe implementation of
|
* A StaticBucketMap is an efficient, thread-safe implementation of
|
||||||
* <code>java.util.Map</code> that performs well in in a highly
|
* <code>java.util.Map</code> that performs well in in a highly
|
||||||
* thread-contentious environment. The map supports very efficient
|
* thread-contentious environment. The map supports very efficient
|
||||||
* {@link #get(Object) get}, {@link #put(Object,Object) put},
|
* {@link #get(Object) get}, {@link #put(Object,Object) put},
|
||||||
* {@link #remove(Object) remove} and {@link #containsKey(Object) containsKey}
|
* {@link #remove(Object) remove} and {@link #containsKey(Object) containsKey}
|
||||||
* operations, assuming (approximate) uniform hashing and
|
* operations, assuming (approximate) uniform hashing and
|
||||||
* that the number of entries does not exceed the number of buckets. If the
|
* that the number of entries does not exceed the number of buckets. If the
|
||||||
|
@ -40,16 +40,16 @@ import org.apache.commons.collections4.KeyValue;
|
||||||
* scenario that is proportional to the number of elements in the map
|
* scenario that is proportional to the number of elements in the map
|
||||||
* (<i>O(n)</i>).<p>
|
* (<i>O(n)</i>).<p>
|
||||||
*
|
*
|
||||||
* Each bucket in the hash table has its own monitor, so two threads can
|
* Each bucket in the hash table has its own monitor, so two threads can
|
||||||
* safely operate on the map at the same time, often without incurring any
|
* safely operate on the map at the same time, often without incurring any
|
||||||
* monitor contention. This means that you don't have to wrap instances
|
* monitor contention. This means that you don't have to wrap instances
|
||||||
* of this class with {@link java.util.Collections#synchronizedMap(Map)};
|
* of this class with {@link java.util.Collections#synchronizedMap(Map)};
|
||||||
* instances are already thread-safe. Unfortunately, however, this means
|
* instances are already thread-safe. Unfortunately, however, this means
|
||||||
* that this map implementation behaves in ways you may find disconcerting.
|
* that this map implementation behaves in ways you may find disconcerting.
|
||||||
* Bulk operations, such as {@link #putAll(Map) putAll} or the
|
* Bulk operations, such as {@link #putAll(Map) putAll} or the
|
||||||
* {@link Collection#retainAll(Collection) retainAll} operation in collection
|
* {@link Collection#retainAll(Collection) retainAll} operation in collection
|
||||||
* views, are <i>not</i> atomic. If two threads are simultaneously
|
* views, are <i>not</i> atomic. If two threads are simultaneously
|
||||||
* executing
|
* executing
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* staticBucketMapInstance.putAll(map);
|
* staticBucketMapInstance.putAll(map);
|
||||||
|
@ -62,23 +62,23 @@ import org.apache.commons.collections4.KeyValue;
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* then the results are generally random. Those two statement could cancel
|
* then the results are generally random. Those two statement could cancel
|
||||||
* each other out, leaving <code>staticBucketMapInstance</code> essentially
|
* each other out, leaving <code>staticBucketMapInstance</code> essentially
|
||||||
* unchanged, or they could leave some random subset of <code>map</code> in
|
* unchanged, or they could leave some random subset of <code>map</code> in
|
||||||
* <code>staticBucketMapInstance</code>.<p>
|
* <code>staticBucketMapInstance</code>.<p>
|
||||||
*
|
*
|
||||||
* Also, much like an encyclopedia, the results of {@link #size()} and
|
* Also, much like an encyclopedia, the results of {@link #size()} and
|
||||||
* {@link #isEmpty()} are out-of-date as soon as they are produced.<p>
|
* {@link #isEmpty()} are out-of-date as soon as they are produced.<p>
|
||||||
*
|
*
|
||||||
* The iterators returned by the collection views of this class are <i>not</i>
|
* The iterators returned by the collection views of this class are <i>not</i>
|
||||||
* fail-fast. They will <i>never</i> raise a
|
* fail-fast. They will <i>never</i> raise a
|
||||||
* {@link java.util.ConcurrentModificationException}. Keys and values
|
* {@link java.util.ConcurrentModificationException}. Keys and values
|
||||||
* added to the map after the iterator is created do not necessarily appear
|
* added to the map after the iterator is created do not necessarily appear
|
||||||
* during iteration. Similarly, the iterator does not necessarily fail to
|
* during iteration. Similarly, the iterator does not necessarily fail to
|
||||||
* return keys and values that were removed after the iterator was created.<p>
|
* return keys and values that were removed after the iterator was created.<p>
|
||||||
*
|
*
|
||||||
* Finally, unlike {@link java.util.HashMap}-style implementations, this
|
* Finally, unlike {@link java.util.HashMap}-style implementations, this
|
||||||
* class <i>never</i> rehashes the map. The number of buckets is fixed
|
* class <i>never</i> rehashes the map. The number of buckets is fixed
|
||||||
* at construction time and never altered. Performance may degrade if
|
* at construction time and never altered. Performance may degrade if
|
||||||
* you do not allocate enough buckets upfront.<p>
|
* you do not allocate enough buckets upfront.<p>
|
||||||
*
|
*
|
||||||
* The {@link #atomic(Runnable)} method is provided to allow atomic iterations
|
* The {@link #atomic(Runnable)} method is provided to allow atomic iterations
|
||||||
|
@ -86,8 +86,8 @@ import org.apache.commons.collections4.KeyValue;
|
||||||
* will basically result in a map that's slower than an ordinary synchronized
|
* will basically result in a map that's slower than an ordinary synchronized
|
||||||
* {@link java.util.HashMap}.
|
* {@link java.util.HashMap}.
|
||||||
*
|
*
|
||||||
* Use this class if you do not require reliable bulk operations and
|
* Use this class if you do not require reliable bulk operations and
|
||||||
* iterations, or if you can make your own guarantees about how bulk
|
* iterations, or if you can make your own guarantees about how bulk
|
||||||
* operations will affect the map.<p>
|
* operations will affect the map.<p>
|
||||||
*
|
*
|
||||||
* @since 3.0 (previously in main package v2.1)
|
* @since 3.0 (previously in main package v2.1)
|
||||||
|
@ -168,7 +168,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
/**
|
/**
|
||||||
* Gets the current size of the map.
|
* Gets the current size of the map.
|
||||||
* The value is computed fresh each time the method is called.
|
* The value is computed fresh each time the method is called.
|
||||||
*
|
*
|
||||||
* @return the current size
|
* @return the current size
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
|
@ -184,7 +184,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the size is currently zero.
|
* Checks if the size is currently zero.
|
||||||
*
|
*
|
||||||
* @return true if empty
|
* @return true if empty
|
||||||
*/
|
*/
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
|
@ -193,7 +193,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value associated with the key.
|
* Gets the value associated with the key.
|
||||||
*
|
*
|
||||||
* @param key the key to retrieve
|
* @param key the key to retrieve
|
||||||
* @return the associated value
|
* @return the associated value
|
||||||
*/
|
*/
|
||||||
|
@ -216,7 +216,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the map contains the specified key.
|
* Checks if the map contains the specified key.
|
||||||
*
|
*
|
||||||
* @param key the key to check
|
* @param key the key to check
|
||||||
* @return true if found
|
* @return true if found
|
||||||
*/
|
*/
|
||||||
|
@ -239,7 +239,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the map contains the specified value.
|
* Checks if the map contains the specified value.
|
||||||
*
|
*
|
||||||
* @param value the value to check
|
* @param value the value to check
|
||||||
* @return true if found
|
* @return true if found
|
||||||
*/
|
*/
|
||||||
|
@ -263,7 +263,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Puts a new key value mapping into the map.
|
* Puts a new key value mapping into the map.
|
||||||
*
|
*
|
||||||
* @param key the key to use
|
* @param key the key to use
|
||||||
* @param value the value to use
|
* @param value the value to use
|
||||||
* @return the previous mapping for the key
|
* @return the previous mapping for the key
|
||||||
|
@ -309,7 +309,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified key from the map.
|
* Removes the specified key from the map.
|
||||||
*
|
*
|
||||||
* @param key the key to remove
|
* @param key the key to remove
|
||||||
* @return the previous value at this key
|
* @return the previous value at this key
|
||||||
*/
|
*/
|
||||||
|
@ -344,7 +344,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the key set.
|
* Gets the key set.
|
||||||
*
|
*
|
||||||
* @return the key set
|
* @return the key set
|
||||||
*/
|
*/
|
||||||
public Set<K> keySet() {
|
public Set<K> keySet() {
|
||||||
|
@ -353,7 +353,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the values.
|
* Gets the values.
|
||||||
*
|
*
|
||||||
* @return the values
|
* @return the values
|
||||||
*/
|
*/
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
|
@ -362,7 +362,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the entry set.
|
* Gets the entry set.
|
||||||
*
|
*
|
||||||
* @return the entry set
|
* @return the entry set
|
||||||
*/
|
*/
|
||||||
public Set<Map.Entry<K, V>> entrySet() {
|
public Set<Map.Entry<K, V>> entrySet() {
|
||||||
|
@ -373,7 +373,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
/**
|
/**
|
||||||
* Puts all the entries from the specified map into this map.
|
* Puts all the entries from the specified map into this map.
|
||||||
* This operation is <b>not atomic</b> and may have undesired effects.
|
* This operation is <b>not atomic</b> and may have undesired effects.
|
||||||
*
|
*
|
||||||
* @param map the map of entries to add
|
* @param map the map of entries to add
|
||||||
*/
|
*/
|
||||||
public void putAll(final Map<? extends K, ? extends V> map) {
|
public void putAll(final Map<? extends K, ? extends V> map) {
|
||||||
|
@ -397,7 +397,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares this map to another, as per the Map specification.
|
* Compares this map to another, as per the Map specification.
|
||||||
*
|
*
|
||||||
* @param obj the object to compare to
|
* @param obj the object to compare to
|
||||||
* @return true if equal
|
* @return true if equal
|
||||||
*/
|
*/
|
||||||
|
@ -415,7 +415,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hash code, as per the Map specification.
|
* Gets the hash code, as per the Map specification.
|
||||||
*
|
*
|
||||||
* @return the hash code
|
* @return the hash code
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -667,7 +667,7 @@ public final class StaticBucketMap<K, V> extends AbstractIterableMap<K, V> {
|
||||||
/**
|
/**
|
||||||
* Prevents any operations from occurring on this map while the
|
* Prevents any operations from occurring on this map while the
|
||||||
* given {@link Runnable} executes. This method can be used, for
|
* given {@link Runnable} executes. This method can be used, for
|
||||||
* instance, to execute a bulk operation atomically:
|
* instance, to execute a bulk operation atomically:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* staticBucketMapInstance.atomic(new Runnable() {
|
* staticBucketMapInstance.atomic(new Runnable() {
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class TransformedMap<K, V>
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, V>) in.readObject(); // (1)
|
map = (Map<K, V>) in.readObject(); // (1)
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.commons.collections4.Transformer;
|
||||||
* <strong>Note that TransformedSortedMap is not synchronized and is not thread-safe.</strong>
|
* <strong>Note that TransformedSortedMap is not synchronized and is not thread-safe.</strong>
|
||||||
* If you wish to use this map from multiple threads concurrently, you must use
|
* If you wish to use this map from multiple threads concurrently, you must use
|
||||||
* appropriate synchronization. The simplest approach is to wrap this map
|
* appropriate synchronization. The simplest approach is to wrap this map
|
||||||
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
* using {@link java.util.Collections#synchronizedSortedMap}. This class may throw
|
||||||
* exceptions when accessed by concurrent threads without synchronization.
|
* exceptions when accessed by concurrent threads without synchronization.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
|
@ -47,13 +47,13 @@ public class TransformedSortedMap<K, V>
|
||||||
|
|
||||||
/** Serialization version */
|
/** Serialization version */
|
||||||
private static final long serialVersionUID = -8751771676410385778L;
|
private static final long serialVersionUID = -8751771676410385778L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a transforming sorted map.
|
* Factory method to create a transforming sorted map.
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the map being decorated, they are NOT transformed.
|
* If there are any elements already in the map being decorated, they are NOT transformed.
|
||||||
* Contrast this with {@link #transformedSortedMap(SortedMap, Transformer, Transformer)}.
|
* Contrast this with {@link #transformedSortedMap(SortedMap, Transformer, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -75,7 +75,7 @@ public class TransformedSortedMap<K, V>
|
||||||
* If there are any elements already in the map being decorated, they
|
* If there are any elements already in the map being decorated, they
|
||||||
* will be transformed by this method.
|
* will be transformed by this method.
|
||||||
* Contrast this with {@link #transformingSortedMap(SortedMap, Transformer, Transformer)}.
|
* Contrast this with {@link #transformingSortedMap(SortedMap, Transformer, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -105,7 +105,7 @@ public class TransformedSortedMap<K, V>
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the collection being decorated, they
|
* If there are any elements already in the collection being decorated, they
|
||||||
* are NOT transformed.</p>
|
* are NOT transformed.</p>
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @param keyTransformer the predicate to validate the keys, null means no transformation
|
* @param keyTransformer the predicate to validate the keys, null means no transformation
|
||||||
* @param valueTransformer the predicate to validate to values, null means no transformation
|
* @param valueTransformer the predicate to validate to values, null means no transformation
|
||||||
|
@ -120,7 +120,7 @@ public class TransformedSortedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
* @return the decorated map
|
* @return the decorated map
|
||||||
*/
|
*/
|
||||||
protected SortedMap<K, V> getSortedMap() {
|
protected SortedMap<K, V> getSortedMap() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.collections4.keyvalue.AbstractMapEntryDecorator;
|
||||||
/**
|
/**
|
||||||
* Decorates a map entry <code>Set</code> to ensure it can't be altered.
|
* Decorates a map entry <code>Set</code> to ensure it can't be altered.
|
||||||
* <p>
|
* <p>
|
||||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -43,7 +43,7 @@ public final class UnmodifiableEntrySet<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create an unmodifiable set of Map Entry objects.
|
* Factory method to create an unmodifiable set of Map Entry objects.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param set the set to decorate, must not be null
|
* @param set the set to decorate, must not be null
|
||||||
|
@ -60,7 +60,7 @@ public final class UnmodifiableEntrySet<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param set the set to decorate, must not be null
|
* @param set the set to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if set is null
|
* @throws IllegalArgumentException if set is null
|
||||||
*/
|
*/
|
||||||
|
@ -104,7 +104,7 @@ public final class UnmodifiableEntrySet<K, V>
|
||||||
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
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
@ -114,7 +114,7 @@ public final class UnmodifiableEntrySet<K, V>
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T[] toArray(final T[] array) {
|
public <T> T[] toArray(final T[] array) {
|
||||||
|
@ -141,7 +141,7 @@ public final class UnmodifiableEntrySet<K, V>
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Implementation of an entry set iterator.
|
* Implementation of an entry set iterator.
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.commons.collections4.iterators.UnmodifiableMapIterator;
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
* <p>
|
* <p>
|
||||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -51,7 +51,7 @@ public final class UnmodifiableMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create an unmodifiable map.
|
* Factory method to create an unmodifiable map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -68,7 +68,7 @@ public final class UnmodifiableMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +79,7 @@ public final class UnmodifiableMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -91,7 +91,7 @@ public final class UnmodifiableMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator;
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
* <p>
|
* <p>
|
||||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -49,7 +49,7 @@ public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecora
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create an unmodifiable sorted map.
|
* Factory method to create an unmodifiable sorted map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -66,7 +66,7 @@ public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecora
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
|
@ -77,7 +77,7 @@ public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecora
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -89,13 +89,13 @@ public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecora
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
@SuppressWarnings("unchecked") // (1) should only fail if input stream is incorrect
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
map = (Map<K, V>) in.readObject(); // (1)
|
map = (Map<K, V>) in.readObject(); // (1)
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.commons.collections4.collection.UnmodifiableCollection;
|
||||||
* <p>
|
* <p>
|
||||||
* This class is Serializable from Commons Collections 3.1.
|
* This class is Serializable from Commons Collections 3.1.
|
||||||
* <p>
|
* <p>
|
||||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -49,7 +49,7 @@ public final class UnmodifiableSortedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create an unmodifiable sorted map.
|
* Factory method to create an unmodifiable sorted map.
|
||||||
*
|
*
|
||||||
* @param <K> the key type
|
* @param <K> the key type
|
||||||
* @param <V> the value type
|
* @param <V> the value type
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
|
@ -66,18 +66,18 @@ public final class UnmodifiableSortedMap<K, V>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor that wraps (not copies).
|
* Constructor that wraps (not copies).
|
||||||
*
|
*
|
||||||
* @param map the map to decorate, must not be null
|
* @param map the map to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
private UnmodifiableSortedMap(final SortedMap<K, V> map) {
|
private UnmodifiableSortedMap(final SortedMap<K, V> map) {
|
||||||
super(map);
|
super(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
*
|
*
|
||||||
* @param out the output stream
|
* @param out the output stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -89,7 +89,7 @@ public final class UnmodifiableSortedMap<K, V>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
|
|
Loading…
Reference in New Issue