1 package com.atlassian.pageobjects.elements.query;
2
3
4
5
6
7 public interface ExpirationHandler
8 {
9
10
11
12
13
14
15
16
17
18
19 <T> T expired(TimedQuery<T> query, T currentValue, long timeout);
20
21
22
23 public static final ExpirationHandler RETURN_CURRENT = new ExpirationHandler()
24 {
25 public <T> T expired(TimedQuery<T> query, T currentValue, long timeout)
26 {
27 return currentValue;
28 }
29 };
30
31 public static final ExpirationHandler RETURN_NULL = new ExpirationHandler()
32 {
33 public <T> T expired(TimedQuery<T> query, T currentValue, long timeout)
34 {
35 return null;
36 }
37 };
38
39 public static final ExpirationHandler THROW_ASSERTION_ERROR = new ExpirationHandler()
40 {
41 public <T> T expired(TimedQuery<T> query, T currentValue, long timeout)
42 {
43 throw new AssertionError("Timeout <" + timeout + "> expired for: " + query);
44 }
45 };
46
47 public static final ExpirationHandler THROW_ILLEGAL_STATE = new ExpirationHandler()
48 {
49 public <T> T expired(TimedQuery<T> query, T currentValue, long timeout)
50 {
51 throw new IllegalStateException("Timeout <" + timeout + "> expired for: " + query);
52 }
53 };
54
55 }