1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

Add IQ.isRequestIQ()

and check IQ argument in IQReplyFilter.
This commit is contained in:
Florian Schmaus 2015-01-21 14:06:27 +01:00
parent 2f739662e5
commit dc6af6dd99
2 changed files with 19 additions and 0 deletions

View file

@ -81,6 +81,9 @@ public class IQReplyFilter implements PacketFilter {
* @param iqPacket An IQ request. Filter for replies to this packet.
*/
public IQReplyFilter(IQ iqPacket, XMPPConnection conn) {
if (!iqPacket.isRequestIQ()) {
throw new IllegalArgumentException("IQ must be a request IQ, i.e. of type 'get' or 'set'.");
}
if (iqPacket.getTo() != null) {
to = iqPacket.getTo().toLowerCase(Locale.US);
} else {

View file

@ -90,6 +90,22 @@ public abstract class IQ extends Packet {
this.type = type;
}
/**
* Return true if this IQ is a request IQ, i.e. an IQ of type {@link Type#get} or {@link Type#set}.
*
* @return true if IQ type is 'get' or 'set', false otherwise.
* @since 4.1
*/
public boolean isRequestIQ() {
switch (type) {
case get:
case set:
return true;
default:
return false;
}
}
public final String getChildElementName() {
return childElementName;
}