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
 
 public static class GitPositionTransformer.PositionedEntity<T> extends Object Wrapper around an instance ofTwhich annotates it with aGitPositionTransformer.Position. Methods such asshiftPositionBy(int)andwithFilePath(String)allow to update the associatedGitPositionTransformer.Position. Afterwards, usegetEntityAtUpdatedPosition()to get an updated version of theTinstance.
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> GitPositionTransformer.PositionedEntity<T>create(T entity, Function<T,GitPositionTransformer.Position> positionExtractor, BiFunction<T,GitPositionTransformer.Position,T> updatedEntityCreator)Creates a newPositionedEntity.TgetEntity()Returns the original underlying entity.TgetEntityAtUpdatedPosition()Returns an updated version of the entity to which the internally storedGitPositionTransformer.Positionwas written back to.GitPositionTransformer.PositionedEntity<T>shiftPositionBy(int amount)Shifts the trackedGitPositionTransformer.Positionby the specified amount.GitPositionTransformer.PositionedEntity<T>withFilePath(String filePath)Updates the file path of the trackedGitPositionTransformer.Position.GitPositionTransformer.PositionedEntity<T>withPosition(GitPositionTransformer.Position newPosition)Updates the trackedGitPositionTransformer.Position.
 
- 
- 
- 
Method Detail- 
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!
 
 - 
getEntitypublic T getEntity() Returns the original underlying entity.- Returns:
- the original instance of T
 
 - 
getEntityAtUpdatedPositionpublic T getEntityAtUpdatedPosition() Returns an updated version of the entity to which the internally storedGitPositionTransformer.Positionwas written back to.- Returns:
- an updated instance of T
 
 - 
shiftPositionBypublic GitPositionTransformer.PositionedEntity<T> shiftPositionBy(int amount) Shifts 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
 
 - 
withFilePathpublic GitPositionTransformer.PositionedEntity<T> withFilePath(String filePath) Updates 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
 
 
- 
 
-