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

com.github.tonivade.purefun.Consumer3 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 three parameters but it doesn't generate any result.

*

It's like a {@code Function3}

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy