package com.imofan.android.pns;

import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;

/**
 *
 */
class XmppMessageFilter implements PacketFilter {

    private final Message.Type type;

    /**
     * Creates a new message type filter using the specified message type.
     *
     * @param type the message type.
     */
    public XmppMessageFilter(Message.Type type) {
        this.type = type;
    }

    public boolean accept(Packet packet) {
        if (!(packet instanceof Message)) {
            return false;
        }
        else {
            return ((Message) packet).getType().equals(this.type);
        }
    }
}
