Package dev.mintychochip.mint
Interface Registry<K,V>
- Type Parameters:
K- the key typeV- the value type
@AvailableSince("1.0")
public sealed interface Registry<K,V>
A generic registry for mapping keys to values.
- Since:
- 1.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionGets a value by key, returning an Optional.getOrThrow(K key) Gets a value by key, throwing an exception if not found.booleanisRegistered(K key) Checks if a key is registered in this registry.keySet()Gets all keys registered in this registry.voidRegisters a key-value pair in this registry.values()Gets all values registered in this registry.
-
Field Details
-
COLOR_ROLE
-
PREFERENCE_TYPE
-
-
Method Details
-
isRegistered
Checks if a key is registered in this registry.- Parameters:
key- the key to check- Returns:
- true if the key is registered, false otherwise
-
register
Registers a key-value pair in this registry.- Parameters:
key- the key to registervalue- the value to register
-
getOrThrow
Gets a value by key, throwing an exception if not found.- Parameters:
key- the key to look up- Returns:
- the value associated with the key
- Throws:
IllegalArgumentException- if the key is not registered
-
get
Gets a value by key, returning an Optional.- Parameters:
key- the key to look up- Returns:
- an Optional containing the value if found, or empty if not
-
keySet
Gets all keys registered in this registry.- Returns:
- a set of all registered keys
-
values
Gets all values registered in this registry.- Returns:
- a collection of all registered values
-