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.HashMap;
020
021import org.jivesoftware.smack.packet.IQ;
022import org.jivesoftware.smackx.muclight.MUCLightAffiliation;
023import org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration;
024import org.jivesoftware.smackx.muclight.MultiUserChatLight;
025import org.jivesoftware.smackx.muclight.element.MUCLightElements.ConfigurationElement;
026import org.jivesoftware.smackx.muclight.element.MUCLightElements.OccupantsElement;
027import org.jxmpp.jid.Jid;
028
029/**
030 * MUC Light info response IQ class.
031 * 
032 * @author Fernando Ramirez
033 *
034 */
035public class MUCLightInfoIQ extends IQ {
036
037    public static final String ELEMENT = QUERY_ELEMENT;
038    public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.INFO;
039
040    private final String version;
041    private final MUCLightRoomConfiguration configuration;
042    private final HashMap<Jid, MUCLightAffiliation> occupants;
043
044    /**
045     * MUCLight info response IQ constructor.
046     * 
047     * @param version
048     * @param configuration
049     * @param occupants
050     */
051    public MUCLightInfoIQ(String version, MUCLightRoomConfiguration configuration,
052            HashMap<Jid, MUCLightAffiliation> occupants) {
053        super(ELEMENT, NAMESPACE);
054        this.version = version;
055        this.configuration = configuration;
056        this.occupants = occupants;
057    }
058
059    @Override
060    protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
061        xml.rightAngleBracket();
062        xml.optElement("version", version);
063        xml.element(new ConfigurationElement(configuration));
064        xml.element(new OccupantsElement(occupants));
065        return xml;
066    }
067
068    /**
069     * Returns the version.
070     * 
071     * @return the version
072     */
073    public String getVersion() {
074        return version;
075    }
076
077    /**
078     * Returns the room configuration.
079     * 
080     * @return the configuration of the room
081     */
082    public MUCLightRoomConfiguration getConfiguration() {
083        return configuration;
084    }
085
086    /**
087     * Returns the room occupants.
088     * 
089     * @return the occupants of the room
090     */
091    public HashMap<Jid, MUCLightAffiliation> getOccupants() {
092        return occupants;
093    }
094
095}