1/*
2 * Copyright (C) 2017 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 */
16
17package com.android.internal.util.function.pooled;
18
19import com.android.internal.util.FunctionalUtils.ThrowingSupplier;
20
21import java.util.function.DoubleSupplier;
22import java.util.function.IntSupplier;
23import java.util.function.LongSupplier;
24import java.util.function.Supplier;
25
26/**
27 * {@link Supplier} + {@link PooledLambda}
28 *
29 * @see PooledLambda
30 * @hide
31 */
32public interface PooledSupplier<T> extends PooledLambda, Supplier<T>, ThrowingSupplier<T> {
33
34    /**
35     * Ignores the result
36     */
37    PooledRunnable asRunnable();
38
39    /** @inheritDoc */
40    PooledSupplier<T> recycleOnUse();
41
42    /** {@link PooledLambda} + {@link IntSupplier} */
43    interface OfInt extends IntSupplier, PooledLambda {
44        /** @inheritDoc */
45        PooledSupplier.OfInt recycleOnUse();
46    }
47
48    /** {@link PooledLambda} + {@link LongSupplier} */
49    interface OfLong extends LongSupplier, PooledLambda {
50        /** @inheritDoc */
51        PooledSupplier.OfLong recycleOnUse();
52    }
53
54    /** {@link PooledLambda} + {@link DoubleSupplier} */
55    interface OfDouble extends DoubleSupplier, PooledLambda {
56        /** @inheritDoc */
57        PooledSupplier.OfDouble recycleOnUse();
58    }
59}
60