public class Timer extends Object
resolutionLogic.
Setting the sleep interval to value less than 15 ms is questionable since some operating systems do not provide such precision. Moreover such values may impact test performance.
In case of no stop conditions are specified, timer logic corresponds to regular Thread.sleep(long) execution.
| Modifier and Type | Class and Description |
|---|---|
static class |
Timer.ResolutionLogic |
static interface |
Timer.StopCondition |
| Constructor and Description |
|---|
Timer()
Create new timer with default delay and sleep interval.
|
| Modifier and Type | Method and Description |
|---|---|
Timer |
addStopCondition(Timer.StopCondition condition)
Add new stop condition.
|
Timer |
addStopCondition(Timer.StopCondition condition,
boolean clear)
Add new stop condition.
|
void |
clearStopConditions()
Clear stop conditions and reset
stopConditionsSatisfiedBeforeTimeout. |
boolean |
isStopConditionsSatisfiedBeforeTimeout() |
void |
reset()
Reset to default values.
|
Timer |
setDelay(long delay)
Set new delay value.
|
Timer |
setResolutionLogic(Timer.ResolutionLogic resolutionLogic)
Set new resolution logic.
|
Timer |
setSleepInterval(long sleepInterval)
Set new sleep interval value.
|
Timer |
start()
Start the timer.
|
static Timer |
startNew(long delay)
Start a new timer with specified delay.
|
static Timer |
startNew(long delay,
long sleepInterval)
Start a new timer with specified delay and sleep interval.
|
public Timer()
delay - public Timer setDelay(long delay)
delay - public Timer setSleepInterval(long sleepInterval)
sleepInterval - public Timer setResolutionLogic(Timer.ResolutionLogic resolutionLogic)
resolutionLogic - public Timer addStopCondition(Timer.StopCondition condition)
condition - public Timer addStopCondition(Timer.StopCondition condition, boolean clear)
condition - clear - Clear stop conditions and reset stopConditionsSatisfiedBeforeTimeoutpublic Timer start() throws InterruptedException
InterruptedExceptionpublic void reset()
public void clearStopConditions()
stopConditionsSatisfiedBeforeTimeout.public boolean isStopConditionsSatisfiedBeforeTimeout()
true if stop conditions are satisfied according to actual resolutionLogic before timeout
occurs, false otherwisepublic static Timer startNew(long delay) throws InterruptedException
delay - InterruptedExceptionpublic static Timer startNew(long delay, long sleepInterval) throws InterruptedException
delay - InterruptedExceptionCopyright © 2008-2013 Seam Framework. All Rights Reserved.