From 87591655ad6114e17b549bfdcf61667dc29c95bc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 17 May 2020 20:47:18 +0200 Subject: [PATCH] [core] Add StanzaFilter.asPredicate(Class) --- .../java/org/jivesoftware/smack/filter/StanzaFilter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java index f37d08b11..147d0c9f1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java @@ -66,4 +66,13 @@ public interface StanzaFilter extends Predicate { default boolean test(Stanza stanza) { return accept(stanza); } + + default Predicate asPredicate(Class stanzaClass) { + return s -> { + if (!stanzaClass.isAssignableFrom(s.getClass())) { + return false; + } + return accept(s); + }; + } }