Interface CollectionConditional<C extends CollectionConditional<C>>

  • All Superinterfaces:
    Conditional<C>, Copyable<C>
    All Known Implementing Classes:
    DefaultCollectionConditional

    public interface CollectionConditional<C extends CollectionConditional<C>>
    extends Conditional<C>
    An extension of Conditional that is used for matching a set of conditionals against each member of a collection field. This conditional is useful in scenarios where the states of members of a collection are relevant to gate certain functionality.

    For example, a conditional that is a match when all members of a collection have a "type" of "PRODUCT, or is empty:

     Conditionals.whenCollection("choices")
             .conditional(PropertyConditional.when("type").equalTo("PRODUCT"))
             .allMatch()
             .matchIfEmpty()
     
    Author:
    Nick Crum (ncrum)
    • Method Detail

      • getMatchStrategy

        String getMatchStrategy()
      • isMatchIfEmpty

        boolean isMatchIfEmpty()
      • setField

        void setField​(String field)
      • setMatchStrategy

        void setMatchStrategy​(String matchStrategy)
      • setConditionals

        void setConditionals​(List<Conditional<?>> conditionals)
      • setMatchIfEmpty

        void setMatchIfEmpty​(boolean matchIfEmpty)
      • field

        default C field​(String field)
        Define the property name of the collection the conditional targets.
        Parameters:
        field - the property name
        Returns:
        this
      • anyMatch

        default C anyMatch()
        Mark this conditional as requiring any collection members to match the conditions.
        Returns:
        this
      • allMatch

        default C allMatch()
        Mark this conditional as requiring all collection member to match the condition.
        Returns:
        this
      • conditional

        default C conditional​(Conditional<?>... conditionals)
        Adds one or more conditions to this conditional.
        Parameters:
        conditionals - the conditional(s)
        Returns:
        this
      • conditionals

        default C conditionals​(List<Conditional<?>> conditionals)
        Adds one or more conditions to this conditional.
        Parameters:
        conditionals - the conditional(s)
        Returns:
        this
      • clearConditionals

        default C clearConditionals()
        Clears the current conditions on this conditional.
        Returns:
        this
      • matchIfEmpty

        default C matchIfEmpty()
        Marks this conditional as treating an empty collection as a match.
        Returns:
        this
      • notMatchIfEmpty

        default C notMatchIfEmpty()
        Marks this conditional as treating an empty collection as NOT a match.
        Returns:
        this