/*
 * Decompiled with CFR 0.152.
 */
package org.jivesoftware.smack.filter;

import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils;

public class StanzaExtensionFilter
implements StanzaFilter {
    private final String elementName;
    private final String namespace;

    public StanzaExtensionFilter(String elementName, String namespace) {
        StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
        this.elementName = elementName;
        this.namespace = namespace;
    }

    public StanzaExtensionFilter(String namespace) {
        this(null, namespace);
    }

    public StanzaExtensionFilter(ExtensionElement packetExtension) {
        this(packetExtension.getElementName(), packetExtension.getNamespace());
    }

    @Override
    public boolean accept(Stanza packet) {
        return packet.hasExtension(this.elementName, this.namespace);
    }

    public String toString() {
        return this.getClass().getSimpleName() + ": element=" + this.elementName + " namespace=" + this.namespace;
    }
}
