Java 17 features (N-S) (#15565)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -14,7 +14,6 @@ package org.openhab.binding.novafinedust.internal;
|
||||
|
||||
import static org.openhab.binding.novafinedust.internal.NovaFineDustBindingConstants.THING_TYPE_SDS011;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -39,7 +38,7 @@ import org.osgi.service.component.annotations.Reference;
|
||||
@Component(configurationPid = "binding.novafinedust", service = ThingHandlerFactory.class)
|
||||
public class NovaFineDustHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SDS011);
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_SDS011);
|
||||
|
||||
private final SerialPortManager serialPortManager;
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ public class SDS011Communicator {
|
||||
*/
|
||||
public void initialize(WorkMode mode, Duration interval)
|
||||
throws PortInUseException, TooManyListenersException, IOException, UnsupportedCommOperationException {
|
||||
|
||||
logger.trace("Initializing with mode={}, interval={}", mode, interval);
|
||||
|
||||
SerialPort localSerialPort = portId.open(thingHandler.getThing().getUID().toString(), 2000);
|
||||
@@ -246,8 +245,7 @@ public class SDS011Communicator {
|
||||
private boolean doRead() throws IOException {
|
||||
SensorReply reply = readReply();
|
||||
logger.trace("doRead(): Read reply={}", reply);
|
||||
if (reply instanceof SensorMeasuredDataReply) {
|
||||
SensorMeasuredDataReply sensorData = (SensorMeasuredDataReply) reply;
|
||||
if (reply instanceof SensorMeasuredDataReply sensorData) {
|
||||
logger.trace("We received sensor data");
|
||||
if (sensorData.isValidData()) {
|
||||
logger.trace("Sensor data is valid => updating channels");
|
||||
|
||||
@@ -40,8 +40,7 @@ public class SensorFirmwareReply extends SensorReply {
|
||||
* @return firmware of the sensor formatted as YY-MM-DD
|
||||
*/
|
||||
public String getFirmware() {
|
||||
String firmware = year + "-" + month + "-" + day;
|
||||
return firmware;
|
||||
return year + "-" + month + "-" + day;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user