[lutron] Replace calls to methods deprecated in Java 11 (#8602)

* [lutron] Replace calls to methods deprecated in Java 11
* [lutron] Resolve comments

Signed-off-by: Bob Adair <bob.github@att.net>
This commit is contained in:
Bob A 2020-09-29 13:16:54 -04:00 committed by GitHub
parent c071b2ea06
commit 78c81ab93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 14 deletions

View File

@ -15,6 +15,7 @@ package org.openhab.binding.lutron.action;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.math.RoundingMode;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@ -90,7 +91,7 @@ public class DimmerActions implements ThingActions, IDimmerActions {
lightLevel = 0.0;
}
try {
dimmerHandler.setLightLevel(new BigDecimal(lightLevel).setScale(2, BigDecimal.ROUND_HALF_UP),
dimmerHandler.setLightLevel(new BigDecimal(lightLevel).setScale(2, RoundingMode.HALF_UP),
new LutronDuration(fadeTime), new LutronDuration(delayTime));
} catch (IllegalArgumentException e) {
logger.debug("Ignoring setLevel command due to illegal argument exception: {}", e.getMessage());

View File

@ -31,5 +31,5 @@ public class DimmerConfig {
public BigDecimal fadeInTime = new BigDecimal(DEFAULT_FADE);
public BigDecimal fadeOutTime = new BigDecimal(DEFAULT_FADE);
public BigDecimal onLevel = new BigDecimal(DEFAULT_ONLEVEL);
public Boolean onToLast = new Boolean(DEFAULT_ONTOLAST);
public Boolean onToLast = DEFAULT_ONTOLAST;
}

View File

@ -113,10 +113,11 @@ public class GreenModeHandler extends LutronHandler {
}
private void stopPolling() {
ScheduledFuture<?> pollJob = this.pollJob;
if (pollJob != null) {
this.pollJob = null;
logger.debug("Canceling green mode polling job for integration ID {}", integrationId);
pollJob.cancel(true);
pollJob = null;
}
}
@ -140,7 +141,7 @@ public class GreenModeHandler extends LutronHandler {
} else if (command == OnOffType.OFF) {
greenMode(ACTION_STEP, 1);
} else if (command instanceof Number) {
Integer step = new Integer(((Number) command).intValue());
Integer step = ((Number) command).intValue();
if (step.intValue() >= GREENSTEP_MIN) {
greenMode(ACTION_STEP, step);
}
@ -159,7 +160,7 @@ public class GreenModeHandler extends LutronHandler {
try {
if (type == LutronCommandType.MODE && parameters.length > 1
&& ACTION_STEP.toString().equals(parameters[0])) {
Long step = new Long(parameters[1]);
Long step = Long.valueOf(parameters[1]);
if (getThing().getStatus() == ThingStatus.UNKNOWN) {
updateStatus(ThingStatus.ONLINE);
startPolling();

View File

@ -102,7 +102,7 @@ public class TimeclockHandler extends LutronHandler {
if (channelUID.getId().equals(CHANNEL_CLOCKMODE)) {
if (command instanceof DecimalType) {
Integer mode = new Integer(((DecimalType) command).intValue());
Integer mode = ((DecimalType) command).intValue();
timeclock(ACTION_CLOCKMODE, mode);
} else if (command instanceof RefreshType) {
queryTimeclock(ACTION_CLOCKMODE);
@ -111,7 +111,7 @@ public class TimeclockHandler extends LutronHandler {
}
} else if (channelUID.getId().equals(CHANNEL_EXECEVENT)) {
if (command instanceof DecimalType) {
Integer index = new Integer(((DecimalType) command).intValue());
Integer index = ((DecimalType) command).intValue();
timeclock(ACTION_EXECEVENT, index);
} else {
logger.debug("Invalid command type for execevent channnel");
@ -130,14 +130,14 @@ public class TimeclockHandler extends LutronHandler {
}
} else if (channelUID.getId().equals(CHANNEL_ENABLEEVENT)) {
if (command instanceof DecimalType) {
Integer index = new Integer(((DecimalType) command).intValue());
Integer index = ((DecimalType) command).intValue();
timeclock(ACTION_SETEVENT, index, EVENT_ENABLE);
} else {
logger.debug("Invalid command type for enableevent channnel");
}
} else if (channelUID.getId().equals(CHANNEL_DISABLEEVENT)) {
if (command instanceof DecimalType) {
Integer index = new Integer(((DecimalType) command).intValue());
Integer index = ((DecimalType) command).intValue();
timeclock(ACTION_SETEVENT, index, EVENT_DISABLE);
} else {
logger.debug("Invalid command type for disableevent channnel");
@ -173,7 +173,7 @@ public class TimeclockHandler extends LutronHandler {
try {
if (parameters.length >= 2 && ACTION_CLOCKMODE.toString().equals(parameters[0])) {
Integer mode = new Integer(parameters[1]);
Integer mode = Integer.valueOf(parameters[1]);
if (getThing().getStatus() == ThingStatus.UNKNOWN) {
updateStatus(ThingStatus.ONLINE);
}
@ -194,12 +194,12 @@ public class TimeclockHandler extends LutronHandler {
}
} else if (parameters.length >= 2 && ACTION_EXECEVENT.toString().equals(parameters[0])) {
Integer index = new Integer(parameters[1]);
Integer index = Integer.valueOf(parameters[1]);
updateState(CHANNEL_EXECEVENT, new DecimalType(index));
} else if (parameters.length >= 3 && ACTION_SETEVENT.toString().equals(parameters[0])) {
Integer index = new Integer(parameters[1]);
Integer state = new Integer(parameters[2]);
Integer index = Integer.valueOf(parameters[1]);
Integer state = Integer.valueOf(parameters[2]);
if (state.equals(EVENT_ENABLE)) {
updateState(CHANNEL_ENABLEEVENT, new DecimalType(index));
} else if (state.equals(EVENT_DISABLE)) {

View File

@ -13,6 +13,7 @@
package org.openhab.binding.lutron.internal.protocol;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -75,7 +76,7 @@ public class LutronDuration {
* Constructor accepting duration in seconds as a Double
*/
public LutronDuration(Double seconds) {
this(new BigDecimal(seconds).setScale(2, BigDecimal.ROUND_HALF_UP));
this(new BigDecimal(seconds).setScale(2, RoundingMode.HALF_UP));
}
/**