Class CallbackInfo

  • All Implemented Interfaces:
    Cancellable
    Direct Known Subclasses:
    CallbackInfoReturnable

    public class CallbackInfo
    extends java.lang.Object
    implements Cancellable
    CallbackInfo instances are passed to callbacks in order to provide information and handling opportunities to the callback to interact with the callback itself. For example by allowing the callback to be "cancelled" and return from a method prematurely.
    • Constructor Summary

      Constructors 
      Constructor Description
      CallbackInfo​(java.lang.String name, boolean cancellable)
      This ctor is always called by injected code
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      If the object is cancellable, cancels the object, implementors may throw an EventCancellationException if the object is not actually cancellable.
      static java.lang.String getCallInfoClassName​(org.objectweb.asm.Type returnType)
      Gets the CallbackInfo class name to use for the specified return type.
      java.lang.String getId()
      Get the ID of the injector which defined this callback.
      boolean isCancellable()
      Get whether this is actually cancellable
      boolean isCancelled()
      Get whether this is cancelled
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CallbackInfo

        public CallbackInfo​(java.lang.String name,
                            boolean cancellable)
        This ctor is always called by injected code
        Parameters:
        name - calling method name
        cancellable - true if the callback can be cancelled
    • Method Detail

      • getId

        public java.lang.String getId()
        Get the ID of the injector which defined this callback. This defaults to the method name but can be overridden by specifying the Inject.id() parameter on the injector
        Returns:
        the injector ID
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isCancellable

        public final boolean isCancellable()
        Description copied from interface: Cancellable
        Get whether this is actually cancellable
        Specified by:
        isCancellable in interface Cancellable
        Returns:
        whether this is actually cancellable
      • isCancelled

        public final boolean isCancelled()
        Description copied from interface: Cancellable
        Get whether this is cancelled
        Specified by:
        isCancelled in interface Cancellable
        Returns:
        whether this is cancelled
      • cancel

        public void cancel()
                    throws CancellationException
        Description copied from interface: Cancellable
        If the object is cancellable, cancels the object, implementors may throw an EventCancellationException if the object is not actually cancellable.
        Specified by:
        cancel in interface Cancellable
        Throws:
        CancellationException - (optional) may be thrown if the object is not actually cancellable. Contractually, this object may not throw the exception if isCancellable() returns true.
      • getCallInfoClassName

        public static java.lang.String getCallInfoClassName​(org.objectweb.asm.Type returnType)
        Gets the CallbackInfo class name to use for the specified return type. Currently returns CallbackInfo for void types and CallbackInfoReturnable for non-void types.
        Parameters:
        returnType - return type of the target method
        Returns:
        CallbackInfo class name to use