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:
parent
4239dac440
commit
87591655ad
1 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue