LCOV - code coverage report
Current view: top level - server - CmdLineParserModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 15 15 100.0 %
Date: 2022-11-19 15:00:39 Functions: 3 3 100.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.server;
      16             : 
      17             : import com.google.gerrit.entities.Account;
      18             : import com.google.gerrit.entities.AccountGroup;
      19             : import com.google.gerrit.entities.Change;
      20             : import com.google.gerrit.entities.PatchSet;
      21             : import com.google.gerrit.extensions.config.FactoryModule;
      22             : import com.google.gerrit.server.args4j.AccountGroupIdHandler;
      23             : import com.google.gerrit.server.args4j.AccountGroupUUIDHandler;
      24             : import com.google.gerrit.server.args4j.AccountIdHandler;
      25             : import com.google.gerrit.server.args4j.ChangeIdHandler;
      26             : import com.google.gerrit.server.args4j.InstantHandler;
      27             : import com.google.gerrit.server.args4j.ObjectIdHandler;
      28             : import com.google.gerrit.server.args4j.PatchSetIdHandler;
      29             : import com.google.gerrit.server.args4j.ProjectHandler;
      30             : import com.google.gerrit.server.args4j.SocketAddressHandler;
      31             : import com.google.gerrit.server.project.ProjectState;
      32             : import com.google.gerrit.util.cli.CmdLineParser;
      33             : import com.google.gerrit.util.cli.OptionHandlerUtil;
      34             : import com.google.gerrit.util.cli.OptionHandlers;
      35             : import java.net.SocketAddress;
      36             : import java.time.Instant;
      37             : import org.eclipse.jgit.lib.ObjectId;
      38             : import org.kohsuke.args4j.spi.OptionHandler;
      39             : 
      40             : public class CmdLineParserModule extends FactoryModule {
      41         152 :   public CmdLineParserModule() {}
      42             : 
      43             :   @Override
      44             :   protected void configure() {
      45         152 :     factory(CmdLineParser.Factory.class);
      46         152 :     bind(OptionHandlers.class);
      47             : 
      48         152 :     registerOptionHandler(Account.Id.class, AccountIdHandler.class);
      49         152 :     registerOptionHandler(AccountGroup.Id.class, AccountGroupIdHandler.class);
      50         152 :     registerOptionHandler(AccountGroup.UUID.class, AccountGroupUUIDHandler.class);
      51         152 :     registerOptionHandler(Change.Id.class, ChangeIdHandler.class);
      52         152 :     registerOptionHandler(Instant.class, InstantHandler.class);
      53         152 :     registerOptionHandler(ObjectId.class, ObjectIdHandler.class);
      54         152 :     registerOptionHandler(PatchSet.Id.class, PatchSetIdHandler.class);
      55         152 :     registerOptionHandler(ProjectState.class, ProjectHandler.class);
      56         152 :     registerOptionHandler(SocketAddress.class, SocketAddressHandler.class);
      57         152 :   }
      58             : 
      59             :   private <T> void registerOptionHandler(Class<T> type, Class<? extends OptionHandler<T>> impl) {
      60         152 :     install(OptionHandlerUtil.moduleFor(type, impl));
      61         152 :   }
      62             : }

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