Class PredicateUtil

java.lang.Object
org.forgerock.openig.util.PredicateUtil

public final class PredicateUtil extends Object
Utility class for Predicate.
  • Method Details

    • andLog

      public static <T> Predicate<T> andLog(Predicate<T> predicate, Consumer<org.slf4j.Logger> loggerAction)
      A method that tests a Predicate and perform the given Consumer's action on the class logger if the Predicate test returns false. Can be used to log messages when filtering on an Optional.

      Example:

      
       .filter(andLog(p -> !p.isUnlimited(), logger -> logger.warn("message)))
       
      Type Parameters:
      T - The type of the predicate.
      Parameters:
      predicate - The Predicate to test.
      loggerAction - The Consumer action to accept if the previous predicate is false to display the message on the current logger.
      Returns:
      The Predicate result.