01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.object.dmi;
06:
07: import com.tc.util.Assert;
08:
09: /**
10: * Specify class for DMI
11: */
12: public class DmiClassSpec {
13:
14: private final String classLoaderDesc;
15: private final String className;
16: private final String spec;
17:
18: /**
19: * Construct new spec
20: * @param classLoaderDesc Classloader name
21: * @param className Class name
22: */
23: public DmiClassSpec(final String classLoaderDesc,
24: final String className) {
25: Assert.pre(classLoaderDesc != null);
26: Assert.pre(className != null);
27: this .classLoaderDesc = classLoaderDesc;
28: this .className = className;
29: this .spec = classLoaderDesc + "-" + className;
30: }
31:
32: /**
33: * @return Classloader name
34: */
35: public String getClassLoaderDesc() {
36: return classLoaderDesc;
37: }
38:
39: /**
40: * @return Class name
41: */
42: public String getClassName() {
43: return className;
44: }
45:
46: public int hashCode() {
47: return spec.hashCode();
48: }
49:
50: public boolean equals(Object obj) {
51: if (!(obj instanceof DmiClassSpec))
52: return false;
53: DmiClassSpec that = (DmiClassSpec) obj;
54: return this .spec.equals(that.spec);
55: }
56:
57: public String toString() {
58: return "DmiClassSpec{loader=" + classLoaderDesc
59: + ", className=" + className + "}";
60: }
61:
62: public static String toString(DmiClassSpec[] specs) {
63: StringBuffer sb = new StringBuffer();
64: sb.append("[");
65: for (int i = 0; i < specs.length; i++) {
66: sb.append(specs[i].toString()).append(",");
67: }
68: sb.append("]");
69: return sb.toString();
70: }
71: }
|