|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ChangeKey.java | 0% | 0% | 0% | 0% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.record;
|
|
16 |
|
|
17 |
import org.apache.commons.lang.builder.EqualsBuilder;
|
|
18 |
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
19 |
|
|
20 |
/**
|
|
21 |
* Used to identify a property change.
|
|
22 |
*
|
|
23 |
* @author Howard Lewis Ship
|
|
24 |
*
|
|
25 |
**/
|
|
26 |
|
|
27 |
public class ChangeKey |
|
28 |
{ |
|
29 |
private int _hashCode = -1; |
|
30 |
private String _componentPath;
|
|
31 |
private String _propertyName;
|
|
32 |
|
|
33 | 0 |
public ChangeKey(String componentPath, String propertyName)
|
34 |
{ |
|
35 | 0 |
_componentPath = componentPath; |
36 | 0 |
_propertyName = propertyName; |
37 |
} |
|
38 |
|
|
39 | 0 |
public boolean equals(Object object) |
40 |
{ |
|
41 | 0 |
if (object == null) |
42 | 0 |
return false; |
43 |
|
|
44 | 0 |
if (this == object) |
45 | 0 |
return true; |
46 |
|
|
47 | 0 |
if (!(object instanceof ChangeKey)) |
48 | 0 |
return false; |
49 |
|
|
50 | 0 |
ChangeKey other = (ChangeKey) object; |
51 |
|
|
52 | 0 |
EqualsBuilder builder = new EqualsBuilder();
|
53 |
|
|
54 | 0 |
builder.append(_propertyName, other._propertyName); |
55 | 0 |
builder.append(_componentPath, other._componentPath); |
56 |
|
|
57 | 0 |
return builder.isEquals();
|
58 |
} |
|
59 |
|
|
60 | 0 |
public String getComponentPath()
|
61 |
{ |
|
62 | 0 |
return _componentPath;
|
63 |
} |
|
64 |
|
|
65 | 0 |
public String getPropertyName()
|
66 |
{ |
|
67 | 0 |
return _propertyName;
|
68 |
} |
|
69 |
|
|
70 |
/**
|
|
71 |
*
|
|
72 |
* Returns a hash code computed from the
|
|
73 |
* property name and component path.
|
|
74 |
*
|
|
75 |
**/
|
|
76 |
|
|
77 | 0 |
public int hashCode() |
78 |
{ |
|
79 | 0 |
if (_hashCode == -1)
|
80 |
{ |
|
81 | 0 |
HashCodeBuilder builder = new HashCodeBuilder(257, 23); // Random |
82 |
|
|
83 | 0 |
builder.append(_propertyName); |
84 | 0 |
builder.append(_componentPath); |
85 |
|
|
86 | 0 |
_hashCode = builder.toHashCode(); |
87 |
} |
|
88 |
|
|
89 | 0 |
return _hashCode;
|
90 |
} |
|
91 |
} |
|