@NotThreadSafe public abstract class AbstractTimedQuery<T> extends AbstractPollingQuery implements TimedQuery<T>, ClockAware
Abstract query that implements byDefaultTimeout() in terms of by(long), and by(long) as a
template method calling the following hooks (to be implemented by subclasses):
currentValue() - to determine current evaluation of the query
shouldReturn(Object) - which indicates, if current value of the query should be returned
In addition, an ExpirationHandler must be provided to handle the case of expired query.
ExpirationHandlerdefaultTimeout, intervalDEFAULT_INTERVAL| Modifier | Constructor and Description |
|---|---|
protected |
AbstractTimedQuery(Clock clock,
long defTimeout,
long interval,
ExpirationHandler expirationHandler) |
protected |
AbstractTimedQuery(long defTimeout,
long interval,
ExpirationHandler expirationHandler) |
protected |
AbstractTimedQuery(PollingQuery other,
ExpirationHandler expirationHandler) |
| Modifier and Type | Method and Description |
|---|---|
T |
by(long timeout)
Evaluate this query by given timeout.
|
T |
by(long timeout,
TimeUnit unit)
Evaluate this query by given timeout.
|
T |
byDefaultTimeout()
Evaluate this query by a timeout deemed default by this query.
|
Clock |
clock()
Clock used by this instance.
|
protected abstract T |
currentValue()
Current evaluation of the query.
|
ExpirationHandler |
expirationHandler()
Expiration handler of this query
|
T |
now()
Evaluate this query immediately.
|
protected void |
resetLastRun() |
protected abstract boolean |
shouldReturn(T currentEval)
If the current evaluated query value should be returned.
|
String |
toString() |
defaultTimeout, intervalclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultTimeout, intervalprotected AbstractTimedQuery(Clock clock, long defTimeout, long interval, ExpirationHandler expirationHandler)
protected AbstractTimedQuery(long defTimeout,
long interval,
ExpirationHandler expirationHandler)
protected AbstractTimedQuery(PollingQuery other, ExpirationHandler expirationHandler)
public final T by(long timeout)
TimedQuerynull, or throw exceptionby in interface TimedQuery<T>timeout - timeout in milliseconds (must be greater than 0)public final T by(long timeout, TimeUnit unit)
TimedQuerynull, or throw exceptionby in interface TimedQuery<T>timeout - timeout (must be greater than 0)unit - the unit that the timeout is inpublic T byDefaultTimeout()
TimedQuerybyDefaultTimeout in interface TimedQuery<T>PollingQuery.defaultTimeout()public final T now()
TimedQuerynow in interface TimedQuery<T>public final ExpirationHandler expirationHandler()
protected abstract boolean shouldReturn(T currentEval)
currentEval - current query evaluation
expirestrue, if the current query evaluation should be returned as a result of this timed queryprotected abstract T currentValue()
public Clock clock()
ClockAwareclock in interface ClockAwareprotected void resetLastRun()
Copyright © 2015 Atlassian. All rights reserved.