package org.jivesoftware.smack.packet;

import org.jivesoftware.smack.util.XmlStringBuilder;

public class Session extends SimpleIQ {
   public static final String ELEMENT = "session";
   public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-session";

   public Session() {
      super("session", "urn:ietf:params:xml:ns:xmpp-session");
      this.setType(IQ.Type.set);
   }

   public static class Feature implements ExtensionElement {
      public static final String OPTIONAL_ELEMENT = "optional";
      private final boolean optional;

      public Feature(boolean optional) {
         this.optional = optional;
      }

      public boolean isOptional() {
         return this.optional;
      }

      public String getElementName() {
         return "session";
      }

      public String getNamespace() {
         return "urn:ietf:params:xml:ns:xmpp-session";
      }

      public XmlStringBuilder toXML() {
         XmlStringBuilder xml = new XmlStringBuilder(this);
         if (this.optional) {
            xml.rightAngleBracket();
            xml.emptyElement("optional");
            xml.closeElement((NamedElement)this);
         } else {
            xml.closeEmptyElement();
         }

         return xml;
      }
   }
}
