WrappedScript
com.jsmacrosce.jsmacros.core.event.impl.EventWrappedScript
Payload for scripts run through wrapScriptRun() or wrapScriptRunAsync. The wrapper dispatches this event before running the script.
Arguments depend on the Java functional interface: no-argument interfaces provide two nulls,
one-argument interfaces provide arg1 and a null arg2, and two-argument interfaces provide both, except Comparator, which forwards only its first value.
The wrapped script can set result for interfaces that return a value; consumers and runnables ignore it.
js
// In a wrapped two-argument function script, return a result to the Java caller.
event.setReturnInt(Number(event.arg1) + Number(event.arg2));Type Parameters
T: the type the first argument arrives asU: the type the second argument arrives as, andnullunless the wrapper was passed as a two argument interfaceR: the type of the value the script returns to the caller
Constructors
new EventWrappedScript
Fields
arg1
the first argument supplied by the wrapped interface, or
null for no-argument interfacesarg2
the second argument supplied by a two-argument interface, or
null otherwiseresult
result: R#Value supplied by the script for the wrapped Java interface. Value-returning interfaces read it after the script finishes: functions and suppliers return it as-is, predicates cast it to
Boolean, and comparators cast it to Integer. Consumers and runnables ignore it; an incompatible predicate or comparator value fails in the Java caller.Methods
setReturnBoolean
setReturnBoolean(boolean b): void#Sets a boolean result, as read by
Predicate and BiPredicate wrappers. Other result types may fail their caller-side cast.Parameters:
b: the value to return to the caller
setReturnDouble
setReturnDouble(double d): void#Sets a double result, boxed as
Double when returned by a function or supplier. To return a Float, use setReturnObject(java.lang.Object) with a Float.Parameters:
d: the value to return to the caller
setReturnInt
setReturnInt(int i): void#Sets an integer result, as read by
Comparator wrappers. Function and supplier wrappers return the boxed value as-is; an incompatible comparator result fails its caller-side cast.Parameters:
i: the value to return to the caller