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:
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) {
|
||||
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