java.lang.Object
org.spongepowered.asm.mixin.injection.callback.CallbackInfo
All Implemented Interfaces:
Cancellable
Direct Known Subclasses:
CallbackInfoReturnable

public class CallbackInfo extends 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(String name, boolean cancellable)
    This ctor is always called by injected code
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    If the object is cancellable, cancels the object, implementors may throw an EventCancellationException if the object is not actually cancellable.
    static String
    getCallInfoClassName(org.objectweb.asm.Type returnType)
    Gets the CallbackInfo class name to use for the specified return type.
    Get the ID of the injector which defined this callback.
    final boolean
    Get whether this is actually cancellable
    final boolean
    Get whether this is cancelled
     

    Methods inherited from class java.lang.Object

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

    • CallbackInfo

      public CallbackInfo(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 Details

    • getId

      public 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 String toString()
      Overrides:
      toString in class 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 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