Skip to content

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 type
  • U: the second input type
  • R: the result type
  • C: 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 be null

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 value
  • u: 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 by after
Returns: a wrapper that composes this wrapper with after
andThen(Consumer<? super T> arg0): Consumer<T>#

Returns: Consumer<T>

andThen(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 null
apply(T t, U u): R#
Applies this callback to two input values and returns its result.

Parameters:

  • t: the first input value
  • u: the second input value
Returns: the callback result, which may be null

getCtx ​

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 set

negate ​

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 ​

overrideThread(): Thread#
Returns the thread to use for an event callback instead of the thread captured at registration, or null to use the captured thread.
Returns: the alternative callback thread, or null to use the captured thread

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 value
  • u: the second input value
Returns: the callback's boolean result