Class CallbackInfo
- java.lang.Object
-
- org.spongepowered.asm.mixin.injection.callback.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 voidcancel()If the object is cancellable, cancels the object, implementors may throw an EventCancellationException if the object is not actually cancellable.static java.lang.StringgetCallInfoClassName(org.objectweb.asm.Type returnType)Gets theCallbackInfoclass name to use for the specified return type.java.lang.StringgetId()Get the ID of the injector which defined this callback.booleanisCancellable()Get whether this is actually cancellablebooleanisCancelled()Get whether this is cancelledjava.lang.StringtoString()
-
-
-
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 theInject.id()parameter on the injector- Returns:
- the injector ID
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isCancellable
public final boolean isCancellable()
Description copied from interface:CancellableGet whether this is actually cancellable- Specified by:
isCancellablein interfaceCancellable- Returns:
- whether this is actually cancellable
-
isCancelled
public final boolean isCancelled()
Description copied from interface:CancellableGet whether this is cancelled- Specified by:
isCancelledin interfaceCancellable- Returns:
- whether this is cancelled
-
cancel
public void cancel() throws CancellationExceptionDescription copied from interface:CancellableIf the object is cancellable, cancels the object, implementors may throw an EventCancellationException if the object is not actually cancellable.- Specified by:
cancelin interfaceCancellable- 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 theCallbackInfoclass name to use for the specified return type. Currently returnsCallbackInfofor void types andCallbackInfoReturnablefor non-void types.- Parameters:
returnType- return type of the target method- Returns:
- CallbackInfo class name to use
-
-