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 aGitPositionTransformer.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 Summary
All 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
- 
create
public 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 aGitPositionTransformer.Position- Parameters:
 entity- an instance which should be annotated with aGitPositionTransformer.PositionpositionExtractor- a function describing how aGitPositionTransformer.Positioncan be derived from the given entityupdatedEntityCreator- a function to create a new entity of typeTfrom an existing entity and a givenGitPositionTransformer.Position. This must return a new instance of typeT! The existing instance must not be modified!
 
- 
getEntity
public T getEntity()
Returns the original underlying entity.- Returns:
 - the original instance of 
T 
 
- 
getEntityAtUpdatedPosition
public T getEntityAtUpdatedPosition()
Returns an updated version of the entity to which the internally storedGitPositionTransformer.Positionwas written back to.- Returns:
 - an updated instance of 
T 
 
- 
shiftPositionBy
public 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 
 
- 
withFilePath
public 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 
 
- 
withPosition
public GitPositionTransformer.PositionedEntity<T> withPosition(GitPositionTransformer.Position newPosition)
Updates the trackedGitPositionTransformer.Position.- Returns:
 - a 
PositionedEntitywith updatedGitPositionTransformer.Position 
 
 - 
 
 -