Skip to content

Package: ThrowingConsumer

ThrowingConsumer

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.utils;
19:
20: /**
21: * Represents an operation that accepts a single input argument and returns no result. Unlike most other functional
22: * interfaces, {@code ThrowingConsumer} is expected to operate via side-effects.
23: * <p>
24: * This is a functional interface whose functional method is {@link #accept(Object)}.
25: * <p>
26: * This version allows the accept method to throw checked exceptions.
27: *
28: * @param <T> the type of the input to the operation
29: * @param <E> The type of the checked exception thrown by the consumer code
30: */
31: @FunctionalInterface
32: public interface ThrowingConsumer<T, E extends Exception> {
33:
34: void accept(T t) throws E;
35: }