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 ofRefactoringDeltawhich contains theTextEditthat 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 voidaddTextEdit(TextEdit textEdit)Adds the givenTextEditat the right position.voidaddTextEdits(java.lang.Iterable<? extends TextEdit> textEdits)Adds the given collection ofTextEditobjects.java.lang.StringapplyChanges()Applies the changes to the JPQL query and returns the refactoring operations.protected intcalculateInsertionPosition(TextEdit textEdit)Calculates the insertion position for the givenTextEditbased on those already registeredbooleanhasTextEdits()Determines whether at least oneTextEditwas added.protected voidinitialize(java.lang.CharSequence jpqlQuery)Initializes thisDefaultRefactoringDelta.intsize()Returns the number ofTextEditobjects that have been added.ListIterable<TextEdit>textEdits()Returns the collection ofTextEditobjects that have been added during one or several refactoring operations.java.lang.StringtoString()
-
-
-
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 givenTextEditat 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 ofTextEditobjects. 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 ofTextEditwill be cleared.- Specified by:
applyChangesin interfaceRefactoringDelta
-
calculateInsertionPosition
protected int calculateInsertionPosition(TextEdit textEdit)
Calculates the insertion position for the givenTextEditbased on those already registered
-
hasTextEdits
public boolean hasTextEdits()
Determines whether at least oneTextEditwas added.- Specified by:
hasTextEditsin interfaceRefactoringDelta- Returns:
trueif there is at least oneTextEdit;falseotherwise
-
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 ofTextEditobjects that have been added.- Specified by:
sizein interfaceRefactoringDelta- Returns:
- The count of
TextEditobjects
-
textEdits
public ListIterable<TextEdit> textEdits()
Returns the collection ofTextEditobjects 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:
textEditsin interfaceRefactoringDelta- Returns:
- The ordered collection of
TextEditobjects
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-