# 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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_constructor-C-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_accept-T-}

```js
accept(T t): void
```

Accepts one input value.

**Parameters:**
- `t`: the input value

### accept {#com.jsmacrosce.jsmacros.core.MethodWrapper_accept-T-U-}

```js
accept(T t, U u): void
```

Accepts two input values.

**Parameters:**
- `t`: the first input value
- `u`: the second input value

### andThen {#com.jsmacrosce.jsmacros.core.MethodWrapper_andThen-Function-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_andThen-Consumer-}

```js
andThen(Consumer<? super T> arg0): Consumer<T>
```

**Returns:** `Consumer<T>`

### andThen {#com.jsmacrosce.jsmacros.core.MethodWrapper_andThen-BiConsumer-}

```js
andThen(BiConsumer<? super T, ? super U> arg0): BiConsumer<T, U>
```

**Returns:** `BiConsumer<T, U>`

### apply {#com.jsmacrosce.jsmacros.core.MethodWrapper_apply-T-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_apply-T-U-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_getCtx-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_negate-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_overrideThread-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_test-T-}

```js
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 {#com.jsmacrosce.jsmacros.core.MethodWrapper_test-T-U-}

```js
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
