Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d90c249 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove PooledConsumer"

parents b4db10fc 4c4a9a77
Loading
Loading
Loading
Loading
+2 −17
Original line number Diff line number Diff line
@@ -51,13 +51,13 @@ import java.util.function.Function;
 * @hide
 */
abstract class OmniFunction<A, B, C, D, E, F, G, H, I, J, K, R> implements
        PooledFunction<A, R>, BiFunction<A, B, R>, TriFunction<A, B, C, R>,
        BiFunction<A, B, R>, TriFunction<A, B, C, R>,
        QuadFunction<A, B, C, D, R>, QuintFunction<A, B, C, D, E, R>,
        HexFunction<A, B, C, D, E, F, R>, HeptFunction<A, B, C, D, E, F, G, R>,
        OctFunction<A, B, C, D, E, F, G, H, R>, NonaFunction<A, B, C, D, E, F, G, H, I, R>,
        DecFunction<A, B, C, D, E, F, G, H, I, J, R>,
        UndecFunction<A, B, C, D, E, F, G, H, I, J, K, R>,
        PooledConsumer<A>, BiConsumer<A, B>, TriConsumer<A, B, C>, QuadConsumer<A, B, C, D>,
        BiConsumer<A, B>, TriConsumer<A, B, C>, QuadConsumer<A, B, C, D>,
        QuintConsumer<A, B, C, D, E>, HexConsumer<A, B, C, D, E, F>,
        HeptConsumer<A, B, C, D, E, F, G>, OctConsumer<A, B, C, D, E, F, G, H>,
        NonaConsumer<A, B, C, D, E, F, G, H, I>, DecConsumer<A, B, C, D, E, F, G, H, I, J>,
@@ -73,11 +73,6 @@ abstract class OmniFunction<A, B, C, D, E, F, G, H, I, J, K, R> implements
        return invoke(o, o2, null, null, null, null, null, null, null, null, null);
    }

    @Override
    public R apply(A o) {
        return invoke(o, null, null, null, null, null, null, null, null, null, null);
    }

    public abstract <V> OmniFunction<A, B, C, D, E, F, G, H, I, J, K, V> andThen(
            Function<? super R, ? extends V> after);
    public abstract OmniFunction<A, B, C, D, E, F, G, H, I, J, K, R> negate();
@@ -87,11 +82,6 @@ abstract class OmniFunction<A, B, C, D, E, F, G, H, I, J, K, R> implements
        invoke(o, o2, null, null, null, null, null, null, null, null, null);
    }

    @Override
    public void accept(A o) {
        invoke(o, null, null, null, null, null, null, null, null, null, null);
    }

    @Override
    public void run() {
        invoke(null, null, null, null, null, null, null, null, null, null, null);
@@ -132,11 +122,6 @@ abstract class OmniFunction<A, B, C, D, E, F, G, H, I, J, K, R> implements
        return this;
    }

    @Override
    public PooledConsumer<A> asConsumer() {
        return this;
    }

    @Override
    public R apply(A a, B b, C c) {
        return invoke(a, b, c, null, null, null, null, null, null, null, null);
+0 −31
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.util.function.pooled;

import java.util.function.Consumer;

/**
 * {@link Consumer} + {@link PooledLambda}
 *
 * @see PooledLambda
 * @hide
 */
public interface PooledConsumer<T> extends PooledLambda, Consumer<T> {

    /** @inheritDoc */
    PooledConsumer<T> recycleOnUse();
}
+0 −36
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.util.function.pooled;

import java.util.function.Function;

/**
 * {@link Function} + {@link PooledLambda}
 *
 * @see PooledLambda
 * @hide
 */
public interface PooledFunction<A, R> extends PooledLambda, Function<A, R> {

    /**
     * Ignores the result
     */
    PooledConsumer<A> asConsumer();

    /** @inheritDoc */
    PooledFunction<A, R> recycleOnUse();
}
+0 −173
Original line number Diff line number Diff line
@@ -232,24 +232,6 @@ public interface PooledLambda {
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 placeholder for a missing argument. Use {@link #__} to get one
     * @param arg2 parameter supplied to {@code function} on call
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg1) -> function(arg1, arg2) }
     */
    static <A, B> PooledConsumer<A> obtainConsumer(
            BiConsumer<? super A, ? super B> function,
            ArgumentPlaceholder<A> arg1, B arg2) {
        return acquire(PooledLambdaImpl.sPool,
                function, 2, 1, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledPredicate} factory
     *
@@ -328,24 +310,6 @@ public interface PooledLambda {
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 parameter supplied to {@code function} on call
     * @param arg2 placeholder for a missing argument. Use {@link #__} to get one
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg2) -> function(arg1, arg2) }
     */
    static <A, B> PooledConsumer<B> obtainConsumer(
            BiConsumer<? super A, ? super B> function,
            A arg1, ArgumentPlaceholder<B> arg2) {
        return acquire(PooledLambdaImpl.sPool,
                function, 2, 1, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledPredicate} factory
     *
@@ -417,63 +381,6 @@ public interface PooledLambda {
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 placeholder for a missing argument. Use {@link #__} to get one
     * @param arg2 parameter supplied to {@code function} on call
     * @param arg3 parameter supplied to {@code function} on call
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg1) -> function(arg1, arg2, arg3) }
     */
    static <A, B, C> PooledConsumer<A> obtainConsumer(
            TriConsumer<? super A, ? super B, ? super C> function,
            ArgumentPlaceholder<A> arg1, B arg2, C arg3) {
        return acquire(PooledLambdaImpl.sPool,
                function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 parameter supplied to {@code function} on call
     * @param arg2 placeholder for a missing argument. Use {@link #__} to get one
     * @param arg3 parameter supplied to {@code function} on call
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg2) -> function(arg1, arg2, arg3) }
     */
    static <A, B, C> PooledConsumer<B> obtainConsumer(
            TriConsumer<? super A, ? super B, ? super C> function,
            A arg1, ArgumentPlaceholder<B> arg2, C arg3) {
        return acquire(PooledLambdaImpl.sPool,
                function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 parameter supplied to {@code function} on call
     * @param arg2 parameter supplied to {@code function} on call
     * @param arg3 placeholder for a missing argument. Use {@link #__} to get one
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg3) -> function(arg1, arg2, arg3) }
     */
    static <A, B, C> PooledConsumer<C> obtainConsumer(
            TriConsumer<? super A, ? super B, ? super C> function,
            A arg1, B arg2, ArgumentPlaceholder<C> arg3) {
        return acquire(PooledLambdaImpl.sPool,
                function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null,
                null, null, null, null);
    }

    /**
     * Factory of {@link Message}s that contain an
     * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its
@@ -529,86 +436,6 @@ public interface PooledLambda {
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 placeholder for a missing argument. Use {@link #__} to get one
     * @param arg2 parameter supplied to {@code function} on call
     * @param arg3 parameter supplied to {@code function} on call
     * @param arg4 parameter supplied to {@code function} on call
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg1) -> function(arg1, arg2, arg3, arg4) }
     */
    static <A, B, C, D> PooledConsumer<A> obtainConsumer(
            QuadConsumer<? super A, ? super B, ? super C, ? super D> function,
            ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4) {
        return acquire(PooledLambdaImpl.sPool,
                function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 parameter supplied to {@code function} on call
     * @param arg2 placeholder for a missing argument. Use {@link #__} to get one
     * @param arg3 parameter supplied to {@code function} on call
     * @param arg4 parameter supplied to {@code function} on call
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg2) -> function(arg1, arg2, arg3, arg4) }
     */
    static <A, B, C, D> PooledConsumer<B> obtainConsumer(
            QuadConsumer<? super A, ? super B, ? super C, ? super D> function,
            A arg1, ArgumentPlaceholder<B> arg2, C arg3, D arg4) {
        return acquire(PooledLambdaImpl.sPool,
                function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 parameter supplied to {@code function} on call
     * @param arg2 parameter supplied to {@code function} on call
     * @param arg3 placeholder for a missing argument. Use {@link #__} to get one
     * @param arg4 parameter supplied to {@code function} on call
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg3) -> function(arg1, arg2, arg3, arg4) }
     */
    static <A, B, C, D> PooledConsumer<C> obtainConsumer(
            QuadConsumer<? super A, ? super B, ? super C, ? super D> function,
            A arg1, B arg2, ArgumentPlaceholder<C> arg3, D arg4) {
        return acquire(PooledLambdaImpl.sPool,
                function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
                null, null, null, null);
    }

    /**
     * {@link PooledConsumer} factory
     *
     * @param function non-capturing lambda(typically an unbounded method reference)
     *                 to be invoked on call
     * @param arg1 parameter supplied to {@code function} on call
     * @param arg2 parameter supplied to {@code function} on call
     * @param arg3 parameter supplied to {@code function} on call
     * @param arg4 placeholder for a missing argument. Use {@link #__} to get one
     * @return a {@link PooledConsumer}, equivalent to lambda:
     *         {@code (arg4) -> function(arg1, arg2, arg3, arg4) }
     */
    static <A, B, C, D> PooledConsumer<D> obtainConsumer(
            QuadConsumer<? super A, ? super B, ? super C, ? super D> function,
            A arg1, B arg2, C arg3, ArgumentPlaceholder<D> arg4) {
        return acquire(PooledLambdaImpl.sPool,
                function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
                null, null, null, null);
    }

    /**
     * Factory of {@link Message}s that contain an
     * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its
+0 −5
Original line number Diff line number Diff line
@@ -26,11 +26,6 @@ import java.util.function.Predicate;
 */
public interface PooledPredicate<T> extends PooledLambda, Predicate<T> {

    /**
     * Ignores the result
     */
    PooledConsumer<T> asConsumer();

    /** @inheritDoc */
    PooledPredicate<T> recycleOnUse();
}
Loading