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

Add (To|From)TypeFilter.(FROM|TO)_ANY_JID

to filter all stanzas which have a valid jid set as to/from.
This commit is contained in:
Florian Schmaus 2018-06-20 18:55:24 +02:00
parent 61be4d768d
commit c73219b797
3 changed files with 8 additions and 3 deletions

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus. * Copyright 2017-2018 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,6 +27,7 @@ public abstract class AbstractJidTypeFilter implements StanzaFilter {
entityBare, entityBare,
domainFull, domainFull,
domainBare, domainBare,
any,
; ;
} }
@ -55,6 +56,8 @@ public abstract class AbstractJidTypeFilter implements StanzaFilter {
return jid.isDomainFullJid(); return jid.isDomainFullJid();
case domainBare: case domainBare:
return jid.isDomainBareJid(); return jid.isDomainBareJid();
case any:
return true;
default: default:
throw new AssertionError(); throw new AssertionError();
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus. * Copyright 2017-2018 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,6 +26,7 @@ public final class FromTypeFilter extends AbstractJidTypeFilter {
public static final FromTypeFilter ENTITY_BARE_JID = new FromTypeFilter(JidType.entityBare); public static final FromTypeFilter ENTITY_BARE_JID = new FromTypeFilter(JidType.entityBare);
public static final FromTypeFilter DOMAIN_FULL_JID = new FromTypeFilter(JidType.domainFull); public static final FromTypeFilter DOMAIN_FULL_JID = new FromTypeFilter(JidType.domainFull);
public static final FromTypeFilter DOMAIN_BARE_JID = new FromTypeFilter(JidType.domainBare); public static final FromTypeFilter DOMAIN_BARE_JID = new FromTypeFilter(JidType.domainBare);
public static final FromTypeFilter FROM_ANY_JID = new FromTypeFilter(JidType.any);
private FromTypeFilter(JidType jidType) { private FromTypeFilter(JidType jidType) {
super(jidType); super(jidType);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus. * Copyright 2017-2018 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,6 +26,7 @@ public final class ToTypeFilter extends AbstractJidTypeFilter {
public static final ToTypeFilter ENTITY_BARE_JID = new ToTypeFilter(JidType.entityBare); public static final ToTypeFilter ENTITY_BARE_JID = new ToTypeFilter(JidType.entityBare);
public static final ToTypeFilter DOMAIN_FULL_JID = new ToTypeFilter(JidType.domainFull); public static final ToTypeFilter DOMAIN_FULL_JID = new ToTypeFilter(JidType.domainFull);
public static final ToTypeFilter DOMAIN_BARE_JID = new ToTypeFilter(JidType.domainBare); public static final ToTypeFilter DOMAIN_BARE_JID = new ToTypeFilter(JidType.domainBare);
public static final ToTypeFilter TO_ANY_JID = new ToTypeFilter(JidType.any);
public static final StanzaFilter ENTITY_FULL_OR_BARE_JID = new OrFilter(ENTITY_FULL_JID, ENTITY_BARE_JID); public static final StanzaFilter ENTITY_FULL_OR_BARE_JID = new OrFilter(ENTITY_FULL_JID, ENTITY_BARE_JID);