All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hu.akarnokd.rxjava2.functions.FunctionsEx Maven / Gradle / Ivy

There is a newer version: 0.20.10
Show newest version
/*
 * Copyright 2016-2018 David Karnok
 *
 * 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 hu.akarnokd.rxjava2.functions;

import io.reactivex.functions.*;

/**
 * Utility methods to work with functional interfaces of this package.
 */
public final class FunctionsEx {

    /** Utility class. */
    private FunctionsEx() {
        throw new IllegalStateException("No instances!");
    }

    /** Implements many consumer interfaces to no-op. */
    @SuppressWarnings("rawtypes")
    enum EmptyConsumer implements
    Consumer, BiConsumer, Consumer3, Consumer4, Consumer5, Consumer6, Consumer7, Consumer8, Consumer9 {
        INSTANCE;

        @Override
        public void accept(Object t1, Object t2, Object t3, Object t4, Object t5, Object t6, Object t7, Object t8,
                Object t9) throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2, Object t3, Object t4, Object t5, Object t6, Object t7, Object t8)
                throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2, Object t3, Object t4, Object t5, Object t6, Object t7)
                throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2, Object t3, Object t4, Object t5, Object t6) throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2, Object t3, Object t4, Object t5) throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2, Object t3, Object t4) throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2, Object t3) throws Exception {
        }

        @Override
        public void accept(Object t1, Object t2) throws Exception {
        }

        @Override
        public void accept(Object t) throws Exception {
        }
    }

    /**
     * Returns a Consumer1-9 shared instance that ignores the argument(s) of its {@code accept()} methods.
     * @param  the combined types of Consumer 1-9.
     * @return the empty Consumer1-9 shared instance
     */
    @SuppressWarnings("unchecked")
    public static 
    & BiConsumer
    & Consumer3
    & Consumer4
    & Consumer5
    & Consumer6
    & Consumer7
    & Consumer8
    & Consumer9>
    T emptyConsumer() {
        return (T)EmptyConsumer.INSTANCE;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy