blob: 415652fd6c49dacbc43b7eba95a7016a76eb3331 [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.service;
Madan Jampani08822c42014-11-04 17:17:46 -080017
18/**
19 * A container object which either has a result or an exception.
20 * <p>
21 * If a result is present, get() will return it otherwise get() will throw
22 * the exception that was encountered in the process of generating the result.
Madan Jampani37c2e702014-11-04 18:11:10 -080023 * </p>
Madan Jampani08822c42014-11-04 17:17:46 -080024 * @param <R> type of result.
25 * @param <E> exception encountered in generating the result.
26 */
27public interface OptionalResult<R, E extends Throwable> {
28
29 /**
Madan Jampani37c2e702014-11-04 18:11:10 -080030 * Returns the result or throws an exception if there is no
31 * valid result.
Madan Jampani08822c42014-11-04 17:17:46 -080032 * @return result
Madan Jampani08822c42014-11-04 17:17:46 -080033 */
34 public R get();
35
36 /**
37 * Returns true if there is a valid result.
38 * @return true is yes, false otherwise.
39 */
40 public boolean hasValidResult();
41}