]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix Java and Jetty deprecations (#10349)
authorWouter Born <github@maindrain.net>
Fri, 19 Mar 2021 09:40:14 +0000 (10:40 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Mar 2021 09:40:14 +0000 (10:40 +0100)
Signed-off-by: Wouter Born <github@maindrain.net>
43 files changed:
bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/discovery/AutelisDiscoveryParticipant.java
bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account/SmartherAccountService.java
bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java
bundles/org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler/HVACHandler.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinHttpClientFactoryImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse/BaseDmxChannel.java
bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java
bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpHandlerFactory.java
bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ChannelUtils.java
bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyWebSocket.java
bundles/org.openhab.binding.ism8/src/main/java/org/openhab/binding/ism8/server/Server.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapper.java
bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java
bundles/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/handler/NestRedirectUrlSupplier.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java
bundles/org.openhab.binding.paradoxalarm/src/test/java/main/Main.java
bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java
bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java
bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java
bundles/org.openhab.binding.robonect/src/main/java/org/openhab/binding/robonect/internal/RobonectClient.java
bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/model/ModelParserTest.java
bundles/org.openhab.binding.seneye/src/main/java/org/openhab/binding/seneye/internal/SeneyeService.java
bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/discovery/SqueezeBoxServerDiscoveryParticipant.java
bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java
bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/BaseHomeThingHandler.java
bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java
bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java
bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model/TradfriVersionTest.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiThingHandlerFactory.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java
bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler/LEDStateDTO.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZAutomationDeviceHandler.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZWaveDeviceHandler.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RgbLightDevice.java
itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroValidConfigurationTest.java

index 67a29b9a9fb5efa99619a190757c306536250f54..23c859c5ef95cabd39f84b28c6b228a3762299eb 100644 (file)
@@ -65,7 +65,7 @@ public class AutelisDiscoveryParticipant implements UpnpDiscoveryParticipant {
             properties.put("host", url.getHost());
             properties.put("user", "admin");
             properties.put("password", "admin");
-            properties.put("port", new Integer(port));
+            properties.put("port", Integer.valueOf(port));
 
             DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel(label)
                     .build();
index b80a02c66ebeab2fedc0ba2b5b37059c584b80ce..3669f87a56ed1e594f3039d3cdb20c9f7b9cc728 100644 (file)
@@ -13,6 +13,8 @@
 package org.openhab.binding.autelis.internal.handler;
 
 import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,8 +32,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.http.HttpHeader;
 import org.eclipse.jetty.http.HttpStatus;
-import org.eclipse.jetty.util.B64Code;
-import org.eclipse.jetty.util.StringUtil;
 import org.openhab.binding.autelis.internal.AutelisBindingConstants;
 import org.openhab.binding.autelis.internal.config.AutelisConfiguration;
 import org.openhab.core.library.types.DecimalType;
@@ -313,7 +313,8 @@ public class AutelisHandler extends BaseThingHandler {
         }
 
         baseURL = "http://" + host + ":" + port;
-        basicAuthentication = "Basic " + B64Code.encode(username + ":" + password, StringUtil.__ISO_8859_1);
+        basicAuthentication = "Basic "
+                + Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.ISO_8859_1));
         logger.debug("Autelius binding configured with base url {} and refresh period of {}", baseURL, refresh);
 
         initPolling(0);
index b3914acb496c15a37d6d5ad7546b99cba09dd436..30fe6f84f5f1214504b5a640c721964993bd7873 100644 (file)
@@ -22,13 +22,13 @@ import java.util.Hashtable;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.jetty.util.ConcurrentHashSet;
 import org.openhab.binding.bticinosmarther.internal.api.dto.Notification;
 import org.openhab.binding.bticinosmarther.internal.api.dto.Sender;
 import org.openhab.binding.bticinosmarther.internal.api.exception.SmartherGatewayException;
@@ -61,7 +61,7 @@ public class SmartherAccountService {
 
     private final Logger logger = LoggerFactory.getLogger(SmartherAccountService.class);
 
-    private final Set<SmartherAccountHandler> handlers = new ConcurrentHashSet<>();
+    private final Set<SmartherAccountHandler> handlers = ConcurrentHashMap.newKeySet();
 
     private @Nullable HttpService httpService;
     private @Nullable BundleContext bundleContext;
index 60a800c93c09c56acd6a29c30a4395d7aab9efdc..e9ef9043f93c556c16f242c8557f297cface5cfe 100644 (file)
@@ -357,7 +357,7 @@ public class X10Interface extends Thread implements SerialPortEventListener {
      */
     public static boolean validateAddress(String address) {
         return (!(address.length() < 2 || address.length() > 3
-                || !HOUSE_CODES.containsKey(new Character(address.charAt(0)))
+                || !HOUSE_CODES.containsKey(Character.valueOf(address.charAt(0)))
                 || !DEVICE_CODES.containsKey(Integer.parseInt(address.substring(1)))));
     }
 
index 509e224b6f0f1990cce4f5c1e00585ec2479092a..4eb327b1147c40ba9e7619e57d2fd8a3332de034 100644 (file)
@@ -136,7 +136,7 @@ public class HVACHandler extends BaseThingHandler {
                     if (command instanceof RefreshType) {
                         final String currentTemp = query(controller, "a");
                         if (currentTemp != null) {
-                            final Integer temp = new Integer(currentTemp);
+                            final Integer temp = Integer.parseInt(currentTemp);
                             final QuantityType<?> value = new QuantityType<>(temp, controller.getUnit());
                             updateState(CURRENT_TEMP, value);
                         }
@@ -157,7 +157,7 @@ public class HVACHandler extends BaseThingHandler {
                     if (command instanceof RefreshType) {
                         final String setTemp = query(controller, "t");
                         if (setTemp != null) {
-                            final Integer temp = new Integer(setTemp);
+                            final Integer temp = Integer.parseInt(setTemp);
                             final QuantityType<?> value = new QuantityType<>(temp, controller.getUnit());
                             updateState(SET_TEMP, value);
                         }
index 947a388929f67e7a5a67da671aee1d9d80c72332..b7729ef13492d7ff9fdccae8e0a37ab4ebdd4904 100644 (file)
@@ -62,7 +62,7 @@ public class DaikinHttpClientFactoryImpl implements DaikinHttpClientFactory {
 
     private synchronized void initialize() {
         if (httpClient == null) {
-            httpClient = new HttpClient(new SslContextFactory(true));
+            httpClient = new HttpClient(new SslContextFactory.Client(true));
             try {
                 httpClient.start();
                 logger.debug("Daikin http client started");
index ee37d31a2d4892f6557bcf86402361ad2ed04d35..2225d95d6d371743c069ca4c8c2b54f6901643e9 100644 (file)
@@ -15,6 +15,7 @@ package org.openhab.binding.digitalstrom.internal.handler;
 import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants.*;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -410,7 +411,7 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
         if (value <= 0 || max <= 0) {
             return 0;
         }
-        int percentValue = new BigDecimal(value * ((float) 100 / max)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
+        int percentValue = new BigDecimal(value * ((float) 100 / max)).setScale(0, RoundingMode.HALF_UP).intValue();
         return percentValue < 0 ? 0 : percentValue > 100 ? 100 : percentValue;
     }
 
index 88292e44bada4f26124a2990126d609ca4e682d7..2abd1fa9e5698535b14d3b98e99b6c3093df29c0 100644 (file)
@@ -95,9 +95,10 @@ public class BaseDmxChannel implements Comparable<BaseDmxChannel> {
         if (otherDmxChannel == null) {
             return -1;
         }
-        int universeCompare = new Integer(getUniverseId()).compareTo(new Integer(otherDmxChannel.getUniverseId()));
+        int universeCompare = Integer.valueOf(getUniverseId())
+                .compareTo(Integer.valueOf(otherDmxChannel.getUniverseId()));
         if (universeCompare == 0) {
-            return new Integer(getChannelId()).compareTo(new Integer(otherDmxChannel.getChannelId()));
+            return Integer.valueOf(getChannelId()).compareTo(Integer.valueOf(otherDmxChannel.getChannelId()));
         } else {
             return universeCompare;
         }
index 49da817f56a5154515d7b35facc01ed23b2bd3a8..5284de881c6ce3c62f8a258ae8b8d11f1319c2b1 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.feican.internal;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.library.types.HSBType;
@@ -82,7 +83,7 @@ public class Commands {
      */
     private byte convertColorPercentToByte(PercentType percent) {
         return percent.toBigDecimal().multiply(BigDecimal.valueOf(255))
-                .divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).byteValue();
+                .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).byteValue();
     }
 
     /**
index 1869a1e54e10a46d6b1dcca0520f5261f84145f1..73ccda0c8ee4668e0fef2e40d601eb8dc99311cb 100644 (file)
@@ -16,6 +16,7 @@ import static org.openhab.binding.gree.internal.GreeBindingConstants.*;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.net.DatagramSocket;
 import java.time.Instant;
 import java.util.List;
@@ -567,7 +568,7 @@ public class GreeHandler extends BaseThingHandler {
 
     public static QuantityType<?> toQuantityType(Number value, int digits, Unit<?> unit) {
         BigDecimal bd = new BigDecimal(value.doubleValue());
-        return new QuantityType<>(bd.setScale(digits, BigDecimal.ROUND_HALF_EVEN), unit);
+        return new QuantityType<>(bd.setScale(digits, RoundingMode.HALF_EVEN), unit);
     }
 
     private void stopRefreshTask() {
index 3318fb9d4385c0b21d6886c5617df02080747ee5..064984de0b3981a74f0880ef5d2de4076c67390f 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.http.internal;
 
-import static org.openhab.binding.http.internal.HttpBindingConstants.*;
+import static org.openhab.binding.http.internal.HttpBindingConstants.THING_TYPE_URL;
 
 import java.util.Set;
 
@@ -59,8 +59,8 @@ public class HttpHandlerFactory extends BaseThingHandlerFactory
     @Activate
     public HttpHandlerFactory(@Reference HttpClientFactory httpClientFactory,
             @Reference HttpDynamicStateDescriptionProvider httpDynamicStateDescriptionProvider) {
-        this.secureClient = new HttpClient(new SslContextFactory());
-        this.insecureClient = new HttpClient(new SslContextFactory(true));
+        this.secureClient = new HttpClient(new SslContextFactory.Client());
+        this.insecureClient = new HttpClient(new SslContextFactory.Client(true));
         try {
             this.secureClient.start();
             this.insecureClient.start();
index e8b3fd52eccd171ab794dfe8c7e5a7732a9828a3..2bb837d5fc58d96b4af8e87a4b86beeaf643b2d1 100644 (file)
@@ -202,7 +202,7 @@ public class ChannelUtils {
                 ChannelUID channelUID = new ChannelUID(thing.getUID(), group + resourceId);
                 ChannelTypeUID type = new ChannelTypeUID(BINDING_ID, channelType);
                 Configuration configuration = new Configuration();
-                configuration.put(PARAM_RESOURCE_ID, new Integer(resourceId));
+                configuration.put(PARAM_RESOURCE_ID, Integer.valueOf(resourceId));
 
                 Channel channel = ChannelBuilder.create(channelUID, acceptedItemType).withConfiguration(configuration)
                         .withLabel(description).withType(type).build();
index 5b0a5caa11a5c23213257a96124d736d3cb28498..61aa8d650d743ab4b5a3cb3c9021aea37a1b2e50 100644 (file)
@@ -149,7 +149,7 @@ public class InnogyWebSocket {
     }
 
     WebSocketClient startWebSocketClient() throws Exception {
-        WebSocketClient client = new WebSocketClient(new SslContextFactory());
+        WebSocketClient client = new WebSocketClient(new SslContextFactory.Client());
         client.setMaxIdleTimeout(this.maxIdleTimeout);
         client.start();
         return client;
index f0d6fcfd69eb0a301421e449f553cefa98a4c208..8b2ac26cce94c647d51fba5ee0102adf079b9945 100644 (file)
@@ -85,6 +85,7 @@ public class Server extends Thread {
      * Starts the server
      *
      */
+    @Override
     public void run() {
         this.startRetries = 0;
         while (!this.isInterrupted()) {
@@ -132,7 +133,7 @@ public class Server extends Thread {
 
         IDataPoint dp = DataPointFactory.createDataPoint(id, knxType, description);
         if (dp != null) {
-            this.dataPoints.put(new Integer(id), dp);
+            this.dataPoints.put(Integer.valueOf(id), dp);
         }
     }
 
index 605f18a7b271c72314135d7a5e2425fde9f0fe2c..ef2f93085dca4670f5c3bbb4f67d033b3724828c 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.knx.internal.dpt;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
 import java.text.ParseException;
@@ -1017,6 +1018,6 @@ public class KNXCoreTypeMapper implements KNXTypeMapper {
      */
     private int convertPercentToByte(PercentType percent) {
         return percent.toBigDecimal().multiply(BigDecimal.valueOf(255))
-                .divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).intValue();
+                .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).intValue();
     }
 }
index 812371394eaf77d5f54d278f2f1d05cc97fa7ab4..d1927d1c910622e823105c44f88ba77613d2e32d 100644 (file)
@@ -402,7 +402,7 @@ public class LifxLightHandler extends BaseThingHandler {
 
         Configuration configuration = channel.getConfiguration();
         Object speed = configuration.get(parameter);
-        return speed == null ? null : new Double(speed.toString());
+        return speed == null ? null : Double.valueOf(speed.toString());
     }
 
     private LifxProduct getProduct() {
@@ -414,7 +414,7 @@ public class LifxLightHandler extends BaseThingHandler {
             // Without first conversion to double, on a very first thing creation from discovery inbox,
             // the product type is incorrectly parsed, as framework passed it as a floating point number
             // (e.g. 50.0 instead of 50)
-            Double d = Double.parseDouble((String) propertyValue);
+            Double d = Double.valueOf((String) propertyValue);
             long productID = d.longValue();
             return LifxProduct.getProductFromProductID(productID);
         } catch (IllegalArgumentException e) {
index 3d027ced5f32eb1f3fc87763b1c13ce753105090..90d08da70d14b7783355373f9d377b35dce70aaf 100644 (file)
@@ -71,7 +71,7 @@ public class NestRedirectUrlSupplier {
      * @see https://developers.nest.com/documentation/cloud/how-to-handle-redirects
      */
     private String resolveRedirectUrl() throws FailedResolvingNestUrlException {
-        HttpClient httpClient = new HttpClient(new SslContextFactory());
+        HttpClient httpClient = new HttpClient(new SslContextFactory.Client());
         httpClient.setFollowRedirects(false);
 
         Request request = httpClient.newRequest(NestBindingConstants.NEST_URL).method(HttpMethod.GET).timeout(30,
index 16cbaeda2d8d08c88f81704ee00c9f7ebdbe19fc..909187a1895c2f10f8b435680e23737ce29a080c 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.netatmo.internal;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.Instant;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
@@ -83,7 +84,7 @@ public class ChannelTypeUtils {
     }
 
     public static State toDecimalType(@Nullable BigDecimal decimal) {
-        return decimal == null ? UnDefType.NULL : new DecimalType(decimal.setScale(2, BigDecimal.ROUND_HALF_UP));
+        return decimal == null ? UnDefType.NULL : new DecimalType(decimal.setScale(2, RoundingMode.HALF_UP));
     }
 
     public static State toDecimalType(@Nullable String textualDecimal) {
index d8e646565909d810f076fb7377205924192752b9..7f9f893fc904e1da08372629ed1ec48802683d78 100644 (file)
@@ -100,7 +100,7 @@ public class Main {
         ipAddress = parser.getIpAddress();
         logger.info("IP150 IP Address: {}", ipAddress);
 
-        port = new Integer(parser.getPort());
+        port = Integer.parseInt(parser.getPort());
         logger.info("IP150 port: {}", port);
     }
 }
index 5c660cd620cd4adb7a5659a1b34f095b93c2632f..2c84bcbf71b6a6f8df34643e67b108245ad744b1 100644 (file)
@@ -18,6 +18,7 @@ import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.Pac
 import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting2Message.Commands.*;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
@@ -155,7 +156,7 @@ public class RFXComLighting2Message extends RFXComDeviceMessageImpl<RFXComLighti
      */
     public static int getDimLevelFromPercentType(PercentType pt) {
         return pt.toBigDecimal().multiply(BigDecimal.valueOf(15))
-                .divide(PercentType.HUNDRED.toBigDecimal(), 0, BigDecimal.ROUND_UP).intValue();
+                .divide(PercentType.HUNDRED.toBigDecimal(), 0, RoundingMode.UP).intValue();
     }
 
     /**
@@ -168,7 +169,7 @@ public class RFXComLighting2Message extends RFXComDeviceMessageImpl<RFXComLighti
         value = Math.min(value, 15);
 
         return new PercentType(BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(100))
-                .divide(BigDecimal.valueOf(15), 0, BigDecimal.ROUND_UP).intValue());
+                .divide(BigDecimal.valueOf(15), 0, RoundingMode.UP).intValue());
     }
 
     @Override
index adb91f3c70049709ddc2d02bdc42e4be75976403..3602810be1ac8f988f41d0b32b11d53c1c309671 100644 (file)
@@ -17,6 +17,7 @@ import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte
 import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting5Message.SubType.*;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Arrays;
 import java.util.List;
 
@@ -216,7 +217,7 @@ public class RFXComLighting5Message extends RFXComDeviceMessageImpl<RFXComLighti
      */
     public static int getDimLevelFromPercentType(PercentType pt) {
         return pt.toBigDecimal().multiply(BigDecimal.valueOf(31))
-                .divide(PercentType.HUNDRED.toBigDecimal(), 0, BigDecimal.ROUND_UP).intValue();
+                .divide(PercentType.HUNDRED.toBigDecimal(), 0, RoundingMode.UP).intValue();
     }
 
     /**
@@ -229,7 +230,7 @@ public class RFXComLighting5Message extends RFXComDeviceMessageImpl<RFXComLighti
         value = Math.min(value, 31);
 
         return new PercentType(BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(100))
-                .divide(BigDecimal.valueOf(31), 0, BigDecimal.ROUND_UP).intValue());
+                .divide(BigDecimal.valueOf(31), 0, RoundingMode.UP).intValue());
     }
 
     @Override
index 776b06ff36efea8785148d5d36af708dd056c26f..e5af3962a5eb4041185370fda38b2682083ed310 100644 (file)
@@ -12,8 +12,7 @@
  */
 package org.openhab.binding.rfxcom.internal.messages;
 
-import static java.math.BigDecimal.*;
-import static java.math.RoundingMode.HALF_DOWN;
+import static java.math.RoundingMode.*;
 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
 import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
 
@@ -257,12 +256,12 @@ public class RFXComRFXSensorMessage extends RFXComDeviceMessageImpl<RFXComRFXSen
         BigDecimal supplyVoltage = ((DecimalType) referenceVoltageState).toBigDecimal();
 
         // RH = (((A/D voltage / supply voltage) - 0.16) / 0.0062) / (1.0546 - 0.00216 * temperature)
-        BigDecimal belowTheDivider = adVoltage.divide(supplyVoltage, 4, ROUND_HALF_DOWN)
-                .subtract(HUMIDITY_VOLTAGE_SUBTRACTION).divide(HUMIDITY_VOLTAGE_DIVIDER, 4, ROUND_HALF_DOWN);
+        BigDecimal belowTheDivider = adVoltage.divide(supplyVoltage, 4, HALF_DOWN)
+                .subtract(HUMIDITY_VOLTAGE_SUBTRACTION).divide(HUMIDITY_VOLTAGE_DIVIDER, 4, HALF_DOWN);
         BigDecimal underTheDivider = HUMIDITY_TEMPERATURE_CORRECTION
                 .subtract(HUMIDITY_TEMPERATURE_MULTIPLIER.multiply(temperature));
 
-        return new DecimalType(belowTheDivider.divide(underTheDivider, 4, ROUND_HALF_DOWN));
+        return new DecimalType(belowTheDivider.divide(underTheDivider, 4, HALF_DOWN));
     }
 
     private State handlePressure(DeviceState deviceState) {
@@ -277,14 +276,14 @@ public class RFXComRFXSensorMessage extends RFXComDeviceMessageImpl<RFXComRFXSen
 
         // hPa = ((A/D voltage / supply voltage) + 0.095) / 0.0009
         return new DecimalType((adVoltage.divide(supplyVoltage, 4, HALF_DOWN).add(PRESSURE_ADDITION))
-                .divide(PRESSURE_DIVIDER, 4, ROUND_HALF_DOWN));
+                .divide(PRESSURE_DIVIDER, 4, HALF_DOWN));
     }
 
     private BigDecimal getVoltage() {
         if (miliVoltageTimesTen == null) {
             return null;
         }
-        return miliVoltageTimesTen.divide(ONE_HUNDRED, 100, ROUND_CEILING);
+        return miliVoltageTimesTen.divide(ONE_HUNDRED, 100, CEILING);
     }
 
     @Override
index 1f3f0e6b91c8c6e469eaa94eafa882d07fc69d1c..30f458e757bff5a2a53d1dbd9e7223887b59c5d2 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.robonect.internal;
 
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -25,7 +26,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.http.HttpHeader;
 import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.util.B64Code;
 import org.openhab.binding.robonect.internal.model.ErrorList;
 import org.openhab.binding.robonect.internal.model.ModelParser;
 import org.openhab.binding.robonect.internal.model.MowerInfo;
@@ -177,8 +177,9 @@ public class RobonectClient {
     private void addPreemptiveAuthentication(HttpClient httpClient, RobonectEndpoint endpoint) {
         AuthenticationStore auth = httpClient.getAuthenticationStore();
         URI uri = URI.create(baseUrl);
-        auth.addAuthenticationResult(new BasicResult(HttpHeader.AUTHORIZATION, uri, "Basic "
-                + B64Code.encode(endpoint.getUser() + ":" + endpoint.getPassword(), StandardCharsets.ISO_8859_1)));
+        auth.addAuthenticationResult(
+                new BasicResult(HttpHeader.AUTHORIZATION, uri, "Basic " + Base64.getEncoder().encodeToString(
+                        (endpoint.getUser() + ":" + endpoint.getPassword()).getBytes(StandardCharsets.ISO_8859_1))));
     }
 
     /**
index 64d2206b441f0f54c07ebdb5018c8aa3274e5255..f22f522f45286c2dd48fef334e7c54c1cf3dd92c 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
 /**
  * The goal of this class is to test the model parser to make sure the structures
  * returned from the module can be handled.
- * 
+ *
  * @author Marco Meyer - Initial contribution
  */
 public class ModelParserTest {
@@ -48,12 +48,12 @@ public class ModelParserTest {
         String correctModel = "{\"successful\": false, \"error_code\": 7, \"error_message\": \"Automower already stopped\"}";
         RobonectAnswer answer = subject.parse(correctModel, RobonectAnswer.class);
         assertFalse(answer.isSuccessful());
-        assertEquals(new Integer(7), answer.getErrorCode());
+        assertEquals(Integer.valueOf(7), answer.getErrorCode());
         assertEquals("Automower already stopped", answer.getErrorMessage());
 
         MowerInfo info = subject.parse(correctModel, MowerInfo.class);
         assertFalse(info.isSuccessful());
-        assertEquals(new Integer(7), info.getErrorCode());
+        assertEquals(Integer.valueOf(7), info.getErrorCode());
         assertEquals("Automower already stopped", info.getErrorMessage());
     }
 
@@ -143,7 +143,7 @@ public class ModelParserTest {
         assertTrue(mowerInfo.getStatus().isStopped());
         assertNotNull(mowerInfo.getError());
         assertEquals("Mein Automower ist angehoben", mowerInfo.getError().getErrorMessage());
-        assertEquals(new Integer(15), mowerInfo.getError().getErrorCode());
+        assertEquals(Integer.valueOf(15), mowerInfo.getError().getErrorCode());
         assertEquals("02.05.2017", mowerInfo.getError().getDate());
         assertEquals("20:36:43", mowerInfo.getError().getTime());
         assertEquals("1493757403", mowerInfo.getError().getUnix());
@@ -155,7 +155,7 @@ public class ModelParserTest {
         ErrorList errorList = subject.parse(errorsListResponse, ErrorList.class);
         assertTrue(errorList.isSuccessful());
         assertEquals(10, errorList.getErrors().size());
-        assertEquals(new Integer(15), errorList.getErrors().get(0).getErrorCode());
+        assertEquals(Integer.valueOf(15), errorList.getErrors().get(0).getErrorCode());
         assertEquals("Grasi ist angehoben", errorList.getErrors().get(0).getErrorMessage());
         assertEquals("02.05.2017", errorList.getErrors().get(0).getDate());
         assertEquals("20:36:43", errorList.getErrors().get(0).getTime());
index a1efb1df25b11957e1d28175b0d91934a596c623..7488dc4c2f513ebdac81c1e39e308c5af339abd1 100644 (file)
@@ -43,7 +43,7 @@ public class SeneyeService {
     public int seneyeType;
     private boolean isInitialized;
     private final Gson gson;
-    private HttpClient httpClient = new HttpClient(new SslContextFactory());
+    private HttpClient httpClient = new HttpClient(new SslContextFactory.Client());
     private ScheduledFuture<?> scheduledJob;
 
     public SeneyeService(SeneyeConfigurationParameters config) throws CommunicationException {
index b914e5c7a7e70a6f7796cdaac35515ab420df6f7..3a5726b792c713a3b4256409787caefd86b22029 100644 (file)
@@ -84,8 +84,8 @@ public class SqueezeBoxServerDiscoveryParticipant implements UpnpDiscoveryPartic
 
             String representationPropertyName = "ipAddress";
             properties.put(representationPropertyName, host);
-            properties.put("webport", new Integer(webPort));
-            properties.put("cliPort", new Integer(cliPort));
+            properties.put("webport", Integer.valueOf(webPort));
+            properties.put("cliPort", Integer.valueOf(cliPort));
 
             DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
                     .withRepresentationProperty(representationPropertyName).withLabel(label).build();
index c95b7165764c7c32c5d87fc1201b91e37a98585e..7bb4b63badced4a2b99f09813dd953fbc88a23ea 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.systeminfo.internal.model;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -316,14 +317,14 @@ public class OSHISysteminfo implements SysteminfoInterface {
     @Override
     public @Nullable DecimalType getSensorsCpuTemperature() {
         BigDecimal cpuTemp = new BigDecimal(sensors.getCpuTemperature());
-        cpuTemp = cpuTemp.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
+        cpuTemp = cpuTemp.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
         return cpuTemp.signum() == 1 ? new DecimalType(cpuTemp) : null;
     }
 
     @Override
     public @Nullable DecimalType getSensorsCpuVoltage() {
         BigDecimal cpuVoltage = new BigDecimal(sensors.getCpuVoltage());
-        cpuVoltage = cpuVoltage.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
+        cpuVoltage = cpuVoltage.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
         return cpuVoltage.signum() == 1 ? new DecimalType(cpuVoltage) : null;
     }
 
@@ -464,13 +465,13 @@ public class OSHISysteminfo implements SysteminfoInterface {
 
     private BigDecimal getPercentsValue(double decimalFraction) {
         BigDecimal result = new BigDecimal(decimalFraction * 100);
-        result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
+        result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
         return result;
     }
 
     private BigDecimal getTimeInMinutes(double timeInSeconds) {
         BigDecimal timeInMinutes = new BigDecimal(timeInSeconds / 60);
-        timeInMinutes = timeInMinutes.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_UP);
+        timeInMinutes = timeInMinutes.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.UP);
         return timeInMinutes;
     }
 
@@ -525,7 +526,7 @@ public class OSHISysteminfo implements SysteminfoInterface {
         }
         double processorLoads[] = cpu.getSystemLoadAverage(index + 1);
         BigDecimal result = new BigDecimal(processorLoads[index]);
-        result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
+        result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
         return result;
     }
 
index a2bd5c89e4974b8f03e9596f487e2f2067ecacfd..515e840e3ff293d4719f5535fa5e30cb50b1fb2d 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.tacmi.internal.schema;
 
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,7 +37,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.http.HttpHeader;
 import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.util.B64Code;
 import org.openhab.binding.tacmi.internal.TACmiChannelTypeProvider;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
@@ -109,8 +109,8 @@ public class TACmiSchemaHandler extends BaseThingHandler {
         this.online = false;
         updateStatus(ThingStatus.UNKNOWN);
 
-        this.authHeader = "Basic "
-                + B64Code.encode(config.username + ":" + config.password, StandardCharsets.ISO_8859_1);
+        this.authHeader = "Basic " + Base64.getEncoder()
+                .encodeToString((config.username + ":" + config.password).getBytes(StandardCharsets.ISO_8859_1));
 
         final String serverBase = "http://" + config.host + "/";
         this.serverBase = serverBase;
index b75ff8cd4361f9cca2cbe744205b96bb3a886623..e5e27defff258a5e77d0392bb866d64c89979d6f 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.tado.internal.adapter;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.OffsetDateTime;
 
 import org.openhab.binding.tado.internal.TadoBindingConstants.HvacMode;
@@ -48,7 +49,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dennis Frommknecht - Initial contribution
  * @author Andrew Fiddian-Green - Added Low Battery Alarm, A/C Power and Open Window channels
- * 
+ *
  */
 public class TadoZoneStateAdapter {
     private ZoneState zoneState;
@@ -199,7 +200,7 @@ public class TadoZoneStateAdapter {
     }
 
     private static DecimalType toDecimalType(double value) {
-        BigDecimal decimal = new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP);
+        BigDecimal decimal = new BigDecimal(value).setScale(2, RoundingMode.HALF_UP);
         return new DecimalType(decimal);
     }
 
index 6aede76182425c061b8766287256cbe524ef60eb..32a4881702c6aca723f18f833944699bebd9ccf5 100644 (file)
@@ -31,7 +31,7 @@ public abstract class BaseHomeThingHandler extends BaseThingHandler {
 
     public Long getHomeId() {
         TadoHomeHandler handler = getHomeHandler();
-        return handler != null ? handler.getHomeId() : new Long(0);
+        return handler != null ? handler.getHomeId() : Long.valueOf(0);
     }
 
     protected TadoHomeHandler getHomeHandler() {
index 964f36c43b85174e5d0bc6fb8df3c2b2003a4283..61932b4d73e918b9ffa89c7242b34a40c829ea68 100644 (file)
@@ -36,7 +36,6 @@ import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.client.util.FutureResponseListener;
 import org.eclipse.jetty.http.HttpHeader;
 import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.util.B64Code;
 import org.openhab.binding.telegram.internal.TelegramHandler;
 import org.openhab.core.automation.annotation.ActionInput;
 import org.openhab.core.automation.annotation.RuleAction;
@@ -314,7 +313,8 @@ public class TelegramActions implements ThingActions {
                     AuthenticationStore auth = client.getAuthenticationStore();
                     URI uri = URI.create(photoURL);
                     auth.addAuthenticationResult(new BasicResult(HttpHeader.AUTHORIZATION, uri,
-                            "Basic " + B64Code.encode(username + ":" + password, StandardCharsets.ISO_8859_1)));
+                            "Basic " + Base64.getEncoder().encodeToString(
+                                    (username + ":" + password).getBytes(StandardCharsets.ISO_8859_1))));
                 }
                 try {
                     // API has 10mb limit to jpg file size, without this it can only accept 2mb
index 9481695a54ab575dd0039776797818fed6d97685..9f709c3f90a50b0ca01c3b15f65545f716a08f0f 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.tellstick.internal.core;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Collections;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -119,7 +120,7 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
             case JNA.CLibrary.TELLSTICK_DIM:
                 dimValue = new BigDecimal(((TellstickDevice) device).getData());
                 dimValue = dimValue.multiply(new BigDecimal(100));
-                dimValue = dimValue.divide(new BigDecimal(255), 0, BigDecimal.ROUND_HALF_UP);
+                dimValue = dimValue.divide(new BigDecimal(255), 0, RoundingMode.HALF_UP);
                 break;
             default:
                 logger.warn("Could not handle {} for {}", ((TellstickDevice) device).getStatus(), device);
index ecdd033d507cd0acf34ca46bc7e23b2f59913b5b..12cffa05f5af5b92d3c590518fb901f804e9bf0c 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.tellstick.internal.live;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -248,7 +249,7 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
             case JNA.CLibrary.TELLSTICK_DIM:
                 dimValue = new BigDecimal(((TellstickNetDevice) device).getStatevalue());
                 dimValue = dimValue.multiply(new BigDecimal(100));
-                dimValue = dimValue.divide(new BigDecimal(255), 0, BigDecimal.ROUND_HALF_UP);
+                dimValue = dimValue.divide(new BigDecimal(255), 0, RoundingMode.HALF_UP);
                 break;
             default:
                 logger.warn("Could not handle {} for {}", (((TellstickNetDevice) device).getState()), device);
index 425f76e29ae2600be0af9938a8b8e195363d66d6..1ab4b9dc7c8b189fdb409b77aa3fcadd1f5cd81b 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.tellstick.internal.local;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
@@ -221,7 +222,7 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
             case JNA.CLibrary.TELLSTICK_DIM:
                 dimValue = new BigDecimal(((TellstickLocalDeviceDTO) device).getStatevalue());
                 dimValue = dimValue.multiply(new BigDecimal(100));
-                dimValue = dimValue.divide(new BigDecimal(255), 0, BigDecimal.ROUND_HALF_UP);
+                dimValue = dimValue.divide(new BigDecimal(255), 0, RoundingMode.HALF_UP);
                 break;
             default:
                 logger.warn("Could not handle {} for {}", (((TellstickLocalDeviceDTO) device).getState()), device);
index 84f7f468c187b5d914ac5864408a6be12d389e39..952cbc584bc3eae45082221c38fbd3f521bbe97a 100644 (file)
@@ -69,7 +69,7 @@ public class TibberHandler extends BaseThingHandler {
     private static final int REQUEST_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(20);
     private final Logger logger = LoggerFactory.getLogger(TibberHandler.class);
     private final Properties httpHeader = new Properties();
-    private final SslContextFactory sslContextFactory = new SslContextFactory(true);
+    private final SslContextFactory sslContextFactory = new SslContextFactory.Client(true);
     private final Executor websocketExecutor = ThreadPoolManager.getPool("tibber.websocket");
     private TibberConfiguration tibberConfig = new TibberConfiguration();
     private @Nullable TibberWebSocketListener socket;
index 9511b609eb4fcd0046e07d5b15d2c39895ed67fa..e184c9c25b6f7cb0910cdb2703989f5f8fd667e0 100644 (file)
@@ -72,7 +72,7 @@ public class TradfriVersionTest {
         assertTrue(VERSION.equals(new TradfriVersion(VERSION_STRING)));
 
         assertFalse(VERSION.equals((TradfriVersion) null));
-        assertFalse(VERSION.equals(new Integer("1")));
+        assertFalse(VERSION.equals(Integer.valueOf("1")));
         assertFalse(VERSION.equals(new TradfriVersion("1.2.5")));
     }
 
index acf86a41d87d374ab9503b2631e71d8da185fc0b..36d7d395f3ffcdb48769c9c7e7cd20d104d9d2d5 100644 (file)
@@ -46,7 +46,7 @@ public class UniFiThingHandlerFactory extends BaseThingHandlerFactory {
     public UniFiThingHandlerFactory(@Reference final HttpClientFactory httpClientFactory) {
         // [wip] mgb: disabled due to missing common name attributes with certs
         // this.httpClient = httpClientFactory.getCommonHttpClient();
-        httpClient = new HttpClient(new SslContextFactory(true));
+        httpClient = new HttpClient(new SslContextFactory.Client(true));
         try {
             httpClient.start();
         } catch (Exception e) {
index 37116b6932e7ec6a82696c6c7e4f1d1d10ec415f..153ae2ba429032eeb46f5b827e7f8d6e122d3be7 100644 (file)
@@ -106,7 +106,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
 
     public VenstarThermostatHandler(Thing thing) {
         super(thing);
-        httpClient = new HttpClient(new SslContextFactory(true));
+        httpClient = new HttpClient(new SslContextFactory.Client(true));
         gson = new GsonBuilder().registerTypeAdapter(VenstarSystemState.class, new VenstarSystemStateSerializer())
                 .registerTypeAdapter(VenstarSystemMode.class, new VenstarSystemModeSerializer()).create();
 
index 0a60f42b093403f4f560962f46f633149c399972..a84809ac6cfe99d38fc828d83e9efac4dcc812e0 100644 (file)
@@ -16,6 +16,7 @@ import static java.lang.Math.*;
 
 import java.awt.Color;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.HSBType;
@@ -92,13 +93,13 @@ public class LEDStateDTO {
         PercentType b = new PercentType(new BigDecimal(hsv[2]).multiply(new BigDecimal(100.0)));
         HSBType hsbType = new HSBType(h, s, b);
 
-        PercentType w = new PercentType(new BigDecimal(white).divide(new BigDecimal(255.0), 3, BigDecimal.ROUND_HALF_UP)
+        PercentType w = new PercentType(new BigDecimal(white).divide(new BigDecimal(255.0), 3, RoundingMode.HALF_UP)
+                .multiply(new BigDecimal(100.0)));
+        PercentType w2 = new PercentType(new BigDecimal(white2).divide(new BigDecimal(255.0), 3, RoundingMode.HALF_UP)
                 .multiply(new BigDecimal(100.0)));
-        PercentType w2 = new PercentType(new BigDecimal(white2)
-                .divide(new BigDecimal(255.0), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100.0)));
 
         // Range: 0x00 .. 0x1F. Speed is inversed
-        BigDecimal ps = new BigDecimal(programSpeed).divide(new BigDecimal(0x1f), 2, BigDecimal.ROUND_HALF_UP)
+        BigDecimal ps = new BigDecimal(programSpeed).divide(new BigDecimal(0x1f), 2, RoundingMode.HALF_UP)
                 .multiply(new BigDecimal(100.0));
         PercentType e = new PercentType(new BigDecimal(100.0).subtract(ps));
 
index 63335021b0d7f4996260d75cd63cc69314e456ee..6ee8b5042663ed5110d3ec950190759baf636f00 100644 (file)
@@ -181,7 +181,7 @@ public class ZWayZAutomationDeviceHandler extends ZWayDeviceHandler {
             }
 
             Calendar lastUpdateOfDevice = Calendar.getInstance();
-            lastUpdateOfDevice.setTimeInMillis(new Long(device.getUpdateTime()) * 1000);
+            lastUpdateOfDevice.setTimeInMillis(Long.valueOf(device.getUpdateTime()) * 1000);
 
             if (lastUpdate == null || lastUpdateOfDevice.after(lastUpdate)) {
                 lastUpdate = lastUpdateOfDevice;
index 944df80e82bc5e5264093c661baf6cbca13339ab..ce4b8c16b6f484c56df6dbf03b2856a10ab8bdbc 100644 (file)
@@ -211,7 +211,8 @@ public class ZWayZWaveDeviceHandler extends ZWayDeviceHandler {
         }
 
         Calendar lastUpdateOfDevice = Calendar.getInstance();
-        lastUpdateOfDevice.setTimeInMillis(new Long(zwaveDevice.getData().getLastReceived().getUpdateTime()) * 1000);
+        lastUpdateOfDevice
+                .setTimeInMillis(Long.valueOf(zwaveDevice.getData().getLastReceived().getUpdateTime()) * 1000);
 
         if (lastUpdate == null || lastUpdateOfDevice.after(lastUpdate)) {
             lastUpdate = lastUpdateOfDevice;
index fc2668ca88d7b91cfcb6a3450b935fb0ac18878e..05cd3d37bf8da372d51b6fd3cb0bf7d25c6602ce 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.io.imperihome.internal.model.device;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import org.apache.commons.lang3.StringUtils;
 import org.openhab.core.items.Item;
@@ -84,6 +85,6 @@ public class RgbLightDevice extends AbstractEnergyLinkDevice {
 
     private int convertPercentToByte(PercentType percent) {
         return percent.toBigDecimal().multiply(BigDecimal.valueOf(255))
-                .divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).intValue();
+                .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).intValue();
     }
 }
index a3e6cbf371c74f995613aa8e5370db1127d64d06..d0671e30de790122ec3779e9dec4abf1811cbe87 100644 (file)
@@ -108,7 +108,7 @@ public class AstroValidConfigurationTest {
     public void testIfTheIntervalForASunThingIsLessThan1_theThingStatusBecomesOFFLINE() {
         Configuration thingConfiguration = new Configuration();
         thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
-        thingConfiguration.put(INTERVAL_PROPERTY, new Integer(0));
+        thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(0));
         assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
     }
 
@@ -116,7 +116,7 @@ public class AstroValidConfigurationTest {
     public void testIfTheIntervalForAMoonThingIsLessThan1_theThingStatusBecomesOFFLINE() {
         Configuration thingConfiguration = new Configuration();
         thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
-        thingConfiguration.put(INTERVAL_PROPERTY, new Integer(0));
+        thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(0));
         assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
     }
 
@@ -124,7 +124,7 @@ public class AstroValidConfigurationTest {
     public void testIfTheIntervalForASunThingIsGreaterThan86400_theThingStatusBecomesOFFLINE() {
         Configuration thingConfiguration = new Configuration();
         thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
-        thingConfiguration.put(INTERVAL_PROPERTY, new Integer(86401));
+        thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(86401));
         assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
     }
 
@@ -132,7 +132,7 @@ public class AstroValidConfigurationTest {
     public void testIfTheIntervalForAMoonThingIsGreaterThan86400_theThingStatusBecomesOFFLINE() {
         Configuration thingConfiguration = new Configuration();
         thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
-        thingConfiguration.put(INTERVAL_PROPERTY, new Integer(86401));
+        thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(86401));
         assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
     }