Source:
private void updateChannel(String channelId) { Channel channel = getThing().getChannel(channelId); if (channel != null && isLinked(channelId)) { String sourceUnit = (String) channel.getConfiguration() .get(WeatherUndergroundBindingConstants.PROPERTY_SOURCE_UNIT); if (sourceUnit == null) { sourceUnit = ""; } else if (sourceUnit.length() > 0) { sourceUnit = sourceUnit.substring(0, 1).toUpperCase() + sourceUnit.substring(1); } Object value; try { value = WeatherUndergroundJsonUtils.getValue(channelId + sourceUnit, weatherData); } catch (Exception e) { logger.debug("Update channel {}: Can't get value: {}", channelId, e.getMessage()); return; } State state = null; if (value == null) { state = UnDefType.UNDEF; } else if (value instanceof ZonedDateTime) { state = new DateTimeType((ZonedDateTime) value); } else if (value instanceof BigDecimal) { state = new DecimalType((BigDecimal) value); } else if (value instanceof Integer) { state = new DecimalType(BigDecimal.valueOf(((Integer) value).longValue())); } else if (value instanceof String) { state = new StringType(value.toString()); } else if (value instanceof URL) { state = HttpUtil.downloadImage(((URL) value).toExternalForm()); if (state == null) { logger.debug("Failed to download the content of URL {}", ((URL) value).toExternalForm()); state = UnDefType.UNDEF; } } else { logger.debug("Update channel {}: Unsupported value type {}", channelId, value.getClass().getSimpleName()); } logger.debug("Update channel with state ({})", channelId, (state == null) ? "null" : state.toString(), (value == null) ? "null" : value.getClass().getSimpleName()); if (state != null) { updateState(channelId, state); } } }

Target:
private void updateChannel(String channelId) { Channel channel = getThing().getChannel(channelId); if (channel != null && isLinked(channelId)) { String sourceUnit = (String) channel.getConfiguration() .get(WeatherUndergroundBindingConstants.PROPERTY_SOURCE_UNIT); if (sourceUnit == null) { sourceUnit = ""; } else if (sourceUnit.length() > 0) { sourceUnit = sourceUnit.substring(0, 1).toUpperCase() + sourceUnit.substring(1); } Object value; try { value = WeatherUndergroundJsonUtils.getValue(channelId + sourceUnit, weatherData); } catch (Exception e) { logger.debug("Update channel {}: Can't get value: {}", channelId, e.getMessage()); return; } State state = null; if (value == null) { state = UnDefType.UNDEF; } else if (value instanceof Calendar) { state = new DateTimeType((Calendar) value); } else if (value instanceof BigDecimal) { state = new DecimalType((BigDecimal) value); } else if (value instanceof Integer) { state = new DecimalType(BigDecimal.valueOf(((Integer) value).longValue())); } else if (value instanceof String) { state = new StringType(value.toString()); } else if (value instanceof URL) { state = HttpUtil.downloadImage(((URL) value).toExternalForm()); if (state == null) { logger.debug("Failed to download the content of URL {}", ((URL) value).toExternalForm()); state = UnDefType.UNDEF; } } else { logger.debug("Update channel {}: Unsupported value type {}", channelId, value.getClass().getSimpleName()); } logger.debug("Update channel with state ({})", channelId, (state == null) ? "null" : state.toString(), (value == null) ? "null" : value.getClass().getSimpleName()); if (state != null) { updateState(channelId, state); } } }