alshabib | ab98466 | 2014-12-04 18:56:18 -0800 | [diff] [blame^] | 1 | /* |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.service; |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 17 | |
| 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 Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 23 | * </p> |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 24 | * @param <R> type of result. |
| 25 | * @param <E> exception encountered in generating the result. |
| 26 | */ |
| 27 | public interface OptionalResult<R, E extends Throwable> { |
| 28 | |
| 29 | /** |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 30 | * Returns the result or throws an exception if there is no |
| 31 | * valid result. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 32 | * @return result |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 33 | */ |
| 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 | } |