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