1 package org.apache.commons.jcs.engine.control.group;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.Serializable;
23
24
25
26
27 public class GroupAttrName<T>
28 implements Serializable
29 {
30
31 private static final long serialVersionUID = 1586079686300744198L;
32
33
34 public final GroupId groupId;
35
36
37 public final T attrName;
38
39
40 private String toString;
41
42
43
44
45
46
47 public GroupAttrName( GroupId groupId, T attrName )
48 {
49 this.groupId = groupId;
50 this.attrName = attrName;
51
52 if ( groupId == null )
53 {
54 throw new IllegalArgumentException( "groupId must not be null." );
55 }
56 }
57
58
59
60
61
62
63 @Override
64 public boolean equals( Object obj )
65 {
66 if ( obj == null || !( obj instanceof GroupAttrName ) )
67 {
68 return false;
69 }
70 GroupAttrName<?> to = (GroupAttrName<?>) obj;
71
72 if (groupId.equals( to.groupId ))
73 {
74 if (attrName == null && to.attrName == null)
75 {
76 return true;
77 }
78 else if (attrName == null || to.attrName == null)
79 {
80 return false;
81 }
82
83 return attrName.equals( to.attrName );
84 }
85
86 return false;
87 }
88
89
90
91
92 @Override
93 public int hashCode()
94 {
95 if (attrName == null)
96 {
97 return groupId.hashCode();
98 }
99
100 return groupId.hashCode() ^ attrName.hashCode();
101 }
102
103
104
105
106 @Override
107 public String toString()
108 {
109 if ( toString == null )
110 {
111 toString = "[GAN: groupId=" + groupId + ", attrName=" + attrName + "]";
112 }
113
114 return toString;
115 }
116
117 }