public class IntroduceParameterObjectDescriptor extends JavaRefactoringDescriptor
An instance of this refactoring descriptor may be obtained by calling
RefactoringContribution.createDescriptor()
on a refactoring
contribution requested by invoking
RefactoringCore.getRefactoringContribution(String)
with the
appropriate refactoring id.
Modifier and Type | Class and Description |
---|---|
static class |
IntroduceParameterObjectDescriptor.Parameter
Instances of Parameter are used to describe the position of parameter and fields.
|
Modifier and Type | Field and Description |
---|---|
static IntroduceParameterObjectDescriptor.Parameter |
PARAMETER_OBJECT
Singleton instance that represents the parameter object
|
static int |
PARAMETER_OBJECT_IDX
The parameter index of the special parameter object.
|
ATTRIBUTE_ELEMENT, ATTRIBUTE_INPUT, ATTRIBUTE_NAME, ATTRIBUTE_REFERENCES, ATTRIBUTE_SELECTION, ATTRIBUTE_VERSION, fArguments, JAR_MIGRATION, JAR_REFACTORING, JAR_SOURCE_ATTACHMENT, VALUE_VERSION_1_0
BREAKING_CHANGE, ID_UNKNOWN, MULTI_CHANGE, NONE, STRUCTURAL_CHANGE, USER_CHANGE
Constructor and Description |
---|
IntroduceParameterObjectDescriptor()
Creates a new refactoring descriptor.
|
IntroduceParameterObjectDescriptor(String project,
String description,
String comment,
Map<String,String> arguments,
int flags)
Creates a new refactoring descriptor.
|
Modifier and Type | Method and Description |
---|---|
static IntroduceParameterObjectDescriptor.Parameter[] |
createParameters(IMethod method)
Creates the parameters for this method.
|
String |
getClassName()
The name of the class that will be generated.
|
IMethod |
getMethod()
The method the refactoring will operate on.
|
String |
getPackageName()
The parameter object class will be created in this package if the top level is
true . |
String |
getParameterName()
Returns the name of the parameter.
|
IntroduceParameterObjectDescriptor.Parameter[] |
getParameters()
Returns the parameters.
|
boolean |
isDelegate()
Returns
true if delegates will be kept. |
boolean |
isDeprecateDelegate()
Returns
true if delegates will be marked as deprecated. |
boolean |
isGetters()
Returns
true if getters are generated for fields. |
boolean |
isSetters()
Returns
true if setters are generated for fields. |
boolean |
isTopLevel()
Returns
true if the new type is created as top level type. |
protected void |
populateArgumentMap()
Populates the refactoring descriptor argument map based on the specified
arguments.
|
void |
setClassName(String className)
Sets the name of the class for the generated parameter object.
|
void |
setDelegate(boolean delegate)
Sets delegate keeping.
|
void |
setDeprecateDelegate(boolean deprecateDelegate)
Sets deprecate delegate.
|
void |
setGetters(boolean getters)
Sets whether getters will be created for all fields.
|
void |
setMethod(IMethod method)
Sets the method.
|
void |
setPackageName(String packageName)
Sets the package where the parameter object will be created in if it is created as top level class.
|
void |
setParameterName(String parameterName)
Sets the name of the parameter object as it will appear in the method signature.
|
void |
setParameters(IntroduceParameterObjectDescriptor.Parameter[] parameters)
Sets the parameters.
|
void |
setSetters(boolean setters)
Sets whether setters will be created for all fields.
|
void |
setTopLevel(boolean topLevel)
Sets whether the parameter object class will be created as top level class.
|
RefactoringStatus |
validateDescriptor()
Validates the refactoring descriptor with respect to the constraints
imposed by the represented refactoring.
|
createRefactoring, elementToHandle, getArguments, handleToElement, handleToElement, handleToElement, handleToResource, resourceToHandle, setComment, setDescription, setFlags, setProject
compareTo, createRefactoringContext, equals, getComment, getDescription, getFlags, getID, getProject, getTimeStamp, hashCode, setTimeStamp, toString
public static final int PARAMETER_OBJECT_IDX
public static final IntroduceParameterObjectDescriptor.Parameter PARAMETER_OBJECT
public IntroduceParameterObjectDescriptor()
public IntroduceParameterObjectDescriptor(String project, String description, String comment, Map<String,String> arguments, int flags) throws IllegalArgumentException
project
- the non-empty name of the project associated with this
refactoring, or null
for a workspace
refactoringdescription
- a non-empty human-readable description of the particular
refactoring instancecomment
- the human-readable comment of the particular refactoring
instance, or null
for no commentarguments
- a map of arguments that will be persisted and describes
all settings for this refactoringflags
- the flags of the refactoring descriptorIllegalArgumentException
- if the argument map contains invalid keys/valuespublic static IntroduceParameterObjectDescriptor.Parameter[] createParameters(IMethod method)
method
- derive parameter from this methodpublic String getClassName()
null
the refactoring will automatically choose a class name.null
if the name will be automatically chosenpublic IMethod getMethod()
setMethod(IMethod)
.public String getPackageName()
true
. Can be set using
setPackageName(String)
. If the package name was null
and the method has already been set this method returns
the package where the method is declared in.null
if neither the package nor the method has been setpublic String getParameterName()
null
in which case the refactoring chooses a name. Default is null
null
in which case the refactoring chooses a name. Default is null
public IntroduceParameterObjectDescriptor.Parameter[] getParameters()
null
if all parameters should be converted to fields. Default is null
.null
if all parameters should be converted to fields. Default is null
public boolean isDelegate()
true
if delegates will be kept. Default is false
.true
if delegates will be kept. Default is false
public boolean isDeprecateDelegate()
true
if delegates will be marked as deprecated. Default is false
.true
if delegates will be marked as deprecated. Default is false
public boolean isGetters()
true
if getters are generated for fields. Default is false
.true
if getters are generated for fields. Default is false
public boolean isSetters()
true
if setters are generated for fields. Default is false
.true
if setters are generated for fields. Default is false
public boolean isTopLevel()
true
if the new type is created as top level type.
false
is returned when the type is created as enclosing type
of the type declaring the method declaration to be changed. Default is true
.true
if the new type is created as top level type.
false
is returned when the type is created as enclosing
type of the type declaring the method declaration to be changed. Default is true
protected void populateArgumentMap()
JavaRefactoringDescriptor
JavaRefactoringDescriptor.fArguments
.populateArgumentMap
in class JavaRefactoringDescriptor
public void setClassName(String className)
null
to
indicate that the refactoring should chose one.className
- the name of the generated class or null
. Default is null
public void setDelegate(boolean delegate)
true
delegates will be kept.delegate
- true
to keep delegates. Default is false
public void setDeprecateDelegate(boolean deprecateDelegate)
true
generated delegates will be marked as deprecated.deprecateDelegate
- true
to deprecate kept delegates. Default is false
public void setGetters(boolean getters)
getters
- true
to create getters. Default is false
.public void setMethod(IMethod method)
null
, has to exist, and has to be
in a Java project.method
- the method. May not be null
public void setPackageName(String packageName)
null
to indicate that the package of the method should be used.packageName
- the package for the top level class or null
. Default is null
.public void setParameterName(String parameterName)
null
to indicate that the refactoring will choose a name.parameterName
- the name of the parameter or null
. Default is null
.public void setParameters(IntroduceParameterObjectDescriptor.Parameter[] parameters)
null
to indicate that all parameter
should be used as fields. If not null
, the number of parameters passed has to be
the number of parameter of the method + 1. One element has to be the PARAMETER_OBJECT
.
Each parameter may only appear once.parameters
- the parameters or null
. Default is null
public void setSetters(boolean setters)
setters
- true
to create setters. Default is false
public void setTopLevel(boolean topLevel)
true
the class will be created as top level class in the package
returned by getPackageName()
. If false
the class will be
created as as nested class in the class containing the methodtopLevel
- true
to create the parameter object as top level. Default is true
public RefactoringStatus validateDescriptor()
JavaRefactoringDescriptor
Clients must call this method to verify that all arguments have been
correctly set and that they satisfy the constraints imposed by specific
refactorings. Returning a refactoring status of severity
RefactoringStatus.FATAL
indicates that the refactoring descriptor
cannot be used to create a refactoring instance.
validateDescriptor
in class JavaRefactoringDescriptor
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.