blob: 88ba2735eb0e72ea92d00acf2d6f181016e654c2 [file] [log] [blame]
Brian O'Connorabafb502014-12-02 22:26:20 -08001package org.onosproject.store.service;
Madan Jampani08822c42014-11-04 17:17:46 -08002
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 Jampani37c2e702014-11-04 18:11:10 -08008 * </p>
Madan Jampani08822c42014-11-04 17:17:46 -08009 * @param <R> type of result.
10 * @param <E> exception encountered in generating the result.
11 */
12public interface OptionalResult<R, E extends Throwable> {
13
14 /**
Madan Jampani37c2e702014-11-04 18:11:10 -080015 * Returns the result or throws an exception if there is no
16 * valid result.
Madan Jampani08822c42014-11-04 17:17:46 -080017 * @return result
Madan Jampani08822c42014-11-04 17:17:46 -080018 */
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}