package com.yanzuoguang.db.impl;

import java.util.Objects;

/**
 * 处理2个参数的函数接口
 *
 * @param <H> 影响的函数
 * @param <I> 开始执行的时间
 * @author 颜佐光
 */
@FunctionalInterface
public interface DbSqlFunction<H, I> {
    /**
     * Performs this operation on the given argument.
     *
     * @param row   the input argument
     * @param start the input argument
     */
    void accept(H row, I start);

    /**
     * Returns a composed {@code Consumer} 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 {@code Consumer} that performs in sequence this
     * operation followed by the {@code after} operation
     * @throws NullPointerException if {@code after} is null
     */
    default DbSqlFunction<H, I> andThen(DbSqlFunction<? super H, ? super I> after) {
        Objects.requireNonNull(after);
        return (H h, I i) -> {
            accept(h, i);
            after.accept(h, i);
        };
    }
}