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 Summary

    Constructors
    Constructor
    Description
    Holder(Supplier<T> supplier)
    Constructs a new Holder.
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Retrieves the held object, creating it if it hasn't been instantiated yet.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.