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.

The 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.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;

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

/**
 * The Throwables class is a utility class that provides methods for handling exceptions.
 * It includes methods for running commands that may throw exceptions, calling methods that may throw exceptions, and more.
 * It also provides a variety of functional interfaces that can throw exceptions.
 *
 */
@SuppressWarnings({ "java:S6539" })
public final class Throwables {

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

    /**
     * Executes the provided {@code cmd} that may throw an exception.
     *
     * This method is useful when you want to run a piece of code that might throw an exception.
     * If an exception occurs during the execution of the {@code cmd}, it is rethrown as a RuntimeException.
     *
     * @param cmd The runnable task that might throw an exception. Must not be {@code null}.
     * @throws RuntimeException if an exception occurs during the execution of the {@code cmd}.
     * @see Try#run(Throwables.Runnable)
     */
    @Beta
    public static void run(final Throwables.Runnable cmd) {
        try {
            cmd.run();
        } catch (final Throwable e) {
            throw ExceptionUtil.toRuntimeException(e, true);
        }
    }

    /**
     * Executes the provided {@code cmd} and if an exception occurs, applies the {@code actionOnError} consumer on the exception.
     *
     * 

This method is useful when you want to run a piece of code that might throw an exception, and you want to handle that exception in a specific way.

* * @param cmd The runnable task that might throw an exception, must not be {@code null}. * @param actionOnError The consumer to handle any exceptions thrown by the {@code cmd}, must not be {@code null}. * @see Try#run(Throwables.Runnable, java.util.function.Consumer) */ @Beta public static void run(final Throwables.Runnable cmd, final java.util.function.Consumer actionOnError) { try { cmd.run(); } catch (final Throwable e) { actionOnError.accept(e); } } /** * Executes the provided {@code cmd} that may throw an exception and returns the result. * * This method is useful when you want to run a piece of code that might throw an exception, and you need the result of that code. * If an exception occurs during the execution of the {@code cmd}, it is rethrown as a RuntimeException. * * @param The type of the result. * @param cmd The callable task that might throw an exception and returns a result. Must not be {@code null}. * @return The result of the {@code cmd}. * @throws RuntimeException if an exception occurs during the execution of the {@code cmd}. * @see Try#call(java.util.concurrent.Callable) */ @Beta public static R call(final Throwables.Callable cmd) { try { return cmd.call(); } catch (final Throwable e) { throw ExceptionUtil.toRuntimeException(e, true); } } /** * Executes the provided {@code cmd} that may throw an exception and returns the result. * If an exception occurs during the execution of the {@code cmd}, the {@code actionOnError} function is applied to the exception to provide a return value. * * This method is useful when you want to run a piece of code that might throw an exception, and you need the result of that code. * It allows you to handle exceptions in a specific way by providing a function that can transform an exception into a return value. * * @param The type of the result. * @param cmd The callable task that might throw an exception and returns a result. Must not be {@code null}. * @param actionOnError The function to apply to the exception if one is thrown by the {@code cmd}. Must not be {@code null}. * @return The result of the {@code cmd} or the result of applying the {@code actionOnError} function to the exception if one is thrown. * @see Try#call(java.util.concurrent.Callable, java.util.function.Function) */ @Beta public static R call(final Throwables.Callable cmd, final java.util.function.Function actionOnError) { try { return cmd.call(); } catch (final Throwable e) { return actionOnError.apply(e); } } /** * Executes the provided {@code cmd} that may throw an exception and returns the result. * If an exception occurs during the execution of the {@code cmd}, the {@code supplier} is used to provide a return value. * * This method is useful when you want to run a piece of code that might throw an exception, and you need the result of that code. * It allows you to handle exceptions in a specific way by providing a supplier that can provide a return value when an exception occurs. * * @param The type of the result. * @param cmd The callable task that might throw an exception and returns a result. Must not be {@code null}. * @param supplier The supplier to provide a return value when an exception occurs. Must not be {@code null}. * @return The result of the {@code cmd} or the result of the {@code supplier} if an exception occurs. * @see Try#call(java.util.concurrent.Callable, java.util.function.Supplier) */ @Beta public static R call(final Throwables.Callable cmd, final java.util.function.Supplier supplier) { N.checkArgNotNull(supplier); try { return cmd.call(); } catch (final Throwable e) { return supplier.get(); } } /** * Executes the provided {@code cmd} that may throw an exception and returns the result. * If an exception occurs during the execution of the {@code cmd}, the provided default value is returned. * * This method is useful when you want to run a piece of code that might throw an exception, and you need the result of that code. * It allows you to handle exceptions in a specific way by providing a default value that will be returned when an exception occurs. * * @param The type of the result. * @param cmd The callable task that might throw an exception and returns a result. Must not be {@code null}. * @param defaultValue The default value to return if an exception occurs during the execution of the {@code cmd}. * @return The result of the {@code cmd} or the default value if an exception occurs. * @see Try#call(java.util.concurrent.Callable, Object) */ @Beta public static R call(final Throwables.Callable cmd, final R defaultValue) { try { return cmd.call(); } catch (final Throwable e) { return defaultValue; } } /** * Executes the provided {@code cmd} and if an exception occurs, applies the {@code supplier} to provide a return value. * The {@code predicate} is used to test the exception. If the {@code predicate} returns {@code true}, the {@code supplier} is used to provide a return value. * If the {@code predicate} returns {@code false}, the exception is rethrown as a RuntimeException. * * @param The type of the result. * @param cmd The callable task that might throw an exception, must not be {@code null}. * @param predicate The predicate to test the exception, must not be {@code null}. * @param supplier The supplier to provide a return value when an exception occurs and the {@code predicate} returns {@code true}, must not be {@code null}. * @return The result of the {@code cmd} or the result of the {@code supplier} if an exception occurs and the {@code predicate} returns {@code true}. * @throws RuntimeException if an exception occurs and the {@code predicate} returns {@code false}. * @see Try#call(java.util.concurrent.Callable, java.util.function.Predicate, java.util.function.Supplier) */ @Beta public static R call(final Throwables.Callable cmd, final java.util.function.Predicate predicate, final java.util.function.Supplier supplier) { N.checkArgNotNull(supplier); try { return cmd.call(); } catch (final Throwable e) { if (predicate.test(e)) { return supplier.get(); } else { throw ExceptionUtil.toRuntimeException(e, true); } } } /** * Executes the provided {@code cmd} that may throw an exception and returns the result. * If an exception occurs during the execution of the {@code cmd}, the provided default value is returned if the {@code predicate} returns {@code true}. * If the {@code predicate} returns {@code false}, the exception is rethrown as a RuntimeException. * * This method is useful when you want to run a piece of code that might throw an exception, and you need the result of that code. * It allows you to handle exceptions in a specific way by providing a default value that will be returned when an exception occurs and the {@code predicate} returns {@code true}. * * @param The type of the result. * @param cmd The callable task that might throw an exception and returns a result. Must not be {@code null}. * @param predicate The predicate to test the exception. If it returns {@code true}, the default value is returned. If it returns {@code false}, the exception is rethrown. Must not be {@code null}. * @param defaultValue The default value to return if an exception occurs during the execution of the {@code cmd} and the {@code predicate} returns {@code true}. * @return The result of the {@code cmd} or the default value if an exception occurs and the {@code predicate} returns {@code true}. * @throws RuntimeException if an exception occurs and the {@code predicate} returns {@code false}. * @see Try#call(java.util.concurrent.Callable, java.util.function.Predicate, Object) */ @Beta public static R call(final Throwables.Callable cmd, final java.util.function.Predicate predicate, final R defaultValue) { try { return cmd.call(); } catch (final Throwable e) { if (predicate.test(e)) { return defaultValue; } else { throw ExceptionUtil.toRuntimeException(e, true); } } } @SuppressWarnings("rawtypes") private static final Throwables.Iterator EMPTY = new Throwables.Iterator() { @Override public boolean hasNext() { return false; } @Override public Object next() { throw new NoSuchElementException(InternalUtil.ERROR_MSG_FOR_NO_SUCH_EX); } }; /** * * @param * @param * @see ObjIterator */ @SuppressWarnings({ "java:S6548" }) public abstract static class Iterator implements AutoCloseable, Immutable { /** * * @param * @param * @return */ public static Throwables.Iterator empty() { return EMPTY; } /** * * @param * @param * @param val * @return */ public static Throwables.Iterator just(final T val) { return new Throwables.Iterator<>() { 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 a * @return */ @SafeVarargs public static Throwables.Iterator of(final T... a) { return N.isEmpty(a) ? EMPTY : of(a, 0, a.length); } /** * * @param * @param * @param a * @param fromIndex * @param toIndex * @return * @throws IndexOutOfBoundsException */ public static Throwables.Iterator of(final T[] a, final int fromIndex, final int toIndex) throws IndexOutOfBoundsException { N.checkFromToIndex(fromIndex, toIndex, a == null ? 0 : a.length); if (N.isEmpty(a) || fromIndex == toIndex) { return EMPTY; } return new Throwables.Iterator<>() { private int cursor = fromIndex; @Override public boolean hasNext() { return cursor < toIndex; } @Override public T next() { if (cursor >= toIndex) { throw new NoSuchElementException(InternalUtil.ERROR_MSG_FOR_NO_SUCH_EX); } return a[cursor++]; } @Override public void advance(final long n) throws E { if (n > toIndex - cursor) { cursor = toIndex; } else { cursor += (int) n; } } @Override public long count() { return toIndex - cursor; //NOSONAR } }; } /** * * @param * @param * @param iterable * @return */ public static Iterator of(final Iterable iterable) { if (iterable == null) { return empty(); } final java.util.Iterator iter = iterable.iterator(); return new Throwables.Iterator<>() { @Override public boolean hasNext() { return iter.hasNext(); } @Override public T next() throws E { return iter.next(); } }; } /** * * @param * @param * @param iter * @return */ public static Throwables.Iterator of(final java.util.Iterator iter) { if (iter == null) { return EMPTY; } return new Throwables.Iterator<>() { @Override public boolean hasNext() throws E { return iter.hasNext(); } @Override public T next() throws E { return iter.next(); } }; } /** * Returns a Throwables.Iterator instance that is created lazily using the provided Supplier. * The Supplier is responsible for producing the Iterator instance when the Iterator's methods are first called. * * @param The type of the elements in the Iterator. * @param The type of the exception that may be thrown. * @param iteratorSupplier A Supplier that provides the Throwables.Iterator when needed. * @return A Throwables.Iterator that is initialized on the first call to hasNext() or next(). * @throws IllegalArgumentException if iteratorSupplier is {@code null}. */ public static Throwables.Iterator defer(final java.util.function.Supplier> iteratorSupplier) { N.checkArgNotNull(iteratorSupplier, cs.iteratorSupplier); return new Throwables.Iterator<>() { private Throwables.Iterator iter = null; private boolean isInitialized = false; @Override public boolean hasNext() throws E { if (!isInitialized) { init(); } return iter.hasNext(); } @Override public T next() throws E { if (!isInitialized) { init(); } return iter.next(); } @Override public void advance(final long n) throws IllegalArgumentException, E { N.checkArgNotNegative(n, cs.n); if (!isInitialized) { init(); } iter.advance(n); } @Override public long count() throws E { if (!isInitialized) { init(); } return iter.count(); } @Override protected void closeResource() { if (!isInitialized) { init(); } if (iter != null) { iter.close(); } } private void init() { if (!isInitialized) { isInitialized = true; iter = iteratorSupplier.get(); } } }; } /** * * @param * @param * @param a * @return */ @SafeVarargs public static Throwables.Iterator concat(final Throwables.Iterator... a) { return concat(N.asList(a)); } /** * * @param * @param * @param c * @return */ public static Throwables.Iterator concat(final Collection> c) { if (N.isEmpty(c)) { return Iterator.empty(); } return new Throwables.Iterator<>() { private final java.util.Iterator> iter = c.iterator(); private Throwables.Iterator cur; @Override public boolean hasNext() throws E { while ((cur == null || !cur.hasNext()) && iter.hasNext()) { cur = iter.next(); } return cur != null && cur.hasNext(); } @Override public T next() throws E { if ((cur == null || !cur.hasNext()) && !hasNext()) { throw new NoSuchElementException(InternalUtil.ERROR_MSG_FOR_NO_SUCH_EX); } return cur.next(); } }; } /** * It's caller's responsibility to close the specified {@code reader}. * * @param reader * @return */ public static Throwables.Iterator ofLines(final Reader reader) { if (reader == null) { return empty(); } return new Throwables.Iterator<>() { private final BufferedReader br = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); private String cachedLine; /** A flag indicating if the iterator has been fully read. */ private boolean finished = false; @Override public boolean hasNext() throws IOException { if (cachedLine != null) { return true; } else if (finished) { return false; } else { cachedLine = br.readLine(); if (cachedLine == null) { finished = true; return false; } else { return true; } } } @Override public String next() throws IOException { if (!hasNext()) { throw new NoSuchElementException("No more lines"); } final String res = cachedLine; cachedLine = null; return res; } }; } /** * * @return * @throws E */ public abstract boolean hasNext() throws E; /** * * @return * @throws E */ public abstract T next() throws E; /** * * @param n * @throws IllegalArgumentException * @throws E the e */ public void advance(long n) throws IllegalArgumentException, E { N.checkArgNotNegative(n, cs.n); while (n-- > 0 && hasNext()) { next(); } } /** * * @return * @throws E the e */ public long count() throws E { long result = 0; while (hasNext()) { next(); result++; } return result; } private boolean isClosed = false; @Override public final void close() { if (isClosed) { return; } isClosed = true; closeResource(); } @Internal protected void closeResource() { } /** * * @param predicate * @return */ public Throwables.Iterator filter(final Throwables.Predicate predicate) { final Throwables.Iterator iter = this; return new Throwables.Iterator<>() { 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 Throwables.Iterator map(final Throwables.Function mapper) { final Throwables.Iterator iter = this; return new Throwables.Iterator<>() { @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(final 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(final java.util.function.Consumer action) throws E { // NOSONAR while (hasNext()) { action.accept(next()); } } /** * * @param * @param action * @throws E the e * @throws E2 */ public void foreachRemaining(final Throwables.Consumer action) throws E, E2 { // NOSONAR while (hasNext()) { action.accept(next()); } } /** * * @param * @param action * @throws E the e * @throws E2 */ public void foreachIndexed(final Throwables.IntObjConsumer action) throws E, E2 { int idx = 0; while (hasNext()) { action.accept(idx++, next()); } } } /** * The Interface Runnable. * * @param */ public interface Runnable { /** * * @throws E the e */ void run() throws E; @Beta default com.landawn.abacus.util.function.Runnable unchecked() { return () -> { try { run(); } catch (final Throwable e) { throw ExceptionUtil.toRuntimeException(e, true); } }; } } /** * The Interface Callable. * * @param * @param */ public interface Callable { /** * * @return * @throws E the e */ R call() throws E; @Beta default com.landawn.abacus.util.function.Callable unchecked() { return () -> { try { return call(); } catch (final Throwable e) { throw ExceptionUtil.toRuntimeException(e, true); } }; } } /** * The Interface Supplier. * * @param * @param */ public interface Supplier { /** * * @return * @throws E the e */ T get() throws E; @Beta default com.landawn.abacus.util.function.Supplier unchecked() { return () -> { try { return get(); } catch (final 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; default Predicate negate() { return t -> !test(t); } @Beta default com.landawn.abacus.util.function.Predicate unchecked() { return t -> { try { return test(t); } catch (final 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; @Beta default com.landawn.abacus.util.function.BiPredicate unchecked() { return (t, u) -> { try { return test(t, u); } catch (final 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; @Beta default com.landawn.abacus.util.function.Function unchecked() { return t -> { try { return apply(t); } catch (final 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; @Beta default com.landawn.abacus.util.function.BiFunction unchecked() { return (t, u) -> { try { return apply(t, u); } catch (final 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; @Beta default com.landawn.abacus.util.function.Consumer unchecked() { return t -> { try { accept(t); } catch (final 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; @Beta default com.landawn.abacus.util.function.BiConsumer unchecked() { return (t, u) -> { try { accept(t, u); } catch (final 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 extends IntIntConsumer { /** * * @param t * @param u * @throws E the e */ @Override 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(final 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(final 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(final 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(final java.util.function.Function 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(final java.util.function.Function 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(final java.util.function.Function 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(final java.util.function.Function 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(final java.util.function.Function 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(final java.util.function.Function 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(final java.util.function.Function 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(final java.util.function.Function after) { return args -> after.apply(apply(args)); } } public interface NFunction { /** * * @param args * @return * @throws E */ @SuppressWarnings("unchecked") R apply(T... args) throws E; /** * * @param * @param after * @return */ default NFunction andThen(final java.util.function.Function after) { return args -> after.apply(apply(args)); } } /** * The Interface IntBooleanConsumer. * * @param */ public interface IntBooleanConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, boolean e) throws E; } /** * The Interface IndexedCharConsumer. * * @param */ public interface IntCharConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, char e) throws E; } /** * The Interface IndexedByteConsumer. * * @param */ public interface IntByteConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, byte e) throws E; } /** * The Interface IndexedShortConsumer. * * @param */ public interface IntShortConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, short e) throws E; } /** * The Interface IndexedIntConsumer. * * @param */ public interface IntIntConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, int e) throws E; } /** * The Interface IndexedLongConsumer. * * @param */ public interface IntLongConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, long e) throws E; } /** * The Interface IndexedFloatConsumer. * * @param */ public interface IntFloatConsumer { /** * * @param idx * @param e * @throws E the e */ void accept(int idx, float e) throws E; } /** * The Interface IndexedDoubleConsumer. * * @param */ public interface IntDoubleConsumer { /** * * @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, cs.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; } } }