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

org.tinyj.lava.LavaConsumer Maven / Gradle / Ivy

package org.tinyj.lava;

/**
 * An operation on an input value. This is the exception declaring version of
 * Java's [`Consumer`](https://docs.oracle.com/javase/8/docs/api/java/util/function/Consumer.html)
 *
 * Usually invoking a consumer results in side effects. Subsequent
 * invocations may or may not result in further side effects.
 *
 * This is a functional interface whose functional method is `checkedAccept(X)`.
 *
 * @param  consumed value type
 * @param  upper limit of thrown exception types
 */
@FunctionalInterface
public interface LavaConsumer {

  /**
   * Perform operation on input.
   *
   * @param x consumed value
   */
  void checkedAccept(X x) throws E;

  /**
   * Safely casts between different (#LavaConsumer) parametrization
   *
   * @param  accepted input type
   * @param  required exception limit
   * @param consumer consumer to adopt
   * @return `consumer` casted to the compatible parametrization (#LavaConsumer)``
   */
  @SuppressWarnings("unchecked")
  static 
  LavaConsumer castDown(LavaConsumer consumer) {
    return (LavaConsumer) consumer;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy