1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

[core] Add StanzaFilter.asPredicate(Class)

This commit is contained in:
Florian Schmaus 2020-05-17 20:47:18 +02:00
parent 4239dac440
commit 87591655ad

View file

@ -66,4 +66,13 @@ public interface StanzaFilter extends Predicate<Stanza> {
default boolean test(Stanza stanza) { default boolean test(Stanza stanza) {
return accept(stanza); return accept(stanza);
} }
default <S extends Stanza> Predicate<S> asPredicate(Class<?> stanzaClass) {
return s -> {
if (!stanzaClass.isAssignableFrom(s.getClass())) {
return false;
}
return accept(s);
};
}
} }