Package net.shibboleth.shared.logic
Class ScriptedBiPredicate<T,U>
java.lang.Object
net.shibboleth.shared.scripting.AbstractScriptEvaluator
net.shibboleth.shared.logic.ScriptedBiPredicate<T,U>
- Type Parameters:
T- first input typeU- second input type
- All Implemented Interfaces:
BiPredicate<T,U>
A
BiPredicate which calls out to a supplied script.- Since:
- 8.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionInput type 1.private final org.slf4j.LoggerClass logger.Fields inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScriptedBiPredicate(EvaluableScript theScript) Constructor.protectedScriptedBiPredicate(EvaluableScript theScript, String extraInfo) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the input type to be enforced.static <T,U> ScriptedBiPredicate<T, U> inlineScript(String scriptSource) Factory to createScriptedBiPredicatefrom inline data.static <T,U> ScriptedBiPredicate<T, U> inlineScript(String engineName, String scriptSource) Factory to createScriptedBiPredicatefrom inline data.protected voidprepareContext(ScriptContext scriptContext, Object... input) Pre-process the script context before execution.static <T,U> ScriptedBiPredicate<T, U> resourceScript(String engineName, Resource resource) Factory to createScriptedBiPredicatefrom aResource.static <T,U> ScriptedBiPredicate<T, U> resourceScript(Resource resource) Factory to createScriptedBiPredicatefrom aResource.private booleanHelper function to sanity check return-on-error object.voidSet the input types to be enforced.voidsetReturnOnError(boolean flag) Set value to return if an error occurs.booleanMethods inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
evaluate, finalizeContext, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setContextExtenders, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.function.BiPredicate
and, negate, or
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
inputTypes
Input type 1.
-
-
Constructor Details
-
Method Details
-
getInputTypes
Get the input type to be enforced.- Returns:
- input type
-
setReturnOnError
public void setReturnOnError(boolean flag) Set value to return if an error occurs.- Parameters:
flag- value to return
-
test
- Specified by:
testin interfaceBiPredicate<T,U>
-
returnError
Helper function to sanity check return-on-error object.- Returns:
- a boolean-valued error fallback
- Throws:
ClassCastException- if the installed fallback is null or non-Boolean
-
prepareContext
Pre-process the script context before execution.- Specified by:
prepareContextin classAbstractScriptEvaluator- Parameters:
scriptContext- the script contextinput- the input
-
inlineScript
@Nonnull public static <T,U> ScriptedBiPredicate<T,U> inlineScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedBiPredicatefrom inline data.- Type Parameters:
T- first input typeU- second input type- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the scripting initialization fails
-
inlineScript
@Nonnull public static <T,U> ScriptedBiPredicate<T,U> inlineScript(@Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedBiPredicatefrom inline data.- Type Parameters:
T- first input typeU- second input type- Parameters:
scriptSource- the script, as a string- Returns:
- the function
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the scripting initialization fails
-