Class ScriptedBiPredicate<T,U>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
-
- net.shibboleth.utilities.java.support.logic.ScriptedBiPredicate<T,U>
-
- Type Parameters:
T- first input typeU- second input type
- All Implemented Interfaces:
BiPredicate<T,U>
public class ScriptedBiPredicate<T,U> extends AbstractScriptEvaluator implements BiPredicate<T,U>
ABiPredicatewhich calls out to a supplied script.- Since:
- 8.2.0
-
-
Field Summary
Fields Modifier and Type Field Description private Pair<Class<T>,Class<U>>inputTypesInput type 1.private org.slf4j.LoggerlogClass logger.-
Fields inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedScriptedBiPredicate(EvaluableScript theScript)Constructor.protectedScriptedBiPredicate(EvaluableScript theScript, String extraInfo)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Pair<Class<T>,Class<U>>getInputTypes()Get 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.voidsetInputTypes(Pair<Class<T>,Class<U>> types)Set the input types to be enforced.voidsetReturnOnError(boolean flag)Set value to return if an error occurs.booleantest(T first, U second)-
Methods inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
evaluate, finalizeContext, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnError
-
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.BiPredicate
and, negate, or
-
-
-
-
Constructor Detail
-
ScriptedBiPredicate
protected ScriptedBiPredicate(@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.
-
ScriptedBiPredicate
protected ScriptedBiPredicate(@Nonnull @NotEmpty @ParameterName(name="theScript") EvaluableScript theScript)
Constructor.- Parameters:
theScript- the script we will evaluate.
-
-
Method Detail
-
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
-
setReturnOnError
public void setReturnOnError(boolean flag)
Set value to return if an error occurs.- Parameters:
flag- value to return
-
test
public boolean test(@Nullable T first, @Nullable U second)- Specified by:
testin interfaceBiPredicate<T,U>
-
prepareContext
protected void prepareContext(@Nonnull ScriptContext scriptContext, @Nullable Object... input)Pre-process the script context before execution.- Specified by:
prepareContextin classAbstractScriptEvaluator- Parameters:
scriptContext- the script contextinput- the input
-
resourceScript
public static <T,U> ScriptedBiPredicate<T,U> resourceScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
Factory to createScriptedBiPredicatefrom aResource.- Type Parameters:
T- first input typeU- second input type- Parameters:
resource- the resource to look atengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceScript
public static <T,U> ScriptedBiPredicate<T,U> resourceScript(Resource resource) throws ScriptException, IOException
Factory to createScriptedBiPredicatefrom aResource.- Type Parameters:
T- first input typeU- second input type- Parameters:
resource- the resource to look at- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
inlineScript
public static <T,U> ScriptedBiPredicate<T,U> inlineScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource) throws ScriptException
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 fails
-
inlineScript
public static <T,U> ScriptedBiPredicate<T,U> inlineScript(@Nonnull @NotEmpty String scriptSource) throws ScriptException
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 fails
-
-