LCOV - code coverage report
Current view: top level - extensions/webui - WebUiPlugin.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 4 6 66.7 %
Date: 2022-11-19 15:00:39 Functions: 3 5 60.0 %

          Line data    Source code
       1             : // Copyright (C) 2012 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.webui;
      16             : 
      17             : import com.google.gerrit.extensions.annotations.ExtensionPoint;
      18             : import com.google.gerrit.extensions.annotations.PluginName;
      19             : import com.google.inject.Inject;
      20             : 
      21             : /**
      22             :  * Specifies JavaScript to dynamically load into the web UI.
      23             :  *
      24             :  * <p>To automatically register (instead of writing a Guice module), declare the intention with
      25             :  * {@code @Listen}, extend the correct class and define a constructor to configure the correct
      26             :  * resource:
      27             :  *
      28             :  * <pre>
      29             :  * &#064;Listen
      30             :  * class MyJs extends JavaScriptPlugin {
      31             :  *   MyJs() {
      32             :  *     super(&quot;hello.js&quot;);
      33             :  *   }
      34             :  * }
      35             :  * </pre>
      36             :  *
      37             :  * @see JavaScriptPlugin
      38             :  */
      39             : @ExtensionPoint
      40           3 : public abstract class WebUiPlugin {
      41             :   public static final JavaScriptPlugin js(String scriptName) {
      42           0 :     return new JavaScriptPlugin(scriptName);
      43             :   }
      44             : 
      45             :   private String pluginName;
      46             : 
      47             :   /** Returns installed name of the plugin that provides this UI feature. */
      48             :   public final String getPluginName() {
      49           1 :     return pluginName;
      50             :   }
      51             : 
      52             :   @Inject
      53             :   void setPluginName(@PluginName String pluginName) {
      54           3 :     this.pluginName = pluginName;
      55           3 :   }
      56             : 
      57             :   /** Returns path to initialization script within the plugin's JAR. */
      58             :   public abstract String getJavaScriptResourcePath();
      59             : 
      60             :   @Override
      61             :   public String toString() {
      62           0 :     return getJavaScriptResourcePath();
      63             :   }
      64             : }

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