LCOV - code coverage report
Current view: top level - server/update - ChangeContext.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 1 1 100.0 %
Date: 2022-11-19 15:00:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2017 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.update;
      16             : 
      17             : import static java.util.Objects.requireNonNull;
      18             : 
      19             : import com.google.gerrit.entities.Change;
      20             : import com.google.gerrit.entities.PatchSet;
      21             : import com.google.gerrit.server.notedb.ChangeNotes;
      22             : import com.google.gerrit.server.notedb.ChangeUpdate;
      23             : 
      24             : /**
      25             :  * Context for performing the {@link BatchUpdateOp#updateChange} phase.
      26             :  *
      27             :  * <p>A single {@code ChangeContext} corresponds to updating a single change; if a {@link
      28             :  * BatchUpdate} spans multiple changes, then multiple {@code ChangeContext} instances will be
      29             :  * created.
      30             :  */
      31             : public interface ChangeContext extends Context {
      32             :   /**
      33             :    * Get the first update for this change at a given patch set.
      34             :    *
      35             :    * <p>A single operation can modify changes at different patch sets. Commits in the NoteDb graph
      36             :    * within this update are created in patch set order.
      37             :    *
      38             :    * <p>To get the current patch set ID, use {@link com.google.gerrit.server.PatchSetUtil#current}.
      39             :    *
      40             :    * @param psId patch set ID.
      41             :    * @return handle for change updates.
      42             :    */
      43             :   ChangeUpdate getUpdate(PatchSet.Id psId);
      44             : 
      45             :   /**
      46             :    * Gets a new ChangeUpdate for this change at a given patch set.
      47             :    *
      48             :    * <p>To get the current patch set ID, use {@link com.google.gerrit.server.PatchSetUtil#current}.
      49             :    *
      50             :    * @param psId patch set ID.
      51             :    * @return handle for change updates.
      52             :    */
      53             :   ChangeUpdate getDistinctUpdate(PatchSet.Id psId);
      54             : 
      55             :   /**
      56             :    * Get the up-to-date notes for this change.
      57             :    *
      58             :    * <p>The change data is read within the same transaction that {@link
      59             :    * BatchUpdateOp#updateChange(ChangeContext)} is executing.
      60             :    *
      61             :    * @return notes for this change.
      62             :    */
      63             :   ChangeNotes getNotes();
      64             : 
      65             :   /**
      66             :    * Instruct {@link BatchUpdate} to delete this change.
      67             :    *
      68             :    * <p>If called, all other updates are ignored.
      69             :    */
      70             :   void deleteChange();
      71             : 
      72             :   /** Returns change corresponding to {@link #getNotes()}. */
      73             :   default Change getChange() {
      74         103 :     return requireNonNull(getNotes().getChange());
      75             :   }
      76             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750