LCOV - code coverage report
Current view: top level - entities - LabelValue.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 12 13 92.3 %
Date: 2022-11-19 15:00:39 Functions: 5 6 83.3 %

          Line data    Source code
       1             : // Copyright (C) 2013 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.entities;
      16             : 
      17             : import com.google.auto.value.AutoValue;
      18             : 
      19             : @AutoValue
      20         154 : public abstract class LabelValue {
      21             :   public static String formatValue(short value) {
      22         151 :     if (value < 0) {
      23         151 :       return Short.toString(value);
      24         151 :     } else if (value == 0) {
      25         151 :       return " 0";
      26             :     } else {
      27         151 :       return "+" + value;
      28             :     }
      29             :   }
      30             : 
      31             :   public abstract short getValue();
      32             : 
      33             :   public abstract String getText();
      34             : 
      35             :   public static LabelValue create(short value, String text) {
      36         154 :     return new AutoValue_LabelValue(value, text);
      37             :   }
      38             : 
      39             :   public String formatValue() {
      40         151 :     return formatValue(getValue());
      41             :   }
      42             : 
      43             :   public String format() {
      44         151 :     StringBuilder sb = new StringBuilder(formatValue());
      45         151 :     if (!getText().isEmpty()) {
      46         151 :       sb.append(' ').append(getText());
      47             :     }
      48         151 :     return sb.toString();
      49             :   }
      50             : 
      51             :   @Override
      52             :   public final String toString() {
      53           0 :     return format();
      54             :   }
      55             : }

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