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); + }; + } }