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

org.openstreetmap.atlas.utilities.function.TernaryConsumer Maven / Gradle / Ivy

There is a newer version: 7.0.8
Show newest version
package org.openstreetmap.atlas.utilities.function;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * Represents an operation that accepts three input arguments and returns no result. This is the
 * three-arity specialization of {@link Consumer}. Unlike most other functional interfaces,
 * {@link TernaryConsumer} is expected to operate via side-effects.
 *
 * @param 
 *            the type of the first argument to the operation
 * @param 
 *            the type of the second argument to the operation
 * @param 
 *            the type of the third argument to the operation
 * @author lcram
 */
@FunctionalInterface
public interface TernaryConsumer
{

    /**
     * Performs this operation on the given arguments.
     *
     * @param t
     *            the first input argument
     * @param u
     *            the second input argument
     * @param v
     *            the third input argument
     */
    void accept(T t, U u, V v);

    /**
     * Returns a composed {@link TernaryConsumer} that performs, in sequence, this operation
     * followed by the {@code after} operation. If performing either operation throws an exception,
     * it is relayed to the caller of the composed operation. If performing this operation throws an
     * exception, the {@code after} operation will not be performed.
     *
     * @param after
     *            the operation to perform after this operation
     * @return a composed {@link TernaryConsumer} that performs in sequence this operation followed
     *         by the {@code after} operation
     * @throws NullPointerException
     *             if {@code after} is null
     */
    default TernaryConsumer andThen(
            final TernaryConsumer after)
    {
        Objects.requireNonNull(after);
        return (l, c, r) ->
        {
            accept(l, c, r);
            after.accept(l, c, r);
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy