Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2011 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* If you wish your version of this file to be governed by only the CDDL |
28 |
* or only the GPL Version 2, indicate your decision by adding |
29 |
* "[Contributor] elects to include this software in this distribution |
30 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
31 |
* single choice of license, a recipient has the option to distribute |
32 |
* your version of this file under either the CDDL, the GPL Version 2 or |
33 |
* to extend the choice of license to its licensees as provided above. |
34 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
35 |
* Version 2 license, then the option applies only if the new code is |
36 |
* made subject to such option by the copyright holder. |
37 |
* |
38 |
* Contributor(s): |
39 |
* |
40 |
* Portions Copyrighted 2011 Sun Microsystems, Inc. |
41 |
*/ |
42 |
package org.netbeans.modules.refactoring.java.api; |
43 |
|
44 |
import org.netbeans.modules.refactoring.api.MoveRefactoring; |
45 |
import org.openide.util.Lookup; |
46 |
|
47 |
/** |
48 |
* This class is just holder for parameters of Move Members Refactoring. |
49 |
* Refactoring itself is implemented in plugins. |
50 |
* |
51 |
* @see org.netbeans.modules.refactoring.api.MoveRefactoring |
52 |
* @see org.netbeans.modules.refactoring.spi.RefactoringPlugin |
53 |
* @see org.netbeans.modules.refactoring.spi.RefactoringPluginFactory |
54 |
* @see AbstractRefactoring |
55 |
* @see RefactoringSession |
56 |
* @author Ralph Ruijs |
57 |
* @since 1.31 |
58 |
*/ |
59 |
public class MoveMembersRefactoring extends MoveRefactoring { |
60 |
|
61 |
private Visibility visibility; |
62 |
private boolean delegate; |
63 |
private boolean addDeprecated; |
64 |
private boolean updateJavaDoc; |
65 |
|
66 |
/** |
67 |
* Public constructor takes Lookup containing objects to refactor as |
68 |
* parameter. |
69 |
* |
70 |
* @param objectsToMove store your objects into Lookup |
71 |
*/ |
72 |
public MoveMembersRefactoring(Lookup objectsToMove) { |
73 |
super(objectsToMove); |
74 |
} |
75 |
|
76 |
/** |
77 |
* |
78 |
* @param moveRefactoring |
79 |
*/ |
80 |
public MoveMembersRefactoring(MoveRefactoring moveRefactoring) { |
81 |
super(moveRefactoring.getRefactoringSource()); |
82 |
setTarget(moveRefactoring.getTarget()); |
83 |
this.visibility = Visibility.ESCALATE; |
84 |
} |
85 |
|
86 |
/** |
87 |
* The new visibility of the members. |
88 |
* |
89 |
* @return visibility |
90 |
*/ |
91 |
public Visibility getVisibility() { |
92 |
return visibility; |
93 |
} |
94 |
|
95 |
/** |
96 |
* The new visibility of the members. |
97 |
* |
98 |
* @param visibility the visibility to use |
99 |
*/ |
100 |
public void setVisibility(Visibility visibility) { |
101 |
this.visibility = visibility; |
102 |
} |
103 |
|
104 |
/** |
105 |
* Leave the old method in place and let it delegate to the new location. |
106 |
* All references to the method will not be touched. |
107 |
* |
108 |
* @return true if the old method will delegate to the new location, false |
109 |
* otherwise |
110 |
*/ |
111 |
public boolean isDelegate() { |
112 |
return delegate; |
113 |
} |
114 |
|
115 |
/** |
116 |
* Leave the old method in place and let it delegate to the new location. |
117 |
* All references to the method will not be touched. |
118 |
* |
119 |
* @param delegate true if the old method needs delegate to the new location |
120 |
*/ |
121 |
public void setDelegate(boolean delegate) { |
122 |
this.delegate = delegate; |
123 |
} |
124 |
|
125 |
/** |
126 |
* Add a deprecated tag to the JavaDoc of the delegating method. |
127 |
* |
128 |
* @return true if the old method will delegate to the new location and a |
129 |
* deprecated tag will be added, false otherwise |
130 |
*/ |
131 |
public boolean isAddDeprecated() { |
132 |
return delegate && addDeprecated; |
133 |
} |
134 |
|
135 |
/** |
136 |
* Add a deprecated tag to the JavaDoc of the delegating method. |
137 |
* |
138 |
* @param addDeprecated true if a deprecated tag has to be added to the |
139 |
* delegate method |
140 |
*/ |
141 |
public void setAddDeprecated(boolean addDeprecated) { |
142 |
this.addDeprecated = addDeprecated; |
143 |
} |
144 |
|
145 |
/** |
146 |
* Update or create the JavaDoc for moved methods. |
147 |
* |
148 |
* @return true if JavaDoc will be created or the existing will be updated, |
149 |
* false otherwise |
150 |
*/ |
151 |
public boolean isUpdateJavaDoc() { |
152 |
return updateJavaDoc; |
153 |
} |
154 |
|
155 |
/** |
156 |
* Add a deprecated tag to the javadoc of the delegating method. |
157 |
* |
158 |
* @param updateJavaDoc true if the method's JavaDoc needs to be created or |
159 |
* updated. |
160 |
*/ |
161 |
public void setUpdateJavaDoc(boolean updateJavaDoc) { |
162 |
this.updateJavaDoc = updateJavaDoc; |
163 |
} |
164 |
|
165 |
/** |
166 |
* Used to specify visibility level. It can either be set explicitly, or set |
167 |
* to Escalate to automatically raise it to a necessary level. |
168 |
*/ |
169 |
public static enum Visibility { |
170 |
|
171 |
/** |
172 |
* Escalate, automatically raise the visibility to a necessary level, |
173 |
* based on usages. |
174 |
*/ |
175 |
ESCALATE, |
176 |
/** |
177 |
* As is, keep the current visibility level of the member. |
178 |
*/ |
179 |
ASIS, |
180 |
/** |
181 |
* Change to, or keep, the visibility public. |
182 |
*/ |
183 |
PUBLIC, |
184 |
/** |
185 |
* Change to, or keep, the visibility protected. |
186 |
*/ |
187 |
PROTECTED, |
188 |
/** |
189 |
* Change to, or keep, the visibility the default level. |
190 |
*/ |
191 |
DEFAULT, |
192 |
/** |
193 |
* Change to, or keep, the visibility private. |
194 |
*/ |
195 |
PRIVATE |
196 |
} |
197 |
} |