Coverage Report - org.apache.giraph.metrics.LongAndTimeUnit
 
Classes in this File Line Coverage Branch Coverage Complexity
LongAndTimeUnit
0%
0/19
0%
0/2
1.4
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 package org.apache.giraph.metrics;
 20  
 
 21  
 import com.google.common.collect.ImmutableMap;
 22  
 
 23  
 import java.util.concurrent.TimeUnit;
 24  
 
 25  
 /**
 26  
  * Pair of long,TimeUnit
 27  
  */
 28  0
 public class LongAndTimeUnit {
 29  
   /** Mapping from TimeUnit to abbreviation used for printing */
 30  0
   private static final ImmutableMap<TimeUnit, String> TIME_UNIT_TO_ABBREV =
 31  0
       ImmutableMap.<TimeUnit, String>builder().
 32  0
           put(TimeUnit.DAYS, "days").
 33  0
           put(TimeUnit.HOURS, "hours").
 34  0
           put(TimeUnit.MICROSECONDS, "us").
 35  0
           put(TimeUnit.MILLISECONDS, "ms").
 36  0
           put(TimeUnit.MINUTES, "mins").
 37  0
           put(TimeUnit.NANOSECONDS, "ns").
 38  0
           put(TimeUnit.SECONDS, "secs").build();
 39  
 
 40  
   /** value held */
 41  
   private long value;
 42  
   /** TimeUnit part */
 43  
   private TimeUnit timeUnit;
 44  
 
 45  
   @Override
 46  
   public String toString() {
 47  0
     if (timeUnit == null) {
 48  0
       return String.valueOf(value);
 49  
     } else {
 50  0
       return value + " " + TIME_UNIT_TO_ABBREV.get(timeUnit);
 51  
     }
 52  
   }
 53  
 
 54  
   /**
 55  
    * Get the value
 56  
    *
 57  
    * @return value
 58  
    */
 59  
   public long getValue() {
 60  0
     return value;
 61  
   }
 62  
 
 63  
   /**
 64  
    * Set the value
 65  
    *
 66  
    * @param value to set
 67  
    */
 68  
   public void setValue(long value) {
 69  0
     this.value = value;
 70  0
   }
 71  
 
 72  
   /**
 73  
    * Get the TimeUnit
 74  
    *
 75  
    * @return TimeUnit
 76  
    */
 77  
   public TimeUnit getTimeUnit() {
 78  0
     return timeUnit;
 79  
   }
 80  
 
 81  
   /**
 82  
    * Set the TimeUnit
 83  
    * @param timeUnit to set
 84  
    */
 85  
   public void setTimeUnit(TimeUnit timeUnit) {
 86  0
     this.timeUnit = timeUnit;
 87  0
   }
 88  
 }