Package me.datafox.dfxengine.handles.api
Interface HandleMap<T>
- Type Parameters:
T- the type of mapped values
- All Known Subinterfaces:
ValueMap
- All Known Implementing Classes:
DelegatedValueMap,HashHandleMap,TreeHandleMap
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) Returnstrueif this map contains a mapping for the specified key.booleancontainsKeys(Collection<?> keys) Returnstrueif this map contains a mapping for all the specified keys.Returns the value to which the specified key is mapped, ornullif none is present.Returns all values mapped to keys containing the specified tag.getByTags(Collection<?> tags) Returns all values mapped to keys containing the specified tag.getOrDefault(Object key, T defaultValue) Returnstrueif this map contains a mapping for the specified key, or the specified default value if none is present.getSpace()Returns theSpaceassociated with this map.Associates the specified value with the specified key in this map.voidCopies all of the mappings from the specified map to this map.putHandled(T value) putIfAbsent(Handle key, T value) Associates the specified key with the specified value and returnsnullif the specified key is not already associated with a value, otherwise returns the current value.Removes the mapping for a key from this map if it is present.booleanRemoves the entry for the specified key only if it is currently mapped to the specified value.Returns an unmodifiable version of this map.Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, equals, forEach, hashCode, isEmpty, keySet, merge, replace, replace, replaceAll, size, values
-
Method Details
-
getSpace
Space getSpace()Returns theSpaceassociated with this map. AllHandlekeys present in this map must be associated with this space.- Returns:
Spaceassociated with this map
-
containsKeys
Returnstrueif this map contains a mapping for all the specified keys. The keys may either beHandlesor theirStringids.- Parameters:
keys-Handlekeys or theirStringids whose presence in this map is to be tested- Returns:
trueif this map contains a mapping for all the specified keys- Throws:
ClassCastException- if any of the keys are of an inappropriate type for this mapNullPointerException- if any of the keys isnull
-
putHandled
Associates aHandledvalue with its associatedHandle. If the map previously contained a mapping for the key, the old value is replaced by the specified value. TheHandlekey must be present in this map's associatedSpace.- Parameters:
value-Handledvalue to be associated with its associatedHandlekey- Returns:
- the previous value associated with the key, or
nullif none was present - Throws:
UnsupportedOperationException- if theputoperation is not supported by this mapClassCastException- if the value does not implementHandledNullPointerException- if the specified value isnullIllegalArgumentException- if the value's associatedHandleis not present in this map's associatedSpace
-
unmodifiable
Returns an unmodifiable version of this map. All changes made to the original map will be reflected in the returned one.- Returns:
- unmodifiable version of this map
-
getByTag
Returns all values mapped to keys containing the specified tag. The tag may be aHandleor itsStringid.- Parameters:
tag- tagHandleor itsStringid- Returns:
- all values mapped to keys containing the specified tag
- Throws:
ClassCastException- if the tag is not aHandleor aStringNullPointerException- if the tag isnullIllegalArgumentException- if theHandleis not a tag
-
getByTags
Returns all values mapped to keys containing the specified tag. The tags may beHandlesor theirStringids.- Parameters:
tags- tagHandlesor theirStringids- Returns:
- all values mapped to keys containing the specified tags
- Throws:
ClassCastException- if any of the tags are notHandlesor aStringsNullPointerException- if any of the tags isnullIllegalArgumentException- if any of theHandlesis not a tag
-
containsKey
Returnstrueif this map contains a mapping for the specified key. The key may either be aHandleor itsStringid.- Specified by:
containsKeyin interfaceMap<Handle,T> - Parameters:
key-Handlekey or itsStringid whose presence in this map is to be tested- Returns:
trueif this map contains a mapping for the specified key- Throws:
ClassCastException- if the key is of an inappropriate type for this mapNullPointerException- if the specified key isnull
-
get
Returns the value to which the specified key is mapped, ornullif none is present. The key may either be aHandleor itsStringid.- Specified by:
getin interfaceMap<Handle,T> - Parameters:
key-Handlekey or itsStringid whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif none is present - Throws:
ClassCastException- if the key is of not aHandleor aStringNullPointerException- if the specified key isnull
-
put
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value. TheHandlekey must be present in this map's associatedSpace.- Specified by:
putin interfaceMap<Handle,T> - Parameters:
key-Handlekey with which the specified value is to be associated withvalue- value to be associated with the specified key- Returns:
- the previous value associated with the key, or
nullif none was present - Throws:
UnsupportedOperationException- if theputoperation is not supported by this mapNullPointerException- if the specified key or value isnullIllegalArgumentException- if theHandlekey is not present in this map's associatedSpace
-
remove
Removes the mapping for a key from this map if it is present. Returns the value to which this map previously associated the key, ornullif the map contained no mapping for the key. The key may either be aHandleor itsStringid.- Specified by:
removein interfaceMap<Handle,T> - Parameters:
key-Handlekey or itsStringid whose mapping is to be removed from this map- Returns:
- the previous value associated with
key, ornullif none was present - Throws:
UnsupportedOperationException- if theremoveoperation is not supported by this mapClassCastException- if the key is of not aHandleor aStringNullPointerException- if the specified key isnull
-
putAll
Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of callingput(Handle, Object)on this map once for each mapping from key to value in the specified map. AllHandlekeys must be present in this map's associatedSpace.- Specified by:
putAllin interfaceMap<Handle,T> - Parameters:
map- mappings to be stored in this map- Throws:
UnsupportedOperationException- if theputAlloperation is not supported by this mapNullPointerException- if the specified map isnullor containsnullkeys or valuesIllegalArgumentException- if the specified map contains aHandlekey that is not present in this map's associatedSpace
-
getOrDefault
Returnstrueif this map contains a mapping for the specified key, or the specified default value if none is present. The key may either be aHandleor itsStringid.- Specified by:
getOrDefaultin interfaceMap<Handle,T> - Parameters:
key-Handlekey or itsStringid whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- the value to which the specified key is mapped, or the specified default value if this map contains no mapping for the key
- Throws:
ClassCastException- if the key is of not aHandleor aStringNullPointerException- if the specified key isnull
-
putIfAbsent
Associates the specified key with the specified value and returnsnullif the specified key is not already associated with a value, otherwise returns the current value.- Specified by:
putIfAbsentin interfaceMap<Handle,T> - Parameters:
key-Handlekey with which the specified value is to be associated withvalue- value to be associated with the specified key- Returns:
- the previous value associated with the specified key, or
nullif there was no mapping for the key - Throws:
UnsupportedOperationException- if theputoperation is not supported by this mapNullPointerException- if the specified key or value isnullIllegalArgumentException- if theHandlekey is not present in this map's associatedSpace
-
remove
Removes the entry for the specified key only if it is currently mapped to the specified value. The key may either be aHandleor itsStringid.- Specified by:
removein interfaceMap<Handle,T> - Parameters:
key-Handlekey or itsStringid with which the specified value is associatedvalue- value expected to be associated with the specified key- Returns:
trueif the value was removed- Throws:
UnsupportedOperationException- if theremoveoperation is not supported by this mapClassCastException- if the key is of not aHandleor aStringNullPointerException- if the specified key or value isnull
-