Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
41159 views
1
/*
2
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
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
*
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.
24
*/
25
26
package java.beans.beancontext;
27
28
import java.io.Serial;
29
import java.util.Arrays;
30
import java.util.Collection;
31
import java.util.Iterator;
32
33
/**
34
* A {@code BeanContextMembershipEvent} encapsulates
35
* the list of children added to, or removed from,
36
* the membership of a particular {@code BeanContext}.
37
* An instance of this event is fired whenever a successful
38
* add(), remove(), retainAll(), removeAll(), or clear() is
39
* invoked on a given {@code BeanContext} instance.
40
* Objects interested in receiving events of this type must
41
* implement the {@code BeanContextMembershipListener}
42
* interface, and must register their intent via the
43
* {@code BeanContext}'s
44
* {@code addBeanContextMembershipListener(BeanContextMembershipListener bcml)}
45
* method.
46
*
47
* @author Laurence P. G. Cable
48
* @since 1.2
49
* @see java.beans.beancontext.BeanContext
50
* @see java.beans.beancontext.BeanContextEvent
51
* @see java.beans.beancontext.BeanContextMembershipListener
52
*/
53
public class BeanContextMembershipEvent extends BeanContextEvent {
54
55
/**
56
* Use serialVersionUID from JDK 1.7 for interoperability.
57
*/
58
@Serial
59
private static final long serialVersionUID = 3499346510334590959L;
60
61
/**
62
* Contruct a BeanContextMembershipEvent
63
*
64
* @param bc The BeanContext source
65
* @param changes The Children affected
66
* @throws NullPointerException if {@code changes} is {@code null}
67
*/
68
69
@SuppressWarnings("rawtypes")
70
public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
71
super(bc);
72
73
if (changes == null) throw new NullPointerException(
74
"BeanContextMembershipEvent constructor: changes is null.");
75
76
children = changes;
77
}
78
79
/**
80
* Contruct a BeanContextMembershipEvent
81
*
82
* @param bc The BeanContext source
83
* @param changes The Children effected
84
* @exception NullPointerException if changes associated with this
85
* event are null.
86
*/
87
88
public BeanContextMembershipEvent(BeanContext bc, Object[] changes) {
89
super(bc);
90
91
if (changes == null) throw new NullPointerException(
92
"BeanContextMembershipEvent: changes is null.");
93
94
children = Arrays.asList(changes);
95
}
96
97
/**
98
* Gets the number of children affected by the notification.
99
* @return the number of children affected by the notification
100
*/
101
public int size() { return children.size(); }
102
103
/**
104
* Is the child specified affected by the event?
105
* @return {@code true} if affected, {@code false}
106
* if not
107
* @param child the object to check for being affected
108
*/
109
public boolean contains(Object child) {
110
return children.contains(child);
111
}
112
113
/**
114
* Gets the array of children affected by this event.
115
* @return the array of children affected
116
*/
117
public Object[] toArray() { return children.toArray(); }
118
119
/**
120
* Gets the array of children affected by this event.
121
* @return the array of children effected
122
*/
123
@SuppressWarnings("rawtypes")
124
public Iterator iterator() { return children.iterator(); }
125
126
/*
127
* fields
128
*/
129
130
/**
131
* The list of children affected by this
132
* event notification.
133
*/
134
@SuppressWarnings({"rawtypes",
135
"serial"}) // Not statically typed as Serializable
136
protected Collection children;
137
}
138
139