Skip to content

Package: TriConsumer

TriConsumer

nameinstructionbranchcomplexitylinemethod
andThen(TriConsumer)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
lambda$0(TriConsumer, Object, Object, Object)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019 Christian W. Damus and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Christian W. Damus - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.common;
15:
16: import java.util.Objects;
17: import java.util.function.BiConsumer;
18: import java.util.function.Consumer;
19:
20: /**
21: * Protocol for an action that accepts three inputs. This is the ternary variant of {@link Consumer}
22: * as {@link BiConsumer} is a binary variant of it.
23: *
24: * @param <T> the type of the first input
25: * @param <U> the type of the second input
26: * @param <V> the type of the third input
27: *
28: * @since 1.22
29: *
30: * @see TriFunction
31: * @see BiConsumer
32: * @see Consumer
33: */
34: @FunctionalInterface
35: public interface TriConsumer<T, U, V> {
36:
37:         /**
38:          * Accept the inputs and operate on them.
39:          *
40:          * @param t the first input
41:          * @param u the second input
42:          * @param v the third input
43:          */
44:         void accept(T t, U u, V v);
45:
46:         /**
47:          * Obtain a composed {@code TriConsumer} that performs me followed by an
48:          * {@code after} operation. If the {@code after} consumer throws, then
49:          * that exception is propagated to the caller. If I throw, then likewise
50:          * but also the {@code after} consumer will not be invoked.
51:          *
52:          * @param after a consumer to invoke after me. Must not be {@code null}
53:          * @return the composition of myself with the {@code after} consumer
54:          *
55:          * @throws NullPointerException if {@code after} is {@code null}
56:          */
57:         default TriConsumer<T, U, V> andThen(TriConsumer<? super T, ? super U, ? super V> after) {
58:                 final TriConsumer<? super T, ? super U, ? super V> next = Objects.requireNonNull(after);
59:
60:                 return (t, u, v) -> {
61:                         this.accept(t, u, v);
62:                         next.accept(t, u, v);
63:                 };
64:         }
65:
66: }