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
;
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;
42 myDefaultValue
= CanonicalTypes
.createTypeWrapper(aType
);
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() {
62 public void setNewName(String 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;