Class AbstractMappedDeferredRegistry<K,V,M extends Map<K,V>,R extends AbstractMappedRegistry<K,V,M>>

java.lang.Object
org.geysermc.geyser.registry.AbstractMappedDeferredRegistry<K,V,M,R>
Direct Known Subclasses:
SimpleMappedDeferredRegistry, VersionedDeferredRegistry

public abstract class AbstractMappedDeferredRegistry<K,V,M extends Map<K,V>,R extends AbstractMappedRegistry<K,V,M>> extends Object
  • Constructor Details

    • AbstractMappedDeferredRegistry

      protected AbstractMappedDeferredRegistry(Function<RegistryLoader<I,M>,R> registryLoader, RegistryLoader<I,M> deferredLoader)
    • AbstractMappedDeferredRegistry

      protected AbstractMappedDeferredRegistry(Function<RegistryLoader<I,M>,R> registryLoader, Supplier<RegistryLoader<I,M>> deferredLoader)
    • AbstractMappedDeferredRegistry

      protected AbstractMappedDeferredRegistry(I input, org.geysermc.geyser.registry.DeferredRegistry.RegistryInitializer<M,R> registryInitializer, RegistryLoader<I,M> deferredLoader)
    • AbstractMappedDeferredRegistry

      protected AbstractMappedDeferredRegistry(I input, org.geysermc.geyser.registry.DeferredRegistry.RegistryInitializer<M,R> registryInitializer, Supplier<RegistryLoader<I,M>> deferredLoader)
  • Method Details

    • get

      public @Nullable V get(K key)
      Returns the value registered by the given key.
      Parameters:
      key - the key
      Returns:
      the value registered by the given key.
    • map

      public <U> Optional<U> map(K key, Function<? super V,? extends U> mapper)
      Returns and maps the value by the given key if present.
      Type Parameters:
      U - the type
      Parameters:
      key - the key
      mapper - the mapper
      Returns:
      the mapped value from the given key if present
    • getOrDefault

      public V getOrDefault(K key, V defaultValue)
      Returns the value registered by the given key or the default value specified if null.
      Parameters:
      key - the key
      defaultValue - the default value
      Returns:
      the value registered by the given key or the default value specified if null.
    • register

      public V register(K key, V value)
      Registers a new value into this registry with the given key.
      Parameters:
      key - the key
      value - the value
      Returns:
      a new value into this registry with the given key.
    • backingRegistry

      protected R backingRegistry()
    • get

      public M get()
      Gets the underlying value held by this registry.
      Returns:
      the underlying value held by this registry
      Throws:
      IllegalStateException - if this deferred registry has not been loaded yet
    • set

      public void set(M mappings)
    • register

      public void register(Consumer<M> consumer)
      Registers what is specified in the given Consumer into the underlying value.
      Parameters:
      consumer - the consumer
      Throws:
      IllegalStateException - if this deferred registry has not been loaded yet
    • load

      public void load()
      Loads the registry.
    • loaded

      public boolean loaded()
      Whether this registry was loaded.