Class LifecycledCallbackHandler<T>

java.lang.Object
com.sk89q.worldedit.util.lifecycle.LifecycledCallbackHandler<T>
All Implemented Interfaces:
Lifecycled.Events<T>

public class LifecycledCallbackHandler<T> extends Object implements Lifecycled.Events<T>
Convenience class for implementing the callbacks of Lifecycled.
  • Constructor Details

    • LifecycledCallbackHandler

      public LifecycledCallbackHandler(Lifecycled<T> lifecycled)
  • Method Details

    • onInvalidated

      public <O> void onInvalidated(O owner, BiConsumer<O,? super Lifecycled<T>> callback)
      Description copied from interface: Lifecycled.Events
      Add a callback for when this lifecycled is invalidated. Will be called immediately if this lifecycled is currently invalid.

      The callback should not reference the owner, it must only access it via the parameter. This ensures that the owner will be GC-able, otherwise it may be stuck in a reference loop.

      Specified by:
      onInvalidated in interface Lifecycled.Events<T>
      Parameters:
      owner - when the owner is GC'd, the callback is removed
      callback - the callback, will be passed the lifecycled object
    • onNewValue

      public <O> void onNewValue(O owner, BiConsumer<O,? super Lifecycled<T>> callback)
      Description copied from interface: Lifecycled.Events
      Add a callback for when this lifecycled is given a new value. Will be called immediately if this lifecycled is currently valid.

      The callback should not reference the owner, it must only access it via the parameter. This ensures that the owner will be GC-able, otherwise it may be stuck in a reference loop.

      Specified by:
      onNewValue in interface Lifecycled.Events<T>
      Parameters:
      owner - when the owner is GC'd, the callback is removed
      callback - the callback, will be passed the lifecycled object
    • fireInvalidated

      public void fireInvalidated()
    • fireOnNewValue

      public void fireOnNewValue()
      Fire onNewValue(Object, BiConsumer) callbacks, the Lifecycled.value() must be available.