Class AbstractRegistry<R extends RegistryKey,T>

java.lang.Object
ovh.mythmc.social.api.util.registry.AbstractRegistry<R,T>
All Implemented Interfaces:
Iterable<T>, Registry<R,T>
Direct Known Subclasses:
AbstractRegistry.Identified, AbstractRegistry.Namespaced

public abstract class AbstractRegistry<R extends RegistryKey,T> extends Object implements Registry<R,T>
  • Constructor Details

    • AbstractRegistry

      public AbstractRegistry()
  • Method Details

    • iterator

      @NotNull public @NotNull Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<R extends RegistryKey>
    • register

      public void register(@NotNull R registryKey, @NotNull T value)
      Description copied from interface: Registry
      Registers a value to the registry, associating it with the given registry key.
      Specified by:
      register in interface Registry<R extends RegistryKey,T>
      Parameters:
      registryKey - the key to associate with the value.
      value - the value to register.
    • unregister

      @Nullable public T unregister(@NotNull R registryKey)
      Description copied from interface: Registry
      Unregisters a value from the registry, removing it associated with the given registry key.
      Specified by:
      unregister in interface Registry<R extends RegistryKey,T>
      Parameters:
      registryKey - the key whose associated value should be removed.
      Returns:
      the removed value, or null if no value was associated with the key.
    • containsKey

      public boolean containsKey(@NotNull R registryKey)
      Description copied from interface: Registry
      Checks if a value exists in the registry for the given registry key.
      Specified by:
      containsKey in interface Registry<R extends RegistryKey,T>
      Parameters:
      registryKey - the key to check.
      Returns:
      true if the key exists in the registry, false otherwise.
    • containsValue

      public boolean containsValue(@NotNull T value)
      Description copied from interface: Registry
      Checks if a given value exists in the registry.
      Specified by:
      containsValue in interface Registry<R extends RegistryKey,T>
      Parameters:
      value - the value to check.
      Returns:
      true if the value exists in the registry, false otherwise.
    • value

      @NotNull public @NotNull Optional<T> value(@NotNull R registryKey)
      Description copied from interface: Registry
      Retrieves the value associated with the given registry key, wrapped in an Optional.
      Specified by:
      value in interface Registry<R extends RegistryKey,T>
      Parameters:
      registryKey - the key whose associated value to retrieve.
      Returns:
      an Optional containing the associated value, or an empty Optional if no value is associated with the key.
    • valuesByType

      @NotNull public <V extends T> @NotNull List<V> valuesByType(@NotNull @NotNull Class<V> type)
      Description copied from interface: Registry
      Retrieves a list of values of a specific type associated with the registry.
      Specified by:
      valuesByType in interface Registry<R extends RegistryKey,T>
      Type Parameters:
      V - the type of the values to retrieve.
      Parameters:
      type - the class type of the values to retrieve.
      Returns:
      a list of values that match the given type.
    • keys

      @NotNull public @NotNull Set<R> keys()
      Description copied from interface: Registry
      Retrieves a set of all the registry keys in the registry.
      Specified by:
      keys in interface Registry<R extends RegistryKey,T>
      Returns:
      a Set of registry keys.
    • values

      @NotNull public @NotNull List<T> values()
      Description copied from interface: Registry
      Retrieves a list of all the values in the registry.
      Specified by:
      values in interface Registry<R extends RegistryKey,T>
      Returns:
      a List of all values in the registry.