mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
Added new parent class for units to fix import problems. (#618)
The change with unit classes parent (#617) causes it to report missing imports of tec.uom.se when using static import. Before the change this was not a problem because the parent class was SmartHomeUnits. This change adds a new parent class for all units. Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
parent
4517f3959b
commit
caa9b71c21
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2014,2019 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*
|
||||
* 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.eclipse.smarthome.core.library.unit;
|
||||
|
||||
import tec.uom.se.AbstractSystemOfUnits;
|
||||
|
||||
/**
|
||||
* Base class for all custom unit classes added in openHAB.
|
||||
*
|
||||
* @author Hilbrand Bouwkamp - initial contribution
|
||||
*/
|
||||
class CustomUnits extends AbstractSystemOfUnits {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,6 @@ import javax.measure.spi.SystemOfUnits;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
import tec.uom.se.AbstractSystemOfUnits;
|
||||
import tec.uom.se.format.SimpleUnitFormat;
|
||||
import tec.uom.se.function.AddConverter;
|
||||
import tec.uom.se.function.MultiplyConverter;
|
||||
@ -39,7 +38,7 @@ import tec.uom.se.unit.Units;
|
||||
*
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public final class ImperialUnits extends AbstractSystemOfUnits {
|
||||
public final class ImperialUnits extends CustomUnits {
|
||||
|
||||
private static final ImperialUnits INSTANCE = new ImperialUnits();
|
||||
|
||||
@ -99,11 +98,6 @@ public final class ImperialUnits extends AbstractSystemOfUnits {
|
||||
// avoid external instantiation
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ImperialUnits.class.getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique instance of this class.
|
||||
*
|
||||
|
@ -24,7 +24,6 @@ import javax.measure.spi.SystemOfUnits;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
import tec.uom.se.AbstractSystemOfUnits;
|
||||
import tec.uom.se.format.SimpleUnitFormat;
|
||||
import tec.uom.se.unit.Units;
|
||||
|
||||
@ -36,7 +35,7 @@ import tec.uom.se.unit.Units;
|
||||
*
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public final class SIUnits extends AbstractSystemOfUnits {
|
||||
public final class SIUnits extends CustomUnits {
|
||||
|
||||
private static final SIUnits INSTANCE = new SIUnits();
|
||||
|
||||
@ -49,13 +48,13 @@ public final class SIUnits extends AbstractSystemOfUnits {
|
||||
public static final Unit<Volume> CUBIC_METRE = addUnit(Units.CUBIC_METRE);
|
||||
public static final Unit<Pressure> PASCAL = addUnit(Units.PASCAL);
|
||||
|
||||
private SIUnits() {
|
||||
// avoid external instantiation
|
||||
static {
|
||||
// Override the default unit symbol ℃ to better support TTS and UIs:
|
||||
SimpleUnitFormat.getInstance().label(CELSIUS, "°C");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
private SIUnits() {
|
||||
// avoid external instantiation
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,9 +76,4 @@ public final class SIUnits extends AbstractSystemOfUnits {
|
||||
INSTANCE.units.add(unit);
|
||||
return unit;
|
||||
}
|
||||
|
||||
static {
|
||||
// Override the default unit symbol ℃ to better support TTS and UIs:
|
||||
SimpleUnitFormat.getInstance().label(CELSIUS, "°C");
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ import org.eclipse.smarthome.core.library.dimension.Density;
|
||||
import org.eclipse.smarthome.core.library.dimension.Intensity;
|
||||
import org.eclipse.smarthome.core.library.dimension.VolumetricFlowRate;
|
||||
|
||||
import tec.uom.se.AbstractSystemOfUnits;
|
||||
import tec.uom.se.AbstractUnit;
|
||||
import tec.uom.se.format.SimpleUnitFormat;
|
||||
import tec.uom.se.function.ExpConverter;
|
||||
@ -75,7 +74,7 @@ import tec.uom.se.unit.Units;
|
||||
*
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public final class SmartHomeUnits extends AbstractSystemOfUnits {
|
||||
public final class SmartHomeUnits extends CustomUnits {
|
||||
|
||||
private static final SmartHomeUnits INSTANCE = new SmartHomeUnits();
|
||||
|
||||
@ -198,11 +197,6 @@ public final class SmartHomeUnits extends AbstractSystemOfUnits {
|
||||
// avoid external instantiation
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SmartHomeUnits.class.getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique instance of this class.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user