Class RefactoringTool
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.AbstractRefactoringTool
org.eclipse.persistence.jpa.jpql.tools.RefactoringTool
- Direct Known Subclasses:
DefaultRefactoringTool
,EclipseLinkRefactoringTool
The abstract implementation providing refactoring support for JPQL queries.
Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
This visitor renames a fully qualified class name.protected static class
This visitor renames an entity name.protected static class
This visitor renames an enum constant.protected static class
This visitor renames any segment of a path expression.protected static class
This visitor renames all the result variables found in the JPQL query.protected static interface
This interface is used to transparently push the new value into theStateObject
.protected static class
This visitor renames all the identification variables found in the JPQL query. -
Constructor Summary
ModifierConstructorDescriptionprotected
RefactoringTool
(IManagedTypeProvider managedTypeProvider, IJPQLQueryBuilder jpqlQueryBuilder, CharSequence jpqlQuery) Creates a newRefactoringTool
.protected
RefactoringTool
(IManagedTypeProvider managedTypeProvider, IJPQLQueryBuilder jpqlQueryBuilder, CharSequence jpqlFragment, String jpqlQueryBNFId) Creates a newRefactoringTool
. -
Method Summary
Modifier and TypeMethodDescriptionprotected RefactoringTool.ClassNameRenamer
buildClassNameRenamer
(String oldClassName, String newClassName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename the fully qualified class name.protected RefactoringTool.EntityNameRenamer
buildEntityNameRenamer
(String oldEntityName, String newEntityName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename the entity name.protected RefactoringTool.EnumConstantRenamer
buildEnumConstantRenamer
(String oldClassName, String newClassName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename the enum constant.protected RefactoringTool.FieldNameRenamer
buildFieldNameRenamer
(String typeName, String oldFieldName, String newFieldName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename a type's attribute name.protected abstract IJPQLQueryFormatter
Creates a new formatter that will convert theStateObject
representation of the JPQL query, once the refactoring occurred into a string.protected abstract JPQLQueryContext
Creates a newJPQLQueryContext
that can retrieve information from the declaration portion of the JPQL query.buildResultVariableNameRenamer
(String oldVariableName, String newVariableName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename a result variable.protected JPQLQueryStateObject
Creates theStateObject
representation of the JPQL fragment to manipulate.protected RefactoringTool.VariableNameRenamer
buildVariableNameRenamer
(String oldVariableName, String newVariableName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename an identification variable.Returns theIJPQLQueryFormatter
that creates an accurate representation of theStateObject
, i.e.Returns theJPQLGrammar
that is associated with this builder.Returns the builder that creates theStateObject
representation of the JPQL query.Returns theStateObject
representation of the JPQL query or JPQL fragment that was parsed.void
renameClassName
(String oldClassName, String newClassName) Renames a fully qualified class name.void
renameEntityName
(String oldEntityName, String newEntityName) Renames a given entity name.void
renameEnumConstant
(String oldEnumConstant, String newEnumConstant) Renames an enum constant, which has to be fully qualified.void
renameField
(Class<?> type, String oldFieldName, String newFieldName) Renames a field from the given type.void
renameField
(String typeName, String oldFieldName, String newFieldName) Renames a field from the given type.void
renameField
(IType type, String oldFieldName, String newFieldName) Renames a field from the given type.void
renameResultVariable
(String oldVariableName, String newVariableName) Renames a result variable name.void
renameVariable
(String oldVariableName, String newVariableName) Renames a variable name.void
setFormatter
(IJPQLQueryFormatter jpqlQueryFormatter) Sets theIJPQLQueryFormatter
that creates an accurate representation of theStateObject
, i.e.Returns the resulted of the refactoring operations.Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.AbstractRefactoringTool
getJPQLFragment, getJPQLQueryBNFId, getManagedTypeProvider, isTolerant, setTolerant
-
Constructor Details
-
RefactoringTool
protected RefactoringTool(IManagedTypeProvider managedTypeProvider, IJPQLQueryBuilder jpqlQueryBuilder, CharSequence jpqlQuery) Creates a newRefactoringTool
.- Parameters:
managedTypeProvider
- The external form of a provider that gives access to the JPA metadatajpqlQueryBuilder
- The builder that creates theStateObject
representation of the JPQL queryjpqlQuery
- The JPQL query to manipulate
-
RefactoringTool
protected RefactoringTool(IManagedTypeProvider managedTypeProvider, IJPQLQueryBuilder jpqlQueryBuilder, CharSequence jpqlFragment, String jpqlQueryBNFId) Creates a newRefactoringTool
.- Parameters:
managedTypeProvider
- The external form of a provider that gives access to the JPA metadatajpqlQueryBuilder
- The builder that creates theStateObject
representation of the JPQL queryjpqlFragment
- The JPQL query to manipulate or a single JPQL fragment, which is parsed using the JPQL query BNF identifier by the given IDjpqlQueryBNFId
- The unique identifier of theJPQLQueryBNF
that determines how to parse the JPQL fragment
-
-
Method Details
-
buildClassNameRenamer
protected RefactoringTool.ClassNameRenamer buildClassNameRenamer(String oldClassName, String newClassName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename the fully qualified class name.- Parameters:
oldClassName
- The current name of the class to renamenewClassName
- The new name of the class- Returns:
- A new
RefactoringTool.ClassNameRenamer
-
buildEntityNameRenamer
protected RefactoringTool.EntityNameRenamer buildEntityNameRenamer(String oldEntityName, String newEntityName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename the entity name.- Parameters:
oldEntityName
- The current name of the entity to renamenewEntityName
- The new name of the entity- Returns:
- A new
RefactoringTool.EntityNameRenamer
-
buildEnumConstantRenamer
protected RefactoringTool.EnumConstantRenamer buildEnumConstantRenamer(String oldClassName, String newClassName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename the enum constant.- Parameters:
oldClassName
- The new name of the enum constantnewClassName
- The current name of the enum constant to rename- Returns:
- A new
RefactoringTool.EnumConstantRenamer
-
buildFieldNameRenamer
protected RefactoringTool.FieldNameRenamer buildFieldNameRenamer(String typeName, String oldFieldName, String newFieldName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename a type's attribute name.- Parameters:
typeName
- The fully qualified name of the type that got one of its attributes renamedoldFieldName
- The current name of the attribute to renamenewFieldName
- The new name of the attribute- Returns:
- A new
AttributeNameRenamer
-
buildFormatter
Creates a new formatter that will convert theStateObject
representation of the JPQL query, once the refactoring occurred into a string.- Returns:
- A new concrete instance of
IJPQLQueryFormatter
-
buildJPQLQueryContext
Creates a newJPQLQueryContext
that can retrieve information from the declaration portion of the JPQL query.NOTE: This is temporary because the
StateObject
API does not have that knowledge yet.- Returns:
- A new concrete instance of
JPQLQueryContext
-
buildResultVariableNameRenamer
protected RefactoringTool.ResultVariableNameRenamer buildResultVariableNameRenamer(String oldVariableName, String newVariableName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename a result variable.- Parameters:
oldVariableName
- The current result variable namenewVariableName
- The new name of the result variable- Returns:
- A new
RefactoringTool.ResultVariableNameRenamer
-
buildStateObject
Creates theStateObject
representation of the JPQL fragment to manipulate.- Returns:
- The parsed and editable JPQL query
- See Also:
-
buildVariableNameRenamer
protected RefactoringTool.VariableNameRenamer buildVariableNameRenamer(String oldVariableName, String newVariableName) Creates the visitor that will traverse theStateObject
representation of the JPQL query and will rename an identification variable.- Parameters:
oldVariableName
- The current identification variable namenewVariableName
- The new name of the identification variable- Returns:
- A new
RefactoringTool.VariableNameRenamer
-
getFormatter
Returns theIJPQLQueryFormatter
that creates an accurate representation of theStateObject
, i.e. that output the JPQL query with the case used for the JPQL identifier.- Returns:
- An instance of
IJPQLQueryFormatter
-
getGrammar
Returns theJPQLGrammar
that is associated with this builder.- Returns:
- The
JPQLGrammar
that was used to parse the JPQL query or JPQL fragments
-
getJPQLQueryBuilder
Returns the builder that creates theStateObject
representation of the JPQL query.- Returns:
- The builder of the
StateObject
to be manipulated
-
getStateObject
Returns theStateObject
representation of the JPQL query or JPQL fragment that was parsed.- Returns:
- The editable state model
-
renameClassName
Renames a fully qualified class name.- Parameters:
oldClassName
- The current fully qualified class name of the class to renamenewClassName
- The new fully qualified class name
-
renameEntityName
Renames a given entity name.- Parameters:
oldEntityName
- The current name of the entity to renamenewEntityName
- The new name of the entity
-
renameEnumConstant
Renames an enum constant, which has to be fully qualified.- Parameters:
oldEnumConstant
- The current fully qualified name of the enum constant to renamenewEnumConstant
- The new fully qualified name of the enum constant
-
renameField
Renames a field from the given type.- Parameters:
type
- The Java class from which the change originateoldFieldName
- The current name of the attribute to renamenewFieldName
- The new name of the attribute
-
renameField
Renames a field from the given type.- Parameters:
type
- TheIType
from which the change originateoldFieldName
- The current name of the attribute to renamenewFieldName
- The new name of the attribute
-
renameField
Renames a field from the given type.- Parameters:
typeName
- The fully qualified name of the type that got one of its attributes renamedoldFieldName
- The current name of the attribute to renamenewFieldName
- The new name of the attribute
-
renameResultVariable
Renames a result variable name.- Parameters:
oldVariableName
- The current identification variable namenewVariableName
- The new name of the identification variable
-
renameVariable
Renames a variable name.- Parameters:
oldVariableName
- The current identification variable namenewVariableName
- The new name of the identification variable
-
setFormatter
Sets theIJPQLQueryFormatter
that creates an accurate representation of theStateObject
, i.e. that output the JPQL query with the case used for the JPQL identifier.- Parameters:
jpqlQueryFormatter
- This formatter converts aStateObject
representation of the JPQL query into a string representation
-
toActualText
Description copied from class:AbstractRefactoringTool
Returns the resulted of the refactoring operations. The list of changes will be removed after applying the changes.- Specified by:
toActualText
in classAbstractRefactoringTool
- Returns:
- The string representation of the JPQL query that contains the changes
-