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,TextFileSystemViewCrudMapAdapter
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 classCrudMapAdapter.Immutable<Key,Value>ACrudMapAdapterfor an immutable map.static classCrudMapAdapter.SetLike<Value>
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intcomputeSize()Gets the number of values associated with a key.voiddelete(Key key)Removes the mapping for the given key.Iterable<Key>enumerateCandidateKeys()Enumerates all keys for which a mapping may be present.Valueget(Key key)Gets the value for the given key.default booleanisEmpty()Checks whether any keys are associated with a value.voidset(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 keyand 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. Returnsnullwhen no value is available for the key.- Parameters:
key- Key to access.- Returns:
- The value associated with the key, or
nullwhen 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 keyand checks if any key is associated with a value.- Returns:
trueif no keys are associated with a value.
-
-