KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jdt.core.ICompilationUnit;
16 import org.eclipse.jdt.core.dom.IMethodBinding;
17
18 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType;
19
20 /**
21  * A ParameterTypeVariable is a ConstraintVariable which stands for
22  * the type of a method parameter.
23  */

24 public final class ParameterTypeVariable2 extends ConstraintVariable2 implements ISourceConstraintVariable {
25
26     private final int fParameterIndex;
27     private final String JavaDoc fKey;
28     private ICompilationUnit fCompilationUnit;
29     
30     public ParameterTypeVariable2(TType type, int index, IMethodBinding binding) {
31         super(type);
32         Assert.isNotNull(binding);
33         Assert.isTrue(0 <= index);
34         fParameterIndex= index;
35         fKey= binding.getKey();
36     }
37     
38     public void setCompilationUnit(ICompilationUnit cu) {
39         fCompilationUnit= cu;
40     }
41     
42     public ICompilationUnit getCompilationUnit() {
43         return fCompilationUnit;
44     }
45
46     public int getParameterIndex() {
47         return fParameterIndex;
48     }
49     
50     public String JavaDoc getKey() {
51         return fKey;
52     }
53
54     /*
55      * @see java.lang.Object#hashCode()
56      */

57     public int hashCode() {
58         return getParameterIndex() ^ getKey().hashCode();
59     }
60
61     /*
62      * @see java.lang.Object#equals(java.lang.Object)
63      */

64     public boolean equals(Object JavaDoc other) {
65         if (this == other)
66             return true;
67         if (other.getClass() != ParameterTypeVariable2.class)
68             return false;
69         
70         ParameterTypeVariable2 other2= (ParameterTypeVariable2) other;
71         return getParameterIndex() == other2.getParameterIndex()
72                 && getKey().equals(other2.getKey());
73     }
74
75     public String JavaDoc toString() {
76         String JavaDoc toString= (String JavaDoc) getData(TO_STRING);
77         return toString == null ? "[Parameter(" + fParameterIndex + "," + fKey + ")]" : toString; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
78
}
79 }
80
Popular Tags