Skip to content

Commit

Permalink
nul annotations, checkstyle, forbidden packagel (openhab#13981)
Browse files Browse the repository at this point in the history
Signed-off-by: lsiepel <[email protected]>
  • Loading branch information
lsiepel authored Dec 19, 2022
1 parent 40b8b77 commit 1519cb4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @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;

Expand Down Expand Up @@ -283,5 +283,5 @@ private boolean isTimeToRead() {
*
* @param is the content of the bluetooth characteristic
*/
abstract protected void updateChannels(int[] is);
protected abstract void updateChannels(int[] is);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Dimensionless> PARTS_PER_BILLION = new TransformedUnit<>(Units.ONE,
MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000)));
public static final Unit<Density> 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³");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ public boolean requiresConnection(BluetoothDiscoveryDevice device) {

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void updateChannels(int[] is) {
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:
Expand All @@ -97,7 +97,7 @@ protected void updateChannels(int[] is) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void updateChannels(int[] is) {
}
Number tvoc = data.get(AirthingsDataParser.TVOC);
if (tvoc != null) {
updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, PARTS_PER_BILLION));
updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, Units.PARTS_PER_BILLION));
}
} catch (AirthingsParserException e) {
logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ protected void updateChannels(int[] is) {
}
Number tvoc = data.get(AirthingsDataParser.TVOC);
if (tvoc != null) {
updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, PARTS_PER_BILLION));
updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(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<Density>(radonShortTermAvg, BECQUEREL_PER_CUBIC_METRE));
new QuantityType<Density>(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<Density>(radonLongTermAvg, BECQUEREL_PER_CUBIC_METRE));
new QuantityType<Density>(radonLongTermAvg, Units.BECQUEREL_PER_CUBIC_METRE));
}
} catch (AirthingsParserException e) {
logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());
Expand Down

0 comments on commit 1519cb4

Please sign in to comment.