Class AbstractMappedRegistry<K,​V,​M extends Map<K,​V>>

java.lang.Object
org.geysermc.geyser.registry.Registry<M>
org.geysermc.geyser.registry.AbstractMappedRegistry<K,​V,​M>
Type Parameters:
K - the key
V - the value
M - the map
Direct Known Subclasses:
MappedRegistry, PacketTranslatorRegistry, SimpleMappedRegistry, VersionedRegistry

public abstract class AbstractMappedRegistry<K,​V,​M extends Map<K,​V>> extends Registry<M>
An abstract registry holding a map of various registrations as defined by AbstractMappedRegistry. The M represents the map class, which can be anything that extends Map. The AbstractMappedRegistry and AbstractMappedRegistry generics are the key and value respectively.
  • Constructor Details

    • AbstractMappedRegistry

      protected AbstractMappedRegistry(I input, RegistryLoader<I,​M> registryLoader)
  • Method Details

    • get

      @Nullable public 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.