Class StrategyIndirectedPredicate<T1,T2>

java.lang.Object
net.shibboleth.utilities.java.support.logic.StrategyIndirectedPredicate<T1,T2>
Type Parameters:
T1 - type of object used as the source of the data to compare
T2 - type of object being compared
All Implemented Interfaces:
Predicate<T1>, Predicate<T1>

public class StrategyIndirectedPredicate<T1,T2> extends Object implements Predicate<T1>
Generic predicate that checks a candidate Object returned by a lookup function against an injected predicate.
  • Field Details

    • objectLookupStrategy

      @Nonnull private final Function<T1,T2> objectLookupStrategy
      Lookup strategy for object.
    • predicate

      @Nonnull private final Predicate<T2> predicate
      Predicate to apply to indirected object.
  • Constructor Details

    • StrategyIndirectedPredicate

      public StrategyIndirectedPredicate(@ParameterName(name="objectStrategy") @Nonnull Function<T1,T2> objectStrategy, @ParameterName(name="pred") @Nonnull Predicate<T2> pred)
      Constructor.
      Parameters:
      objectStrategy - lookup strategy for object
      pred - the predicate to apply
    • StrategyIndirectedPredicate

      public StrategyIndirectedPredicate(@ParameterName(name="objectStrategy") @Nonnull Function<T1,T2> objectStrategy, @ParameterName(name="collection") @Nonnull Collection<T2> collection)
      Constructor that simplifies constructing a test for containment in a collection, which is a common use case.
      Parameters:
      objectStrategy - lookup strategy for object
      collection - a collection to test for containment
  • Method Details

    • test

      public boolean test(@Nullable T1 input)
      Specified by:
      test in interface Predicate<T1>
    • forPredicate

      @Nonnull public static <T1, T2> StrategyIndirectedPredicate<T1,T2> forPredicate(@Nonnull Function<T1,T2> objectStrategy, @Nonnull Predicate<T2> pred)
      Factory method for predicate-based constructor.
      Type Parameters:
      T1 - type of object used as the source of the data to compare
      T2 - type of object being compared
      Parameters:
      objectStrategy - the lookup strategy for object
      pred - the predicate to apply
      Returns:
      a suitably constructed predicate
      Since:
      7.3.0
    • forCollection

      @Nonnull public static <T1, T2> StrategyIndirectedPredicate<T1,T2> forCollection(@Nonnull Function<T1,T2> objectStrategy, @Nonnull Collection<T2> collection)
      Factory method for collection-based constructor.
      Type Parameters:
      T1 - type of object used as the source of the data to compare
      T2 - type of object being compared
      Parameters:
      objectStrategy - the lookup strategy for object
      collection - a collection to test for containment
      Returns:
      a suitably constructed predicate
      Since:
      7.3.0