Interface Registry<T extends RegistryKey<K>,K>

All Known Implementing Classes:
AbstractRegistry, FrozenRegistry, NewFrozenRegistry, WriteableRegistry

public interface Registry<T extends RegistryKey<K>,K>
Represents a basic registry object which contained RegistryKey objects
Since:
1.0.0-SNAPSHOT
  • Method Summary

    Modifier and Type
    Method
    Description
    get(K key)
    Fetches an entry from the registry
    getOrDefault(K key, @NotNull Supplier<T> defaultValue)
    Fetches the value at the given key or a provided default key
    getOrDefault(K key, T defaultValue)
    Fetches the value at the given key or a provided default key
    getOrNull(K key)
    Fetches an entry from the registry
    Fetches an entry from the registry using the specified key or throws an exception if no entry exists.
    Retrieves a set of all keys from the registry
    static <T extends RegistryKey<K>, K>
    FrozenRegistry<T,K>
    newFrozen(Supplier<Map<K,T>> data)
    Creates a new FrozenRegistry with the given data
    static <T extends RegistryKey<K>, K>
    WriteableRegistry<T,K>
    Creates a new WriteableRegistry with the given data
  • Method Details

    • newWriteable

      static <T extends RegistryKey<K>, K> WriteableRegistry<T,K> newWriteable(Supplier<Map<K,T>> data)
      Creates a new WriteableRegistry with the given data
      Type Parameters:
      T - the type
      K - the key type
      Parameters:
      data - the data
      Returns:
      the newly created WriteableRegistry
      Since:
      1.0.0-SNAPSHOT
    • newFrozen

      static <T extends RegistryKey<K>, K> FrozenRegistry<T,K> newFrozen(Supplier<Map<K,T>> data)
      Creates a new FrozenRegistry with the given data
      Type Parameters:
      T - the type
      K - the key type
      Parameters:
      data - the data
      Returns:
      the newly created FrozenRegistry
      Since:
      1.0.0-SNAPSHOT
    • get

      Optional<T> get(@NotNull K key)
      Fetches an entry from the registry
      Parameters:
      key - the key to use to fetch the entry
      Returns:
      an optional wrapping the nullable result
      Since:
      1.0.0-SNAPSHOT
    • getOrNull

      @Nullable T getOrNull(@NotNull K key)
      Fetches an entry from the registry
      Parameters:
      key - the key to use to fetch the entry
      Returns:
      the resulting object at that key, or null if it doesn't exist
      Since:
      1.0.0-SNAPSHOT
    • getOrDefault

      @NotNull T getOrDefault(@NotNull K key, @NotNull T defaultValue)
      Fetches the value at the given key or a provided default key
      Parameters:
      key - the key
      defaultValue - the default value given the key has no value
      Returns:
      a non null value from either the key or default
    • getOrDefault

      @NotNull T getOrDefault(@NotNull K key, @NotNull @NotNull Supplier<T> defaultValue)
      Fetches the value at the given key or a provided default key
      Parameters:
      key - the key
      defaultValue - the default value function triggered if the key has no value
      Returns:
      a non null value from either the key or default
    • getOrThrow

      @NotNull T getOrThrow(@NotNull K key)
      Fetches an entry from the registry using the specified key or throws an exception if no entry exists.
      Parameters:
      key - the key to fetch the entry from the registry
      Returns:
      the entry corresponding to the specified key
      Throws:
      IllegalArgumentException - if no entry exists for the specified key
    • keys

      Set<K> keys()
      Retrieves a set of all keys from the registry
      Returns:
      a set of string keys
      Since:
      1.0.0-SNAPSHOT