001package Torello.Java.Function;
002
003/**
004 * Function-Pointer
005 * <SPAN CLASS=TJF>Input:</SPAN> {@code byte}
006 * <SPAN CLASS=TJF>Output:</SPAN> {@code void}.
007 * 
008 * <BR /><BR />
009 * This is an extension of {@code java.util.function.*}.  This consumer accepts a {@code 'byte'}
010 * as input to its  {@code 'accept'} method.
011 */
012@FunctionalInterface
013public interface ByteConsumer
014{
015    /**
016     * Performs this operation on the given argument.
017     * @param b {@code byte} input-argument.
018     */
019    public void accept(byte b);
020
021    /**
022     * <EMBED CLASS="external-html" DATA-FILE-ID="CONTHENMETH">
023     * @param after <EMBED CLASS="external-html" DATA-FILE-ID="CONTHENAFT">
024     * @return <EMBED CLASS="external-html" DATA-FILE-ID="CONTHENRET">
025     * @throws NullPointerException if parameter {@code 'other'} is null.
026     */
027    default ByteConsumer andThen(ByteConsumer after)
028    {
029        if (after == null)
030            throw new NullPointerException("null has been passed to parameter 'after'");
031
032        return (byte b) ->
033        {
034            this.accept(b); 
035            after.accept(b);
036        };
037    }
038}