Package net.shibboleth.shared.logic

# Class ScriptedBiFunction<T,U,V>

java.lang.Object
net.shibboleth.shared.scripting.AbstractScriptEvaluator
net.shibboleth.shared.logic.ScriptedBiFunction<T,U,V>

Type Parameters:
  `T` - first input type
  `U` - second input type
  `V` - return type

All Implemented Interfaces:
  `BiFunction<T,U,V>`

public class ScriptedBiFunction<T,U,V> extends AbstractScriptEvaluator implements BiFunction<T,U,V>
A `BiFunction` which calls out to a supplied script.

Since:
  8.2.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private Pair<Class<T>,Class<U>>`
`inputTypes`
Input types.
`private final org.slf4j.Logger`
`log`
Class logger.

### Fields inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator

`DEFAULT_ENGINE`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`ScriptedBiFunction(EvaluableScript theScript)`
Constructor.
`protected`
`ScriptedBiFunction(EvaluableScript theScript, String extraInfo)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`V`
`apply(T first, U second)`
`Pair<Class<T>,Class<U>>`
`getInputTypes()`
Get the input type to be enforced.
`static <T, U, V> ScriptedBiFunction<T,U,V>`
`inlineScript(String scriptSource)`
Factory to create `ScriptedBiFunction` from inline data.
`static <T, U, V> ScriptedBiFunction<T,U,V>`
`inlineScript(String engineName, String scriptSource)`
Factory to create `ScriptedBiFunction` from inline data.
`protected void`
`prepareContext(ScriptContext scriptContext, Object... input)`
Pre-process the script context before execution.
`static <T, U, V> ScriptedBiFunction<T,U,V>`
`resourceScript(String engineName, Resource resource)`
Factory to create `ScriptedBiFunction` from a `Resource`.
`static <T, U, V> ScriptedBiFunction<T,U,V>`
`resourceScript(Resource resource)`
Factory to create `ScriptedBiFunction` from a `Resource`.
`void`
`setInputTypes(Pair<Class<T>,Class<U>> types)`
Set the input types to be enforced.
`void`
`setOutputType(Class<?> type)`
Set the output type to be enforced.
`void`
`setReturnOnError(Object value)`
Set value to return if an error occurs.

### Methods inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator

`evaluate, finalizeContext, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setContextExtenders, setCustomObject, setHideExceptions, setLogPrefix`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.function.BiFunction

`andThen`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### inputTypes

@Nullable private Pair<Class<T>,Class<U>> inputTypes
Input types.

## Constructor Details

### ScriptedBiFunction

protected ScriptedBiFunction(@Nonnull @NotEmpty EvaluableScript theScript, @Nullable @NotEmpty String extraInfo)
Constructor.

Parameters:
  `theScript` - the script we will evaluate.
  `extraInfo` - debugging information.

### ScriptedBiFunction

protected ScriptedBiFunction(@Nonnull @NotEmpty EvaluableScript theScript)
Constructor.

Parameters:
  `theScript` - the script we will evaluate.

## Method Details

### getInputTypes

@Nullable public Pair<Class<T>,Class<U>> getInputTypes()
Get the input type to be enforced.

Returns:
  input type

### setInputTypes

public void setInputTypes(@Nullable Pair<Class<T>,Class<U>> types)
Set the input types to be enforced.

Parameters:
  `types` - the input types

### setOutputType

public void setOutputType(@Nullable Class<?> type)
Set the output type to be enforced.

Overrides:
  `setOutputType` in class `AbstractScriptEvaluator`
Parameters:
  `type` - output type

### setReturnOnError

public void setReturnOnError(@Nullable Object value)
Set value to return if an error occurs.

Overrides:
  `setReturnOnError` in class `AbstractScriptEvaluator`
Parameters:
  `value` - value to return

### apply

@Nullable public V apply(@Nullable T first, @Nullable U second)

Specified by:
  `apply` in interface `BiFunction<T,U,V>`

### prepareContext

protected void prepareContext(@Nonnull ScriptContext scriptContext, @Nullable Object... input)
Pre-process the script context before execution.

Specified by:
  `prepareContext` in class `AbstractScriptEvaluator`
Parameters:
  `scriptContext` - the script context
  `input` - the input

### resourceScript

@Nonnull public static <T, U, V> ScriptedBiFunction<T,U,V> resourceScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @ParameterName(name="resource") Resource resource) throws ScriptException, IOException, ComponentInitializationException
Factory to create `ScriptedBiFunction` from a `Resource`.

Type Parameters:
  `T` - first input type
  `U` - second input type
  `V` - return type
Parameters:
  `resource` - the resource to look at
  `engineName` - the language
Returns:
  the function
Throws:
  `ScriptException` - if the compile fails
  `IOException` - if the file doesn't exist.
  `ComponentInitializationException` - if the scripting initialization fails

### resourceScript

@Nonnull public static <T, U, V> ScriptedBiFunction<T,U,V> resourceScript(@Nonnull @ParameterName(name="resource") Resource resource) throws ScriptException, IOException, ComponentInitializationException
Factory to create `ScriptedBiFunction` from a `Resource`.

Type Parameters:
  `T` - first input type
  `U` - second input type
  `V` - return type
Parameters:
  `resource` - the resource to look at
Returns:
  the function
Throws:
  `ScriptException` - if the compile fails
  `IOException` - if the file doesn't exist.
  `ComponentInitializationException` - if the scripting initialization fails

### inlineScript

@Nonnull public static <T, U, V> ScriptedBiFunction<T,U,V> inlineScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException
Factory to create `ScriptedBiFunction` from inline data.

Type Parameters:
  `T` - first input type
  `U` - second input type
  `V` - return type
Parameters:
  `scriptSource` - the script, as a string
  `engineName` - the language
Returns:
  the function
Throws:
  `ScriptException` - if the compile fails
  `ComponentInitializationException` - if the scripting initialization fails

### inlineScript

@Nonnull public static <T, U, V> ScriptedBiFunction<T,U,V> inlineScript(@Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException
Factory to create `ScriptedBiFunction` from inline data.

Type Parameters:
  `T` - first input type
  `U` - second input type
  `V` - return type
Parameters:
  `scriptSource` - the script, as a string
Returns:
  the function
Throws:
  `ScriptException` - if the compile fails
  `ComponentInitializationException` - if the scripting initialization fails