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 : /** 18 : * Interface for {@link BatchUpdate} operations that touch a change. 19 : * 20 : * <p>Each operation has {@link #updateChange(ChangeContext)} called once the change is read in a 21 : * transaction. Ops are associated with updates via {@link 22 : * BatchUpdate#addOp(com.google.gerrit.entities.Change.Id, BatchUpdateOp)}. 23 : * 24 : * <p>Usually, a single {@code BatchUpdateOp} instance is only associated with a single change, i.e. 25 : * {@code addOp} is only called once with that instance. Additionally, each method in {@code 26 : * BatchUpdateOp} is called at most once per {@link BatchUpdate} execution. 27 : * 28 : * <p>Taken together, these two properties mean an instance may communicate between phases by 29 : * storing data in private fields, and a single instance must not be reused. 30 : */ 31 : public interface BatchUpdateOp extends RepoOnlyOp { 32 : /** 33 : * Override this method to modify a change. 34 : * 35 : * @param ctx context 36 : * @return whether anything was changed that might require a write to the metadata storage. 37 : */ 38 : default boolean updateChange(ChangeContext ctx) throws Exception { 39 30 : return false; 40 : } 41 : }