01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.internal.navigator.extensions;
11:
12: import java.lang.ref.SoftReference;
13:
14: /**
15: * @since 3.3
16: *
17: */
18: public class EvalutationReference extends SoftReference {
19:
20: private final int hashCode;
21:
22: private final Class type;
23:
24: /**
25: * @param referent
26: * The object to be referenced
27: */
28: public EvalutationReference(Object referent) {
29: super (referent);
30: hashCode = referent.hashCode();
31: type = referent.getClass();
32: }
33:
34: /*
35: * (non-Javadoc)
36: *
37: * @see java.lang.Object#hashCode()
38: */
39: public int hashCode() {
40: return hashCode;
41: }
42:
43: /*
44: * (non-Javadoc)
45: *
46: * @see java.lang.Object#equals(java.lang.Object)
47: */
48: public boolean equals(Object obj) {
49: if (obj == null)
50: return false;
51: else if (obj instanceof EvalutationReference) {
52: if (!type.equals(((EvalutationReference) obj).type))
53: return false;
54: return hashCode == obj.hashCode();
55: }
56: return false;
57: }
58:
59: /* (non-Javadoc)
60: * @see java.lang.Object#toString()
61: */
62: public String toString() {
63: Object referent = get();
64: if (referent == null)
65: return "Evalutation[type=" + type + "]"; //$NON-NLS-1$//$NON-NLS-2$
66: return "Evalutation[referent=" + referent + "]"; //$NON-NLS-1$ //$NON-NLS-2$
67: }
68:
69: }
|