1 package org.apache.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 * Used to avoid name conflict when group cache items are mixed with non-group
26 * cache items in the same cache.
27 *
28 */
29 public class GroupId
30 implements Serializable
31 {
32 private static final long serialVersionUID = 4626368486444860133L;
33
34 /*** Description of the Field */
35 public final String groupName;
36
37 /***
38 * the name of the region.
39 */
40 public final String cacheName;
41
42 private String toString;
43
44 /***
45 * Constructor for the GroupId object
46 *
47 * @param cacheName
48 * @param groupName
49 */
50 public GroupId( String cacheName, String groupName )
51 {
52 this.cacheName = cacheName;
53 this.groupName = groupName;
54
55 if ( cacheName == null )
56 {
57 throw new IllegalArgumentException( "cacheName must not be null." );
58 }
59 if ( groupName == null )
60 {
61 throw new IllegalArgumentException( "groupName must not be null." );
62 }
63 }
64
65
66
67
68
69 public boolean equals( Object obj )
70 {
71 if ( obj == null || !( obj instanceof GroupId ) )
72 {
73 return false;
74 }
75 GroupId g = (GroupId) obj;
76 return cacheName.equals( g.cacheName ) && groupName.equals( g.groupName );
77 }
78
79
80
81
82
83 public int hashCode()
84 {
85 return cacheName.hashCode() + groupName.hashCode();
86 }
87
88
89
90
91
92 public String toString()
93 {
94 if ( toString == null )
95 {
96 toString = "[groupId=" + cacheName + ", " + groupName + ']';
97 }
98
99 return toString;
100 }
101 }