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
All Implemented Interfaces:
Predicate<T>, Predicate<T>

public class ScriptedPredicate<T>
extends AbstractScriptEvaluator
implements Predicate<T>
A Predicate which calls out to a supplied script.
Since:
7.4.0
  • Field Details

    • log

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

      @Nullable private Class<T> inputTypeClass
      Input type.
  • Constructor Details

  • Method Details

    • getInputType

      @Nullable public Class<T> getInputType()
      Get the input type to be enforced.
      Returns:
      input type
      Since:
      8.2.0
    • setInputType

      public void setInputType​(@Nullable Class<T> type)
      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

      public boolean test​(@Nullable T input)
      Specified by:
      test in interface Predicate<T>
    • 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

      public static <T> ScriptedPredicate<T> resourceScript​(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
      Factory to create ScriptedPredicate from a Resource.
      Type Parameters:
      T - input type
      Parameters:
      resource - the resource to look at
      engineName - the language
      Returns:
      the predicate
      Throws:
      ScriptException - if the compile fails
      IOException - if the file doesn't exist.
    • resourceScript

      public static <T> ScriptedPredicate<T> resourceScript​(Resource resource) throws ScriptException, IOException
      Factory to create ScriptedPredicate from a Resource.
      Type Parameters:
      T - input type
      Parameters:
      resource - the resource to look at
      Returns:
      the predicate
      Throws:
      ScriptException - if the compile fails
      IOException - 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 create ScriptedPredicate from inline data.
      Type Parameters:
      T - input type
      Parameters:
      scriptSource - the script, as a string
      engineName - 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 create ScriptedPredicate from inline data.
      Type Parameters:
      T - input type
      Parameters:
      scriptSource - the script, as a string
      Returns:
      the predicate
      Throws:
      ScriptException - if the compile fails