forked from openhab/openhab-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uom] Add
unit
metadata for NumberItem (openhab#3481)
* Add defaultUnit metadata for NumberItem Signed-off-by: Jan N. Klug <[email protected]> GitOrigin-RevId: 9ef076d
- Loading branch information
Showing
31 changed files
with
915 additions
and
695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...rthouse.core.i18n.core/src/test/java/org/openhab/core/internal/i18n/TestUnitProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2010-2023 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.internal.i18n; | ||
|
||
import java.util.Map; | ||
|
||
import javax.measure.Quantity; | ||
import javax.measure.Unit; | ||
import javax.measure.spi.SystemOfUnits; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.core.i18n.UnitProvider; | ||
import org.openhab.core.library.unit.SIUnits; | ||
|
||
/** | ||
* The {@link TestUnitProvider} implements a {@link UnitProvider} for testing purposes | ||
* | ||
* @author Jan N. Klug - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class TestUnitProvider implements UnitProvider { | ||
|
||
private final Map<Class<? extends Quantity<?>>, Map<SystemOfUnits, Unit<? extends Quantity<?>>>> dimensionMap = I18nProviderImpl | ||
.getDimensionMap(); | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T extends Quantity<T>> Unit<T> getUnit(Class<T> dimension) { | ||
Unit<T> unit = (Unit<T>) dimensionMap.getOrDefault(dimension, Map.of()).get(SIUnits.getInstance()); | ||
assert unit != null; | ||
return unit; | ||
} | ||
|
||
@Override | ||
public SystemOfUnits getMeasurementSystem() { | ||
return SIUnits.getInstance(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.