diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/function/ExceptionalBiConsumer.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/function/ExceptionalBiConsumer.java new file mode 100644 index 000000000..cd5e87a2f --- /dev/null +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/function/ExceptionalBiConsumer.java @@ -0,0 +1,33 @@ +/* + * Hello Minecraft! Launcher + * Copyright (C) 2019 huangyuhui and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.jackhuang.hmcl.util.function; + +import static java.util.Objects.requireNonNull; + +public interface ExceptionalBiConsumer { + void accept(T t, U u) throws E; + + default ExceptionalBiConsumer andThen(ExceptionalBiConsumer after) { + requireNonNull(after); + + return (l, r) -> { + this.accept(l, r); + after.accept(l, r); + }; + } +} diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/function/ExceptionalBiFunction.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/function/ExceptionalBiFunction.java new file mode 100644 index 000000000..3e8701438 --- /dev/null +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/function/ExceptionalBiFunction.java @@ -0,0 +1,29 @@ +/* + * Hello Minecraft! Launcher + * Copyright (C) 2019 huangyuhui and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.jackhuang.hmcl.util.function; + +import static java.util.Objects.requireNonNull; + +public interface ExceptionalBiFunction { + R apply(T t, U u) throws E; + + default ExceptionalBiFunction andThen(ExceptionalFunction after) { + requireNonNull(after); + return (t, u) -> after.apply(apply(t, u)); + } +} \ No newline at end of file