1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.record; |
16 | |
|
17 | |
import org.apache.hivemind.util.Defense; |
18 | |
import org.apache.hivemind.util.ToStringBuilder; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class PropertyChangeImpl implements PropertyChange |
27 | |
{ |
28 | |
|
29 | |
private String _componentPath; |
30 | |
|
31 | |
private String _propertyName; |
32 | |
|
33 | |
private Object _newValue; |
34 | |
|
35 | |
public PropertyChangeImpl(String componentPath, String propertyName, |
36 | |
Object newValue) |
37 | 0 | { |
38 | 0 | Defense.notNull(propertyName, "propertyName"); |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 0 | _componentPath = componentPath; |
44 | 0 | _propertyName = propertyName; |
45 | 0 | _newValue = newValue; |
46 | 0 | } |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public String getComponentPath() |
54 | |
{ |
55 | 0 | return _componentPath; |
56 | |
} |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public Object getNewValue() |
63 | |
{ |
64 | 0 | return _newValue; |
65 | |
} |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
public String getPropertyName() |
72 | |
{ |
73 | 0 | return _propertyName; |
74 | |
} |
75 | |
|
76 | |
public String toString() |
77 | |
{ |
78 | 0 | ToStringBuilder builder = new ToStringBuilder(this); |
79 | |
|
80 | 0 | builder.append("componentPath", _componentPath); |
81 | 0 | builder.append("propertyName", _propertyName); |
82 | 0 | builder.append("newValue", _newValue); |
83 | |
|
84 | 0 | return builder.toString(); |
85 | |
} |
86 | |
|
87 | |
public boolean equals(Object object) |
88 | |
{ |
89 | 0 | if (this == object) return true; |
90 | |
|
91 | 0 | if (object == null || object.getClass() != this.getClass()) |
92 | 0 | return false; |
93 | |
|
94 | 0 | PropertyChangeImpl other = (PropertyChangeImpl) object; |
95 | |
|
96 | 0 | return same(_componentPath, other._componentPath) |
97 | |
&& same(_propertyName, other._propertyName) |
98 | |
&& same(_newValue, other._newValue); |
99 | |
} |
100 | |
|
101 | |
private boolean same(Object o1, Object o2) |
102 | |
{ |
103 | 0 | return o1 == o2 || (o1 != null && o1.equals(o2)); |
104 | |
} |
105 | |
} |