- Type Parameters:
K
- The type of the key.V
- The type of the value which relates to a key.
- All Known Subinterfaces:
CanonicalMap
,CanonicalMap.CanonicalMapBuilder
,CanonicalMap.MutableCanonicalMap
,ClassStructMap
,ClassStructMap.ClassStructMapBuilder
,ClassStructMap.MutableClassStructMap
,Dictionary<K,
,V> Dictionary.MutableDictionary<K,
,V> Dictionary.MutableDictionary.DictionaryBuilder<K,
,V, B> InterOperableMap<T>
,InterOperableMap.InterOperableMapBuilder<T>
,InterOperableMap.MutableInterOperableMap<T>
,Keys.MutableKeys<K,
,V> Keys.MutableValues<K,
,V> PathMap<T>
,PathMap.MutablePathMap<T>
,PathMap.PathMapBuilder<T>
,SimpleTypeMap
,SimpleTypeMap.MutableSimpleTypeMap
,SimpleTypeMap.SimpleTypeMapBuilder
- All Known Implementing Classes:
CanonicalMapBuilderImpl
,CanonicalMapImpl
,ClassStructMapBuilderImpl
,ClassStructMapImpl
,PathMapBuilderImpl
,PathMapImpl
,SimpleTypeMapBuilderImpl
,SimpleTypeMapImpl
public interface Keys<K,V>
This interface provides functionality for working with keys.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object aKey) Tests whether there is an element with the given key.boolean
containsValue
(Object aValue) This method is defined for the sake ofMap
conformity.Retrieves the element assigned to the given key.default V
Retrieves the element assigned to the given key or the provided default value if there is no such value for the given key.keySet()
Retrieves a collection containing all the keys found in the elements of this collection.default V
Retrieves the element assigned to the given key.values()
Returns aCollection
view of the values related to the contained keys.
-
Method Details
-
containsKey
Tests whether there is an element with the given key.- Parameters:
aKey
- The key for which to test whether there is an element.- Returns:
- True in case there is an element for the given key.
-
containsValue
This method is defined for the sake ofMap
conformity. Tests whether the provided value has a key assigned.- Parameters:
aValue
- The value to test if a key references this value.- Returns:
- True in case the given value is referenced by a key.
-
get
Retrieves the element assigned to the given key.- Parameters:
aKey
- The key for which to get the element.- Returns:
- The value for the key in question or null if there is none such value.
-
getOr
Retrieves the element assigned to the given key or the provided default value if there is no such value for the given key.- Parameters:
aKey
- The key for which to get the element.aDefaultValue
- The default value in case there is no such value for the given key.- Returns:
- The value for the key in question or the default value if there is none such value.
-
use
Retrieves the element assigned to the given key. In case the given key does not exist, then anKeyNotFoundException
is thrown.- Parameters:
aKey
- The key for which to get the element.- Returns:
- The value assigned to the given key.
- Throws:
KeyNotFoundException
- thrown in case this instance does not contain the requested element (no such key found in the collection).
-
keySet
Retrieves a collection containing all the keys found in the elements of this collection.- Returns:
- A collection with key objects being the keys of all elements in this collection.
-
values
Collection<V> values()Returns aCollection
view of the values related to the contained keys.- Returns:
- A
Collection
view of the values related to the contained keys.
-