1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
27
28 public class LongAndTimeUnit {
29
30 private static final ImmutableMap<TimeUnit, String> TIME_UNIT_TO_ABBREV =
31 ImmutableMap.<TimeUnit, String>builder().
32 put(TimeUnit.DAYS, "days").
33 put(TimeUnit.HOURS, "hours").
34 put(TimeUnit.MICROSECONDS, "us").
35 put(TimeUnit.MILLISECONDS, "ms").
36 put(TimeUnit.MINUTES, "mins").
37 put(TimeUnit.NANOSECONDS, "ns").
38 put(TimeUnit.SECONDS, "secs").build();
39
40
41 private long value;
42
43 private TimeUnit timeUnit;
44
45 @Override
46 public String toString() {
47 if (timeUnit == null) {
48 return String.valueOf(value);
49 } else {
50 return value + " " + TIME_UNIT_TO_ABBREV.get(timeUnit);
51 }
52 }
53
54
55
56
57
58
59 public long getValue() {
60 return value;
61 }
62
63
64
65
66
67
68 public void setValue(long value) {
69 this.value = value;
70 }
71
72
73
74
75
76
77 public TimeUnit getTimeUnit() {
78 return timeUnit;
79 }
80
81
82
83
84
85 public void setTimeUnit(TimeUnit timeUnit) {
86 this.timeUnit = timeUnit;
87 }
88 }