LCOV - code coverage report
Current view: top level - sshd - PluginCommandModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 0 12 0.0 %
Date: 2022-11-19 15:00:39 Functions: 0 6 0.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.sshd;
      16             : 
      17             : import static com.google.common.base.Preconditions.checkState;
      18             : 
      19             : import com.google.gerrit.extensions.annotations.PluginName;
      20             : import com.google.inject.Inject;
      21             : import com.google.inject.binder.LinkedBindingBuilder;
      22             : import org.apache.sshd.server.command.Command;
      23             : 
      24           0 : public abstract class PluginCommandModule extends CommandModule {
      25             :   private CommandName command;
      26             : 
      27             :   @Inject
      28             :   void setPluginName(@PluginName String name) {
      29           0 :     this.command = Commands.named(name);
      30           0 :   }
      31             : 
      32             :   @Override
      33             :   protected final void configure() {
      34           0 :     checkState(command != null, "@PluginName must be provided");
      35           0 :     bind(Commands.key(command)).toProvider(new DispatchCommandProvider(command));
      36           0 :     configureCommands();
      37           0 :   }
      38             : 
      39             :   protected abstract void configureCommands();
      40             : 
      41             :   @Override
      42             :   protected LinkedBindingBuilder<Command> command(String subCmd) {
      43           0 :     return bind(Commands.key(command, subCmd));
      44             :   }
      45             : 
      46             :   protected void command(Class<? extends BaseCommand> clazz) {
      47           0 :     command(command, clazz);
      48           0 :   }
      49             : 
      50             :   protected void alias(String name, Class<? extends BaseCommand> clazz) {
      51           0 :     alias(command, name, clazz);
      52           0 :   }
      53             : }

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