Class Holder<T>

java.lang.Object
com.github.darksoulq.abyssallib.server.registry.object.Holder<T>
Type Parameters:
T - The type of object held.

public class Holder<T> extends Object
A wrapper for a registry object that enables lazy initialization and caching.

The Holder stores a supplier that creates the object. The first time get() is called, the supplier is executed and the result is cached for all subsequent calls.

  • Constructor Details

    • Holder

      public Holder(Supplier<T> supplier)
      Constructs a new Holder.
      Parameters:
      supplier - The logic used to create the object when requested.
  • Method Details

    • get

      public T get()
      Retrieves the held object, creating it if it hasn't been instantiated yet.
      Returns:
      The cached object instance.