Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
38918 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans.beancontext;2627import java.util.EventObject;2829import java.beans.beancontext.BeanContext;30import java.beans.beancontext.BeanContextEvent;3132import java.util.Arrays;33import java.util.Collection;34import java.util.Iterator;3536/**37* A <code>BeanContextMembershipEvent</code> encapsulates38* the list of children added to, or removed from,39* the membership of a particular <code>BeanContext</code>.40* An instance of this event is fired whenever a successful41* add(), remove(), retainAll(), removeAll(), or clear() is42* invoked on a given <code>BeanContext</code> instance.43* Objects interested in receiving events of this type must44* implement the <code>BeanContextMembershipListener</code>45* interface, and must register their intent via the46* <code>BeanContext</code>'s47* <code>addBeanContextMembershipListener(BeanContextMembershipListener bcml)48* </code> method.49*50* @author Laurence P. G. Cable51* @since 1.252* @see java.beans.beancontext.BeanContext53* @see java.beans.beancontext.BeanContextEvent54* @see java.beans.beancontext.BeanContextMembershipListener55*/56public class BeanContextMembershipEvent extends BeanContextEvent {57private static final long serialVersionUID = 3499346510334590959L;5859/**60* Contruct a BeanContextMembershipEvent61*62* @param bc The BeanContext source63* @param changes The Children affected64* @throws NullPointerException if <CODE>changes</CODE> is <CODE>null</CODE>65*/6667@SuppressWarnings("rawtypes")68public BeanContextMembershipEvent(BeanContext bc, Collection changes) {69super(bc);7071if (changes == null) throw new NullPointerException(72"BeanContextMembershipEvent constructor: changes is null.");7374children = changes;75}7677/**78* Contruct a BeanContextMembershipEvent79*80* @param bc The BeanContext source81* @param changes The Children effected82* @exception NullPointerException if changes associated with this83* event are null.84*/8586public BeanContextMembershipEvent(BeanContext bc, Object[] changes) {87super(bc);8889if (changes == null) throw new NullPointerException(90"BeanContextMembershipEvent: changes is null.");9192children = Arrays.asList(changes);93}9495/**96* Gets the number of children affected by the notification.97* @return the number of children affected by the notification98*/99public int size() { return children.size(); }100101/**102* Is the child specified affected by the event?103* @return <code>true</code> if affected, <code>false</code>104* if not105* @param child the object to check for being affected106*/107public boolean contains(Object child) {108return children.contains(child);109}110111/**112* Gets the array of children affected by this event.113* @return the array of children affected114*/115public Object[] toArray() { return children.toArray(); }116117/**118* Gets the array of children affected by this event.119* @return the array of children effected120*/121@SuppressWarnings("rawtypes")122public Iterator iterator() { return children.iterator(); }123124/*125* fields126*/127128/**129* The list of children affected by this130* event notification.131*/132@SuppressWarnings("rawtypes")133protected Collection children;134}135136137