Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/java/beans/PropertyChangeEvent.java
41152 views
1
/*
2
* Copyright (c) 1996, 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;
27
28
import java.io.Serial;
29
import java.util.EventObject;
30
31
/**
32
* A "PropertyChange" event gets delivered whenever a bean changes a "bound"
33
* or "constrained" property. A PropertyChangeEvent object is sent as an
34
* argument to the PropertyChangeListener and VetoableChangeListener methods.
35
* <P>
36
* Normally PropertyChangeEvents are accompanied by the name and the old
37
* and new value of the changed property. If the new value is a primitive
38
* type (such as int or boolean) it must be wrapped as the
39
* corresponding java.lang.* Object type (such as Integer or Boolean).
40
* <P>
41
* Null values may be provided for the old and the new values if their
42
* true values are not known.
43
* <P>
44
* An event source may send a null object as the name to indicate that an
45
* arbitrary set of if its properties have changed. In this case the
46
* old and new values should also be null.
47
*
48
* @since 1.1
49
*/
50
public class PropertyChangeEvent extends EventObject {
51
52
/**
53
* Use serialVersionUID from JDK 1.7 for interoperability.
54
*/
55
@Serial
56
private static final long serialVersionUID = 7042693688939648123L;
57
58
/**
59
* Constructs a new {@code PropertyChangeEvent}.
60
*
61
* @param source the bean that fired the event
62
* @param propertyName the programmatic name of the property that was changed
63
* @param oldValue the old value of the property
64
* @param newValue the new value of the property
65
*
66
* @throws IllegalArgumentException if {@code source} is {@code null}
67
*/
68
public PropertyChangeEvent(Object source, String propertyName,
69
Object oldValue, Object newValue) {
70
super(source);
71
this.propertyName = propertyName;
72
this.newValue = newValue;
73
this.oldValue = oldValue;
74
}
75
76
/**
77
* Gets the programmatic name of the property that was changed.
78
*
79
* @return The programmatic name of the property that was changed.
80
* May be null if multiple properties have changed.
81
*/
82
public String getPropertyName() {
83
return propertyName;
84
}
85
86
/**
87
* Gets the new value for the property, expressed as an Object.
88
*
89
* @return The new value for the property, expressed as an Object.
90
* May be null if multiple properties have changed.
91
*/
92
public Object getNewValue() {
93
return newValue;
94
}
95
96
/**
97
* Gets the old value for the property, expressed as an Object.
98
*
99
* @return The old value for the property, expressed as an Object.
100
* May be null if multiple properties have changed.
101
*/
102
public Object getOldValue() {
103
return oldValue;
104
}
105
106
/**
107
* Sets the propagationId object for the event.
108
*
109
* @param propagationId The propagationId object for the event.
110
*/
111
public void setPropagationId(Object propagationId) {
112
this.propagationId = propagationId;
113
}
114
115
/**
116
* The "propagationId" field is reserved for future use. In Beans 1.0
117
* the sole requirement is that if a listener catches a PropertyChangeEvent
118
* and then fires a PropertyChangeEvent of its own, then it should
119
* make sure that it propagates the propagationId field from its
120
* incoming event to its outgoing event.
121
*
122
* @return the propagationId object associated with a bound/constrained
123
* property update.
124
*/
125
public Object getPropagationId() {
126
return propagationId;
127
}
128
129
/**
130
* name of the property that changed. May be null, if not known.
131
* @serial
132
*/
133
private String propertyName;
134
135
/**
136
* New value for property. May be null if not known.
137
* @serial
138
*/
139
@SuppressWarnings("serial") // Not statically typed as Serializable
140
private Object newValue;
141
142
/**
143
* Previous value for property. May be null if not known.
144
* @serial
145
*/
146
@SuppressWarnings("serial") // Not statically typed as Serializable
147
private Object oldValue;
148
149
/**
150
* Propagation ID. May be null.
151
* @serial
152
* @see #getPropagationId
153
*/
154
@SuppressWarnings("serial") // Not statically typed as Serializable
155
private Object propagationId;
156
157
/**
158
* Returns a string representation of the object.
159
*
160
* @return a string representation of the object
161
*
162
* @since 1.7
163
*/
164
public String toString() {
165
StringBuilder sb = new StringBuilder(getClass().getName());
166
sb.append("[propertyName=").append(getPropertyName());
167
appendTo(sb);
168
sb.append("; oldValue=").append(getOldValue());
169
sb.append("; newValue=").append(getNewValue());
170
sb.append("; propagationId=").append(getPropagationId());
171
sb.append("; source=").append(getSource());
172
return sb.append("]").toString();
173
}
174
175
void appendTo(StringBuilder sb) {
176
}
177
}
178
179