1   package com.atlassian.pageobjects.elements.query;
2   
3   import com.atlassian.pageobjects.elements.query.util.Clock;
4   import com.atlassian.pageobjects.elements.query.util.ClockAware;
5   import com.atlassian.pageobjects.elements.query.util.SystemClock;
6   
7   import javax.annotation.concurrent.NotThreadSafe;
8   
9   import static com.atlassian.pageobjects.elements.query.util.Clocks.getClock;
10  
11  
12  /**
13   * Abstract timed condition based on {@link com.atlassian.pageobjects.elements.query.AbstractTimedQuery}. Override
14   * {@link #currentValue()} to complete implementation. 
15   *
16   */
17  @NotThreadSafe
18  public abstract class AbstractTimedCondition extends AbstractTimedQuery<Boolean> implements TimedCondition, ClockAware
19  {
20      protected AbstractTimedCondition(Clock clock, long defTimeout, long interval)
21      {
22          super(clock, defTimeout, interval, ExpirationHandler.RETURN_CURRENT);
23      }
24  
25      protected AbstractTimedCondition(long defTimeout, long interval)
26      {
27          this(SystemClock.INSTANCE, defTimeout, interval);
28      }
29  
30      protected AbstractTimedCondition(PollingQuery other)
31      {
32          this(getClock(other), other.defaultTimeout(), other.interval());
33      }
34  
35      @Override
36      protected final boolean shouldReturn(Boolean currentEval)
37      {
38          return currentEval;
39      }
40  }