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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.structure;
13 import org.eclipse.core.runtime.Assert;
16 * Maplet from a type variable in a source class to a type variable in a target class.
18 public final class TypeVariableMaplet {
20 /** The source index */
21 private final int fSourceIndex;
23 /** The source of the mapping */
24 private final String fSourceName;
26 /** The target index */
27 private final int fTargetIndex;
29 /** The target of the mapping */
30 private final String fTargetName;
33 * Creates a new type variable maplet.
36 * the simple name of the type variable in the source class
38 * the index of the source type variable in the source class declaration
40 * the simple name of the type variable in the range class
42 * the index of the range type variable in the range class declaration
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);
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;
67 * Returns the source index of this type variable maplet.
69 * @return the source index of this maplet
71 public final int getSourceIndex() {
76 * Returns the source of this type variable maplet.
78 * @return the source of this maplet
80 public final String getSourceName() {
85 * Returns the target index of this type variable maplet.
87 * @return the target index of this maplet
89 public final int getTargetIndex() {
94 * Returns the target of this type variable maplet.
96 * @return the target of this maplet
98 public final String getTargetName() {
103 public final int hashCode() {
104 return fSourceIndex | fTargetIndex | fSourceName.hashCode() | fTargetName.hashCode();