LCOV - code coverage report
Current view: top level - server/args4j - PatchSetIdHandler.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 0 11 0.0 %
Date: 2022-11-19 15:00:39 Functions: 0 3 0.0 %

          Line data    Source code
       1             : // Copyright (C) 2009 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.args4j;
      16             : 
      17             : import static com.google.gerrit.util.cli.Localizable.localizable;
      18             : 
      19             : import com.google.gerrit.entities.PatchSet;
      20             : import com.google.inject.Inject;
      21             : import com.google.inject.assistedinject.Assisted;
      22             : import org.kohsuke.args4j.CmdLineException;
      23             : import org.kohsuke.args4j.CmdLineParser;
      24             : import org.kohsuke.args4j.OptionDef;
      25             : import org.kohsuke.args4j.spi.OptionHandler;
      26             : import org.kohsuke.args4j.spi.Parameters;
      27             : import org.kohsuke.args4j.spi.Setter;
      28             : 
      29             : public class PatchSetIdHandler extends OptionHandler<PatchSet.Id> {
      30             : 
      31             :   @Inject
      32             :   public PatchSetIdHandler(
      33             :       @Assisted final CmdLineParser parser,
      34             :       @Assisted final OptionDef option,
      35             :       @Assisted final Setter<PatchSet.Id> setter) {
      36           0 :     super(parser, option, setter);
      37           0 :   }
      38             : 
      39             :   @Override
      40             :   public final int parseArguments(Parameters params) throws CmdLineException {
      41           0 :     final String token = params.getParameter(0);
      42             :     final PatchSet.Id id;
      43             :     try {
      44           0 :       id = PatchSet.Id.parse(token);
      45           0 :     } catch (IllegalArgumentException e) {
      46           0 :       throw new CmdLineException(
      47           0 :           owner, localizable("\"%s\" is not a valid patch set: %s"), token, e.getMessage());
      48           0 :     }
      49             : 
      50           0 :     setter.addValue(id);
      51           0 :     return 1;
      52             :   }
      53             : 
      54             :   @Override
      55             :   public final String getDefaultMetaVariable() {
      56           0 :     return "CHANGE,PATCHSET";
      57             :   }
      58             : }

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