Package me.a8kj.util

Interface Registry<T>

Type Parameters:
T - the type of objects maintained in this registry.
All Known Implementing Classes:
ConfigRegistry

public interface Registry<T>
A generic contract for object registration and management. This interface defines the standard operations for a central repository, allowing objects of type T to be stored and retrieved using unique string keys.
Since:
0.1
Author:
a8kj7sea
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull Iterable<Pair<String,T>>
    Provides an iterable collection of all currently registered entries.
    get(@NonNull String key)
    Retrieves the object associated with the given key.
    boolean
    hasEntry(@NonNull String key)
    Checks if the registry contains an entry for the specified key.
    void
    register(@NonNull String key, T value)
    Registers a value associated with a specific key.
    void
    unregister(@NonNull String key)
    Removes an entry from the registry using its key.
  • Method Details

    • register

      void register(@NonNull @NonNull String key, @NonNull T value)
      Registers a value associated with a specific key.
      Parameters:
      key - the unique identifier for the entry. Must not be null.
      value - the object to be registered. Must not be null.
    • unregister

      void unregister(@NonNull @NonNull String key)
      Removes an entry from the registry using its key.
      Parameters:
      key - the unique identifier of the entry to be removed. Must not be null.
    • hasEntry

      boolean hasEntry(@NonNull @NonNull String key)
      Checks if the registry contains an entry for the specified key.
      Parameters:
      key - the identifier to check. Must not be null.
      Returns:
      true if an entry exists, false otherwise.
    • get

      @NonNull T get(@NonNull @NonNull String key)
      Retrieves the object associated with the given key.
      Parameters:
      key - the unique identifier of the entry. Must not be null.
      Returns:
      the registered object of type T.
    • entries

      @NonNull @NonNull Iterable<Pair<String,T>> entries()
      Provides an iterable collection of all currently registered entries. Each entry is returned as a Pair containing the key and the object.
      Returns:
      an iterable of key-value pairs.