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.Collections;
020import java.util.List;
021
022/**
023 * Represents an event in which items have been deleted from the node.
024 *
025 * @author Robin Collier
026 */
027public class ItemDeleteEvent extends SubscriptionEvent {
028    private List<String> itemIds = Collections.emptyList();
029
030    /**
031     * Constructs an <code>ItemDeleteEvent</code> that indicates the the supplied
032     * items (by id) have been deleted, and that the event matches the listed
033     * subscriptions.  The subscriptions would have been created by calling
034     * {@link LeafNode#subscribe(String)}.
035     *
036     * @param nodeId The id of the node the event came from
037     * @param deletedItemIds The item ids of the items that were deleted.
038     * @param subscriptionIds The subscriptions that match the event.
039     */
040    public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds) {
041        super(nodeId, subscriptionIds);
042
043        if (deletedItemIds == null)
044            throw new IllegalArgumentException("deletedItemIds cannot be null");
045        itemIds = deletedItemIds;
046    }
047
048    /**
049     * Get the item id's of the items that have been deleted.
050     *
051     * @return List of item id's
052     */
053    public List<String> getItemIds() {
054        return Collections.unmodifiableList(itemIds);
055    }
056
057    @Override
058    public String toString() {
059        return getClass().getName() + "  [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']';
060    }
061}