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();
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;
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;
}
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);
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;
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;
*/
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)))));
}
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);
}
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);
}
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");
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;
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;
}
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;
}
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;
*/
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();
}
/**
import java.io.IOException;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.net.DatagramSocket;
import java.time.Instant;
import java.util.List;
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() {
*/
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;
@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();
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();
}
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;
* Starts the server
*
*/
+ @Override
public void run() {
this.startRetries = 0;
while (!this.isInterrupted()) {
IDataPoint dp = DataPointFactory.createDataPoint(id, knxType, description);
if (dp != null) {
- this.dataPoints.put(new Integer(id), dp);
+ this.dataPoints.put(Integer.valueOf(id), dp);
}
}
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;
*/
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();
}
}
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() {
// 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) {
* @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,
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;
}
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) {
ipAddress = parser.getIpAddress();
logger.info("IP150 IP Address: {}", ipAddress);
- port = new Integer(parser.getPort());
+ port = Integer.parseInt(parser.getPort());
logger.info("IP150 port: {}", port);
}
}
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;
*/
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();
}
/**
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
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;
*/
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();
}
/**
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
*/
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;
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) {
// 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
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;
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;
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))));
}
/**
/**
* 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 {
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());
}
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());
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());
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 {
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();
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;
@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;
}
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;
}
}
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;
}
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;
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;
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;
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;
*
* @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;
}
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);
}
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() {
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;
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
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;
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);
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;
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);
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;
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);
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;
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")));
}
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) {
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();
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;
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));
}
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;
}
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;
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;
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();
}
}
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);
}
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);
}
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);
}
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);
}