Class CountCondition

  • All Implemented Interfaces:
    Condition

    @ThreadSafe
    public class CountCondition
    extends Object
    implements Condition
    Condition that counts how many times a condition is specified and returns true iff the specified condition is satisfied less than the specified number.
    Author:
    dannyroest@gmail.com (Danny Roest)
    • Field Detail

      • condition

        private final Condition condition
      • maxCount

        private final int maxCount
    • Constructor Detail

      • CountCondition

        public CountCondition​(int maxCount,
                              Condition condition)
        Parameters:
        maxCount - number of times the condition can be satisfied.
        condition - the condition.
    • Method Detail

      • check

        public boolean check​(EmbeddedBrowser browser)
        Note: Check has a side effect (it increments a counter). Invoking it multiple times may result in a different answer.
        Specified by:
        check in interface Condition
        Parameters:
        browser - The browser.
        Returns:
        whether the evaluated condition is satisfied
      • hashCode

        public int hashCode()
        Since "count" is a consequence of invoking "check", it is not included in the equality / hashCode computation.
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object object)
        Since "count" is a consequence of invoking "check", it is not included in the equality / hashCode computation.
        Overrides:
        equals in class Object