]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/TypeVariableMaplet.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / core refactoring / org / eclipse / jdt / internal / corext / refactoring / structure / TypeVariableMaplet.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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.structure;
12
13 import org.eclipse.core.runtime.Assert;
14
15 /**
16  * Maplet from a type variable in a source class to a type variable in a target class.
17  */
18 public final class TypeVariableMaplet {
19
20         /** The source index */
21         private final int fSourceIndex;
22
23         /** The source of the mapping */
24         private final String fSourceName;
25
26         /** The target index */
27         private final int fTargetIndex;
28
29         /** The target of the mapping */
30         private final String fTargetName;
31
32         /**
33          * Creates a new type variable maplet.
34          *
35          * @param source
36          *        the simple name of the type variable in the source class
37          * @param index
38          *        the index of the source type variable in the source class declaration
39          * @param target
40          *        the simple name of the type variable in the range class
41          * @param offset
42          *        the index of the range type variable in the range class declaration
43          */
44         public TypeVariableMaplet(final String source, final int index, final String target, final int offset) {
45                 Assert.isNotNull(source);
46                 Assert.isNotNull(target);
47                 Assert.isTrue(source.length() > 0);
48                 Assert.isTrue(target.length() > 0);
49                 Assert.isTrue(index >= 0);
50                 Assert.isTrue(offset >= 0);
51                 fSourceName= source;
52                 fTargetName= target;
53                 fSourceIndex= index;
54                 fTargetIndex= offset;
55         }
56
57         @Override
58         public final boolean equals(final Object object) {
59                 if (object instanceof TypeVariableMaplet) {
60                         final TypeVariableMaplet mapping= (TypeVariableMaplet) object;
61                         return mapping.getSourceName().equals(fSourceName) && mapping.getTargetName().equals(fTargetName) && mapping.getSourceIndex() == fSourceIndex && mapping.getTargetIndex() == fTargetIndex;
62                 }
63                 return false;
64         }
65
66         /**
67          * Returns the source index of this type variable maplet.
68          *
69          * @return the source index of this maplet
70          */
71         public final int getSourceIndex() {
72                 return fSourceIndex;
73         }
74
75         /**
76          * Returns the source of this type variable maplet.
77          *
78          * @return the source of this maplet
79          */
80         public final String getSourceName() {
81                 return fSourceName;
82         }
83
84         /**
85          * Returns the target index of this type variable maplet.
86          *
87          * @return the target index of this maplet
88          */
89         public final int getTargetIndex() {
90                 return fTargetIndex;
91         }
92
93         /**
94          * Returns the target of this type variable maplet.
95          *
96          * @return the target of this maplet
97          */
98         public final String getTargetName() {
99                 return fTargetName;
100         }
101
102         @Override
103         public final int hashCode() {
104                 return fSourceIndex | fTargetIndex | fSourceName.hashCode() | fTargetName.hashCode();
105         }
106 }