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

com.github.tonivade.purefun.Consumer2 Maven / Gradle / Ivy

/*
 * Copyright (c) 2018-2021, Antonio Gabriel Muñoz Conejo 
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.purefun;

import static com.github.tonivade.purefun.Unit.unit;

/**
 * 

This interface represents a function that receives two parameters but it doesn't generate any result.

*

It's like a {@code Function2}

* @param the type of first parameter received by the function * @param the type of second parameter received by the function */ @FunctionalInterface public interface Consumer2 extends Recoverable { default void accept(A value1, B value2) { try { run(value1, value2); } catch (Throwable t) { sneakyThrow(t); } } void run(A value1, B value2) throws Throwable; default Consumer2 andThen(Consumer2 after) { return (value1, value2) -> { accept(value1, value2); after.accept(value1, value2); }; } default Function2 asFunction() { return (value1, value2) -> { accept(value1, value2); return unit(); }; } @SuppressWarnings("unchecked") static Consumer2 of(Consumer2 reference) { return (Consumer2) reference; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy