Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 1 | package org.onlab.onos.store.service; |
| 2 | |
| 3 | /** |
| 4 | * A container object which either has a result or an exception. |
| 5 | * <p> |
| 6 | * If a result is present, get() will return it otherwise get() will throw |
| 7 | * the exception that was encountered in the process of generating the result. |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 8 | * </p> |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 9 | * @param <R> type of result. |
| 10 | * @param <E> exception encountered in generating the result. |
| 11 | */ |
| 12 | public interface OptionalResult<R, E extends Throwable> { |
| 13 | |
| 14 | /** |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 15 | * Returns the result or throws an exception if there is no |
| 16 | * valid result. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 17 | * @return result |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 18 | */ |
| 19 | public R get(); |
| 20 | |
| 21 | /** |
| 22 | * Returns true if there is a valid result. |
| 23 | * @return true is yes, false otherwise. |
| 24 | */ |
| 25 | public boolean hasValidResult(); |
| 26 | } |