package org.jivesoftware.smack.filter;

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

/** @deprecated */
@Deprecated
public class PacketExtensionFilter implements StanzaFilter {
   private final String elementName;
   private final String namespace;

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

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

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

   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;
   }
}
