ItemDeleteEvent.java

  1. /**
  2.  *
  3.  * Copyright the original author or authors
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.pubsub;

  18. import java.util.Collections;
  19. import java.util.List;

  20. /**
  21.  * Represents an event in which items have been deleted from the node.
  22.  *
  23.  * @author Robin Collier
  24.  */
  25. public class ItemDeleteEvent extends SubscriptionEvent {
  26.     private List<String> itemIds = Collections.emptyList();

  27.     /**
  28.      * Constructs an <code>ItemDeleteEvent</code> that indicates the supplied
  29.      * items (by id) have been deleted, and that the event matches the listed
  30.      * subscriptions.  The subscriptions would have been created by calling
  31.      * {@link LeafNode#subscribe(org.jxmpp.Jid)}.
  32.      *
  33.      * @param nodeId The id of the node the event came from
  34.      * @param deletedItemIds The item ids of the items that were deleted.
  35.      * @param subscriptionIds The subscriptions that match the event.
  36.      */
  37.     public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds) {
  38.         super(nodeId, subscriptionIds);

  39.         if (deletedItemIds == null)
  40.             throw new IllegalArgumentException("deletedItemIds cannot be null");
  41.         itemIds = deletedItemIds;
  42.     }

  43.     /**
  44.      * Get the item id's of the items that have been deleted.
  45.      *
  46.      * @return List of item id's
  47.      */
  48.     public List<String> getItemIds() {
  49.         return Collections.unmodifiableList(itemIds);
  50.     }

  51.     @Override
  52.     public String toString() {
  53.         return getClass().getName() + "  [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']';
  54.     }
  55. }