Path: blob/master/src/java.desktop/share/classes/java/beans/IndexedPropertyChangeEvent.java
41152 views
/*1* Copyright (c) 2003, 2021, 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;2627import java.io.Serial;2829/**30* An "IndexedPropertyChange" event gets delivered whenever a component that31* conforms to the JavaBeans specification (a "bean") changes a bound32* indexed property. This class is an extension of {@code PropertyChangeEvent}33* but contains the index of the property that has changed.34* <P>35* Null values may be provided for the old and the new values if their36* true values are not known.37* <P>38* An event source may send a null object as the name to indicate that an39* arbitrary set of if its properties have changed. In this case the40* old and new values should also be null.41*42* @since 1.543* @author Mark Davidson44*/45public class IndexedPropertyChangeEvent extends PropertyChangeEvent {4647/**48* Use serialVersionUID from JDK 1.7 for interoperability.49*/50@Serial51private static final long serialVersionUID = -320227448495806870L;5253/**54* The index of the property element that was changed.55*/56private int index;5758/**59* Constructs a new {@code IndexedPropertyChangeEvent} object.60*61* @param source The bean that fired the event.62* @param propertyName The programmatic name of the property that63* was changed.64* @param oldValue The old value of the property.65* @param newValue The new value of the property.66* @param index index of the property element that was changed.67*/68public IndexedPropertyChangeEvent(Object source, String propertyName,69Object oldValue, Object newValue,70int index) {71super (source, propertyName, oldValue, newValue);72this.index = index;73}7475/**76* Gets the index of the property that was changed.77*78* @return The index specifying the property element that was79* changed.80*/81public int getIndex() {82return index;83}8485void appendTo(StringBuilder sb) {86sb.append("; index=").append(getIndex());87}88}899091