author | darcy |
Tue, 24 Sep 2019 18:25:54 -0700 | |
changeset 58309 | c6f8b2c3dc66 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
19213 | 2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.beans.beancontext; |
|
27 |
||
28 |
import java.util.EventObject; |
|
29 |
||
30 |
import java.beans.beancontext.BeanContext; |
|
31 |
import java.beans.beancontext.BeanContextEvent; |
|
32 |
||
33 |
import java.util.Arrays; |
|
34 |
import java.util.Collection; |
|
35 |
import java.util.Iterator; |
|
36 |
||
37 |
/** |
|
35667 | 38 |
* A {@code BeanContextMembershipEvent} encapsulates |
2 | 39 |
* the list of children added to, or removed from, |
35667 | 40 |
* the membership of a particular {@code BeanContext}. |
2 | 41 |
* An instance of this event is fired whenever a successful |
42 |
* add(), remove(), retainAll(), removeAll(), or clear() is |
|
35667 | 43 |
* invoked on a given {@code BeanContext} instance. |
2 | 44 |
* Objects interested in receiving events of this type must |
35667 | 45 |
* implement the {@code BeanContextMembershipListener} |
2 | 46 |
* interface, and must register their intent via the |
35667 | 47 |
* {@code BeanContext}'s |
48 |
* {@code addBeanContextMembershipListener(BeanContextMembershipListener bcml)} |
|
49 |
* method. |
|
2 | 50 |
* |
51 |
* @author Laurence P. G. Cable |
|
52 |
* @since 1.2 |
|
53 |
* @see java.beans.beancontext.BeanContext |
|
54 |
* @see java.beans.beancontext.BeanContextEvent |
|
55 |
* @see java.beans.beancontext.BeanContextMembershipListener |
|
56 |
*/ |
|
57 |
public class BeanContextMembershipEvent extends BeanContextEvent { |
|
2482
77898184e343
4769844: classes in java.beans that are serializable but don't define serialVersionUID
malenkov
parents:
2
diff
changeset
|
58 |
private static final long serialVersionUID = 3499346510334590959L; |
2 | 59 |
|
60 |
/** |
|
61 |
* Contruct a BeanContextMembershipEvent |
|
62 |
* |
|
63 |
* @param bc The BeanContext source |
|
64 |
* @param changes The Children affected |
|
35667 | 65 |
* @throws NullPointerException if {@code changes} is {@code null} |
2 | 66 |
*/ |
67 |
||
11120
f8576c769572
7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents:
5506
diff
changeset
|
68 |
@SuppressWarnings("rawtypes") |
2 | 69 |
public BeanContextMembershipEvent(BeanContext bc, Collection changes) { |
70 |
super(bc); |
|
71 |
||
72 |
if (changes == null) throw new NullPointerException( |
|
73 |
"BeanContextMembershipEvent constructor: changes is null."); |
|
74 |
||
75 |
children = changes; |
|
76 |
} |
|
77 |
||
78 |
/** |
|
79 |
* Contruct a BeanContextMembershipEvent |
|
80 |
* |
|
81 |
* @param bc The BeanContext source |
|
82 |
* @param changes The Children effected |
|
83 |
* @exception NullPointerException if changes associated with this |
|
84 |
* event are null. |
|
85 |
*/ |
|
86 |
||
87 |
public BeanContextMembershipEvent(BeanContext bc, Object[] changes) { |
|
88 |
super(bc); |
|
89 |
||
90 |
if (changes == null) throw new NullPointerException( |
|
91 |
"BeanContextMembershipEvent: changes is null."); |
|
92 |
||
93 |
children = Arrays.asList(changes); |
|
94 |
} |
|
95 |
||
96 |
/** |
|
97 |
* Gets the number of children affected by the notification. |
|
98 |
* @return the number of children affected by the notification |
|
99 |
*/ |
|
100 |
public int size() { return children.size(); } |
|
101 |
||
102 |
/** |
|
103 |
* Is the child specified affected by the event? |
|
35667 | 104 |
* @return {@code true} if affected, {@code false} |
2 | 105 |
* if not |
19213 | 106 |
* @param child the object to check for being affected |
2 | 107 |
*/ |
108 |
public boolean contains(Object child) { |
|
109 |
return children.contains(child); |
|
110 |
} |
|
111 |
||
112 |
/** |
|
113 |
* Gets the array of children affected by this event. |
|
114 |
* @return the array of children affected |
|
115 |
*/ |
|
116 |
public Object[] toArray() { return children.toArray(); } |
|
117 |
||
118 |
/** |
|
119 |
* Gets the array of children affected by this event. |
|
120 |
* @return the array of children effected |
|
121 |
*/ |
|
11120
f8576c769572
7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents:
5506
diff
changeset
|
122 |
@SuppressWarnings("rawtypes") |
2 | 123 |
public Iterator iterator() { return children.iterator(); } |
124 |
||
125 |
/* |
|
126 |
* fields |
|
127 |
*/ |
|
128 |
||
129 |
/** |
|
130 |
* The list of children affected by this |
|
131 |
* event notification. |
|
132 |
*/ |
|
58309
c6f8b2c3dc66
8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents:
47216
diff
changeset
|
133 |
@SuppressWarnings({"rawtypes", |
c6f8b2c3dc66
8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents:
47216
diff
changeset
|
134 |
"serial"}) // Not statically typed as Serializable |
2 | 135 |
protected Collection children; |
136 |
} |