LCOV - code coverage report
Current view: top level - server/git/receive - NoteDbPushOption.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 7 7 100.0 %
Date: 2022-11-19 15:00:39 Functions: 3 3 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.server.git.receive;
      16             : 
      17             : import static com.google.common.collect.ImmutableMap.toImmutableMap;
      18             : 
      19             : import com.google.common.collect.ImmutableMap;
      20             : import java.util.Arrays;
      21             : import java.util.Locale;
      22             : import java.util.Optional;
      23             : import java.util.function.Function;
      24             : 
      25             : /** Possible values for {@code -o notedb=X} push option. */
      26          96 : public enum NoteDbPushOption {
      27          96 :   DISALLOW,
      28          96 :   ALLOW;
      29             : 
      30             :   public static final String OPTION_NAME = "notedb";
      31             : 
      32          96 :   private static final ImmutableMap<String, NoteDbPushOption> ALL =
      33          96 :       Arrays.stream(values()).collect(toImmutableMap(NoteDbPushOption::value, Function.identity()));
      34             : 
      35             :   /**
      36             :    * Parses an option value from a lowercase string representation.
      37             :    *
      38             :    * @param value input value.
      39             :    * @return parsed value, or empty if no value matched.
      40             :    */
      41             :   public static Optional<NoteDbPushOption> parse(String value) {
      42           4 :     return Optional.ofNullable(ALL.get(value));
      43             :   }
      44             : 
      45             :   public String value() {
      46          96 :     return name().toLowerCase(Locale.US);
      47             :   }
      48             : }

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