Top Description Constructors Methods
org.pcollections

public abstract Class AbstractUnmodifiableMap<K, V>

extends AbstractMap<K, V>
Class Inheritance
Known Direct Subclasses
org.pcollections.HashPMap, org.pcollections.IntTreePMap, org.pcollections.OrderedPMap, org.pcollections.TreePMap
Type Parameters
<K>
the type of keys maintained by this map
<V>
the type of mapped values
Imports
java.util.AbstractMap, .Map, java.util.function.BiFunction, .Function

A subclass of AbstractMap that overrides the various mutator methods to mark them as deprecated and unconditionally throw UnsupportedOperationException.
Author
Ran Ari-Gur
Since
3.2.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides java.util.AbstractMap.clear.

Implements java.util.Map.clear.

Deprecated Unsupported operation.

Removes all of the mappings from this map (optional operation).

public V
compute(final K
key with which the specified value is to be associated
k
,
final BiFunction<? super K, ? super V, ? extends V>
the remapping function to compute a value
function
)

Overrides default java.util.Map.compute.

Deprecated Unsupported operation.

Attempts to compute a mapping for the specified key and its current mapped value, or null if there is no current mapping (optional operation).

public V
computeIfAbsent(final K
key with which the specified value is to be associated
k
,
final Function<? super K, ? extends V>
the mapping function to compute a value
function
)

Overrides default java.util.Map.computeIfAbsent.

Deprecated Unsupported operation.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null (optional operation).

public V
computeIfPresent(final K
key with which the specified value is to be associated
k
,
final BiFunction<? super K, ? super V, ? extends V>
the remapping function to compute a value
function
)

Overrides default java.util.Map.computeIfPresent.

Deprecated Unsupported operation.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value (optional operation).

public V
merge(final K
key with which the resulting value is to be associated
k
,
final V
the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
v
,
final BiFunction<? super V, ? super V, ? extends V>
the remapping function to recompute a value if present
function
)

Overrides default java.util.Map.merge.

Deprecated Unsupported operation.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value (optional operation).

public V
put(final K
key with which the specified value is to be associated
k
,
final V
value to be associated with the specified key
v
)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Deprecated Unsupported operation.

Associates the specified value with the specified key in this map (optional operation).

public void
putAll(final Map<? extends K, ? extends V>
mappings to be stored in this map
map
)

Overrides java.util.AbstractMap.putAll.

Implements java.util.Map.putAll.

Deprecated Unsupported operation.

Copies all of the mappings from the specified map to this map (optional operation).

public V
putIfAbsent(final K
key with which the specified value is to be associated
k
,
final V
value to be associated with the specified key
v
)

Overrides default java.util.Map.putIfAbsent.

Deprecated Unsupported operation.

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value (optional operation).

public V
remove(final Object
key whose mapping is to be removed from the map
o
)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Deprecated Unsupported operation.

Removes the mapping for a key from this map if it is present (optional operation).

public V
replace(final K
key with which the specified value is associated
k
,
final V
value to be associated with the specified key
v
)

Overrides default java.util.Map.replace.

Deprecated Unsupported operation.

Replaces the entry for the specified key only if it is currently mapped to some value (optional operation).

public void
replaceAll(final BiFunction<? super K, ? super V, ? extends V>
the function to apply to each entry
function
)

Overrides default java.util.Map.replaceAll.

Deprecated Unsupported operation.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception (optional operation).

Inherited from java.util.AbstractMap:
clonecontainsKeycontainsValueentrySetequalsgethashCodeisEmptykeySetsizetoStringvalues

Constructor Detail

AbstractUnmodifiableMapback to summary
public AbstractUnmodifiableMap()

Method Detail

clearback to summary
public void clear()

Overrides java.util.AbstractMap.clear.

Implements java.util.Map.clear.

Doc from java.util.AbstractMap.clear.

Deprecated

Unsupported operation.

Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
computeback to summary
public V compute(final K k, final BiFunction<? super K, ? super V, ? extends V> function)

Overrides default java.util.Map.compute.

Doc from java.util.Map.compute.

Deprecated

Unsupported operation.

Attempts to compute a mapping for the specified key and its current mapped value, or null if there is no current mapping (optional operation). For example, to either create or append a String msg to a value mapping:

 map.compute(key, (k, v) -> (v == null) ? msg : v.concat(msg))
(Method merge() is often simpler to use for such purposes.)

If the remapping function returns null, the mapping is removed (or remains absent if initially absent). If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

The remapping function should not modify this map during computation.

Parameters
k:K

key with which the specified value is to be associated

function:BiFunction<? super K, ? super V, ? extends V>

the remapping function to compute a value

Returns:V

the new value associated with the specified key, or null if none

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
computeIfAbsentback to summary
public V computeIfAbsent(final K k, final Function<? super K, ? extends V> function)

Overrides default java.util.Map.computeIfAbsent.

Doc from java.util.Map.computeIfAbsent.

Deprecated

Unsupported operation.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null (optional operation).

If the mapping function returns null, no mapping is recorded. If the mapping function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded. The most common usage is to construct a new object serving as an initial mapped value or memoized result, as in:

 map.computeIfAbsent(key, k -> new Value(f(k)));

Or to implement a multi-value map, Map<K,Collection<V>>, supporting multiple values per key:

 map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);

The mapping function should not modify this map during computation.

Parameters
k:K

key with which the specified value is to be associated

function:Function<? super K, ? extends V>

the mapping function to compute a value

Returns:V

the current (existing or computed) value associated with the specified key, or null if the computed value is null

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
computeIfPresentback to summary
public V computeIfPresent(final K k, final BiFunction<? super K, ? super V, ? extends V> function)

Overrides default java.util.Map.computeIfPresent.

Doc from java.util.Map.computeIfPresent.

Deprecated

Unsupported operation.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value (optional operation).

If the remapping function returns null, the mapping is removed. If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

The remapping function should not modify this map during computation.

Parameters
k:K

key with which the specified value is to be associated

function:BiFunction<? super K, ? super V, ? extends V>

the remapping function to compute a value

Returns:V

the new value associated with the specified key, or null if none

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
mergeback to summary
public V merge(final K k, final V v, final BiFunction<? super V, ? super V, ? extends V> function)

Overrides default java.util.Map.merge.

Doc from java.util.Map.merge.

Deprecated

Unsupported operation.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value (optional operation). Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null. This method may be of use when combining multiple mapped values for a key. For example, to either create or append a String msg to a value mapping:

 map.merge(key, msg, String::concat)

If the remapping function returns null, the mapping is removed. If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

The remapping function should not modify this map during computation.

Parameters
k:K

key with which the resulting value is to be associated

v:V

the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key

function:BiFunction<? super V, ? super V, ? extends V>

the remapping function to recompute a value if present

Returns:V

the new value associated with the specified key, or null if no value is associated with the key

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
putback to summary
public V put(final K k, final V v)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Doc from java.util.AbstractMap.put.

Deprecated

Unsupported operation.

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters
k:K

Doc from java.util.Map.put.

key with which the specified value is to be associated

v:V

Doc from java.util.Map.put.

value to be associated with the specified key

Returns:V

Doc from java.util.Map.put.

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
putAllback to summary
public void putAll(final Map<? extends K, ? extends V> map)

Overrides java.util.AbstractMap.putAll.

Implements java.util.Map.putAll.

Doc from java.util.AbstractMap.putAll.

Deprecated

Unsupported operation.

Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress. If the specified map has a defined encounter order, processing of its mappings generally occurs in that order.

Parameters
map:Map<? extends K, ? extends V>

Doc from java.util.Map.putAll.

mappings to be stored in this map

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
putIfAbsentback to summary
public V putIfAbsent(final K k, final V v)

Overrides default java.util.Map.putIfAbsent.

Doc from java.util.Map.putIfAbsent.

Deprecated

Unsupported operation.

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value (optional operation).

Parameters
k:K

key with which the specified value is to be associated

v:V

value to be associated with the specified key

Returns:V

the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
removeback to summary
public V remove(final Object o)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Doc from java.util.AbstractMap.remove.

Deprecated

Unsupported operation.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters
o:Object

Doc from java.util.Map.remove.

key whose mapping is to be removed from the map

Returns:V

Doc from java.util.Map.remove.

the previous value associated with key, or null if there was no mapping for key.

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
replaceback to summary
public V replace(final K k, final V v)

Overrides default java.util.Map.replace.

Doc from java.util.Map.replace.

Deprecated

Unsupported operation.

Replaces the entry for the specified key only if it is currently mapped to some value (optional operation).

Parameters
k:K

key with which the specified value is associated

v:V

value to be associated with the specified key

Returns:V

the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always
replaceAllback to summary
public void replaceAll(final BiFunction<? super K, ? super V, ? extends V> function)

Overrides default java.util.Map.replaceAll.

Doc from java.util.Map.replaceAll.

Deprecated

Unsupported operation.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception (optional operation). Exceptions thrown by the function are relayed to the caller.

Parameters
function:BiFunction<? super K, ? super V, ? extends V>

the function to apply to each entry

Annotations
@Deprecated
@Override
Exceptions
UnsupportedOperationException:
always