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

io.github.oliviercailloux.jaris.throwing.TBiConsumer Maven / Gradle / Ivy

There is a newer version: 0.0.38
Show newest version
package io.github.oliviercailloux.jaris.throwing;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Generalization of {@link java.util.function.BiConsumer} that may throw instances of type
 * {@code X}, not just {@code RuntimeException} instances.
 *
 * @param  the type of the first argument to the operation
 * @param  the type of the second argument to the operation
 * @param  a sort of throwable that the {@code Throwing.BiConsumer} may throw
 */
@FunctionalInterface
public interface TBiConsumer {
  /**
   * Performs this operation on the given arguments.
   *
   * @param t the first input argument
   * @param u the second input argument
   * @throws X in generally unspecified circumstances
   */
  public void accept(T t, U u) throws X;

  /**
   * Returns a composed {@code Throwing.BiConsumer} that performs, in sequence, this operation
   * followed by the {@code after} operation.
   *
   * @param after the operation to perform after this operation
   * @return a composed {@code Throwing.BiConsumer} that performs in sequence this operation
   *         followed by the {@code after} operation
   * @see java.util.function.BiConsumer#andThen(java.util.function.BiConsumer)
   */
  default TBiConsumer andThen(TBiConsumer after) {
    checkNotNull(after);

    return (l, r) -> {
      accept(l, r);
      after.accept(l, r);
    };
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy