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