Skip to content

Commit 5c4ce91

Browse files
authored
Improve Javadoc for QuantityType (#5360)
Signed-off-by: David Pace <dev@davidpace.de>
1 parent 3bc47c0 commit 5c4ce91

File tree

1 file changed

+36
-1
lines changed
  • bundles/org.openhab.core/src/main/java/org/openhab/core/library/types

1 file changed

+36
-1
lines changed

bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
import org.eclipse.jdt.annotation.Nullable;
4848
import org.openhab.core.internal.library.unit.UnitInitializer;
4949
import org.openhab.core.items.events.ItemStateEvent;
50+
import org.openhab.core.library.unit.CurrencyUnits;
51+
import org.openhab.core.library.unit.ImperialUnits;
52+
import org.openhab.core.library.unit.SIUnits;
5053
import org.openhab.core.library.unit.Units;
5154
import org.openhab.core.types.Command;
5255
import org.openhab.core.types.PrimitiveType;
@@ -62,7 +65,39 @@
6265
import tech.uom.lib.common.function.QuantityFunctions;
6366

6467
/**
65-
* The measure type extends DecimalType to handle physical unit measurement
68+
* Command type for measurable quantities, such as:
69+
*
70+
* <ul>
71+
* <li>Mass</li>
72+
* <li>Time</li>
73+
* <li>Distance</li>
74+
* <li>Speed</li>
75+
* <li>Temperature</li>
76+
* <li>Electric Current</li>
77+
* <li>Electric Potential</li>
78+
* <li>Energy</li>
79+
* <li>Power</li>
80+
* <li>Data Amount</li>
81+
* </ul>
82+
*
83+
* <p>
84+
* Quantities are usually specified in suitable units of measurement. All units are accessible via the openHAB classes
85+
* {@link Units}, {@link SIUnits}, {@link ImperialUnits} and {@link CurrencyUnits}.
86+
*
87+
* <p>
88+
* Examples:
89+
*
90+
* <pre>
91+
* {@code
92+
* new QuantityType<>("65 kWh") // 65 kWh, unit is parsed automatically
93+
* new QuantityType<>(22d, SIUnits.CELSIUS) // 22°C
94+
* new QuantityType<>(71.6d, ImperialUnits.FAHRENHEIT) // 71.6°F
95+
* new QuantityType<>(1, MetricPrefix.MEGA(Units.BYTE)) // 1 MB
96+
* new QuantityType<>(56.78d, Units.WATT_HOUR) // 56.78 Wh
97+
* }
98+
* </pre>
99+
*
100+
* @param <T> the unit associated with the quantity
66101
*
67102
* @author Gaël L'hopital - Initial contribution
68103
*/

0 commit comments

Comments
 (0)