LCOV - code coverage report
Current view: top level - extensions/common - ActionInfo.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 6 15 40.0 %
Date: 2022-11-19 15:00:39 Functions: 1 4 25.0 %

          Line data    Source code
       1             : // Copyright (C) 2013 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.extensions.common;
      16             : 
      17             : import com.google.gerrit.extensions.webui.UiAction;
      18             : import java.util.Objects;
      19             : 
      20             : /**
      21             :  * Representation of an action in the REST API.
      22             :  *
      23             :  * <p>This class determines the JSON format of actions in the REST API.
      24             :  *
      25             :  * <p>An action describes a REST API call the client can make to manipulate a resource. These are
      26             :  * frequently implemented by plugins and may be discovered at runtime.
      27             :  */
      28             : public class ActionInfo {
      29             :   /**
      30             :    * HTTP method to use with the action. Most actions use {@code POST}, {@code PUT} or {@code
      31             :    * DELETE} to cause state changes.
      32             :    */
      33             :   public String method;
      34             : 
      35             :   /**
      36             :    * Short title to display to a user describing the action. In the Gerrit web interface the label
      37             :    * is used as the text on the button that is presented in the UI.
      38             :    */
      39             :   public String label;
      40             : 
      41             :   /**
      42             :    * Longer text to display describing the action. In a web UI this should be the title attribute of
      43             :    * the element, displaying when the user hovers the mouse.
      44             :    */
      45             :   public String title;
      46             : 
      47             :   /**
      48             :    * If {@code true} the action is permitted at this time and the caller is likely allowed to
      49             :    * execute it. This may change if state is updated at the server or permissions are modified.
      50             :    */
      51             :   public Boolean enabled;
      52             : 
      53          57 :   public ActionInfo(UiAction.Description d) {
      54          57 :     method = d.getMethod();
      55          57 :     label = d.getLabel();
      56          57 :     title = d.getTitle();
      57          57 :     enabled = d.isEnabled() ? true : null;
      58          57 :   }
      59             : 
      60             :   @Override
      61             :   public boolean equals(Object o) {
      62           0 :     if (o instanceof ActionInfo) {
      63           0 :       ActionInfo actionInfo = (ActionInfo) o;
      64           0 :       return Objects.equals(method, actionInfo.method)
      65           0 :           && Objects.equals(label, actionInfo.label)
      66           0 :           && Objects.equals(title, actionInfo.title)
      67           0 :           && Objects.equals(enabled, actionInfo.enabled);
      68             :     }
      69           0 :     return false;
      70             :   }
      71             : 
      72             :   @Override
      73             :   public int hashCode() {
      74           0 :     return Objects.hash(method, label, title, enabled);
      75             :   }
      76             : 
      77           0 :   protected ActionInfo() {}
      78             : }

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