001/**
002 *
003 * Copyright 2016 Fernando Ramirez
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.muclight.element;
018
019import java.util.Map;
020
021import org.jivesoftware.smack.packet.IQ;
022
023import org.jivesoftware.smackx.muclight.MUCLightAffiliation;
024import org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration;
025import org.jivesoftware.smackx.muclight.MultiUserChatLight;
026import org.jivesoftware.smackx.muclight.element.MUCLightElements.ConfigurationElement;
027import org.jivesoftware.smackx.muclight.element.MUCLightElements.OccupantsElement;
028
029import org.jxmpp.jid.Jid;
030
031/**
032 * MUC Light info response IQ class.
033 *
034 * @author Fernando Ramirez
035 *
036 */
037public class MUCLightInfoIQ extends IQ {
038
039    public static final String ELEMENT = QUERY_ELEMENT;
040    public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.INFO;
041
042    private final String version;
043    private final MUCLightRoomConfiguration configuration;
044    private final Map<Jid, MUCLightAffiliation> occupants;
045
046    /**
047     * MUCLight info response IQ constructor.
048     *
049     * @param version TODO javadoc me please
050     * @param configuration TODO javadoc me please
051     * @param occupants TODO javadoc me please
052     */
053    public MUCLightInfoIQ(String version, MUCLightRoomConfiguration configuration,
054            Map<Jid, MUCLightAffiliation> occupants) {
055        super(ELEMENT, NAMESPACE);
056        this.version = version;
057        this.configuration = configuration;
058        this.occupants = occupants;
059    }
060
061    @Override
062    protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
063        xml.rightAngleBracket();
064        xml.optElement("version", version);
065        xml.append(new ConfigurationElement(configuration));
066        xml.append(new OccupantsElement(occupants));
067        return xml;
068    }
069
070    /**
071     * Returns the version.
072     *
073     * @return the version
074     */
075    public String getVersion() {
076        return version;
077    }
078
079    /**
080     * Returns the room configuration.
081     *
082     * @return the configuration of the room
083     */
084    public MUCLightRoomConfiguration getConfiguration() {
085        return configuration;
086    }
087
088    /**
089     * Returns the room occupants.
090     *
091     * @return the occupants of the room
092     */
093    public Map<Jid, MUCLightAffiliation> getOccupants() {
094        return occupants;
095    }
096
097}