Class DefaultRefactoringDelta
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.DefaultRefactoringDelta
- All Implemented Interfaces:
RefactoringDelta
The default implementation of
RefactoringDelta
which contains the TextEdit
that
were creating during the refactoring of a JPQL query.- Since:
- 2.4
- Version:
- 2.5
-
Constructor Summary
ConstructorDescriptionDefaultRefactoringDelta
(CharSequence jpqlQuery) Creates a newDefaultRefactoringDelta
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTextEdit
(TextEdit textEdit) Adds the givenTextEdit
at the right position.void
addTextEdits
(Iterable<? extends TextEdit> textEdits) Adds the given collection ofTextEdit
objects.Applies the changes to the JPQL query and returns the refactoring operations.protected int
calculateInsertionPosition
(TextEdit textEdit) Calculates the insertion position for the givenTextEdit
based on those already registeredboolean
Determines whether at least oneTextEdit
was added.protected void
initialize
(CharSequence jpqlQuery) Initializes thisDefaultRefactoringDelta
.int
size()
Returns the number ofTextEdit
objects that have been added.Returns the collection ofTextEdit
objects that have been added during one or several refactoring operations.toString()
-
Constructor Details
-
DefaultRefactoringDelta
Creates a newDefaultRefactoringDelta
.- Parameters:
jpqlQuery
- The JPQL query or JPQL fragment that will be traversed when refactoring operations will be executed- Throws:
NullPointerException
- The JPQL query cannot benull
-
-
Method Details
-
addTextEdit
Adds the givenTextEdit
at the right position. The list will be kept ordered, meaning the insertion index is based on the offset, from the biggest value to the smallest value.- Parameters:
textEdit
- TheTextEdit
to add- Throws:
NullPointerException
- TheTextEdit
cannot benull
-
addTextEdits
Adds the given collection ofTextEdit
objects. The list will be kept ordered, meaning the insertion index is based on the offset, from the biggest value to the smallest value.- Parameters:
textEdits
- The collection ofTextEdit
objects to add- Throws:
NullPointerException
- The givenIterable
or one of the childTextEdit
wasnull
-
applyChanges
Description copied from interface:RefactoringDelta
Applies the changes to the JPQL query and returns the refactoring operations. The list ofTextEdit
will be cleared.- Specified by:
applyChanges
in interfaceRefactoringDelta
-
calculateInsertionPosition
Calculates the insertion position for the givenTextEdit
based on those already registered -
hasTextEdits
public boolean hasTextEdits()Description copied from interface:RefactoringDelta
Determines whether at least oneTextEdit
was added.- Specified by:
hasTextEdits
in interfaceRefactoringDelta
- Returns:
true
if there is at least oneTextEdit
;false
otherwise
-
initialize
Initializes thisDefaultRefactoringDelta
.- Parameters:
jpqlQuery
- The JPQL query or JPQL fragment that will be traversed when refactoring operations will be executed- Throws:
NullPointerException
- The JPQL query cannot benull
-
size
public int size()Description copied from interface:RefactoringDelta
Returns the number ofTextEdit
objects that have been added.- Specified by:
size
in interfaceRefactoringDelta
- Returns:
- The count of
TextEdit
objects
-
textEdits
Description copied from interface:RefactoringDelta
Returns the collection ofTextEdit
objects that have been added during one or several refactoring operations. The collection has been ordered where theTextEdit
's offset are in reverse order, i.e. from the biggest to the smallest values.- Specified by:
textEdits
in interfaceRefactoringDelta
- Returns:
- The ordered collection of
TextEdit
objects
-
toString
-