update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / refactoring / changeClassSignature / TypeParameterInfo.java
blob17f0abaf2cc1d9e2a6d2bc08381df490896d8d4f
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.refactoring.changeClassSignature;
18 import com.intellij.psi.JavaPsiFacade;
19 import com.intellij.psi.PsiClass;
20 import com.intellij.psi.PsiType;
21 import com.intellij.refactoring.util.CanonicalTypes;
22 import com.intellij.util.IncorrectOperationException;
23 import org.jetbrains.annotations.NonNls;
25 /**
26 * @author dsl
28 class TypeParameterInfo {
29 private final int myOldParameterIndex;
30 private String myNewName;
31 private CanonicalTypes.Type myDefaultValue;
33 TypeParameterInfo(int oldIndex) {
34 myOldParameterIndex = oldIndex;
35 myDefaultValue = null;
38 TypeParameterInfo(String name, PsiType aType) {
39 myOldParameterIndex = -1;
40 myNewName = name;
41 if (aType != null) {
42 myDefaultValue = CanonicalTypes.createTypeWrapper(aType);
44 else {
45 myDefaultValue = null;
49 TypeParameterInfo(PsiClass aClass, @NonNls String name, @NonNls String defaultValue) throws IncorrectOperationException {
50 this(name, JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createTypeFromText(defaultValue, aClass.getLBrace()));
54 public int getOldParameterIndex() {
55 return myOldParameterIndex;
58 public String getNewName() {
59 return myNewName;
62 public void setNewName(String newName) {
63 myNewName = newName;
66 public CanonicalTypes.Type getDefaultValue() {
67 return myDefaultValue;
70 public void setDefaultValue(CanonicalTypes.Type defaultValue) {
71 myDefaultValue = defaultValue;
74 public void setDefaultValue(PsiType aType) {
75 setDefaultValue(CanonicalTypes.createTypeWrapper(aType));
78 boolean isForExistingParameter() {
79 return myOldParameterIndex >= 0;