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 type
U - second input type
All Implemented Interfaces:
BiPredicate<T,​U>

public class ScriptedBiPredicate<T,​U>
extends AbstractScriptEvaluator
implements BiPredicate<T,​U>
A BiPredicate which calls out to a supplied script.
Since:
8.2.0
  • Field Details

    • log

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

      @Nullable private Pair<Class<T>,​Class<U>> inputTypes
      Input type 1.
  • Constructor Details

  • 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
    • 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:
      test in interface BiPredicate<T,​U>
    • 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,​ U> ScriptedBiPredicate<T,​U> resourceScript​(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
      Factory to create ScriptedBiPredicate from a Resource.
      Type Parameters:
      T - first input type
      U - second input 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.
    • resourceScript

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