Class RegistryRef<K,V>
java.lang.Object
de.luckymcdev.foundryengine.common.registry.RegistryRef<K,V>
- Type Parameters:
K- Key Type.V- Value Type.
A Reference to an Entry in a
Registry / GenericRegistry.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanexists()Check if this entry exists in the registry.get()Get the value from the registry.getKey()Get the key this reference points to.inthashCode()voidExecute an action if the value exists.voidifPresentOrElse(Consumer<V> action, Runnable emptyAction) Execute an action if present, or a fallback if not.voidInvalidate the cache, forcing next get() to reload from registry.booleanisCached()Check if the value is cached (registry is frozen).<U> Optional<U> Map the value to another type.Get the value or a default if not present.Get the value or compute a default if not present.Get the value as an Optional.toString()
-
Constructor Details
-
RegistryRef
-
-
Method Details
-
get
Get the value from the registry. Caches the value if the registry is frozen.- Returns:
- the value, or null if not registered
-
orElse
-
orElseGet
-
toOptional
-
getKey
-
exists
public boolean exists()Check if this entry exists in the registry.- Returns:
- true if the key is registered
-
isCached
public boolean isCached()Check if the value is cached (registry is frozen).- Returns:
- true if value is cached
-
ifPresent
-
ifPresentOrElse
-
map
-
invalidateCache
public void invalidateCache()Invalidate the cache, forcing next get() to reload from registry. Useful for hot-reloading during development. -
equals
-
hashCode
-
toString
-