Class CallbackInfo
java.lang.Object
org.spongepowered.asm.mixin.injection.callback.CallbackInfo
- All Implemented Interfaces:
Cancellable
- Direct Known Subclasses:
CallbackInfoReturnable
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
ConstructorsConstructorDescriptionCallbackInfo(String name, boolean cancellable) This ctor is always called by injected code -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()If the object is cancellable, cancels the object, implementors may throw an EventCancellationException if the object is not actually cancellable.static StringgetCallInfoClassName(org.objectweb.asm.Type returnType) Gets theCallbackInfoclass name to use for the specified return type.getId()Get the ID of the injector which defined this callback.final booleanGet whether this is actually cancellablefinal booleanGet whether this is cancelledtoString()
-
Constructor Details
-
CallbackInfo
This ctor is always called by injected code- Parameters:
name- calling method namecancellable- true if the callback can be cancelled
-
-
Method Details
-
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
-
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
Description 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
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
-