1 package net.sf.mbus4j.dataframes.datablocks.vif;
2
3 /*
4 * #%L
5 * mbus4j-core
6 * %%
7 * Copyright (C) 2009 - 2014 MBus4J
8 * %%
9 * mbus4j - Drivers for the M-Bus protocol - http://mbus4j.sourceforge.net/
10 * Copyright (C) 2009-2014, mbus4j.sf.net, and individual contributors as indicated
11 * by the @authors tag. See the copyright.txt in the distribution for a
12 * full listing of individual contributors.
13 *
14 * This is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 3 of
17 * the License, or (at your option) any later version.
18 *
19 * This software is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this software; if not, write to the Free
26 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28 * #L%
29 */
30 /**
31 *
32 * @author arnep@users.sourceforge.net
33 * @version $Id: UnitOfMeasurement.java 155 2016-05-04 08:26:07Z arnep $
34 */
35 public enum UnitOfMeasurement {
36
37 DIMENSIONLESS(""),
38 DEGREE("°"),
39 HERTZ("Hz"),
40 WATT_HOUR("Wh"),
41 VA_HOUR("VAh"),
42 VAR_HOUR("VARh"),
43 JOULE("J"),
44 LITRE("l"),
45 CUBIC_METER("m³"),
46 CUBIC_FEET("feet³"),
47 AMERICAN_GALLON("american gallon"),
48 AMERICAN_GALLON_PER_MINUTE("american gallon / min"),
49 AMERICAN_GALLON_PER_HOUR("american gallon / h"),
50 WATT("W"),
51 VA("VA"),
52 VAR("VAR"),
53 GRAMM("g"),
54 TONNS("t"),
55 JOULE_PER_HOUR("J/h"),
56 DEGREE_FAHRENHEIT("°F"),
57 DEGREE_CELSIUS("°C"),
58 VOLT("V"),
59 AMPERE("A"),
60 CURRENCY("Currency"),
61 SECOND("s"),
62 MINUTE("min"),
63 HOUR("h"),
64 DAY("d"),
65 // DAY_OF_MONTH("day of month"),
66 MONTH("m"),
67 YEAR("y"),
68 BAUD("Baud"),
69 BITTIMES("bittimes"),
70 TIME_AND_DATE("time and date"),
71 LITRE_PER_HOUR("l/h"),
72 CUBIC_METER_PER_HOUR("m³/h"),
73 LITRE_PER_MINUTE("l/min"),
74 CUBIC_METER_PER_MINUTE("m³/min"),
75 LITRE_PER_SECOND("l/s"),
76 CUBIC_METER_PER_SECOND("m³/s"),
77 GRAMM_PER_HOUR("g/h"),
78 TONN_PER_HOUR("t/h"),
79 KELVIN("K"),
80 BAR("bar"),
81 DATE("Date");
82 private final String label;
83
84 private UnitOfMeasurement(String label) {
85 this.label = label;
86 }
87
88 @Override
89 public String toString() {
90 return label;
91 }
92
93 public String getLabel() {
94 return label;
95 }
96
97 public static UnitOfMeasurement fromLabel(String label) {
98 if (label == null) {
99 return null;
100 }
101 for (UnitOfMeasurement value : values()) {
102 if (value.getLabel().equals(label)) {
103 return value;
104 }
105 }
106 return valueOf(label);
107 }
108 }