From 1519cb4b1c33fa979d7c61ec8114264cba712260 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Tue, 20 Dec 2022 00:04:43 +0100 Subject: [PATCH] nul annotations, checkstyle, forbidden packagel (#13981) Signed-off-by: lsiepel --- .../internal/AbstractAirthingsHandler.java | 4 ++-- .../internal/AirthingsBindingConstants.java | 22 ------------------- .../AirthingsDiscoveryParticipant.java | 5 +---- .../internal/AirthingsWaveGen1Handler.java | 4 ++-- .../internal/AirthingsWaveMiniHandler.java | 2 +- .../internal/AirthingsWavePlusHandler.java | 6 ++--- 6 files changed, 9 insertions(+), 34 deletions(-) diff --git a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AbstractAirthingsHandler.java b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AbstractAirthingsHandler.java index 464e99fcb40..b148c7f5ef2 100644 --- a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AbstractAirthingsHandler.java +++ b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AbstractAirthingsHandler.java @@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory; * @author Kai Kreuzer - Added Airthings Wave Mini support */ @NonNullByDefault -abstract public class AbstractAirthingsHandler extends BeaconBluetoothHandler { +public abstract class AbstractAirthingsHandler extends BeaconBluetoothHandler { private static final int CHECK_PERIOD_SEC = 10; @@ -283,5 +283,5 @@ abstract public class AbstractAirthingsHandler extends BeaconBluetoothHandler { * * @param is the content of the bluetooth characteristic */ - abstract protected void updateChannels(int[] is); + protected abstract void updateChannels(int[] is); } diff --git a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsBindingConstants.java b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsBindingConstants.java index bb20d495ed3..6aa5f50c1e3 100644 --- a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsBindingConstants.java +++ b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsBindingConstants.java @@ -12,24 +12,12 @@ */ package org.openhab.binding.bluetooth.airthings.internal; -import java.math.BigInteger; import java.util.Set; -import javax.measure.Unit; -import javax.measure.quantity.Dimensionless; - import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.bluetooth.BluetoothBindingConstants; -import org.openhab.core.library.dimension.Density; -import org.openhab.core.library.unit.SIUnits; -import org.openhab.core.library.unit.Units; import org.openhab.core.thing.ThingTypeUID; -import tech.units.indriya.format.SimpleUnitFormat; -import tech.units.indriya.function.MultiplyConverter; -import tech.units.indriya.unit.ProductUnit; -import tech.units.indriya.unit.TransformedUnit; - /** * The {@link AirthingsBindingConstants} class defines common constants, which are * used across the whole binding. @@ -60,14 +48,4 @@ public class AirthingsBindingConstants { public static final String CHANNEL_ID_TVOC = "tvoc"; public static final String CHANNEL_ID_RADON_ST_AVG = "radon_st_avg"; public static final String CHANNEL_ID_RADON_LT_AVG = "radon_lt_avg"; - - public static final Unit PARTS_PER_BILLION = new TransformedUnit<>(Units.ONE, - MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000))); - public static final Unit BECQUEREL_PER_CUBIC_METRE = new ProductUnit<>( - Units.BECQUEREL.divide(SIUnits.CUBIC_METRE)); - - static { - SimpleUnitFormat.getInstance().label(PARTS_PER_BILLION, "ppb"); - SimpleUnitFormat.getInstance().label(BECQUEREL_PER_CUBIC_METRE, "Bq/m³"); - } } diff --git a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsDiscoveryParticipant.java b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsDiscoveryParticipant.java index 1cccdeaa7ff..6eeccbd122a 100644 --- a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsDiscoveryParticipant.java @@ -98,10 +98,7 @@ public class AirthingsDiscoveryParticipant implements BluetoothDiscoveryParticip private boolean isAirthingsDevice(BluetoothDiscoveryDevice device) { Integer manufacturerId = device.getManufacturerId(); - if (manufacturerId != null && manufacturerId == AIRTHINGS_COMPANY_ID) { - return true; - } - return false; + return manufacturerId != null && manufacturerId == AIRTHINGS_COMPANY_ID; } private DiscoveryResult createResult(BluetoothDiscoveryDevice device, ThingUID thingUID, String label) { diff --git a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveGen1Handler.java b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveGen1Handler.java index 3e632d510b8..6cf56e52283 100644 --- a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveGen1Handler.java +++ b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveGen1Handler.java @@ -87,7 +87,7 @@ public class AirthingsWaveGen1Handler extends AbstractAirthingsHandler { logger.debug("Change next readSensor to: {}", readSensor); logger.debug("Update channel 3"); updateState(CHANNEL_ID_RADON_ST_AVG, - QuantityType.valueOf(Double.valueOf(intResult), BECQUEREL_PER_CUBIC_METRE)); + QuantityType.valueOf(Double.valueOf(intResult), Units.BECQUEREL_PER_CUBIC_METRE)); logger.debug("Update channel 3 done"); break; case RADON_LTA: @@ -97,7 +97,7 @@ public class AirthingsWaveGen1Handler extends AbstractAirthingsHandler { logger.debug("Change next readSensor to: {}", readSensor); logger.debug("Update channel 4"); updateState(CHANNEL_ID_RADON_LT_AVG, - QuantityType.valueOf(Double.valueOf(intResult), BECQUEREL_PER_CUBIC_METRE)); + QuantityType.valueOf(Double.valueOf(intResult), Units.BECQUEREL_PER_CUBIC_METRE)); logger.debug("Update channel 4 done"); break; } diff --git a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveMiniHandler.java b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveMiniHandler.java index 60d263392d1..bf41434d6e4 100644 --- a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveMiniHandler.java +++ b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWaveMiniHandler.java @@ -63,7 +63,7 @@ public class AirthingsWaveMiniHandler extends AbstractAirthingsHandler { } Number tvoc = data.get(AirthingsDataParser.TVOC); if (tvoc != null) { - updateState(CHANNEL_ID_TVOC, new QuantityType(tvoc, PARTS_PER_BILLION)); + updateState(CHANNEL_ID_TVOC, new QuantityType(tvoc, Units.PARTS_PER_BILLION)); } } catch (AirthingsParserException e) { logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage()); diff --git a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWavePlusHandler.java b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWavePlusHandler.java index 3e1d6bd38b5..4f086147a49 100644 --- a/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWavePlusHandler.java +++ b/bundles/org.openhab.binding.bluetooth.airthings/src/main/java/org/openhab/binding/bluetooth/airthings/internal/AirthingsWavePlusHandler.java @@ -73,17 +73,17 @@ public class AirthingsWavePlusHandler extends AbstractAirthingsHandler { } Number tvoc = data.get(AirthingsDataParser.TVOC); if (tvoc != null) { - updateState(CHANNEL_ID_TVOC, new QuantityType(tvoc, PARTS_PER_BILLION)); + updateState(CHANNEL_ID_TVOC, new QuantityType(tvoc, Units.PARTS_PER_BILLION)); } Number radonShortTermAvg = data.get(AirthingsDataParser.RADON_SHORT_TERM_AVG); if (radonShortTermAvg != null) { updateState(CHANNEL_ID_RADON_ST_AVG, - new QuantityType(radonShortTermAvg, BECQUEREL_PER_CUBIC_METRE)); + new QuantityType(radonShortTermAvg, Units.BECQUEREL_PER_CUBIC_METRE)); } Number radonLongTermAvg = data.get(AirthingsDataParser.RADON_LONG_TERM_AVG); if (radonLongTermAvg != null) { updateState(CHANNEL_ID_RADON_LT_AVG, - new QuantityType(radonLongTermAvg, BECQUEREL_PER_CUBIC_METRE)); + new QuantityType(radonLongTermAvg, Units.BECQUEREL_PER_CUBIC_METRE)); } } catch (AirthingsParserException e) { logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());