blob: a9341cbb1a71e5b04946cada095ef3f813e0ffab [file] [log] [blame]
Madan Jampani08822c42014-11-04 17:17:46 -08001package 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 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}