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 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| public class ChangeKey |
26 |
| { |
27 |
| private int _hashCode = -1; |
28 |
| |
29 |
| private String _componentPath; |
30 |
| |
31 |
| private String _propertyName; |
32 |
| |
33 |
28
| public ChangeKey(String componentPath, String propertyName)
|
34 |
| { |
35 |
28
| Defense.notNull(propertyName, "propertyName");
|
36 |
| |
37 |
28
| _componentPath = componentPath;
|
38 |
28
| _propertyName = propertyName;
|
39 |
| } |
40 |
| |
41 |
12
| public boolean equals(Object object)
|
42 |
| { |
43 |
12
| if (object == null)
|
44 |
2
| return false;
|
45 |
| |
46 |
10
| if (this == object)
|
47 |
2
| return true;
|
48 |
| |
49 |
8
| if (!(object instanceof ChangeKey))
|
50 |
2
| return false;
|
51 |
| |
52 |
6
| ChangeKey other = (ChangeKey) object;
|
53 |
| |
54 |
6
| return same(_propertyName, other._propertyName)
|
55 |
| && same(_componentPath, other._componentPath); |
56 |
| } |
57 |
| |
58 |
10
| private boolean same(String s1, String s2)
|
59 |
| { |
60 |
10
| return s1 == s2 || (s1 != null && s1.equals(s2));
|
61 |
| } |
62 |
| |
63 |
14
| public String getComponentPath()
|
64 |
| { |
65 |
14
| return _componentPath;
|
66 |
| } |
67 |
| |
68 |
14
| public String getPropertyName()
|
69 |
| { |
70 |
14
| return _propertyName;
|
71 |
| } |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
20
| public int hashCode()
|
78 |
| { |
79 |
20
| if (_hashCode == -1)
|
80 |
| { |
81 |
18
| _hashCode = 31 * 27 + _propertyName.hashCode();
|
82 |
| |
83 |
18
| if (_componentPath != null)
|
84 |
16
| _hashCode = 31 * _hashCode + _componentPath.hashCode();
|
85 |
| } |
86 |
| |
87 |
20
| return _hashCode;
|
88 |
| } |
89 |
| } |