blob: 386cb6ec2ad06c8337bde26478ab5076c8aff8dc [file] [log] [blame]
Fred Quintanaa698f422009-04-08 19:14:54 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
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 */
16package android.accounts;
17
18import java.util.concurrent.Future;
19import java.util.concurrent.TimeUnit;
20
21/**
22 * An extension of {@link Future} that provides wrappers for {@link #get()} that handle the various
23 * exceptions that {@link #get()} may return and rethrows them as exceptions specific to
24 * {@link AccountManager}.
25 */
26public interface Future1<V> extends Future<V> {
27 /**
28 * Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
29 * {@link Future1} is canceled and {@link OperationCanceledException} is thrown.
30 * @return the {@link android.os.Bundle} that is returned by get()
31 * @throws OperationCanceledException if get() throws the unchecked CancellationException
32 * or if the Future was interrupted.
33 */
34 V getResult() throws OperationCanceledException;
35
36 /**
37 * Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
38 * {@link Future1} is canceled and {@link OperationCanceledException} is thrown.
39 * @param timeout the maximum time to wait
40 * @param unit the time unit of the timeout argument
41 * @return the {@link android.os.Bundle} that is returned by {@link Future#get()}
42 * @throws OperationCanceledException if get() throws the unchecked
43 * {@link java.util.concurrent.CancellationException} or if the {@link Future1} was interrupted.
44 */
45 V getResult(long timeout, TimeUnit unit) throws OperationCanceledException;
46}