diff --git a/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/discovery/AutelisDiscoveryParticipant.java b/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/discovery/AutelisDiscoveryParticipant.java index 67a29b9a9fb5e..23c859c5ef95c 100644 --- a/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/discovery/AutelisDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/discovery/AutelisDiscoveryParticipant.java @@ -65,7 +65,7 @@ public Set getSupportedThingTypeUIDs() { 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(); diff --git a/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java b/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java index b80a02c66ebea..3669f87a56ed1 100644 --- a/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java +++ b/bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java @@ -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.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 @@ private void configure() { } 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); diff --git a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account/SmartherAccountService.java b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account/SmartherAccountService.java index b3914acb496c1..30fe6f84f5f12 100644 --- a/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account/SmartherAccountService.java +++ b/bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account/SmartherAccountService.java @@ -22,13 +22,13 @@ 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 handlers = new ConcurrentHashSet<>(); + private final Set handlers = ConcurrentHashMap.newKeySet(); private @Nullable HttpService httpService; private @Nullable BundleContext bundleContext; diff --git a/bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java b/bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java index 60a800c93c09c..e9ef9043f93c5 100644 --- a/bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java +++ b/bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java @@ -357,7 +357,7 @@ public boolean sendFunction(String address, int function, int dims) throws Inval */ 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))))); } diff --git a/bundles/org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler/HVACHandler.java b/bundles/org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler/HVACHandler.java index 509e224b6f0f1..4eb327b1147c4 100644 --- a/bundles/org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler/HVACHandler.java +++ b/bundles/org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler/HVACHandler.java @@ -136,7 +136,7 @@ public void handleCommand(final ChannelUID channelUID, final Command command) { 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 void handleCommand(final ChannelUID channelUID, final Command command) { 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); } diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinHttpClientFactoryImpl.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinHttpClientFactoryImpl.java index 947a388929f67..b7729ef13492d 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinHttpClientFactoryImpl.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinHttpClientFactoryImpl.java @@ -62,7 +62,7 @@ protected void deactivate() { 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"); diff --git a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java index ee37d31a2d489..2225d95d6d371 100644 --- a/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java +++ b/bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java @@ -15,6 +15,7 @@ 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 @@ private int fromValueToPercent(int value, int max) { 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; } diff --git a/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse/BaseDmxChannel.java b/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse/BaseDmxChannel.java index 88292e44bada4..2abd1fa9e5698 100644 --- a/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse/BaseDmxChannel.java +++ b/bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse/BaseDmxChannel.java @@ -95,9 +95,10 @@ public int compareTo(BaseDmxChannel otherDmxChannel) { 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; } diff --git a/bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java b/bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java index 49da817f56a51..5284de881c6ce 100644 --- a/bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java +++ b/bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java @@ -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 byte[] color(HSBType color) { */ 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(); } /** diff --git a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java index 1869a1e54e10a..73ccda0c8ee46 100644 --- a/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java +++ b/bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java @@ -16,6 +16,7 @@ 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 @@ private String logInfo(String msgKey, Object... arg) { 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() { diff --git a/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpHandlerFactory.java b/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpHandlerFactory.java index 3318fb9d4385c..064984de0b398 100644 --- a/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpHandlerFactory.java +++ b/bundles/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpHandlerFactory.java @@ -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(); diff --git a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ChannelUtils.java b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ChannelUtils.java index e8b3fd52eccd1..2bb837d5fc58d 100644 --- a/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ChannelUtils.java +++ b/bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ChannelUtils.java @@ -202,7 +202,7 @@ private static void addChannelsFromProjectFile(Thing thing, NodeList nodes, Stri 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(); diff --git a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyWebSocket.java b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyWebSocket.java index 5b0a5caa11a5c..61aa8d650d743 100644 --- a/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyWebSocket.java +++ b/bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/InnogyWebSocket.java @@ -149,7 +149,7 @@ public void onMessage(String msg) { } 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; diff --git a/bundles/org.openhab.binding.ism8/src/main/java/org/openhab/binding/ism8/server/Server.java b/bundles/org.openhab.binding.ism8/src/main/java/org/openhab/binding/ism8/server/Server.java index f0d6fcfd69eb0..8b2ac26cce94c 100644 --- a/bundles/org.openhab.binding.ism8/src/main/java/org/openhab/binding/ism8/server/Server.java +++ b/bundles/org.openhab.binding.ism8/src/main/java/org/openhab/binding/ism8/server/Server.java @@ -85,6 +85,7 @@ public boolean getConnected() { * Starts the server * */ + @Override public void run() { this.startRetries = 0; while (!this.isInterrupted()) { @@ -132,7 +133,7 @@ public void addDataPoint(int id, String knxType, String description) { IDataPoint dp = DataPointFactory.createDataPoint(id, knxType, description); if (dp != null) { - this.dataPoints.put(new Integer(id), dp); + this.dataPoints.put(Integer.valueOf(id), dp); } } diff --git a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapper.java b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapper.java index 605f18a7b271c..ef2f93085dca4 100644 --- a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapper.java +++ b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapper.java @@ -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 @@ private int getMainNumber(String dptID) { */ 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(); } } diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java index 812371394eaf7..d1927d1c91062 100644 --- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java +++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java @@ -402,7 +402,7 @@ public String getLogId(@Nullable MACAddress macAddress, @Nullable InetSocketAddr 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 @@ private LifxProduct getProduct() { // 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) { diff --git a/bundles/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/handler/NestRedirectUrlSupplier.java b/bundles/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/handler/NestRedirectUrlSupplier.java index 3d027ced5f32e..90d08da70d14b 100644 --- a/bundles/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/handler/NestRedirectUrlSupplier.java +++ b/bundles/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/handler/NestRedirectUrlSupplier.java @@ -71,7 +71,7 @@ public void resetCache() { * @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, diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java index 16cbaeda2d8d0..909187a1895c2 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java @@ -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 static State toDecimalType(double value) { } 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) { diff --git a/bundles/org.openhab.binding.paradoxalarm/src/test/java/main/Main.java b/bundles/org.openhab.binding.paradoxalarm/src/test/java/main/Main.java index d8e646565909d..7f9f893fc904e 100644 --- a/bundles/org.openhab.binding.paradoxalarm/src/test/java/main/Main.java +++ b/bundles/org.openhab.binding.paradoxalarm/src/test/java/main/Main.java @@ -100,7 +100,7 @@ private static void readArguments(String[] args) { ipAddress = parser.getIpAddress(); logger.info("IP150 IP Address: {}", ipAddress); - port = new Integer(parser.getPort()); + port = Integer.parseInt(parser.getPort()); logger.info("IP150 port: {}", port); } } diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java index 5c660cd620cd4..2c84bcbf71b6a 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting2Message.java @@ -18,6 +18,7 @@ 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 String getDeviceId() { */ 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 static PercentType getPercentTypeFromDimLevel(int value) { 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 diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java index adb91f3c70049..3602810be1ac8 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComLighting5Message.java @@ -17,6 +17,7 @@ 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 String getDeviceId() { */ 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 static PercentType getPercentTypeFromDimLevel(int value) { 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 diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java index 776b06ff36efe..e5af3962a5eb4 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComRFXSensorMessage.java @@ -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 @@ private State handleHumidity(DeviceState deviceState) { 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 @@ private State handlePressure(DeviceState deviceState) { // 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 diff --git a/bundles/org.openhab.binding.robonect/src/main/java/org/openhab/binding/robonect/internal/RobonectClient.java b/bundles/org.openhab.binding.robonect/src/main/java/org/openhab/binding/robonect/internal/RobonectClient.java index 1f3f0e6b91c8c..30f458e757bff 100644 --- a/bundles/org.openhab.binding.robonect/src/main/java/org/openhab/binding/robonect/internal/RobonectClient.java +++ b/bundles/org.openhab.binding.robonect/src/main/java/org/openhab/binding/robonect/internal/RobonectClient.java @@ -14,6 +14,7 @@ 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.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 RobonectClient(HttpClient httpClient, RobonectEndpoint endpoint) { 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)))); } /** diff --git a/bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/model/ModelParserTest.java b/bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/model/ModelParserTest.java index 64d2206b441f0..f22f522f45286 100644 --- a/bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/model/ModelParserTest.java +++ b/bundles/org.openhab.binding.robonect/src/test/java/org/openhab/binding/robonect/internal/model/ModelParserTest.java @@ -22,7 +22,7 @@ /** * 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 void shouldParseErrorResponseOnAllResponseTypes() { 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 void shouldParseCorrectErrorModelInErrorState() { 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 void shouldParseErrorsList() { 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()); diff --git a/bundles/org.openhab.binding.seneye/src/main/java/org/openhab/binding/seneye/internal/SeneyeService.java b/bundles/org.openhab.binding.seneye/src/main/java/org/openhab/binding/seneye/internal/SeneyeService.java index a1efb1df25b11..7488dc4c2f513 100644 --- a/bundles/org.openhab.binding.seneye/src/main/java/org/openhab/binding/seneye/internal/SeneyeService.java +++ b/bundles/org.openhab.binding.seneye/src/main/java/org/openhab/binding/seneye/internal/SeneyeService.java @@ -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 { diff --git a/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/discovery/SqueezeBoxServerDiscoveryParticipant.java b/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/discovery/SqueezeBoxServerDiscoveryParticipant.java index b914e5c7a7e70..3a5726b792c71 100644 --- a/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/discovery/SqueezeBoxServerDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/discovery/SqueezeBoxServerDiscoveryParticipant.java @@ -84,8 +84,8 @@ public DiscoveryResult createResult(RemoteDevice device) { 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(); diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java index c95b7165764c7..7bb4b63badced 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java @@ -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 StringType getDisplayInformation(int index) throws DeviceNotFoundExceptio @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 @@ private long getSizeInMB(long sizeInBytes) { 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 @@ private BigDecimal getAvarageCpuLoad(int timeInMunutes) { } 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; } diff --git a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java index a2bd5c89e4974..515e840e3ff29 100644 --- a/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java +++ b/bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/TACmiSchemaHandler.java @@ -14,6 +14,7 @@ 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.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 void initialize() { 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; diff --git a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java index b75ff8cd4361f..e5e27defff258 100644 --- a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java +++ b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java @@ -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 @@ * * @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 boolean isPowerOn() { } 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); } diff --git a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/BaseHomeThingHandler.java b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/BaseHomeThingHandler.java index 6aede76182425..32a4881702c6a 100644 --- a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/BaseHomeThingHandler.java +++ b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/BaseHomeThingHandler.java @@ -31,7 +31,7 @@ public BaseHomeThingHandler(Thing thing) { 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() { diff --git a/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java b/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java index 964f36c43b851..61932b4d73e91 100644 --- a/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java +++ b/bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java @@ -36,7 +36,6 @@ 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 boolean sendTelegramPhoto(@ActionInput(name = "chatId") @Nullable Long ch 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 diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java index 9481695a54ab5..9f709c3f90a50 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java @@ -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 BigDecimal calcDimValue(Device device) { 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); diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java index ecdd033d507cd..12cffa05f5af5 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java @@ -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 BigDecimal calcDimValue(Device device) { 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); diff --git a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java index 425f76e29ae26..1ab4b9dc7c8b1 100644 --- a/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java +++ b/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java @@ -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 BigDecimal calcDimValue(Device device) { 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); diff --git a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java index 84f7f468c187b..952cbc584bc3e 100644 --- a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java +++ b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java @@ -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; diff --git a/bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model/TradfriVersionTest.java b/bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model/TradfriVersionTest.java index 9511b609eb4fc..e184c9c25b6f7 100644 --- a/bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model/TradfriVersionTest.java +++ b/bundles/org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model/TradfriVersionTest.java @@ -72,7 +72,7 @@ public void testEquals() { 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"))); } diff --git a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiThingHandlerFactory.java b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiThingHandlerFactory.java index acf86a41d87d3..36d7d395f3ffc 100644 --- a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiThingHandlerFactory.java +++ b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiThingHandlerFactory.java @@ -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) { diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java index 37116b6932e7e..153ae2ba42903 100644 --- a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java +++ b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java @@ -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(); diff --git a/bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler/LEDStateDTO.java b/bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler/LEDStateDTO.java index 0a60f42b09340..a84809ac6cfe9 100644 --- a/bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler/LEDStateDTO.java +++ b/bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler/LEDStateDTO.java @@ -16,6 +16,7 @@ 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 static LEDStateDTO valueOf(int state, int program, int programSpeed, int 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)); diff --git a/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZAutomationDeviceHandler.java b/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZAutomationDeviceHandler.java index 63335021b0d7f..6ee8b5042663e 100644 --- a/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZAutomationDeviceHandler.java +++ b/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZAutomationDeviceHandler.java @@ -181,7 +181,7 @@ protected void refreshLastUpdate() { } 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; diff --git a/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZWaveDeviceHandler.java b/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZWaveDeviceHandler.java index 944df80e82bc5..ce4b8c16b6f48 100644 --- a/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZWaveDeviceHandler.java +++ b/bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZWaveDeviceHandler.java @@ -211,7 +211,8 @@ protected void refreshLastUpdate() { } 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; diff --git a/bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RgbLightDevice.java b/bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RgbLightDevice.java index fc2668ca88d7b..05cd3d37bf8da 100644 --- a/bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RgbLightDevice.java +++ b/bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RgbLightDevice.java @@ -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 @@ private String toHex(int value) { 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(); } } diff --git a/itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroValidConfigurationTest.java b/itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroValidConfigurationTest.java index a3e6cbf371c74..d0671e30de790 100644 --- a/itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroValidConfigurationTest.java +++ b/itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test/AstroValidConfigurationTest.java @@ -108,7 +108,7 @@ public void testIfTheLongitudeForAMoonThingIsNull_theThingStatusBecomesOFFLINE() 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 void testIfTheIntervalForASunThingIsLessThan1_theThingStatusBecomesOFFLIN 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 void testIfTheIntervalForAMoonThingIsLessThan1_theThingStatusBecomesOFFLI 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 void testIfTheIntervalForASunThingIsGreaterThan86400_theThingStatusBecome 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); }