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

          Line data    Source code
       1             : // Copyright (C) 2018 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.registration;
      16             : 
      17             : import com.google.gerrit.common.Nullable;
      18             : import com.google.inject.Provider;
      19             : 
      20             : /**
      21             :  * An extension that is provided by a plugin.
      22             :  *
      23             :  * <p>Contains the name of the plugin that provides the extension, the extension point
      24             :  * implementation and optionally the export name under which the extension was exported.
      25             :  *
      26             :  * <p>An export name is only available if this extension is an entry in a {@link DynamicMap}.
      27             :  *
      28             :  * @param <T> Type of extension point that this extension implements
      29             :  */
      30             : public class Extension<T> {
      31             :   private final String pluginName;
      32             :   private final @Nullable String exportName;
      33             :   private final Provider<T> provider;
      34             : 
      35             :   public Extension(String pluginName, Provider<T> provider) {
      36         154 :     this(pluginName, null, provider);
      37         154 :   }
      38             : 
      39         154 :   protected Extension(String pluginName, @Nullable String exportName, Provider<T> provider) {
      40         154 :     this.pluginName = pluginName;
      41         154 :     this.exportName = exportName;
      42         154 :     this.provider = provider;
      43         154 :   }
      44             : 
      45             :   public String getPluginName() {
      46         152 :     return pluginName;
      47             :   }
      48             : 
      49             :   @Nullable
      50             :   public String getExportName() {
      51         151 :     return exportName;
      52             :   }
      53             : 
      54             :   public Provider<T> getProvider() {
      55         132 :     return provider;
      56             :   }
      57             : 
      58             :   public T get() {
      59         151 :     return provider.get();
      60             :   }
      61             : }

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