Class IntroduceParameterObjectDescriptor
- java.lang.Object
-
- org.eclipse.ltk.core.refactoring.RefactoringDescriptor
-
- org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor
-
- org.eclipse.jdt.core.refactoring.descriptors.IntroduceParameterObjectDescriptor
-
- All Implemented Interfaces:
Comparable<RefactoringDescriptor>
public class IntroduceParameterObjectDescriptor extends JavaRefactoringDescriptor
Refactoring descriptor for the introduce parameter object refactoring.An instance of this refactoring descriptor may be obtained by calling
RefactoringContribution.createDescriptor()on a refactoring contribution requested by invokingRefactoringCore.getRefactoringContribution(String)with the appropriate refactoring id.- Since:
- 1.2
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntroduceParameterObjectDescriptor.ParameterInstances of Parameter are used to describe the position of parameter and fields.
-
Field Summary
Fields Modifier and Type Field Description static IntroduceParameterObjectDescriptor.ParameterPARAMETER_OBJECTSingleton instance that represents the parameter objectstatic intPARAMETER_OBJECT_IDXThe parameter index of the special parameter object.-
Fields inherited from class org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor
ATTRIBUTE_ELEMENT, ATTRIBUTE_INPUT, ATTRIBUTE_NAME, ATTRIBUTE_REFERENCES, ATTRIBUTE_SELECTION, ATTRIBUTE_VERSION, fArguments, JAR_MIGRATION, JAR_REFACTORING, JAR_SOURCE_ATTACHMENT, VALUE_VERSION_1_0
-
Fields inherited from class org.eclipse.ltk.core.refactoring.RefactoringDescriptor
BREAKING_CHANGE, ID_UNKNOWN, MULTI_CHANGE, NONE, STRUCTURAL_CHANGE, USER_CHANGE
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IntroduceParameterObjectDescriptor.Parameter[]createParameters(IMethod method)Creates the parameters for this method.StringgetClassName()The name of the class that will be generated.IMethodgetMethod()The method the refactoring will operate on.StringgetPackageName()The parameter object class will be created in this package if the top level istrue.StringgetParameterName()Returns the name of the parameter.IntroduceParameterObjectDescriptor.Parameter[]getParameters()Returns the parameters.booleanisDelegate()Returnstrueif delegates will be kept.booleanisDeprecateDelegate()Returnstrueif delegates will be marked as deprecated.booleanisGetters()Returnstrueif getters are generated for fields.booleanisSetters()Returnstrueif setters are generated for fields.booleanisTopLevel()Returnstrueif the new type is created as top level type.protected voidpopulateArgumentMap()Populates the refactoring descriptor argument map based on the specified arguments.voidsetClassName(String className)Sets the name of the class for the generated parameter object.voidsetDelegate(boolean delegate)Sets delegate keeping.voidsetDeprecateDelegate(boolean deprecateDelegate)Sets deprecate delegate.voidsetGetters(boolean getters)Sets whether getters will be created for all fields.voidsetMethod(IMethod method)Sets the method.voidsetPackageName(String packageName)Sets the package where the parameter object will be created in if it is created as top level class.voidsetParameterName(String parameterName)Sets the name of the parameter object as it will appear in the method signature.voidsetParameters(IntroduceParameterObjectDescriptor.Parameter[] parameters)Sets the parameters.voidsetSetters(boolean setters)Sets whether setters will be created for all fields.voidsetTopLevel(boolean topLevel)Sets whether the parameter object class will be created as top level class.RefactoringStatusvalidateDescriptor()Validates the refactoring descriptor with respect to the constraints imposed by the represented refactoring.-
Methods inherited from class org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor
createRefactoring, elementToHandle, getArguments, handleToElement, handleToElement, handleToElement, handleToResource, resourceToHandle, setComment, setDescription, setFlags, setProject
-
Methods inherited from class org.eclipse.ltk.core.refactoring.RefactoringDescriptor
compareTo, createRefactoringContext, equals, getComment, getDescription, getFlags, getID, getProject, getTimeStamp, hashCode, setTimeStamp, toString
-
-
-
-
Field Detail
-
PARAMETER_OBJECT_IDX
public static final int PARAMETER_OBJECT_IDX
The parameter index of the special parameter object. The value is "-1".- See Also:
- Constant Field Values
-
PARAMETER_OBJECT
public static final IntroduceParameterObjectDescriptor.Parameter PARAMETER_OBJECT
Singleton instance that represents the parameter object
-
-
Constructor Detail
-
IntroduceParameterObjectDescriptor
public IntroduceParameterObjectDescriptor()
Creates a new refactoring descriptor.
-
IntroduceParameterObjectDescriptor
public IntroduceParameterObjectDescriptor(String project, String description, String comment, Map<String,String> arguments, int flags) throws IllegalArgumentException
Creates a new refactoring descriptor.- Parameters:
project- the non-empty name of the project associated with this refactoring, ornullfor a workspace refactoringdescription- a non-empty human-readable description of the particular refactoring instancecomment- the human-readable comment of the particular refactoring instance, ornullfor no commentarguments- a map of arguments that will be persisted and describes all settings for this refactoringflags- the flags of the refactoring descriptor- Throws:
IllegalArgumentException- if the argument map contains invalid keys/values
-
-
Method Detail
-
createParameters
public static IntroduceParameterObjectDescriptor.Parameter[] createParameters(IMethod method)
Creates the parameters for this method. The first object is the parameter object. By default all parameters are marked for field creation- Parameters:
method- derive parameter from this method- Returns:
- an array of parameter corresponding to the parameter declared in the method. The first object will be the parameter object. All parameter are marked for field creation
-
getClassName
public String getClassName()
The name of the class that will be generated. Ifnullthe refactoring will automatically choose a class name.- Returns:
- the name of the class that will be generated or
nullif the name will be automatically chosen
-
getMethod
public IMethod getMethod()
The method the refactoring will operate on. Can be set usingsetMethod(IMethod).- Returns:
- the method that the refactoring will operate on.
-
getPackageName
public String getPackageName()
The parameter object class will be created in this package if the top level istrue. Can be set usingsetPackageName(String). If the package name wasnulland the method has already been set this method returns the package where the method is declared in.- Returns:
- the package name that has been set or the package where the method is declared. Can return
nullif neither the package nor the method has been set
-
getParameterName
public String getParameterName()
Returns the name of the parameter. Can returnnullin which case the refactoring chooses a name. Default isnull- Returns:
- the name of the parameter. Can return
nullin which case the refactoring chooses a name. Default isnull
-
getParameters
public IntroduceParameterObjectDescriptor.Parameter[] getParameters()
Returns the parameters. Can returnnullif all parameters should be converted to fields. Default isnull.- Returns:
- the parameters. Can return
nullif all parameters should be converted to fields. Default isnull
-
isDelegate
public boolean isDelegate()
Returnstrueif delegates will be kept. Default isfalse.- Returns:
trueif delegates will be kept. Default isfalse
-
isDeprecateDelegate
public boolean isDeprecateDelegate()
Returnstrueif delegates will be marked as deprecated. Default isfalse.- Returns:
trueif delegates will be marked as deprecated. Default isfalse
-
isGetters
public boolean isGetters()
Returnstrueif getters are generated for fields. Default isfalse.- Returns:
trueif getters are generated for fields. Default isfalse
-
isSetters
public boolean isSetters()
Returnstrueif setters are generated for fields. Default isfalse.- Returns:
trueif setters are generated for fields. Default isfalse
-
isTopLevel
public boolean isTopLevel()
Returnstrueif the new type is created as top level type.falseis returned when the type is created as enclosing type of the type declaring the method declaration to be changed. Default istrue.- Returns:
trueif the new type is created as top level type.falseis returned when the type is created as enclosing type of the type declaring the method declaration to be changed. Default istrue
-
populateArgumentMap
protected void populateArgumentMap()
Description copied from class:JavaRefactoringDescriptorPopulates the refactoring descriptor argument map based on the specified arguments. Subclasses should extend and add their arguments toJavaRefactoringDescriptor.fArguments.- Overrides:
populateArgumentMapin classJavaRefactoringDescriptor
-
setClassName
public void setClassName(String className)
Sets the name of the class for the generated parameter object. The name can benullto indicate that the refactoring should chose one.- Parameters:
className- the name of the generated class ornull. Default isnull
-
setDelegate
public void setDelegate(boolean delegate)
Sets delegate keeping. Iftruedelegates will be kept.- Parameters:
delegate-trueto keep delegates. Default isfalse
-
setDeprecateDelegate
public void setDeprecateDelegate(boolean deprecateDelegate)
Sets deprecate delegate. Iftruegenerated delegates will be marked as deprecated.- Parameters:
deprecateDelegate-trueto deprecate kept delegates. Default isfalse
-
setGetters
public void setGetters(boolean getters)
Sets whether getters will be created for all fields.- Parameters:
getters-trueto create getters. Default isfalse.
-
setMethod
public void setMethod(IMethod method)
Sets the method. The method may not benull, has to exist, and has to be in a Java project.- Parameters:
method- the method. May not benull
-
setPackageName
public void setPackageName(String packageName)
Sets the package where the parameter object will be created in if it is created as top level class. The package can benullto indicate that the package of the method should be used.- Parameters:
packageName- the package for the top level class ornull. Default isnull.
-
setParameterName
public void setParameterName(String parameterName)
Sets the name of the parameter object as it will appear in the method signature. The name can benullto indicate that the refactoring will choose a name.- Parameters:
parameterName- the name of the parameter ornull. Default isnull.
-
setParameters
public void setParameters(IntroduceParameterObjectDescriptor.Parameter[] parameters)
Sets the parameters. The parameters can benullto indicate that all parameter should be used as fields. If notnull, the number of parameters passed has to be the number of parameter of the method + 1. One element has to be thePARAMETER_OBJECT. Each parameter may only appear once.- Parameters:
parameters- the parameters ornull. Default isnull
-
setSetters
public void setSetters(boolean setters)
Sets whether setters will be created for all fields.- Parameters:
setters-trueto create setters. Default isfalse
-
setTopLevel
public void setTopLevel(boolean topLevel)
Sets whether the parameter object class will be created as top level class. iftruethe class will be created as top level class in the package returned bygetPackageName(). Iffalsethe class will be created as as nested class in the class containing the method- Parameters:
topLevel-trueto create the parameter object as top level. Default istrue
-
validateDescriptor
public RefactoringStatus validateDescriptor()
Description copied from class:JavaRefactoringDescriptorValidates the refactoring descriptor with respect to the constraints imposed by the represented refactoring.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.FATALindicates that the refactoring descriptor cannot be used to create a refactoring instance.- Overrides:
validateDescriptorin classJavaRefactoringDescriptor- Returns:
- a refactoring status describing the outcome of the validation
-
-