Interface Registry<K,V>

Type Parameters:
K - the key type
V - the value type

@AvailableSince("1.0") public sealed interface Registry<K,V>
A generic registry for mapping keys to values.
Since:
1.0
  • Field Details

  • Method Details

    • isRegistered

      @AvailableSince("1.0") boolean isRegistered(K key)
      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

      @AvailableSince("1.0") void register(K key, V value)
      Registers a key-value pair in this registry.
      Parameters:
      key - the key to register
      value - the value to register
    • getOrThrow

      @NotNull @AvailableSince("1.0") V getOrThrow(K key) throws IllegalArgumentException
      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

      @NotNull @AvailableSince("1.0") @NotNull Optional<V> get(K key)
      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

      @AvailableSince("1.0") Set<K> keySet()
      Gets all keys registered in this registry.
      Returns:
      a set of all registered keys
    • values

      @AvailableSince("1.0") Collection<V> values()
      Gets all values registered in this registry.
      Returns:
      a collection of all registered values