KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > typeconstraints2 > VariableVariable2


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2;
13
14 import org.eclipse.jdt.core.ICompilationUnit;
15 import org.eclipse.jdt.core.dom.IVariableBinding;
16
17 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType;
18
19 /**
20  * A VariableVariable is a ConstraintVariable which stands for
21  * the type of a variable, namely a field or a local variable
22  * Use {@link ParameterTypeVariable2} for method parameters).
23  */

24 public final class VariableVariable2 extends ConstraintVariable2 implements ISourceConstraintVariable {
25
26     private final String JavaDoc fKey;
27     private ICompilationUnit fCompilationUnit;
28     
29     public VariableVariable2(TType type, IVariableBinding binding) {
30         super(type);
31         fKey= binding.getKey();
32     }
33
34     public void setCompilationUnit(ICompilationUnit unit) {
35         fCompilationUnit= unit;
36     }
37     
38     public ICompilationUnit getCompilationUnit() {
39         return fCompilationUnit;
40     }
41
42     public String JavaDoc getKey() {
43         return fKey;
44     }
45
46     /*
47      * @see java.lang.Object#hashCode()
48      */

49     public int hashCode() {
50         return fKey.hashCode();
51     }
52
53     /*
54      * @see java.lang.Object#equals(java.lang.Object)
55      */

56     public boolean equals(Object JavaDoc other) {
57         if (this == other)
58             return true;
59         if (other.getClass() != VariableVariable2.class)
60             return false;
61         
62         return fKey.equals(((VariableVariable2) other).getKey());
63     }
64 }
65
Popular Tags