LCOV - code coverage report
Current view: top level - server/permissions - ChangePermission.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 23 23 100.0 %
Date: 2022-11-19 15:00:39 Functions: 4 4 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.permissions;
      16             : 
      17             : import static java.util.Objects.requireNonNull;
      18             : 
      19             : import com.google.gerrit.extensions.api.access.GerritPermission;
      20             : 
      21         150 : public enum ChangePermission implements ChangePermissionOrLabel {
      22         150 :   READ,
      23             :   /**
      24             :    * The change can't be restored if its current patch set is locked.
      25             :    *
      26             :    * <p>Before checking this permission, the caller should first verify the current patch set of the
      27             :    * change is not locked by calling {@code PatchSetUtil.isPatchSetLocked}.
      28             :    */
      29         150 :   RESTORE,
      30         150 :   DELETE,
      31             :   /**
      32             :    * The change can't be abandoned if its current patch set is locked.
      33             :    *
      34             :    * <p>Before checking this permission, the caller should first verify the current patch set of the
      35             :    * change is not locked by calling {@code PatchSetUtil.isPatchSetLocked}.
      36             :    */
      37         150 :   ABANDON,
      38         150 :   EDIT_ASSIGNEE,
      39         150 :   EDIT_DESCRIPTION,
      40         150 :   EDIT_HASHTAGS,
      41         150 :   EDIT_TOPIC_NAME,
      42         150 :   REMOVE_REVIEWER,
      43             :   /**
      44             :    * A new patch set can't be added if the patch set is locked for the change.
      45             :    *
      46             :    * <p>Before checking this permission, the caller should first verify the current patch set of the
      47             :    * change is not locked by calling {@code PatchSetUtil.isPatchSetLocked}.
      48             :    */
      49         150 :   ADD_PATCH_SET,
      50             :   /**
      51             :    * The change can't be rebased if its current patch set is locked.
      52             :    *
      53             :    * <p>Before checking this permission, the caller should first verify the current patch set of the
      54             :    * change is not locked by calling {@code PatchSetUtil.isPatchSetLocked}.
      55             :    */
      56         150 :   REBASE,
      57         150 :   REVERT,
      58         150 :   SUBMIT,
      59         150 :   SUBMIT_AS("submit on behalf of other users"),
      60         150 :   TOGGLE_WORK_IN_PROGRESS_STATE;
      61             : 
      62             :   private final String description;
      63             : 
      64         150 :   ChangePermission() {
      65         150 :     this.description = null;
      66         150 :   }
      67             : 
      68         150 :   ChangePermission(String description) {
      69         150 :     this.description = requireNonNull(description);
      70         150 :   }
      71             : 
      72             :   @Override
      73             :   public String describeForException() {
      74          15 :     return description != null ? description : GerritPermission.describeEnumValue(this);
      75             :   }
      76             : }

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