Package com.google.gerrit.server.patch
Class GitPositionTransformer.PositionedEntity<T>
java.lang.Object
com.google.gerrit.server.patch.GitPositionTransformer.PositionedEntity<T>
- Type Parameters:
- T- an object/entity type which has a- GitPositionTransformer.Position
- Enclosing class:
- GitPositionTransformer
Wrapper around an instance of 
T which annotates it with a GitPositionTransformer.Position. Methods
 such as shiftPositionBy(int) and withFilePath(String) allow to update the
 associated GitPositionTransformer.Position. Afterwards, use getEntityAtUpdatedPosition() to get an
 updated version of the T instance.- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> GitPositionTransformer.PositionedEntity<T>create(T entity, Function<T, GitPositionTransformer.Position> positionExtractor, BiFunction<T, GitPositionTransformer.Position, T> updatedEntityCreator) Creates a newPositionedEntity.Returns the original underlying entity.Returns an updated version of the entity to which the internally storedGitPositionTransformer.Positionwas written back to.shiftPositionBy(int amount) Shifts the trackedGitPositionTransformer.Positionby the specified amount.withFilePath(String filePath) Updates the file path of the trackedGitPositionTransformer.Position.withPosition(GitPositionTransformer.Position newPosition) Updates the trackedGitPositionTransformer.Position.
- 
Method Details- 
createpublic static <T> GitPositionTransformer.PositionedEntity<T> create(T entity, Function<T, GitPositionTransformer.Position> positionExtractor, BiFunction<T, GitPositionTransformer.Position, T> updatedEntityCreator) Creates a newPositionedEntity.- Type Parameters:
- T- an object/entity type which has a- GitPositionTransformer.Position
- Parameters:
- entity- an instance which should be annotated with a- GitPositionTransformer.Position
- positionExtractor- a function describing how a- GitPositionTransformer.Positioncan be derived from the given entity
- updatedEntityCreator- a function to create a new entity of type- Tfrom an existing entity and a given- GitPositionTransformer.Position. This must return a new instance of type- T! The existing instance must not be modified!
 
- 
getEntityReturns the original underlying entity.- Returns:
- the original instance of T
 
- 
getEntityAtUpdatedPositionReturns an updated version of the entity to which the internally storedGitPositionTransformer.Positionwas written back to.- Returns:
- an updated instance of T
 
- 
shiftPositionByShifts the trackedGitPositionTransformer.Positionby the specified amount.- Parameters:
- amount- number of lines to shift. Negative values mean moving the range up, positive values mean moving the range down.
- Returns:
- a PositionedEntitywith updatedGitPositionTransformer.Position
 
- 
withFilePathUpdates the file path of the trackedGitPositionTransformer.Position.- Parameters:
- filePath- the new file path to use
- Returns:
- a PositionedEntitywith updatedGitPositionTransformer.Position
 
- 
withPositionpublic GitPositionTransformer.PositionedEntity<T> withPosition(GitPositionTransformer.Position newPosition) Updates the trackedGitPositionTransformer.Position.- Returns:
- a PositionedEntitywith updatedGitPositionTransformer.Position
 
 
-