Class ScriptedPredicate<T>
java.lang.Object
net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
net.shibboleth.utilities.java.support.logic.ScriptedPredicate<T>
- Type Parameters:
T
- input type
A
Predicate
which calls out to a supplied script.- Since:
- 7.4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionInput type.private final org.slf4j.Logger
Class logger.Fields inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ScriptedPredicate
(EvaluableScript theScript) Constructor.protected
ScriptedPredicate
(EvaluableScript theScript, String extraInfo) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the input type to be enforced.static <T> ScriptedPredicate<T>
inlineScript
(String scriptSource) Factory to createScriptedPredicate
from inline data.static <T> ScriptedPredicate<T>
inlineScript
(String engineName, String scriptSource) Factory to createScriptedPredicate
from inline data.protected void
prepareContext
(ScriptContext scriptContext, Object... input) Pre-process the script context before execution.static <T> ScriptedPredicate<T>
resourceScript
(String engineName, Resource resource) Factory to createScriptedPredicate
from aResource
.static <T> ScriptedPredicate<T>
resourceScript
(Resource resource) Factory to createScriptedPredicate
from aResource
.void
setInputType
(Class<T> type) Set the input type to be enforced.void
setReturnOnError
(boolean flag) Set value to return if an error occurs.boolean
Methods inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
evaluate, finalizeContext, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnError
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
inputTypeClass
Input type.
-
-
Constructor Details
-
ScriptedPredicate
protected ScriptedPredicate(@Nonnull @NotEmpty @ParameterName(name="theScript") EvaluableScript theScript, @Nullable @NotEmpty @ParameterName(name="extraInfo") String extraInfo) Constructor.- Parameters:
theScript
- the script we will evaluate.extraInfo
- debugging information.
-
ScriptedPredicate
protected ScriptedPredicate(@Nonnull @NotEmpty @ParameterName(name="theScript") EvaluableScript theScript) Constructor.- Parameters:
theScript
- the script we will evaluate.
-
-
Method Details
-
getInputType
Get the input type to be enforced.- Returns:
- input type
- Since:
- 8.2.0
-
setInputType
Set the input type to be enforced.- Parameters:
type
- input type- Since:
- 8.2.0
-
setReturnOnError
public void setReturnOnError(boolean flag) Set value to return if an error occurs.- Parameters:
flag
- value to return
-
test
-
prepareContext
Pre-process the script context before execution.- Specified by:
prepareContext
in classAbstractScriptEvaluator
- Parameters:
scriptContext
- the script contextinput
- the input
-
resourceScript
public static <T> ScriptedPredicate<T> resourceScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException Factory to createScriptedPredicate
from aResource
.- Type Parameters:
T
- input type- Parameters:
resource
- the resource to look atengineName
- the language- Returns:
- the predicate
- Throws:
ScriptException
- if the compile failsIOException
- if the file doesn't exist.
-
resourceScript
public static <T> ScriptedPredicate<T> resourceScript(Resource resource) throws ScriptException, IOException Factory to createScriptedPredicate
from aResource
.- Type Parameters:
T
- input type- Parameters:
resource
- the resource to look at- Returns:
- the predicate
- Throws:
ScriptException
- if the compile failsIOException
- if the file doesn't exist.
-
inlineScript
public static <T> ScriptedPredicate<T> inlineScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource) throws ScriptException Factory to createScriptedPredicate
from inline data.- Type Parameters:
T
- input type- Parameters:
scriptSource
- the script, as a stringengineName
- the language- Returns:
- the predicate
- Throws:
ScriptException
- if the compile fails
-
inlineScript
public static <T> ScriptedPredicate<T> inlineScript(@Nonnull @NotEmpty String scriptSource) throws ScriptException Factory to createScriptedPredicate
from inline data.- Type Parameters:
T
- input type- Parameters:
scriptSource
- the script, as a string- Returns:
- the predicate
- Throws:
ScriptException
- if the compile fails
-