1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-24 11:38:00 +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) {
return accept(stanza);
}
default <S extends Stanza> Predicate<S> asPredicate(Class<?> stanzaClass) {
return s -> {
if (!stanzaClass.isAssignableFrom(s.getClass())) {
return false;
}
return accept(s);
};
}
}