Class RefUpdateContext
- java.lang.Object
-
- com.google.gerrit.server.update.context.RefUpdateContext
-
- All Implemented Interfaces:
AutoCloseable
public class RefUpdateContext extends Object implements AutoCloseable
Passes additional information about an operation to theBatchRefUpdate#execute
method.To pass the additional information
RefUpdateContext
, wraps a code into an open RefUpdateContext, e.g.:
When thetry(RefUpdateContext ctx = RefUpdateContext.open(RefUpdateType.CHANGE_MODIFICATION)) { ... // some code which modifies a ref using BatchRefUpdate.execute method }
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 Classes Modifier and Type Class Description static class
RefUpdateContext.RefUpdateType
List of possible ref-update types.
-
Constructor Summary
Constructors Modifier Constructor Description protected
RefUpdateContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the current context.protected static Deque<RefUpdateContext>
getCurrent()
static com.google.common.collect.ImmutableList<RefUpdateContext>
getOpenedContexts()
Returns the list of opened contexts; the first element is the outermost context.RefUpdateContext.RefUpdateType
getUpdateType()
Returns the type ofRefUpdateContext
.static boolean
hasOpen(RefUpdateContext.RefUpdateType type)
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.
-
-
-
Method Detail
-
open
protected static <T extends RefUpdateContext> T open(T ctx)
Opens a provided context.
-
open
public static RefUpdateContext open(RefUpdateContext.RefUpdateType updateType)
Opens a context of a give type.
-
getOpenedContexts
public static com.google.common.collect.ImmutableList<RefUpdateContext> getOpenedContexts()
Returns the list of opened contexts; the first element is the outermost context.
-
hasOpen
public static boolean hasOpen(RefUpdateContext.RefUpdateType type)
Checks if there is an open context of the given type.
-
getCurrent
protected static final Deque<RefUpdateContext> getCurrent()
-
getUpdateType
public final RefUpdateContext.RefUpdateType getUpdateType()
Returns the type ofRefUpdateContext
.For descendants, always return
RefUpdateContext.RefUpdateType.OTHER
-
close
public void close()
Closes the current context.- Specified by:
close
in interfaceAutoCloseable
-
-