[core] Add StanzaFilter.asPredicate(Class)

This commit is contained in:
Florian Schmaus 2020-05-17 20:47:18 +02:00
parent 4239dac440
commit 87591655ad
1 changed files with 9 additions and 0 deletions

View File

@ -66,4 +66,13 @@ public interface StanzaFilter extends Predicate<Stanza> {
default boolean test(Stanza 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);
};
}
}