Class Hook<H,K>

java.lang.Object
net.paulem.arcana.hook.Hook<H,K>
Type Parameters:
H - the type of the object returned by the hook once resolved
K - the type of the key used to select which supplier to resolve the hook from

public abstract class Hook<H,K> extends Object
Base class for hooks resolving an optional third-party implementation of type H, chosen based on a key of type K (typically derived from what's currently available on the server), through a HookCondition mapping keys to lazy suppliers of the implementation.
  • Constructor Details

    • Hook

      public Hook(ArcanaAPI<?> api, HookCondition<K,Supplier<H>> hooks)
      Creates a new Hook.
      Parameters:
      api - the ArcanaAPI instance this hook belongs to
      hooks - the condition mapping keys to suppliers of the hooked implementation
  • Method Details

    • get

      @Nullable public H get(Supplier<K> supplier)
      Resolves the hooked implementation for the key produced by the given supplier. If no supplier is registered for that key, this returns null rather than throwing.
      Parameters:
      supplier - supplies the key used to look up the registered hook supplier
      Returns:
      the resolved implementation, or null if no hook is registered for the key