Class DefaultRefactoringDelta
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.DefaultRefactoringDelta
-
- All Implemented Interfaces:
RefactoringDelta
public class DefaultRefactoringDelta extends java.lang.Object implements RefactoringDelta
The default implementation ofRefactoringDelta
which contains theTextEdit
that were creating during the refactoring of a JPQL query.- Version:
- 2.5
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Constructor Summary
Constructors Constructor Description DefaultRefactoringDelta(java.lang.CharSequence jpqlQuery)
Creates a newDefaultRefactoringDelta
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTextEdit(TextEdit textEdit)
Adds the givenTextEdit
at the right position.void
addTextEdits(java.lang.Iterable<? extends TextEdit> textEdits)
Adds the given collection ofTextEdit
objects.java.lang.String
applyChanges()
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
hasTextEdits()
Determines whether at least oneTextEdit
was added.protected void
initialize(java.lang.CharSequence jpqlQuery)
Initializes thisDefaultRefactoringDelta
.int
size()
Returns the number ofTextEdit
objects that have been added.ListIterable<TextEdit>
textEdits()
Returns the collection ofTextEdit
objects that have been added during one or several refactoring operations.java.lang.String
toString()
-
-
-
Constructor Detail
-
DefaultRefactoringDelta
public DefaultRefactoringDelta(java.lang.CharSequence jpqlQuery)
Creates a newDefaultRefactoringDelta
.- Parameters:
jpqlQuery
- The JPQL query or JPQL fragment that will be traversed when refactoring operations will be executed- Throws:
java.lang.NullPointerException
- The JPQL query cannot benull
-
-
Method Detail
-
addTextEdit
public void addTextEdit(TextEdit textEdit)
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.
-
addTextEdits
public void addTextEdits(java.lang.Iterable<? extends TextEdit> textEdits)
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.
-
applyChanges
public java.lang.String applyChanges()
Applies the changes to the JPQL query and returns the refactoring operations. The list ofTextEdit
will be cleared.- Specified by:
applyChanges
in interfaceRefactoringDelta
-
calculateInsertionPosition
protected int calculateInsertionPosition(TextEdit textEdit)
Calculates the insertion position for the givenTextEdit
based on those already registered
-
hasTextEdits
public boolean hasTextEdits()
Determines whether at least oneTextEdit
was added.- Specified by:
hasTextEdits
in interfaceRefactoringDelta
- Returns:
true
if there is at least oneTextEdit
;false
otherwise
-
initialize
protected void initialize(java.lang.CharSequence jpqlQuery)
Initializes thisDefaultRefactoringDelta
.- Parameters:
jpqlQuery
- The JPQL query or JPQL fragment that will be traversed when refactoring operations will be executed- Throws:
java.lang.NullPointerException
- The JPQL query cannot benull
-
size
public int size()
Returns the number ofTextEdit
objects that have been added.- Specified by:
size
in interfaceRefactoringDelta
- Returns:
- The count of
TextEdit
objects
-
textEdits
public ListIterable<TextEdit> textEdits()
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-