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. {
  27.     private List<String> itemIds = Collections.emptyList();
  28.    
  29.     /**
  30.      * Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied
  31.      * items (by id) have been deleted, and that the event matches the listed
  32.      * subscriptions.  The subscriptions would have been created by calling
  33.      * {@link LeafNode#subscribe(String)}.
  34.      *
  35.      * @param nodeId The id of the node the event came from
  36.      * @param deletedItemIds The item ids of the items that were deleted.
  37.      * @param subscriptionIds The subscriptions that match the event.
  38.      */
  39.     public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds)
  40.     {
  41.         super(nodeId, subscriptionIds);
  42.        
  43.         if (deletedItemIds == null)
  44.             throw new IllegalArgumentException("deletedItemIds cannot be null");
  45.         itemIds = deletedItemIds;
  46.     }
  47.    
  48.     /**
  49.      * Get the item id's of the items that have been deleted.
  50.      *
  51.      * @return List of item id's
  52.      */
  53.     public List<String> getItemIds()
  54.     {
  55.         return Collections.unmodifiableList(itemIds);
  56.     }
  57.    
  58.     @Override
  59.     public String toString()
  60.     {
  61.         return getClass().getName() + "  [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']';
  62.     }
  63. }