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
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 Summary
Modifier 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.Position
was written back to.shiftPositionBy
(int amount) Shifts the trackedGitPositionTransformer.Position
by the specified amount.withFilePath
(String filePath) Updates the file path of the trackedGitPositionTransformer.Position
.withPosition
(GitPositionTransformer.Position newPosition) Updates the trackedGitPositionTransformer.Position
.
-
Method Details
-
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.Position
positionExtractor
- a function describing how aGitPositionTransformer.Position
can be derived from the given entityupdatedEntityCreator
- a function to create a new entity of typeT
from an existing entity and a givenGitPositionTransformer.Position
. This must return a new instance of typeT
! The existing instance must not be modified!
-
getEntity
Returns the original underlying entity.- Returns:
- the original instance of
T
-
getEntityAtUpdatedPosition
Returns an updated version of the entity to which the internally storedGitPositionTransformer.Position
was written back to.- Returns:
- an updated instance of
T
-
shiftPositionBy
Shifts the trackedGitPositionTransformer.Position
by 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
PositionedEntity
with updatedGitPositionTransformer.Position
-
withFilePath
Updates the file path of the trackedGitPositionTransformer.Position
.- Parameters:
filePath
- the new file path to use- Returns:
- a
PositionedEntity
with updatedGitPositionTransformer.Position
-
withPosition
public GitPositionTransformer.PositionedEntity<T> withPosition(GitPositionTransformer.Position newPosition) Updates the trackedGitPositionTransformer.Position
.- Returns:
- a
PositionedEntity
with updatedGitPositionTransformer.Position
-