MethodWrapper
com.jsmacrosce.jsmacros.core.MethodWrapper
Implements several Java functional interfaces in one callback wrapper, optionally associated with a script context.
Script functions are commonly exposed through IFWrapper.
Type Parameters
T: the first input typeU: the second input typeR: the result typeC: the associated script-context type
Constructors
new MethodWrapper
new MethodWrapper(C extends BaseScriptContext<?> containingContext)#Associates this wrapper with a script context, marks it as having had a method wrapper invoked, and captures its synchronization object.
Parameters:
containingContext: the context associated with this wrapper; must not benull
Methods
accept
accept(T t): void#Accepts one input value.
Parameters:
t: the input value
accept(T t, U u): void#Accepts two input values.
Parameters:
t: the first input valueu: the second input value
andThen
andThen(Function<? super R, ? extends V> after): MethodWrapper<T, U, V, C extends BaseScriptContext<?>>#Composes this wrapper with
after. Function and supplier calls pass this wrapper's result to after; consumer and runnable calls invoke this wrapper and then run after if it is a MethodWrapper. Predicate calls pass their boolean result to after if it is a MethodWrapper; otherwise they return this wrapper's predicate result unchanged. Comparator calls retain this wrapper's comparison result and run after only if it is a MethodWrapper.Parameters:
after: function applied to results, or a MethodWrapper for callback-style calls
Type Parameters:
V: the result type produced byafter
Returns: a wrapper that composes this wrapper with
afterandThen(BiConsumer<? super T, ? super U> arg0): BiConsumer<T, U>#Returns: BiConsumer<T, U>
apply
apply(T t): R#Applies this callback to one input value and returns its result.
Parameters:
t: the input value
Returns: the callback result, which may be
nullapply(T t, U u): R#Applies this callback to two input values and returns its result.
Parameters:
t: the first input valueu: the second input value
Returns: the callback result, which may be
nullgetCtx
getCtx(): C extends BaseScriptContext<?>#Returns the script context associated with this wrapper, or
null for a contextless wrapper.Returns: the associated context, or
null if none was setnegate
negate(): MethodWrapper<T, U, R, C extends BaseScriptContext<?>>#Returns a wrapper with inverted predicate results and negated comparator results; other operations are delegated unchanged.
Returns: the negated wrapper
overrideThread
test
test(T t): boolean#Tests one input value and returns the callback's boolean result.
Parameters:
t: the input value
Returns: the callback's boolean result
test(T t, U u): boolean#Tests two input values and returns the callback's boolean result.
Parameters:
t: the first input valueu: the second input value
Returns: the callback's boolean result