< prev index next >
core/JemmyCore/src/org/jemmy/timing/Waiter.java
Print this page
@@ -28,46 +28,28 @@
import org.jemmy.JemmyException;
import org.jemmy.TimeoutExpiredException;
import org.jemmy.env.Timeout;
/**
- *
* @author shura
*/
public class Waiter {
- /**
- *
- */
+
public static final Timeout DEFAULT_DELTA = new Timeout("default.wait.delta", 100);
private long waitTime;
private long delta;
- /**
- *
- * @param waitTime
- * @param delta
- */
public Waiter(Timeout waitTime, Timeout delta) {
this.waitTime = waitTime.getValue();
this.delta = delta.getValue();
}
- /**
- *
- * @param waitTime
- */
public Waiter(Timeout waitTime) {
this.waitTime = waitTime.getValue();
this.delta = DEFAULT_DELTA.getValue();
}
- /**
- *
- * @param <T>
- * @param state
- * @return
- */
public <T> T waitState(State<T> state) {
long start = System.currentTimeMillis();
T res;
while( System.currentTimeMillis() < start + waitTime) {
res = state.reached();
@@ -81,17 +63,10 @@
}
}
return null;
}
- /**
- *
- * @param <T>
- * @param value
- * @param state
- * @return
- */
public <T> T waitValue(final T value, final State<T> state) {
State<T> st = new State<T>() {
public T reached() {
T res = state.reached();
if(res != null && res.equals(value)) {
@@ -102,30 +77,18 @@
}
};
return waitState(st);
}
- /**
- *
- * @param <T>
- * @param state
- * @return
- */
public <T> T ensureState(State<T> state) {
T res = waitState(state);
if(res == null) {
throw new TimeoutExpiredException("State '" + state + "' has not been reached in " + waitTime + " milliseconds");
}
return res;
}
- /**
- *
- * @param <T>
- * @param value
- * @param state
- * @return
- */
+
public <T> T ensureValue(T value, State<T> state) {
T res = waitValue(value, state);
if (res == null) {
throw new TimeoutExpiredException("State '" + state + "' has not been reached in " + waitTime + " milliseconds");
}
< prev index next >