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

com.landawn.abacus.util.Throwables Maven / Gradle / Ivy

Go to download

A general programming library in Java/Android. It's easy to learn and simple to use with concise and powerful APIs.

There is a newer version: 5.3.16
Show newest version
/*
 * Copyright (C) 2019 HaiYang Li
 *
 * 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.landawn.abacus.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

import com.landawn.abacus.annotation.Beta;
import com.landawn.abacus.util.u.Nullable;

/**
 * Catch checked exception and convert it to RuntimeException.
 *
 * @author Haiyang Li
 */
@SuppressWarnings({ "java:S6539" })
public final class Throwables {

    private Throwables() {
        // Singleton for utility class.
    }

    /**
     *
     * @param cmd
     * @throws RuntimeException if some error happens
     */
    public static void run(final Throwables.Runnable cmd) {
        try {
            cmd.run();
        } catch (Throwable e) {
            throw ExceptionUtil.toRuntimeException(e, true);
        }
    }

    /**
     *
     * @param cmd
     * @param actionOnError
     */
    public static void run(final Throwables.Runnable cmd, final java.util.function.Consumer actionOnError) {
        N.checkArgNotNull(actionOnError);

        try {
            cmd.run();
        } catch (Throwable e) {
            actionOnError.accept(e);
        }
    }

    /**
     *
     * @param 
     * @param cmd
     * @return
     * @throws RuntimeException if some error happens
     */
    public static  R call(final Throwables.Callable cmd) {
        try {
            return cmd.call();
        } catch (Throwable e) {
            throw ExceptionUtil.toRuntimeException(e, true);
        }
    }

    /**
     *
     * @param 
     * @param cmd
     * @param actionOnError
     * @return
     */
    public static  R call(final Throwables.Callable cmd,
            final java.util.function.Function actionOnError) {
        N.checkArgNotNull(actionOnError);

        try {
            return cmd.call();
        } catch (Throwable e) {
            return actionOnError.apply(e);
        }
    }

    /**
     *
     * @param 
     * @param cmd
     * @param supplier
     * @return
     */
    public static  R call(final Throwables.Callable cmd, final java.util.function.Supplier supplier) {
        N.checkArgNotNull(supplier);

        try {
            return cmd.call();
        } catch (Throwable e) {
            return supplier.get();
        }
    }

    /**
     *
     * @param 
     * @param cmd
     * @param defaultValue
     * @return
     */
    public static  R call(final Throwables.Callable cmd, final R defaultValue) {
        try {
            return cmd.call();
        } catch (Throwable e) {
            return defaultValue;
        }
    }

    /**
     *
     * @param 
     * @param cmd
     * @param predicate
     * @param supplier
     * @return
     * @throws RuntimeException if some error happens and predicate return false.
     */
    public static  R call(final Throwables.Callable cmd, final java.util.function.Predicate predicate,
            final java.util.function.Supplier supplier) {
        N.checkArgNotNull(predicate);
        N.checkArgNotNull(supplier);

        try {
            return cmd.call();
        } catch (Throwable e) {
            if (predicate.test(e)) {
                return supplier.get();
            } else {
                throw ExceptionUtil.toRuntimeException(e, true);
            }
        }
    }

    /**
     *
     * @param 
     * @param cmd
     * @param predicate
     * @param defaultValue
     * @return
     * @throws RuntimeException if some error happens and predicate return false.
     */
    public static  R call(final Throwables.Callable cmd, final java.util.function.Predicate predicate,
            final R defaultValue) {
        N.checkArgNotNull(predicate);

        try {
            return cmd.call();
        } catch (Throwable e) {
            if (predicate.test(e)) {
                return defaultValue;
            } else {
                throw ExceptionUtil.toRuntimeException(e, true);
            }
        }
    }

    @SuppressWarnings({ "java:S6548" })
    public abstract static class ObjIterator implements Immutable {

        @SuppressWarnings("rawtypes")
        private static final ObjIterator EMPTY = new ObjIterator() {
            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public Object next() {
                throw new NoSuchElementException(InternalUtil.ERROR_MSG_FOR_NO_SUCH_EX);
            }
        };

        /**
         *
         *
         * @param 
         * @param 
         * @return
         */
        public static  ObjIterator empty() {
            return EMPTY;
        }

        /**
         *
         *
         * @param 
         * @param 
         * @param val
         * @return
         */
        public static  ObjIterator just(final T val) {
            return new ObjIterator<>() {
                private boolean done = false;

                @Override
                public boolean hasNext() {
                    return !done;
                }

                @Override
                public T next() {
                    if (done) {
                        throw new NoSuchElementException(InternalUtil.ERROR_MSG_FOR_NO_SUCH_EX);
                    }

                    done = true;

                    return val;
                }
            };
        }

        /**
         *
         *
         * @param 
         * @param 
         * @param iterable
         * @return
         */
        public static  ObjIterator of(final Iterable iterable) {
            if (iterable == null) {
                return empty();
            }

            final Iterator iter = iterable.iterator();

            return new ObjIterator<>() {
                @Override
                public boolean hasNext() {
                    return iter.hasNext();
                }

                @Override
                public T next() throws E {
                    return iter.next();
                }
            };
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        public abstract boolean hasNext() throws E;

        /**
         *
         *
         * @return
         * @throws E
         */
        public abstract T next() throws E;

        /**
         *
         *
         * @param predicate
         * @return
         */
        public ObjIterator filter(final Throwables.Predicate predicate) {
            final ObjIterator iter = this;

            return new ObjIterator<>() {
                private final T NONE = (T) N.NULL_MASK; //NOSONAR
                private T next = NONE;
                private T tmp = null;

                @Override
                public boolean hasNext() throws E {
                    if (next == NONE) {
                        while (iter.hasNext()) {
                            tmp = iter.next();

                            if (predicate.test(tmp)) {
                                next = tmp;
                                break;
                            }
                        }
                    }

                    return next != NONE;
                }

                @Override
                public T next() throws E {
                    if (!hasNext()) {
                        throw new NoSuchElementException(InternalUtil.ERROR_MSG_FOR_NO_SUCH_EX);
                    }

                    tmp = next;
                    next = NONE;
                    return tmp;
                }
            };
        }

        /**
         *
         *
         * @param 
         * @param mapper
         * @return
         */
        public  ObjIterator map(final Throwables.Function mapper) {
            final ObjIterator iter = this;

            return new ObjIterator<>() {
                @Override
                public boolean hasNext() throws E {
                    return iter.hasNext();
                }

                @Override
                public U next() throws E {
                    return mapper.apply(iter.next());
                }
            };
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        public Nullable first() throws E {
            if (hasNext()) {
                return Nullable.of(next());
            } else {
                return Nullable. empty();
            }
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        public u.Optional firstNonNull() throws E {
            T next = null;

            while (hasNext()) {
                next = next();

                if (next != null) {
                    return u.Optional.of(next);
                }
            }

            return u.Optional.empty();
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        public Nullable last() throws E {
            if (hasNext()) {
                T next = next();

                while (hasNext()) {
                    next = next();
                }

                return Nullable.of(next);
            } else {
                return Nullable. empty();
            }
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        public Object[] toArray() throws E {
            return toArray(N.EMPTY_OBJECT_ARRAY);
        }

        /**
         *
         *
         * @param 
         * @param a
         * @return
         * @throws E
         */
        public  A[] toArray(A[] a) throws E {
            return toList().toArray(a);
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        public List toList() throws E {
            final List list = new ArrayList<>();

            while (hasNext()) {
                list.add(next());
            }

            return list;
        }

        /**
         *
         *
         * @param action
         * @throws E
         */
        public void forEachRemaining(java.util.function.Consumer action) throws E { // NOSONAR
            N.checkArgNotNull(action);

            while (hasNext()) {
                action.accept(next());
            }
        }

        /**
         *
         * @param action
         * @throws E the e
         */
        public void foreachRemaining(Throwables.Consumer action) throws E { // NOSONAR
            N.checkArgNotNull(action);

            while (hasNext()) {
                action.accept(next());
            }
        }

        /**
         *
         * @param action
         * @throws E the e
         */
        public void foreachIndexed(Throwables.IntObjConsumer action) throws E {
            N.checkArgNotNull(action);

            int idx = 0;

            while (hasNext()) {
                action.accept(idx++, next());
            }
        }
    }

    /**
     * The Interface Runnable.
     *
     * @param 
     */
    public interface Runnable {

        /**
         *
         * @throws E the e
         */
        void run() throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.Runnable unchecked() {
            return () -> {
                try {
                    run();
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface Callable.
     *
     * @param 
     * @param 
     */
    public interface Callable {

        /**
         *
         * @return
         * @throws E the e
         */
        R call() throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.Callable unchecked() {
            return () -> {
                try {
                    return call();
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface Supplier.
     *
     * @param 
     * @param 
     */
    public interface Supplier {

        /**
         *
         * @return
         * @throws E the e
         */
        T get() throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.Supplier unchecked() {
            return () -> {
                try {
                    return get();
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface BooleanSupplier.
     *
     * @param 
     */
    public interface BooleanSupplier {

        /**
         * Gets the as boolean.
         *
         * @return
         * @throws E the e
         */
        boolean getAsBoolean() throws E; // NOSONAR
    }

    /**
     * The Interface CharSupplier.
     *
     * @param 
     */
    public interface CharSupplier {

        /**
         * Gets the as char.
         *
         * @return
         * @throws E the e
         */
        char getAsChar() throws E;
    }

    /**
     * The Interface ByteSupplier.
     *
     * @param 
     */
    public interface ByteSupplier {

        /**
         * Gets the as byte.
         *
         * @return
         * @throws E the e
         */
        byte getAsByte() throws E;
    }

    /**
     * The Interface ShortSupplier.
     *
     * @param 
     */
    public interface ShortSupplier {

        /**
         * Gets the as short.
         *
         * @return
         * @throws E the e
         */
        short getAsShort() throws E;
    }

    /**
     * The Interface IntSupplier.
     *
     * @param 
     */
    public interface IntSupplier {

        /**
         * Gets the as int.
         *
         * @return
         * @throws E the e
         */
        int getAsInt() throws E;
    }

    /**
     * The Interface LongSupplier.
     *
     * @param 
     */
    public interface LongSupplier {

        /**
         * Gets the as long.
         *
         * @return
         * @throws E the e
         */
        long getAsLong() throws E;
    }

    /**
     * The Interface FloatSupplier.
     *
     * @param 
     */
    public interface FloatSupplier {

        /**
         * Gets the as float.
         *
         * @return
         * @throws E the e
         */
        float getAsFloat() throws E;
    }

    /**
     * The Interface DoubleSupplier.
     *
     * @param 
     */
    public interface DoubleSupplier {

        /**
         * Gets the as double.
         *
         * @return
         * @throws E the e
         */
        double getAsDouble() throws E;
    }

    /**
     * The Interface Predicate.
     *
     * @param 
     * @param 
     */
    public interface Predicate {

        /**
         *
         * @param t
         * @return
         * @throws E the e
         */
        boolean test(T t) throws E;

        /**
         *
         *
         * @return
         */
        default Predicate negate() {
            return t -> !test(t);
        }

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.Predicate unchecked() {
            return t -> {
                try {
                    return test(t);
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface BiPredicate.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface BiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(T t, U u) throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.BiPredicate unchecked() {
            return (t, u) -> {
                try {
                    return test(t, u);
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface TriPredicate.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface TriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(A a, B b, C c) throws E;
    }

    /**
     * The Interface QuadPredicate.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface QuadPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @param d
         * @return
         * @throws E the e
         */
        boolean test(A a, B b, C c, D d) throws E;
    }

    /**
     * The Interface Function.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface Function {

        /**
         *
         * @param t
         * @return
         * @throws E the e
         */
        R apply(T t) throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.Function unchecked() {
            return t -> {
                try {
                    return apply(t);
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface BiFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface BiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(T t, U u) throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.BiFunction unchecked() {
            return (t, u) -> {
                try {
                    return apply(t, u);
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface TriFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface TriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(A a, B b, C c) throws E;
    }

    /**
     * The Interface QuadFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface QuadFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @param d
         * @return
         * @throws E the e
         */
        R apply(A a, B b, C c, D d) throws E;
    }

    /**
     * The Interface Consumer.
     *
     * @param 
     * @param 
     */
    public interface Consumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(T t) throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.Consumer unchecked() {
            return t -> {
                try {
                    accept(t);
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface BiConsumer.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface BiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(T t, U u) throws E;

        /**
         *
         *
         * @return
         */
        @Beta
        default com.landawn.abacus.util.function.BiConsumer unchecked() {
            return (t, u) -> {
                try {
                    accept(t, u);
                } catch (Throwable e) {
                    throw ExceptionUtil.toRuntimeException(e, true);
                }
            };
        }
    }

    /**
     * The Interface TriConsumer.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface TriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(A a, B b, C c) throws E;
    }

    /**
     * The Interface QuadConsumer.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface QuadConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @param d
         * @throws E the e
         */
        void accept(A a, B b, C c, D d) throws E;
    }

    /**
     * The Interface BooleanConsumer.
     *
     * @param 
     */
    public interface BooleanConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(boolean t) throws E;
    }

    /**
     * The Interface BooleanPredicate.
     *
     * @param 
     */
    public interface BooleanPredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(boolean value) throws E;
    }

    /**
     * The Interface BooleanFunction.
     *
     * @param 
     * @param 
     */
    public interface BooleanFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(boolean value) throws E;
    }

    /**
     * The Interface CharConsumer.
     *
     * @param 
     */
    public interface CharConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(char t) throws E;
    }

    /**
     * The Interface CharPredicate.
     *
     * @param 
     */
    public interface CharPredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(char value) throws E;
    }

    /**
     * The Interface CharFunction.
     *
     * @param 
     * @param 
     */
    public interface CharFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(char value) throws E;
    }

    /**
     * The Interface ByteConsumer.
     *
     * @param 
     */
    public interface ByteConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(byte t) throws E;
    }

    /**
     * The Interface BytePredicate.
     *
     * @param 
     */
    public interface BytePredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(byte value) throws E;
    }

    /**
     * The Interface ByteFunction.
     *
     * @param 
     * @param 
     */
    public interface ByteFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(byte value) throws E;
    }

    /**
     * The Interface ShortConsumer.
     *
     * @param 
     */
    public interface ShortConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(short t) throws E;
    }

    /**
     * The Interface ShortPredicate.
     *
     * @param 
     */
    public interface ShortPredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(short value) throws E;
    }

    /**
     * The Interface ShortFunction.
     *
     * @param 
     * @param 
     */
    public interface ShortFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(short value) throws E;
    }

    /**
     * The Interface IntConsumer.
     *
     * @param 
     */
    public interface IntConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(int t) throws E;
    }

    /**
     * The Interface IntPredicate.
     *
     * @param 
     */
    public interface IntPredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(int value) throws E;
    }

    /**
     * The Interface IntFunction.
     *
     * @param 
     * @param 
     */
    public interface IntFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(int value) throws E;
    }

    /**
     * The Interface IntToLongFunction.
     *
     * @param 
     */
    public interface IntToLongFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        long applyAsLong(int value) throws E;
    }

    /**
     * The Interface IntToDoubleFunction.
     *
     * @param 
     */
    public interface IntToDoubleFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        double applyAsDouble(int value) throws E;
    }

    /**
     * The Interface LongConsumer.
     *
     * @param 
     */
    public interface LongConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(long t) throws E;
    }

    /**
     * The Interface LongPredicate.
     *
     * @param 
     */
    public interface LongPredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(long value) throws E;
    }

    /**
     * The Interface LongFunction.
     *
     * @param 
     * @param 
     */
    public interface LongFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(long value) throws E;
    }

    /**
     * The Interface LongToIntFunction.
     *
     * @param 
     */
    public interface LongToIntFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        int applyAsInt(long value) throws E;
    }

    /**
     * The Interface LongToDoubleFunction.
     *
     * @param 
     */
    public interface LongToDoubleFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        double applyAsDouble(long value) throws E;
    }

    /**
     * The Interface FloatConsumer.
     *
     * @param 
     */
    public interface FloatConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(float t) throws E;
    }

    /**
     * The Interface FloatPredicate.
     *
     * @param 
     */
    public interface FloatPredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(float value) throws E;
    }

    /**
     * The Interface FloatFunction.
     *
     * @param 
     * @param 
     */
    public interface FloatFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(float value) throws E;
    }

    /**
     * The Interface DoubleConsumer.
     *
     * @param 
     */
    public interface DoubleConsumer {

        /**
         *
         * @param t
         * @throws E the e
         */
        void accept(double t) throws E;
    }

    /**
     * The Interface DoublePredicate.
     *
     * @param 
     */
    public interface DoublePredicate {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        boolean test(double value) throws E;
    }

    /**
     * The Interface DoubleFunction.
     *
     * @param 
     * @param 
     */
    public interface DoubleFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        R apply(double value) throws E;
    }

    /**
     * The Interface DoubleToIntFunction.
     *
     * @param 
     */
    public interface DoubleToIntFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        int applyAsInt(double value) throws E;
    }

    /**
     * The Interface DoubleToLongFunction.
     *
     * @param 
     */
    public interface DoubleToLongFunction {

        /**
         *
         * @param value
         * @return
         * @throws E the e
         */
        long applyAsLong(double value) throws E;
    }

    /**
     * The Interface ToBooleanFunction.
     *
     * @param 
     * @param 
     */
    public interface ToBooleanFunction {

        /**
         * Apply as boolean.
         *
         * @param t
         * @return
         * @throws E the e
         */
        boolean applyAsBoolean(T t) throws E;
    }

    /**
     * The Interface ToCharFunction.
     *
     * @param 
     * @param 
     */
    public interface ToCharFunction {

        /**
         * Apply as char.
         *
         * @param t
         * @return
         * @throws E the e
         */
        char applyAsChar(T t) throws E;
    }

    /**
     * The Interface ToByteFunction.
     *
     * @param 
     * @param 
     */
    public interface ToByteFunction {

        /**
         * Apply as byte.
         *
         * @param t
         * @return
         * @throws E the e
         */
        byte applyAsByte(T t) throws E;
    }

    /**
     * The Interface ToShortFunction.
     *
     * @param 
     * @param 
     */
    public interface ToShortFunction {

        /**
         * Apply as short.
         *
         * @param t
         * @return
         * @throws E the e
         */
        short applyAsShort(T t) throws E;
    }

    /**
     * The Interface ToIntFunction.
     *
     * @param 
     * @param 
     */
    public interface ToIntFunction {

        /**
         * Apply as int.
         *
         * @param t
         * @return
         * @throws E the e
         */
        int applyAsInt(T t) throws E;
    }

    /**
     * The Interface ToLongFunction.
     *
     * @param 
     * @param 
     */
    public interface ToLongFunction {

        /**
         * Apply as long.
         *
         * @param t
         * @return
         * @throws E the e
         */
        long applyAsLong(T t) throws E;
    }

    /**
     * The Interface ToFloatFunction.
     *
     * @param 
     * @param 
     */
    public interface ToFloatFunction {

        /**
         * Apply as float.
         *
         * @param t
         * @return
         * @throws E the e
         */
        float applyAsFloat(T t) throws E;
    }

    /**
     * The Interface ToDoubleFunction.
     *
     * @param 
     * @param 
     */
    public interface ToDoubleFunction {

        /**
         * Apply as double.
         *
         * @param t
         * @return
         * @throws E the e
         */
        double applyAsDouble(T t) throws E;
    }

    /**
     * The Interface TriIntFunction.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface ToIntBiFunction {

        /**
         *
         * @param a
         * @param b
         * @return
         * @throws E the e
         */
        int applyAsInt(A a, B b) throws E;
    }

    /**
     * The Interface TriLongFunction.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface ToLongBiFunction {

        /**
         *
         * @param a
         * @param b
         * @return
         * @throws E the e
         */
        long applyAsLong(A a, B b) throws E;
    }

    /**
     * The Interface TriDoubleFunction.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface ToDoubleBiFunction {

        /**
         *
         * @param a
         * @param b
         * @return
         * @throws E the e
         */
        double applyAsDouble(A a, B b) throws E;
    }

    /**
     * The Interface TriIntFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface ToIntTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        int applyAsInt(A a, B b, C c) throws E;
    }

    /**
     * The Interface TriLongFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface ToLongTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        long applyAsLong(A a, B b, C c) throws E;
    }

    /**
     * The Interface TriDoubleFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface ToDoubleTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        double applyAsDouble(A a, B b, C c) throws E;
    }

    /**
     * The Interface UnaryOperator.
     *
     * @param 
     * @param 
     */
    public interface UnaryOperator extends Function {
    }

    /**
     * The Interface BinaryOperator.
     *
     * @param 
     * @param 
     */
    public interface BinaryOperator extends BiFunction {
    }

    /**
     * The Interface TernaryOperator.
     *
     * @param 
     * @param 
     */
    public interface TernaryOperator {

        /**
         * Apply as char.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        T apply(T a, T b, T c) throws E;
    }

    /**
     * The Interface BooleanUnaryOperator.
     *
     * @param 
     */
    public interface BooleanUnaryOperator {

        /**
         * Apply as boolean.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        boolean applyAsBoolean(boolean operand) throws E;
    }

    /**
     * The Interface CharUnaryOperator.
     *
     * @param 
     */
    public interface CharUnaryOperator {

        /**
         * Apply as char.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        char applyAsChar(char operand) throws E;
    }

    /**
     * The Interface ByteUnaryOperator.
     *
     * @param 
     */
    public interface ByteUnaryOperator {

        /**
         * Apply as byte.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        byte applyAsByte(byte operand) throws E;
    }

    /**
     * The Interface ShortUnaryOperator.
     *
     * @param 
     */
    public interface ShortUnaryOperator {

        /**
         * Apply as short.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        short applyAsShort(short operand) throws E;
    }

    /**
     * The Interface IntUnaryOperator.
     *
     * @param 
     */
    public interface IntUnaryOperator {

        /**
         * Apply as int.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        int applyAsInt(int operand) throws E;
    }

    /**
     * The Interface IntObjOperator.
     *
     * @param 
     */
    @Beta
    public interface IntObjOperator {

        /**
         * Apply as int.
         *
         * @param operand
         * @param obj
         * @return
         * @throws E the e
         */
        int applyAsInt(int operand, T obj) throws E;
    }

    /**
     * The Interface LongUnaryOperator.
     *
     * @param 
     */
    public interface LongUnaryOperator {

        /**
         * Apply as long.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        long applyAsLong(long operand) throws E;
    }

    /**
     * The Interface FloatUnaryOperator.
     *
     * @param 
     */
    public interface FloatUnaryOperator {

        /**
         * Apply as float.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        float applyAsFloat(float operand) throws E;
    }

    /**
     * The Interface DoubleUnaryOperator.
     *
     * @param 
     */
    public interface DoubleUnaryOperator {

        /**
         * Apply as double.
         *
         * @param operand
         * @return
         * @throws E the e
         */
        double applyAsDouble(double operand) throws E;
    }

    /**
     * The Interface BooleanBinaryOperator.
     *
     * @param 
     */
    public interface BooleanBinaryOperator {

        /**
         * Apply as boolean.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        boolean applyAsBoolean(boolean left, boolean right) throws E;
    }

    /**
     * The Interface CharBinaryOperator.
     *
     * @param 
     */
    public interface CharBinaryOperator {

        /**
         * Apply as char.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        char applyAsChar(char left, char right) throws E;
    }

    /**
     * The Interface ByteBinaryOperator.
     *
     * @param 
     */
    public interface ByteBinaryOperator {

        /**
         * Apply as byte.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        byte applyAsByte(byte left, byte right) throws E;
    }

    /**
     * The Interface ShortBinaryOperator.
     *
     * @param 
     */
    public interface ShortBinaryOperator {

        /**
         * Apply as short.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        short applyAsShort(short left, short right) throws E;
    }

    /**
     * The Interface IntBinaryOperator.
     *
     * @param 
     */
    public interface IntBinaryOperator {

        /**
         * Apply as int.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        int applyAsInt(int left, int right) throws E;
    }

    /**
     * The Interface LongBinaryOperator.
     *
     * @param 
     */
    public interface LongBinaryOperator {

        /**
         * Apply as long.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        long applyAsLong(long left, long right) throws E;
    }

    /**
     * The Interface FloatBinaryOperator.
     *
     * @param 
     */
    public interface FloatBinaryOperator {

        /**
         * Apply as float.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        float applyAsFloat(float left, float right) throws E;
    }

    /**
     * The Interface DoubleBinaryOperator.
     *
     * @param 
     */
    public interface DoubleBinaryOperator {

        /**
         * Apply as double.
         *
         * @param left
         * @param right
         * @return
         * @throws E the e
         */
        double applyAsDouble(double left, double right) throws E;
    }

    /**
     * The Interface BooleanTernaryOperator.
     *
     * @param 
     */
    public interface BooleanTernaryOperator {

        /**
         * Apply as boolean.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean applyAsBoolean(boolean a, boolean b, boolean c) throws E;
    }

    /**
     * The Interface CharTernaryOperator.
     *
     * @param 
     */
    public interface CharTernaryOperator {

        /**
         * Apply as char.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        char applyAsChar(char a, char b, char c) throws E;
    }

    /**
     * The Interface ByteTernaryOperator.
     *
     * @param 
     */
    public interface ByteTernaryOperator {

        /**
         * Apply as byte.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        byte applyAsByte(byte a, byte b, byte c) throws E;
    }

    /**
     * The Interface ShortTernaryOperator.
     *
     * @param 
     */
    public interface ShortTernaryOperator {

        /**
         * Apply as short.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        short applyAsShort(short a, short b, short c) throws E;
    }

    /**
     * The Interface IntTernaryOperator.
     *
     * @param 
     */
    public interface IntTernaryOperator {

        /**
         * Apply as int.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        int applyAsInt(int a, int b, int c) throws E;
    }

    /**
     * The Interface LongTernaryOperator.
     *
     * @param 
     */
    public interface LongTernaryOperator {

        /**
         * Apply as long.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        long applyAsLong(long a, long b, long c) throws E;
    }

    /**
     * The Interface FloatTernaryOperator.
     *
     * @param 
     */
    public interface FloatTernaryOperator {

        /**
         * Apply as float.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        float applyAsFloat(float a, float b, float c) throws E;
    }

    /**
     * The Interface DoubleTernaryOperator.
     *
     * @param 
     */
    public interface DoubleTernaryOperator {

        /**
         * Apply as double.
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        double applyAsDouble(double a, double b, double c) throws E;
    }

    /**
     * The Interface BooleanBiPredicate.
     *
     * @param 
     */
    public interface BooleanBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(boolean t, boolean u) throws E;
    }

    /**
     * The Interface CharBiPredicate.
     *
     * @param 
     */
    public interface CharBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(char t, char u) throws E;
    }

    /**
     * The Interface ByteBiPredicate.
     *
     * @param 
     */
    public interface ByteBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(byte t, byte u) throws E;
    }

    /**
     * The Interface ShortBiPredicate.
     *
     * @param 
     */
    public interface ShortBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(short t, short u) throws E;
    }

    /**
     * The Interface IntBiPredicate.
     *
     * @param 
     */
    public interface IntBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(int t, int u) throws E;
    }

    /**
     * The Interface LongBiPredicate.
     *
     * @param 
     */
    public interface LongBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(long t, long u) throws E;
    }

    /**
     * The Interface FloatBiPredicate.
     *
     * @param 
     */
    public interface FloatBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(float t, float u) throws E;
    }

    /**
     * The Interface DoubleBiPredicate.
     *
     * @param 
     */
    public interface DoubleBiPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(double t, double u) throws E;
    }

    /**
     * The Interface BooleanBiFunction.
     *
     * @param 
     * @param 
     */
    public interface BooleanBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(boolean t, boolean u) throws E;
    }

    /**
     * The Interface CharBiFunction.
     *
     * @param 
     * @param 
     */
    public interface CharBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(char t, char u) throws E;
    }

    /**
     * The Interface ByteBiFunction.
     *
     * @param 
     * @param 
     */
    public interface ByteBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(byte t, byte u) throws E;
    }

    /**
     * The Interface ShortBiFunction.
     *
     * @param 
     * @param 
     */
    public interface ShortBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(short t, short u) throws E;
    }

    /**
     * The Interface IntBiFunction.
     *
     * @param 
     * @param 
     */
    public interface IntBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(int t, int u) throws E;
    }

    /**
     * The Interface LongBiFunction.
     *
     * @param 
     * @param 
     */
    public interface LongBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(long t, long u) throws E;
    }

    /**
     * The Interface FloatBiFunction.
     *
     * @param 
     * @param 
     */
    public interface FloatBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(float t, float u) throws E;
    }

    /**
     * The Interface DoubleBiFunction.
     *
     * @param 
     * @param 
     */
    public interface DoubleBiFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(double t, double u) throws E;
    }

    /**
     * The Interface BooleanBiConsumer.
     *
     * @param 
     */
    public interface BooleanBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(boolean t, boolean u) throws E;
    }

    /**
     * The Interface CharBiConsumer.
     *
     * @param 
     */
    public interface CharBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(char t, char u) throws E;
    }

    /**
     * The Interface ByteBiConsumer.
     *
     * @param 
     */
    public interface ByteBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(byte t, byte u) throws E;
    }

    /**
     * The Interface ShortBiConsumer.
     *
     * @param 
     */
    public interface ShortBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(short t, short u) throws E;
    }

    /**
     * The Interface IntBiConsumer.
     *
     * @param 
     */
    public interface IntBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(int t, int u) throws E;
    }

    /**
     * The Interface LongBiConsumer.
     *
     * @param 
     */
    public interface LongBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(long t, long u) throws E;
    }

    /**
     * The Interface FloatBiConsumer.
     *
     * @param 
     */
    public interface FloatBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(float t, float u) throws E;
    }

    /**
     * The Interface DoubleBiConsumer.
     *
     * @param 
     */
    public interface DoubleBiConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(double t, double u) throws E;
    }

    /**
     * The Interface BooleanTriPredicate.
     *
     * @param 
     */
    public interface BooleanTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(boolean a, boolean b, boolean c) throws E;
    }

    /**
     * The Interface CharTriPredicate.
     *
     * @param 
     */
    public interface CharTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(char a, char b, char c) throws E;
    }

    /**
     * The Interface ByteTriPredicate.
     *
     * @param 
     */
    public interface ByteTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(byte a, byte b, byte c) throws E;
    }

    /**
     * The Interface ShortTriPredicate.
     *
     * @param 
     */
    public interface ShortTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(short a, short b, short c) throws E;
    }

    /**
     * The Interface IntTriPredicate.
     *
     * @param 
     */
    public interface IntTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(int a, int b, int c) throws E;
    }

    /**
     * The Interface LongTriPredicate.
     *
     * @param 
     */
    public interface LongTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(long a, long b, long c) throws E;
    }

    /**
     * The Interface FloatTriPredicate.
     *
     * @param 
     */
    public interface FloatTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(float a, float b, float c) throws E;
    }

    /**
     * The Interface DoubleTriPredicate.
     *
     * @param 
     */
    public interface DoubleTriPredicate {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        boolean test(double a, double b, double c) throws E;
    }

    /**
     * The Interface BooleanTriFunction.
     *
     * @param 
     * @param 
     */
    public interface BooleanTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(boolean a, boolean b, boolean c) throws E;
    }

    /**
     * The Interface CharTriFunction.
     *
     * @param 
     * @param 
     */
    public interface CharTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(char a, char b, char c) throws E;
    }

    /**
     * The Interface ByteTriFunction.
     *
     * @param 
     * @param 
     */
    public interface ByteTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(byte a, byte b, byte c) throws E;
    }

    /**
     * The Interface ShortTriFunction.
     *
     * @param 
     * @param 
     */
    public interface ShortTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(short a, short b, short c) throws E;
    }

    /**
     * The Interface IntTriFunction.
     *
     * @param 
     * @param 
     */
    public interface IntTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(int a, int b, int c) throws E;
    }

    /**
     * The Interface LongTriFunction.
     *
     * @param 
     * @param 
     */
    public interface LongTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(long a, long b, long c) throws E;
    }

    /**
     * The Interface FloatTriFunction.
     *
     * @param 
     * @param 
     */
    public interface FloatTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(float a, float b, float c) throws E;
    }

    /**
     * The Interface DoubleTriFunction.
     *
     * @param 
     * @param 
     */
    public interface DoubleTriFunction {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @return
         * @throws E the e
         */
        R apply(double a, double b, double c) throws E;
    }

    /**
     * The Interface BooleanTriConsumer.
     *
     * @param 
     */
    public interface BooleanTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(boolean a, boolean b, boolean c) throws E;
    }

    /**
     * The Interface CharTriConsumer.
     *
     * @param 
     */
    public interface CharTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(char a, char b, char c) throws E;
    }

    /**
     * The Interface ByteTriConsumer.
     *
     * @param 
     */
    public interface ByteTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(byte a, byte b, byte c) throws E;
    }

    /**
     * The Interface ShortTriConsumer.
     *
     * @param 
     */
    public interface ShortTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(short a, short b, short c) throws E;
    }

    /**
     * The Interface IntTriConsumer.
     *
     * @param 
     */
    public interface IntTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(int a, int b, int c) throws E;
    }

    /**
     * The Interface LongTriConsumer.
     *
     * @param 
     */
    public interface LongTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(long a, long b, long c) throws E;
    }

    /**
     * The Interface FloatTriConsumer.
     *
     * @param 
     */
    public interface FloatTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(float a, float b, float c) throws E;
    }

    /**
     * The Interface DoubleTriConsumer.
     *
     * @param 
     */
    public interface DoubleTriConsumer {

        /**
         *
         * @param a
         * @param b
         * @param c
         * @throws E the e
         */
        void accept(double a, double b, double c) throws E;
    }

    /**
     * The Interface ObjBooleanConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjBooleanConsumer {

        /**
         *
         * @param t
         * @param value
         * @throws E the e
         */
        void accept(T t, boolean value) throws E;
    }

    /**
     * The Interface ObjCharConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjCharConsumer {

        /**
         *
         * @param t
         * @param value
         * @throws E the e
         */
        void accept(T t, char value) throws E;
    }

    /**
     * The Interface ObjByteConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjByteConsumer {

        /**
         *
         * @param t
         * @param value
         * @throws E the e
         */
        void accept(T t, byte value) throws E;
    }

    /**
     * The Interface ObjShortConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjShortConsumer {

        /**
         *
         * @param t
         * @param value
         * @throws E the e
         */
        void accept(T t, short value) throws E;
    }

    /**
     * The Interface ObjIntConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjIntConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(T t, int u) throws E;
    }

    /**
     * The Interface ObjIntConsumer.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface ObjIntFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(T t, int u) throws E;
    }

    /**
     * The Interface ObjIntPredicate.
     *
     * @param 
     * @param 
     */
    public interface ObjIntPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(T t, int u) throws E;
    }

    /**
     * The Interface ObjLongConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjLongConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(T t, long u) throws E;
    }

    /**
     * The Interface ObjLongFunction.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface ObjLongFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(T t, long u) throws E;
    }

    /**
     * The Interface ObjLongPredicate.
     *
     * @param 
     * @param 
     */
    public interface ObjLongPredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(T t, long u) throws E;
    }

    /**
     * The Interface ObjFloatConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjFloatConsumer {

        /**
         *
         * @param t
         * @param value
         * @throws E the e
         */
        void accept(T t, float value) throws E;
    }

    /**
     * The Interface ObjDoubleConsumer.
     *
     * @param 
     * @param 
     */
    public interface ObjDoubleConsumer {

        /**
         *
         * @param t
         * @param u
         * @throws E the e
         */
        void accept(T t, double u) throws E;
    }

    /**
     * The Interface ObjDoubleFunction.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface ObjDoubleFunction {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        R apply(T t, double u) throws E;
    }

    /**
     * The Interface ObjDoublePredicate.
     *
     * @param 
     * @param 
     */
    public interface ObjDoublePredicate {

        /**
         *
         * @param t
         * @param u
         * @return
         * @throws E the e
         */
        boolean test(T t, double u) throws E;
    }

    public interface ObjBiIntConsumer {

        /**
         *
         * @param t
         * @param i
         * @param j
         * @throws E
         */
        void accept(T t, int i, int j) throws E;
    }

    public interface ObjBiIntFunction {

        /**
         *
         *
         * @param t
         * @param i
         * @param j
         * @return
         * @throws E
         */
        R apply(T t, int i, int j) throws E;
    }

    public interface ObjBiIntPredicate {

        /**
         *
         *
         * @param t
         * @param i
         * @param j
         * @return
         * @throws E
         */
        boolean test(T t, int i, int j) throws E;
    }

    /**
     * The Interface IndexedBiConsumer.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface BiObjIntConsumer {

        /**
         *
         * @param t
         * @param u
         * @param i
         * @throws E the e
         */
        void accept(T t, U u, int i) throws E;
    }

    /**
     * The Interface IndexedBiFunction.
     *
     * @param 
     * @param 
     * @param 
     * @param 
     */
    public interface BiObjIntFunction {

        /**
         *
         * @param e
         * @param u
         * @param i
         * @return
         * @throws E the e
         */
        R apply(T e, U u, int i) throws E;
    }

    /**
     * The Interface IndexedBiPredicate.
     *
     * @param 
     * @param 
     * @param 
     */
    public interface BiObjIntPredicate {

        /**
         *
         * @param t
         * @param u
         * @param i
         * @return
         * @throws E the e
         */
        boolean test(T t, U u, int i) throws E;
    }

    public interface IntObjConsumer {

        /**
         *
         *
         * @param 
         * @param 
         * @param consumer
         * @return
         */
        static  IntObjConsumer of(IntObjConsumer consumer) {
            return consumer;
        }

        /**
         *
         * @param i
         * @param t
         * @throws E
         */
        void accept(int i, T t) throws E;
    }

    public interface IntObjFunction {

        /**
         *
         *
         * @param 
         * @param 
         * @param 
         * @param func
         * @return
         */
        static  IntObjFunction of(IntObjFunction func) {
            return func;
        }

        /**
         *
         *
         * @param i
         * @param t
         * @return
         * @throws E
         */
        R apply(int i, T t) throws E;
    }

    public interface IntObjPredicate {

        /**
         *
         *
         * @param 
         * @param 
         * @param predicate
         * @return
         */
        static  IntObjPredicate of(IntObjPredicate predicate) {
            return predicate;
        }

        /**
         *
         *
         * @param i
         * @param t
         * @return
         * @throws E
         */
        boolean test(int i, T t) throws E;
    }

    public interface IntBiObjConsumer {
        /**
         *
         * @param i
         * @param t
         * @param u
         * @throws E
         */
        void accept(int i, T t, U u) throws E;
    }

    public interface IntBiObjFunction {

        /**
         *
         *
         * @param i
         * @param t
         * @param u
         * @return
         * @throws E
         */
        R apply(int i, T t, U u) throws E;
    }

    public interface IntBiObjPredicate {

        /**
         *
         *
         * @param i
         * @param t
         * @param u
         * @return
         * @throws E
         */
        boolean test(int i, T t, U u) throws E;
    }

    public interface BiIntObjConsumer {

        /**
         *
         * @param i
         * @param j
         * @param t
         * @throws E
         */
        void accept(int i, int j, T t) throws E;
    }

    public interface BiIntObjFunction {

        /**
         *
         *
         * @param i
         * @param j
         * @param t
         * @return
         * @throws E
         */
        R apply(int i, int j, T t) throws E;
    }

    public interface BiIntObjPredicate {

        /**
         *
         *
         * @param i
         * @param j
         * @param t
         * @return
         * @throws E
         */
        boolean test(int i, int j, T t) throws E;
    }

    public interface LongObjConsumer {
        /**
         *
         * @param i
         * @param t
         * @throws E
         */
        void accept(long i, T t) throws E;
    }

    public interface LongObjFunction {
        /**
        *
        * @param i
        * @param t
        * @return
        * @throws E
        */
        R apply(long i, T t) throws E;
    }

    public interface LongObjPredicate {
        /**
        *
        * @param i
        * @param t
        * @return
        * @throws E
        */
        boolean test(long i, T t) throws E;
    }

    public interface DoubleObjConsumer {
        /**
         *
         * @param i
         * @param t
         * @throws E
         */
        void accept(double i, T t) throws E;
    }

    public interface DoubleObjFunction {
        /**
        *
        * @param i
        * @param t
        * @return
        * @throws E
        */
        R apply(double i, T t) throws E;
    }

    public interface DoubleObjPredicate {
        /**
        *
        * @param i
        * @param t
        * @return
        * @throws E
        */
        boolean test(double i, T t) throws E;
    }

    public interface BooleanNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(boolean... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  BooleanNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface CharNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(char... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  CharNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface ByteNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(byte... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  ByteNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface ShortNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(short... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  ShortNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface IntNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(int... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  IntNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface LongNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(long... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  LongNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface FloatNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(float... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  FloatNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface DoubleNFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(double... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  DoubleNFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    public interface NFunction {

        /**
         *
         *
         * @param args
         * @return
         * @throws E
         */
        R apply(T... args) throws E;

        /**
         *
         *
         * @param 
         * @param after
         * @return
         */
        default  NFunction andThen(java.util.function.Function after) {
            N.checkArgNotNull(after);

            return args -> after.apply(apply(args));
        }
    }

    /**
     * The Interface IndexedBooleanConsumer.
     *
     * @param 
     */
    public interface IndexedBooleanConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, boolean e) throws E;
    }

    /**
     * The Interface IndexedCharConsumer.
     *
     * @param 
     */
    public interface IndexedCharConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, char e) throws E;
    }

    /**
     * The Interface IndexedByteConsumer.
     *
     * @param 
     */
    public interface IndexedByteConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, byte e) throws E;
    }

    /**
     * The Interface IndexedShortConsumer.
     *
     * @param 
     */
    public interface IndexedShortConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, short e) throws E;
    }

    /**
     * The Interface IndexedIntConsumer.
     *
     * @param 
     */
    public interface IndexedIntConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, int e) throws E;
    }

    /**
     * The Interface IndexedLongConsumer.
     *
     * @param 
     */
    public interface IndexedLongConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, long e) throws E;
    }

    /**
     * The Interface IndexedFloatConsumer.
     *
     * @param 
     */
    public interface IndexedFloatConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, float e) throws E;
    }

    /**
     * The Interface IndexedDoubleConsumer.
     *
     * @param 
     */
    public interface IndexedDoubleConsumer {

        /**
         *
         * @param idx
         * @param e
         * @throws E the e
         */
        void accept(int idx, double e) throws E;
    }

    public static final class EE {
        private EE() {
            // Singleton. Utility class.
        }

        public interface Runnable {

            /**
             *
             *
             * @throws E
             * @throws E2
             */
            void run() throws E, E2;
        }

        public interface Callable {

            /**
             *
             *
             * @return
             * @throws E
             * @throws E2
             */
            R call() throws E, E2;
        }

        public interface Supplier {

            /**
             *
             *
             * @return
             * @throws E
             * @throws E2
             */
            T get() throws E, E2;
        }

        public interface Predicate {

            /**
             *
             *
             * @param t
             * @return
             * @throws E
             * @throws E2
             */
            boolean test(T t) throws E, E2;
        }

        public interface BiPredicate {

            /**
             *
             *
             * @param t
             * @param u
             * @return
             * @throws E
             * @throws E2
             */
            boolean test(T t, U u) throws E, E2;
        }

        public interface TriPredicate {

            /**
             *
             *
             * @param a
             * @param b
             * @param c
             * @return
             * @throws E
             * @throws E2
             */
            boolean test(A a, B b, C c) throws E, E2;
        }

        public interface Function {

            /**
             *
             *
             * @param t
             * @return
             * @throws E
             * @throws E2
             */
            R apply(T t) throws E, E2;
        }

        public interface BiFunction {

            /**
             *
             *
             * @param t
             * @param u
             * @return
             * @throws E
             * @throws E2
             */
            R apply(T t, U u) throws E, E2;
        }

        public interface TriFunction {

            /**
             *
             *
             * @param a
             * @param b
             * @param c
             * @return
             * @throws E
             * @throws E2
             */
            R apply(A a, B b, C c) throws E, E2;
        }

        public interface Consumer {

            /**
             *
             *
             * @param t
             * @throws E
             * @throws E2
             */
            void accept(T t) throws E, E2;
        }

        public interface BiConsumer {

            /**
             *
             *
             * @param t
             * @param u
             * @throws E
             * @throws E2
             */
            void accept(T t, U u) throws E, E2;
        }

        public interface TriConsumer {

            /**
             *
             *
             * @param a
             * @param b
             * @param c
             * @throws E
             * @throws E2
             */
            void accept(A a, B b, C c) throws E, E2;
        }
    }

    /**
     * The Class EEE.
     */
    public static final class EEE {

        private EEE() {
            // Singleton. Utility class.
        }

        public interface Runnable {

            /**
             *
             *
             * @throws E
             * @throws E2
             * @throws E3
             */
            void run() throws E, E2, E3;
        }

        public interface Callable {

            /**
             *
             *
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            R call() throws E, E2, E3;
        }

        public interface Supplier {

            /**
             *
             *
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            T get() throws E, E2, E3;
        }

        public interface Predicate {

            /**
             *
             *
             * @param t
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            boolean test(T t) throws E, E2, E3;
        }

        public interface BiPredicate {

            /**
             *
             *
             * @param t
             * @param u
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            boolean test(T t, U u) throws E, E2, E3;
        }

        public interface TriPredicate {

            /**
             *
             *
             * @param a
             * @param b
             * @param c
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            boolean test(A a, B b, C c) throws E, E2, E3;
        }

        public interface Function {

            /**
             *
             *
             * @param t
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            R apply(T t) throws E, E2, E3;
        }

        public interface BiFunction {

            /**
             *
             *
             * @param t
             * @param u
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            R apply(T t, U u) throws E, E2, E3;
        }

        public interface TriFunction {

            /**
             *
             *
             * @param a
             * @param b
             * @param c
             * @return
             * @throws E
             * @throws E2
             * @throws E3
             */
            R apply(A a, B b, C c) throws E, E2, E3;
        }

        public interface Consumer {

            /**
             *
             *
             * @param t
             * @throws E
             * @throws E2
             * @throws E3
             */
            void accept(T t) throws E, E2, E3;
        }

        public interface BiConsumer {

            /**
             *
             *
             * @param t
             * @param u
             * @throws E
             * @throws E2
             * @throws E3
             */
            void accept(T t, U u) throws E, E2, E3;
        }

        public interface TriConsumer {

            /**
             *
             *
             * @param a
             * @param b
             * @param c
             * @throws E
             * @throws E2
             * @throws E3
             */
            void accept(A a, B b, C c) throws E, E2, E3;
        }
    }

    static final class LazyInitializer implements Throwables.Supplier {
        private final Supplier supplier;
        private volatile boolean initialized = false;
        private volatile T value = null; //NOSONAR

        LazyInitializer(final Throwables.Supplier supplier) {
            N.checkArgNotNull(supplier, "supplier");

            this.supplier = supplier;
        }

        /**
         *
         *
         * @param 
         * @param 
         * @param supplier
         * @return
         */
        public static  LazyInitializer of(final Throwables.Supplier supplier) {
            N.checkArgNotNull(supplier);

            if (supplier instanceof LazyInitializer) {
                return (LazyInitializer) supplier;
            }

            return new LazyInitializer<>(supplier);
        }

        /**
         *
         *
         * @return
         * @throws E
         */
        @Override
        public T get() throws E {
            if (!initialized) {
                synchronized (this) {
                    if (!initialized) {
                        value = supplier.get();

                        initialized = true;
                    }

                }
            }

            return value;
        }
    }
}