Package com.xpdustry.distributor.api.key
Interface KeyContainer
- All Known Subinterfaces:
DynamicKeyContainer,MutableKeyContainer
public interface KeyContainer
A generic container for key-value pairs. Like a
Map<String, Object>, but with type safety.-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanReturns whether the registry contains a value associated with the givenkey.static KeyContainerempty()Returns an empty container.static KeyContainerfrom(KeyContainer container) Returns an immutable view of the givencontainer.default <V> @Nullable VReturns the value associated with the givenkey, ornullif it does not exist.getKeys()Returns an immutable view of the keys in the registry.<V> Optional<V>getOptional(Key<V> key) Returns the value associated with the givenkey.default <V> VgetRequired(Key<V> key) Returns the value associated with the givenkeyor throws a NPE if it's missing.
-
Method Details
-
empty
Returns an empty container.- Returns:
- the empty container
-
from
Returns an immutable view of the givencontainer.- Parameters:
container- the container- Returns:
- the new container
-
getOptional
Returns the value associated with the givenkey.- Type Parameters:
V- the type of the value- Parameters:
key- the key- Returns:
- the value
-
getRequired
Returns the value associated with the givenkeyor throws a NPE if it's missing.- Type Parameters:
V- the type of the value- Parameters:
key- the key- Returns:
- the value
- Throws:
NullPointerException- if the value is missing
-
get
Returns the value associated with the givenkey, ornullif it does not exist.- Type Parameters:
V- the type of the value- Parameters:
key- the key- Returns:
- the value, or
nullif it does not exist
-
contains
Returns whether the registry contains a value associated with the givenkey.- Parameters:
key- the key- Returns:
trueif the value exists, orfalseif it does not
-
getKeys
Returns an immutable view of the keys in the registry.
-