Package de.xima.fc.common.collection
Interface CrudMapAdapter<Key,Value>
-
- Type Parameters:
Key
- Type of the keysValue
- Type of the values associated with the keys.
- All Known Implementing Classes:
CrudMapAdapter.Immutable
,CrudMapAdapter.SetLike
,CrudMapAdapter.SetLike.Immutable
public interface CrudMapAdapter<Key,Value>
CRUD = create, read, update, and deleteA data adapter with operations for adding, reading, updating, and deleting values indexed by a key.
- Since:
- 8.2.0
- Author:
- XIMA MEDIA GmbH
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CrudMapAdapter.Immutable<Key,Value>
ACrudMapAdapter
for an immutable map.static class
CrudMapAdapter.SetLike<Value>
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default int
computeSize()
Gets the number of values associated with a key.void
delete(Key key)
Removes the mapping for the given key.Iterable<Key>
enumerateCandidateKeys()
Enumerates all keys for which a mapping may be present.Value
get(Key key)
Gets the value for the given key.default boolean
isEmpty()
Checks whether any keys are associated with a value.void
set(Key key, Value value)
Associates a value with the given key.
-
-
-
Method Detail
-
computeSize
default int computeSize()
Gets the number of values associated with a key.The default implementation iterates through each
candidate key
and checks which keys are associated with a value.- Returns:
- The number of existing key-value pairs.
-
delete
void delete(Key key)
Removes the mapping for the given key.- Parameters:
key
- Key to disassociate with any values.
-
enumerateCandidateKeys
Iterable<Key> enumerateCandidateKeys()
Enumerates all keys for which a mapping may be present. May include additional keys for which no value is available, seecomputeSize()
. Must NOT contain duplicate keys.- Returns:
- A set with all potential keys.
-
get
Value get(Key key)
Gets the value for the given key. Returnsnull
when no value is available for the key.- Parameters:
key
- Key to access.- Returns:
- The value associated with the key, or
null
when no value is associated with the key.
-
isEmpty
default boolean isEmpty()
Checks whether any keys are associated with a value.The default implementation iterates through each
candidate key
and checks if any key is associated with a value.- Returns:
true
if no keys are associated with a value.
-
-