1 package org.sourceforge.jemm.util;
2
3
4
5
6
7
8
9
10
11
12 public class ConstructorContext {
13 private String clazz;
14 private Object obj;
15
16 public ConstructorContext(String clazz) {
17 if(clazz ==null)
18 throw new IllegalArgumentException("clazz may not be null");
19 this.clazz = clazz;
20 }
21
22 public void associateObject(Object fObj) {
23 if(fObj==null)
24 throw new IllegalArgumentException("Object may not be set to null");
25 this.obj = fObj;
26 }
27
28 public String getClazz() {
29 return clazz;
30 }
31
32 public Object getObject() {
33 return obj;
34 }
35
36 public boolean hasObject() {
37 return obj!=null;
38 }
39
40 @Override
41 public boolean equals(Object other) {
42 if(!(other instanceof ConstructorContext))
43 return false;
44 ConstructorContext rhs = (ConstructorContext)other;
45 return clazz.equals(rhs.clazz) && this.obj==rhs.obj;
46 }
47
48 @Override
49 public int hashCode() {
50 if(obj==null)
51 return clazz.hashCode();
52 return clazz.hashCode() + obj.hashCode();
53 }
54
55 public String toString() {
56 return clazz + "," + obj;
57 }
58 }