Class RefUpdateContext
java.lang.Object
com.google.gerrit.server.update.context.RefUpdateContext
- All Implemented Interfaces:
AutoCloseable
Passes additional information about an operation to the
BatchRefUpdate#execute
method.
To pass the additional information RefUpdateContext
, wraps a code into an open
RefUpdateContext, e.g.:
try(RefUpdateContext ctx = RefUpdateContext.open(RefUpdateType.CHANGE_MODIFICATION)) {
...
// some code which modifies a ref using BatchRefUpdate.execute method
}
When the BatchRefUpdate#execute
method is executed, it can get all opened contexts and
use it for an additional actions, e.g. it can put it in the reflog.
The information provided by this class is used internally in google.
The InMemoryRepositoryManager file makes some validation to ensure that RefUpdateContext is used correctly within the code (see thee validateRefUpdateContext method).
The class includes only operations from open-source gerrit and can be extended (see
TestActionRefUpdateContext
for example how to extend it).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
List of possible ref-update types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the current context.protected static final Deque<RefUpdateContext>
Returns the justification for the operation.static com.google.common.collect.ImmutableList<RefUpdateContext>
Returns the list of opened contexts; the first element is the outermost context.Returns the type ofRefUpdateContext
.static boolean
Checks if there is an open context of the given type.static RefUpdateContext
open
(RefUpdateContext.RefUpdateType updateType) Opens a context of a give type.protected static <T extends RefUpdateContext>
Topen
(T ctx) Opens a provided context.static RefUpdateContext
openDirectPush
(Optional<String> justification) Opens a direct push context with an optional justification.
-
Constructor Details
-
RefUpdateContext
-
-
Method Details
-
open
Opens a provided context. -
open
Opens a context of a give type. -
openDirectPush
Opens a direct push context with an optional justification. -
getOpenedContexts
Returns the list of opened contexts; the first element is the outermost context. -
hasOpen
Checks if there is an open context of the given type. -
getCurrent
-
getUpdateType
Returns the type ofRefUpdateContext
.For descendants, always return
RefUpdateContext.RefUpdateType.OTHER
(except known descendants defined as nested classes). -
getJustification
Returns the justification for the operation. -
close
public void close()Closes the current context.- Specified by:
close
in interfaceAutoCloseable
-