Klasse RegistryRef<K,V>

java.lang.Object
de.luckymcdev.foundryengine.common.registry.RegistryRef<K,V>
Typparameter:
K - Key Type.
V - Value Type.

public class RegistryRef<K,V> extends Object
A Reference to an Entry in a Registry / GenericRegistry.
  • Konstruktordetails

    • RegistryRef

      public RegistryRef(K key, Registry<K,V> registry)
  • Methodendetails

    • get

      public V get()
      Get the value from the registry. Caches the value if the registry is frozen.
      Gibt zurück:
      the value, or null if not registered
    • orElse

      public V orElse(V defaultValue)
      Get the value or a default if not present.
      Parameter:
      defaultValue - value to return if entry doesn't exist
      Gibt zurück:
      the value or default
    • orElseGet

      public V orElseGet(Supplier<? extends V> supplier)
      Get the value or compute a default if not present.
      Parameter:
      supplier - supplier for default value
      Gibt zurück:
      the value or computed default
    • toOptional

      public Optional<V> toOptional()
      Get the value as an Optional.
      Gibt zurück:
      Optional containing the value, or empty if not registered
    • getKey

      public K getKey()
      Get the key this reference points to.
      Gibt zurück:
      the registry key
    • exists

      public boolean exists()
      Check if this entry exists in the registry.
      Gibt zurück:
      true if the key is registered
    • isCached

      public boolean isCached()
      Check if the value is cached (registry is frozen).
      Gibt zurück:
      true if value is cached
    • ifPresent

      public void ifPresent(Consumer<V> action)
      Execute an action if the value exists.
      Parameter:
      action - action to execute with the value
    • ifPresentOrElse

      public void ifPresentOrElse(Consumer<V> action, Runnable emptyAction)
      Execute an action if present, or a fallback if not.
      Parameter:
      action - action to execute with the value
      emptyAction - action to execute if value doesn't exist
    • map

      public <U> Optional<U> map(Function<? super V, ? extends U> mapper)
      Map the value to another type.
      Parameter:
      mapper - function to transform the value
      Gibt zurück:
      Optional of the mapped value
    • invalidateCache

      public void invalidateCache()
      Invalidate the cache, forcing next get() to reload from registry. Useful for hot-reloading during development.
    • equals

      public boolean equals(Object obj)
      Setzt außer Kraft:
      equals in Klasse Object
    • hashCode

      public int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object