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

import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.SimpleIQ;
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(ELEMENT, NAMESPACE);
        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;
        }

        @Override
        public String getElementName() {
            return Session.ELEMENT;
        }

        @Override
        public String getNamespace() {
            return Session.NAMESPACE;
        }

        @Override
        public XmlStringBuilder toXML() {
            XmlStringBuilder xml = new XmlStringBuilder(this);
            if (this.optional) {
                xml.rightAngleBracket();
                xml.emptyElement(OPTIONAL_ELEMENT);
                xml.closeElement(this);
            } else {
                xml.closeEmptyElement();
            }
            return xml;
        }
    }
}
