K
- The 'key' typeV
- The 'value' typepublic abstract class Mapping<K,V> extends Object
get(Object)
is invoked.
Consequently, in contrast with Map
, it has no specific size()
, and thus no entrySet()
, keySet()
and values()
set.
Also the modifying operations (put
, putAll
, remove
and clear
) are all missing, because a Mapping
is not changed
by "putting" key-value-pairs into it.
Actually Map
should extend Mapping
, but it doesn't - thus there are the asMap()
and
Mappings.fromMap(Map)
helper methods.
The relationship between Mapping
and Map
is very much like that between Predicate
and
Collection
.
When using this type in a variable, parameter or field declaration, never write:
Mapping<key-type, value-type>
, but always:
Mapping<? super key-type, ? extends value-type>
That way many type conversions are possible which otherwise aren't.
Constructor and Description |
---|
Mapping() |
Modifier and Type | Method and Description |
---|---|
Map<K,V> |
asMap()
Returns a proxy
Map for a Mapping where all methods declared by Map but not by
Mapping throw an UnsupportedOperationException . |
abstract boolean |
containsKey(Object key) |
abstract V |
get(Object key) |
public abstract boolean containsKey(@Nullable Object key)
Map.containsKey(Object)
@Nullable public abstract V get(@Nullable Object key)
Map.get(Object)
Copyright © 2018 Arno Unkrig. All rights reserved.