From b2c88d68022b107f08bf13dabbb37f9a53458a4b Mon Sep 17 00:00:00 2001 From: mbax Date: Tue, 1 Oct 2019 17:33:43 -0400 Subject: [PATCH] Introduce nag ignoring --- .../irc/client/library/util/NagIgnorer.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/org/kitteh/irc/client/library/util/NagIgnorer.java diff --git a/src/main/java/org/kitteh/irc/client/library/util/NagIgnorer.java b/src/main/java/org/kitteh/irc/client/library/util/NagIgnorer.java new file mode 100644 index 000000000..4aeea6d25 --- /dev/null +++ b/src/main/java/org/kitteh/irc/client/library/util/NagIgnorer.java @@ -0,0 +1,45 @@ +/* + * * Copyright (C) 2013-2019 Matt Baxter https://kitteh.org + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kitteh.irc.client.library.util; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.kitteh.irc.client.library.exception.KittehNagException; + +import java.util.function.Consumer; + +public class NagIgnorer { + public static final Consumer CONSUMER = e -> { + if (!(e instanceof KittehNagException)) { + e.printStackTrace(); + } + }; + + public static Consumer ignore(@NonNull Consumer consumer) { + return e -> { + if (!(e instanceof KittehNagException)) { + consumer.accept(e); + } + }; + } +}