Class RefUpdateContext
- All Implemented Interfaces:
- AutoCloseable
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
 }
 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 SummaryNested ClassesModifier and TypeClassDescriptionstatic enumList of possible ref-update types.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddCustomData(Object data) Add custom data.<T> voidclearCustomData(Class<T> clazz) Remove all custom data that has a type that is assignable from the given class.voidclose()Closes the current context.protected static final Deque<RefUpdateContext> <T> com.google.common.collect.ImmutableList<T> getCustomData(Class<T> clazz) Get all custom data that has a type that is assignable from the given class.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 booleanChecks if there is an open context of the given type.static RefUpdateContextopen(RefUpdateContext.RefUpdateType updateType) Opens a context of a give type.protected static <T extends RefUpdateContext>
 Topen(T ctx) Opens a provided context.static RefUpdateContextopenDirectPush(Optional<String> justification) Opens a direct push context with an optional justification.
- 
Constructor Details- 
RefUpdateContext
 
- 
- 
Method Details- 
openOpens a provided context.
- 
openOpens a context of a give type.
- 
openDirectPushOpens a direct push context with an optional justification.
- 
getOpenedContextsReturns the list of opened contexts; the first element is the outermost context.
- 
hasOpenChecks if there is an open context of the given type.
- 
getCurrent
- 
addCustomDataAdd custom data.Custom data is always stored on the top-level context, but can be added through any context. 
- 
getCustomDataGet all custom data that has a type that is assignable from the given class.Custom data is always stored on the top-level context, but can be retrieved through any context. 
- 
clearCustomDataRemove all custom data that has a type that is assignable from the given class.Custom data is only stored on the top-level context, but clearing custom data can be done through any context. 
- 
getUpdateTypeReturns the type ofRefUpdateContext.For descendants, always return RefUpdateContext.RefUpdateType.OTHER(except known descendants defined as nested classes).
- 
getJustificationReturns the justification for the operation.
- 
closepublic void close()Closes the current context.- Specified by:
- closein interface- AutoCloseable
 
 
-