001/**
002 *
003 * Copyright the original author or authors
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.pubsub;
018
019import java.util.Arrays;
020import java.util.Collections;
021import java.util.List;
022
023import org.jivesoftware.smack.packet.ExtensionElement;
024
025import org.jivesoftware.smackx.pubsub.form.FilledConfigureForm;
026
027/**
028 * Represents the <b>configuration</b> element of a PubSub message event which
029 * associates a configuration form to the node which was configured.  The form
030 * contains the current node configuration.
031 *
032 * @author Robin Collier
033 */
034public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension {
035    private final FilledConfigureForm form;
036
037    public ConfigurationEvent(String nodeId) {
038        this(nodeId, null);
039    }
040
041    public ConfigurationEvent(String nodeId, FilledConfigureForm configForm) {
042        super(PubSubElementType.CONFIGURATION, nodeId);
043        form = configForm;
044    }
045
046    public FilledConfigureForm getConfiguration() {
047        return form;
048    }
049
050    @Override
051    public List<ExtensionElement> getExtensions() {
052        if (getConfiguration() == null)
053            return Collections.emptyList();
054        else
055            return Arrays.asList((ExtensionElement) getConfiguration().getDataForm());
056    }
057}