|
21 | 21 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
22 | 22 | import static java.util.concurrent.TimeUnit.SECONDS; |
23 | 23 |
|
24 | | -import com.google.common.base.Function; |
25 | | -import com.google.common.base.Predicate; |
26 | | -import com.google.common.base.Supplier; |
27 | 24 | import com.google.common.base.Throwables; |
28 | 25 | import com.google.common.collect.ImmutableList; |
29 | 26 | import com.google.common.collect.Lists; |
|
34 | 31 | import java.util.Collection; |
35 | 32 | import java.util.List; |
36 | 33 | import java.util.concurrent.TimeUnit; |
| 34 | +import java.util.function.Function; |
| 35 | +import java.util.function.Predicate; |
| 36 | +import java.util.function.Supplier; |
37 | 37 |
|
38 | 38 | /** |
39 | 39 | * An implementation of the {@link Wait} interface that may have its timeout and polling interval |
|
50 | 50 | * Sample usage: <pre> |
51 | 51 | * // Waiting 30 seconds for an element to be present on the page, checking |
52 | 52 | * // for its presence once every 5 seconds. |
53 | | - * Wait{@literal<WebDriver>} wait = new FluentWait{@literal<WebDriver>}(driver) |
| 53 | + * Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) |
54 | 54 | * .withTimeout(30, SECONDS) |
55 | 55 | * .pollingEvery(5, SECONDS) |
56 | 56 | * .ignoring(NoSuchElementException.class); |
57 | 57 | * |
58 | | - * WebElement foo = wait.until(new Function{@literal<WebDriver, WebElement>}() { |
| 58 | + * WebElement foo = wait.until(new Function<WebDriver, WebElement>() { |
59 | 59 | * public WebElement apply(WebDriver driver) { |
60 | 60 | * return driver.findElement(By.id("foo")); |
61 | 61 | * } |
@@ -181,21 +181,24 @@ public FluentWait<T> ignoring(Class<? extends Throwable> exceptionType) { |
181 | 181 | public FluentWait<T> ignoring(Class<? extends Throwable> firstType, |
182 | 182 | Class<? extends Throwable> secondType) { |
183 | 183 |
|
184 | | - return this.ignoreAll(ImmutableList.<Class<? extends Throwable>>of(firstType, secondType)); |
| 184 | + return this.ignoreAll(ImmutableList.of(firstType, secondType)); |
185 | 185 | } |
186 | 186 |
|
187 | 187 | /** |
188 | 188 | * Repeatedly applies this instance's input value to the given predicate until the timeout expires |
189 | | - * or the predicate evaluates to true. |
| 189 | + * or the predicate evaluates to true. This method has been deprecated to simplify the use of |
| 190 | + * Java 8 lambda expressions with this class. It is suggested calls to this method be replaced by |
| 191 | + * calls to {@link #until(Function)}. |
190 | 192 | * |
191 | 193 | * @param isTrue The predicate to wait on. |
192 | 194 | * @throws TimeoutException If the timeout expires. |
| 195 | + * @deprecated Use a {@link Function} that returns a Boolean. |
193 | 196 | */ |
194 | 197 | public void until(final Predicate<T> isTrue) { |
195 | 198 | until(new Function<T, Boolean>() { |
196 | 199 | @Override |
197 | 200 | public Boolean apply(T input) { |
198 | | - return isTrue.apply(input); |
| 201 | + return isTrue.test(input); |
199 | 202 | } |
200 | 203 |
|
201 | 204 | @Override |
@@ -269,7 +272,8 @@ private Throwable propagateIfNotIgnored(Throwable e) { |
269 | 272 | return e; |
270 | 273 | } |
271 | 274 | } |
272 | | - throw Throwables.propagate(e); |
| 275 | + Throwables.throwIfUnchecked(e); |
| 276 | + throw new RuntimeException(e); |
273 | 277 | } |
274 | 278 |
|
275 | 279 | /** |
|
0 commit comments