KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tcspring > ComplexBeanId


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tcspring;
5
6
7 public class ComplexBeanId {
8   private String JavaDoc scopeId = null;
9   private String JavaDoc beanName = null;
10   
11   public ComplexBeanId(String JavaDoc beanName) {
12     this("singleton", beanName);
13   }
14   
15   public ComplexBeanId(String JavaDoc newScopeId, String JavaDoc newBeanName) {
16     this.scopeId = newScopeId;
17     this.beanName = newBeanName;
18   }
19
20   public String JavaDoc getBeanName() {
21     return beanName;
22   }
23   
24   public String JavaDoc getScopeId() {
25     return scopeId;
26   }
27   
28   public int hashCode() {
29     return (31 * scopeId.hashCode()) + beanName.hashCode();
30   }
31
32   public boolean equals(Object JavaDoc obj) {
33     if (this == obj) return true;
34     if (obj == null) return false;
35     if (getClass() != obj.getClass()) return false;
36     
37     ComplexBeanId other = (ComplexBeanId) obj;
38     if (beanName == null) {
39       if (other.beanName != null) {
40         return false;
41       }
42     } else if (!beanName.equals(other.beanName)) {
43       return false;
44     }
45     
46     if (scopeId == null) {
47       if (other.scopeId != null) {
48         return false;
49       }
50     } else if (!scopeId.equals(other.scopeId)) {
51       return false;
52     }
53     
54     return true;
55   }
56
57   public String JavaDoc toString() {
58     return scopeId + ":" + beanName;
59   }
60   
61 }
62
63
Popular Tags