Fixes 47 SAT UseCollectionIsEmpty findings.
Signed-off-by: Wouter Born <github@maindrain.net>
if ((stateDeviceSerialNumber == null && device.serialNumber == null)
|| (stateDeviceSerialNumber != null && stateDeviceSerialNumber.equals(device.serialNumber))) {
List<PairedDevice> pairedDeviceList = state.getPairedDeviceList();
- if (pairedDeviceList.size() > 0) {
+ if (!pairedDeviceList.isEmpty()) {
html.append("<table><tr><th align='left'>Name</th><th align='left'>Value</th></tr>");
for (PairedDevice pairedDevice : pairedDeviceList) {
html.append("<tr><td>");
}
Set<SmartHomeDevice> supportedChildren = SmartHomeDeviceHandler.getSupportedSmartHomeDevices(shg,
deviceList);
- if (supportedChildren.size() == 0) {
+ if (supportedChildren.isEmpty()) {
// No children with an supported interface
continue;
}
while (isRunning.get()) {
try {
// if no listeners, we don't want to start dispatching yet.
- if (listeners.size() == 0) {
+ if (listeners.isEmpty()) {
Thread.sleep(250);
continue;
}
}
private void updateShortLongPressButton(List<ButtonModel> buttons) {
- ButtonModel shortPressButton = buttons.size() > 0 ? buttons.get(0) : null;
+ ButtonModel shortPressButton = !buttons.isEmpty() ? buttons.get(0) : null;
ButtonModel longPressButton = buttons.size() > 1 ? buttons.get(1) : null;
ButtonModel lastPressedButton = shortPressButton != null && (longPressButton == null
|| shortPressButton.getLastpressedtimestamp() > longPressButton.getLastpressedtimestamp())
Collection<ComfoAirCommand> affectedReadCommands = ComfoAirCommandType
.getAffectedReadCommands(channelId, keysToUpdate);
- if (affectedReadCommands.size() > 0) {
+ if (!affectedReadCommands.isEmpty()) {
Runnable updateThread = new AffectedItemsUpdateThread(affectedReadCommands);
affectedItemsPoller = scheduler.schedule(updateThread, 3, TimeUnit.SECONDS);
}
private State getHotWaterDemandState() {
final List<HotWaterDTO> hotWater = getData().hotWater;
- return OnOffType.from(hotWater.size() >= 1 && "ON".equalsIgnoreCase(hotWater.get(0).getHotWaterRelayState()));
+ return OnOffType.from(!hotWater.isEmpty() && "ON".equalsIgnoreCase(hotWater.get(0).getHotWaterRelayState()));
}
private State getManualModeState() {
final List<HotWaterDTO> hotWater = getData().hotWater;
- return OnOffType.from(hotWater.size() >= 1 && "MANUAL".equalsIgnoreCase(hotWater.get(0).getMode()));
+ return OnOffType.from(!hotWater.isEmpty() && "MANUAL".equalsIgnoreCase(hotWater.get(0).getMode()));
}
private State getSetPointState() {
final List<HotWaterDTO> hotWater = getData().hotWater;
- return OnOffType.from(hotWater.size() >= 1 && "ON".equalsIgnoreCase(hotWater.get(0).getWaterHeatingState()));
+ return OnOffType.from(!hotWater.isEmpty() && "ON".equalsIgnoreCase(hotWater.get(0).getWaterHeatingState()));
}
private void setManualMode(final boolean manualMode) throws DraytonWiserApiException {
* @return true if this CosemObjectType support the requested number of values, false otherwise.
*/
public boolean supportsNrOfValues(int nrOfValues) {
- if (repeatingDescriptors.size() == 0) {
+ if (repeatingDescriptors.isEmpty()) {
return nrOfValues == descriptors.size();
} else {
/* There are repeating descriptors */
private synchronized void discoverSensors() {
List<Thing> thermostatThings = bridgeHandler.getThing().getThings();
- if (thermostatThings.size() == 0) {
+ if (thermostatThings.isEmpty()) {
logger.debug("EcobeeDiscovery: Skipping sensor discovery because there are no thermostat things");
return;
}
if (processedData.size() > i) {
State state = UnDefType.UNDEF;
List<String> departures = processedData.get(i).departures;
+ int departuresCount = departures.size();
List<String> estimatedFlags = processedData.get(i).estimatedFlags;
+ int esitmatedFlagsCount = estimatedFlags.size();
switch (channelId) {
case EnturNoBindingConstants.CHANNEL_DEPARTURE_01:
- state = departures.size() > 0 ? getDateTimeTypeState(departures.get(0)) : state;
+ state = departuresCount > 0 ? getDateTimeTypeState(departures.get(0)) : state;
break;
case EnturNoBindingConstants.CHANNEL_DEPARTURE_02:
- state = departures.size() > 1 ? getDateTimeTypeState(departures.get(1)) : state;
+ state = departuresCount > 1 ? getDateTimeTypeState(departures.get(1)) : state;
break;
case EnturNoBindingConstants.CHANNEL_DEPARTURE_03:
- state = departures.size() > 2 ? getDateTimeTypeState(departures.get(2)) : state;
+ state = departuresCount > 2 ? getDateTimeTypeState(departures.get(2)) : state;
break;
case EnturNoBindingConstants.CHANNEL_DEPARTURE_04:
- state = departures.size() > 3 ? getDateTimeTypeState(departures.get(3)) : state;
+ state = departuresCount > 3 ? getDateTimeTypeState(departures.get(3)) : state;
break;
case EnturNoBindingConstants.CHANNEL_DEPARTURE_05:
- state = departures.size() > 4 ? getDateTimeTypeState(departures.get(4)) : state;
+ state = departuresCount > 4 ? getDateTimeTypeState(departures.get(4)) : state;
break;
case EnturNoBindingConstants.ESTIMATED_FLAG_01:
- state = estimatedFlags.size() > 0 ? getStringTypeState(estimatedFlags.get(0)) : state;
+ state = esitmatedFlagsCount > 0 ? getStringTypeState(estimatedFlags.get(0)) : state;
break;
case EnturNoBindingConstants.ESTIMATED_FLAG_02:
- state = estimatedFlags.size() > 1 ? getStringTypeState(estimatedFlags.get(1)) : state;
+ state = esitmatedFlagsCount > 1 ? getStringTypeState(estimatedFlags.get(1)) : state;
break;
case EnturNoBindingConstants.ESTIMATED_FLAG_03:
- state = estimatedFlags.size() > 2 ? getStringTypeState(estimatedFlags.get(2)) : state;
+ state = esitmatedFlagsCount > 2 ? getStringTypeState(estimatedFlags.get(2)) : state;
break;
case EnturNoBindingConstants.ESTIMATED_FLAG_04:
- state = estimatedFlags.size() > 3 ? getStringTypeState(estimatedFlags.get(3)) : state;
+ state = esitmatedFlagsCount > 3 ? getStringTypeState(estimatedFlags.get(3)) : state;
break;
case EnturNoBindingConstants.ESTIMATED_FLAG_05:
- state = estimatedFlags.size() > 4 ? getStringTypeState(estimatedFlags.get(4)) : state;
+ state = esitmatedFlagsCount > 4 ? getStringTypeState(estimatedFlags.get(4)) : state;
break;
case EnturNoBindingConstants.CHANNEL_LINE_CODE:
state = getStringTypeState(processedData.get(i).lineCode);
@Nullable
List<ShadeData> shadesData = shadesX.shadeData;
assertNotNull(shadesData);
- assertTrue(shadesData.size() > 0);
+ assertTrue(!shadesData.isEmpty());
@Nullable
ShadeData shadeData;
shadeData = shadesData.get(0);
@Nullable
List<Scene> scenesData = scenes.sceneData;
assertNotNull(scenesData);
- assertTrue(scenesData.size() > 0);
+ assertTrue(!scenesData.isEmpty());
@Nullable
Scene sceneZero = scenesData.get(0);
assertNotNull(sceneZero);
events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:55:00Z"),
Instant.parse("2020-01-28T16:05:00Z"));
assertNotNull(events);
- assertTrue(events.size() > 0);
+ assertTrue(!events.isEmpty());
List<CommandTag> cmdTags = events.get(0).commandTags;
- assertTrue(cmdTags.size() > 0);
+ assertTrue(!cmdTags.isEmpty());
CommandTag cmd = cmdTags.get(0);
// accept correct, empty or null configuration codes
assertTrue(cmd.isAuthorized("abc"));
}
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
- if (events != null && events.size() > 0) {
+ if (events != null && !events.isEmpty()) {
JablotronHistoryDataEvent event = events.get(0);
updateLastEvent(event);
}
protected void updateEventChannel(String channel) {
List<JablotronHistoryDataEvent> events = eventCache.getValue();
- if (events != null && events.size() > 0) {
+ if (events != null && !events.isEmpty()) {
JablotronHistoryDataEvent event = events.get(0);
switch (channel) {
case CHANNEL_LAST_EVENT_TIME:
*/
package org.openhab.binding.jablotron.internal.handler;
-import static org.openhab.binding.jablotron.JablotronBindingConstants.BINDING_ID;
-import static org.openhab.binding.jablotron.JablotronBindingConstants.CACHE_TIMEOUT_MS;
-import static org.openhab.binding.jablotron.JablotronBindingConstants.CHANNEL_LAST_CHECK_TIME;
+import static org.openhab.binding.jablotron.JablotronBindingConstants.*;
import java.util.List;
// update events
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
- if (events != null && events.size() > 0) {
+ if (events != null && !events.isEmpty()) {
JablotronHistoryDataEvent event = events.get(0);
updateLastEvent(event);
}
*/
package org.openhab.binding.jablotron.internal.handler;
-import static org.openhab.binding.jablotron.JablotronBindingConstants.BINDING_ID;
-import static org.openhab.binding.jablotron.JablotronBindingConstants.CACHE_TIMEOUT_MS;
-import static org.openhab.binding.jablotron.JablotronBindingConstants.CHANNEL_LAST_CHECK_TIME;
+import static org.openhab.binding.jablotron.JablotronBindingConstants.*;
import java.util.List;
private void updateTemperatureChannel(Channel channel, JablotronServiceDetailSegment segment) {
List<JablotronServiceDetailSegmentInfo> infos = segment.getSegmentInfos();
- if (infos.size() > 0) {
+ if (!infos.isEmpty()) {
logger.debug("Found value: {} and type: {}", infos.get(0).getValue(), infos.get(0).getType());
updateState(channel.getUID(), QuantityType.valueOf(infos.get(0).getValue(), SIUnits.CELSIUS));
} else {
state.setStateValue(update.getValue());
});
- if (perStateUuid.size() == 0) {
+ if (perStateUuid.isEmpty()) {
logger.debug("[{}] State update UUID={} has empty controls table", debugId, update.getUuid());
}
} else {
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jdt.annotation.NonNullByDefault;
if (category != null) {
channelTypeBuilder.withCategory(category);
}
- final LinkedHashSet<String> tags = miChannel.getTags();
- if (tags != null && tags.size() > 0) {
+ final Set<String> tags = miChannel.getTags();
+ if (tags != null && !tags.isEmpty()) {
channelTypeBuilder.withTags(tags);
}
channelTypes.put(channelTypeUID.getAsString(), channelTypeBuilder.build());
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.measure.Unit;
ChannelTypeUID channelTypeUID = new ChannelTypeUID(miChannel.getChannelType());
if (channelTypeRegistry.getChannelType(channelTypeUID) != null) {
newChannel = newChannel.withType(channelTypeUID);
- final LinkedHashSet<String> tags = miChannel.getTags();
- if (tags != null && tags.size() > 0) {
+ final Set<String> tags = miChannel.getTags();
+ if (tags != null && !tags.isEmpty()) {
newChannel.withDefaultTags(tags);
}
} else {
if (useGeneratedChannelType) {
newChannel = newChannel
.withType(new ChannelTypeUID(BINDING_ID, model.toUpperCase().replace(".", "_") + "_" + channel));
- final LinkedHashSet<String> tags = miChannel.getTags();
- if (tags != null && tags.size() > 0) {
+ final Set<String> tags = miChannel.getTags();
+ if (tags != null && !tags.isEmpty()) {
newChannel.withDefaultTags(tags);
}
}
sb.append(supportedChannelList.get(ch));
sb.append("\r\n");
}
- if (supportedChannelList.size() > 0) {
+ if (!supportedChannelList.isEmpty()) {
MiIoBasicDevice mbd = createBasicDeviceDb(model, new ArrayList<>(supportedChannelList.keySet()));
sb.append("Created experimental database for your device:\r\n");
sb.append(GSONP.toJson(mbd));
g2d.draw(new Line2D.Float(xPos, yP, xPos, yP));
}
}
- if (logger.isDebugEnabled() && roomIds.size() > 0) {
+ if (logger.isDebugEnabled() && !roomIds.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (Integer r : roomIds) {
sb.append(" " + r.toString());
StateDescriptionDTO stateDescription = channel.getStateDescription();
if (stateDescription != null && stateDescription.getOptions() != null) {
final List<OptionsValueListDTO> options = stateDescription.getOptions();
- if (options != null && options.size() > 0) {
+ if (options != null && !options.isEmpty()) {
StringBuilder mapping = new StringBuilder();
mapping.append("Value mapping [");
options.forEach((option) -> {
@Nullable
List<? extends AbstractRecord> devices = deviceData.getDevices();
- if (devices == null || devices.size() == 0) {
+ if (devices == null || devices.isEmpty()) {
logger.warn(MSG_FMT_DEVICE_POLL_ERR, "no devices found");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
return null;
.map(api -> api.getmeasure(equipmentId, scale, types, moduleId, null, "last", 1, true, false).getBody())
.orElse(null);
updateStatus(ThingStatus.ONLINE);
- NAMeasureBodyElem element = (data != null && data.size() > 0) ? data.get(0) : null;
+ NAMeasureBodyElem element = data != null && !data.isEmpty() ? data.get(0) : null;
return element != null ? element.getValue().get(0) : Collections.emptyList();
}
*/
public @Nullable Thermostat tryHandleAndGetUpdatedThermostat() {
final LinkedList<SimpleImmutableEntry<String, Command>> updatedValues = this.updatedValues;
- if (updatedValues.size() == 0) {
+ if (updatedValues.isEmpty()) {
return null;
}
this.updatedValues = new LinkedList<>();
logger.debug(
"{} channels defined (with {} different channel types) for the thing {} (from {} items including {} groups)",
channels.size(), nbChannelTypesCreated, getThing().getUID(), items.size(), nbGroups);
- } else if (channels.size() > 0) {
+ } else if (!channels.isEmpty()) {
int nbRemoved = 0;
for (Channel channel : channels) {
if (getThing().getChannel(channel.getUID()) != null) {
Channel channel = getThing().getChannel(item.name);
RemoteopenhabStateDescription descr = item.stateDescription;
List<RemoteopenhabStateOption> options = descr == null ? null : descr.options;
- if (channel != null && options != null && options.size() > 0) {
+ if (channel != null && options != null && !options.isEmpty()) {
List<StateOption> stateOptions = new ArrayList<>();
for (RemoteopenhabStateOption option : options) {
stateOptions.add(new StateOption(option.value, option.label));
.withLabel(channelDTO.label).withDescription(channelDTO.description)
.withConfiguration(channelConfig).build());
}
- if (channels.size() > 0) {
+ if (!channels.isEmpty()) {
ThingBuilder thingBuilder = editThing();
int nbRemoved = 0;
for (Channel channel : channels) {
if (loc.getGeometry() != null) {
List<Double> locationData = loc.getGeometry().getData();
if (locationData != null) {
+ int locationDataCount = locationData.size();
SenseBoxLocation location = new SenseBoxLocation();
- if (locationData.size() > 0) {
+ if (locationDataCount > 0) {
location.setLongitude(locationData.get(0));
}
- if (locationData.size() > 1) {
+ if (locationDataCount > 1) {
location.setLatitude(locationData.get(1));
}
- if (locationData.size() > 2) {
+ if (locationDataCount > 2) {
location.setHeight(locationData.get(2));
}
public boolean updateWakeupReason(@Nullable List<Object> valueArray) {
boolean changed = false;
- if ((valueArray != null) && (valueArray.size() > 0)) {
+ if (valueArray != null && !valueArray.isEmpty()) {
String reason = getString((String) valueArray.get(0));
String newVal = valueArray.toString();
changed = updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_WAKEUP, getStringType(reason));
logger.debug("{}: Setting effect to {}", thingName, newCol.effect);
parms.put(SHELLY_COLOR_EFFECT, newCol.effect.toString());
}
- if (parms.size() > 0) {
+ if (!parms.isEmpty()) {
logger.debug("{}: Send light settings: {}", thingName, parms);
api.setLightParms(lightId, parms);
updateCurrentColors(lightId, newCol);
thingName + " - " + phonebook.getName()))
.collect(Collectors.toList());
- if (parameterOptions.size() > 0) {
+ if (!parameterOptions.isEmpty()) {
parameterOptions.add(new ParameterOption(thingUid, thingName));
}
entries.add(new UpnpEntry(id, refId, parentId, upnpClass.toString()).withTitle(title.toString())
.withAlbum(album.toString()).withAlbumArtUri(albumArtUri.toString())
.withCreator(creator.toString())
- .withArtist(artistList.size() > 0 ? artistList.get(0) : artist.toString())
+ .withArtist(!artistList.isEmpty() ? artistList.get(0) : artist.toString())
.withPublisher(publisher.toString()).withGenre(genre.toString()).withTrackNumber(trackNumberVal)
.withResList(resList));
}
private void updateRelativeMeasure(String channelId, List<QuantityType<?>> reference, double value) {
- if (reference.size() > 0) {
+ if (!reference.isEmpty()) {
double percent = value / reference.get(0).doubleValue() * 100;
updateQuantity(channelId, percent, Units.PERCENT);
}
}
public boolean aFailedBulb() {
- return bulbFailures.size() > 0;
+ return !bulbFailures.isEmpty();
}
/*
}
} else if (channelUID.getId().startsWith(CHANNEL_PREFIX)) {
int channelId = Integer.parseInt(groupId.substring(CHANNEL_PREFIX.length())) - 1;
- if (channelList != null && channelList.size() > 0 && channelId < channelList.size()) {
+ if (channelList != null && !channelList.isEmpty() && channelId < channelList.size()) {
Channel channel = channelList.get(channelId);
switch (channelUID.getIdWithoutGroup()) {
case CHANNEL_NAME:
if (channelUID.getId().startsWith(CHANNEL_PREFIX)) {
int channelId = Integer.parseInt(groupId.substring(CHANNEL_PREFIX.length())) - 1;
- if (channelList.size() > 0 && channelId < channelList.size()) {
+ if (!channelList.isEmpty() && channelId < channelList.size()) {
Channel channel = channelList.get(channelId);
switch (channelUID.getIdWithoutGroup()) {
case CHANNEL_NAME:
if (channelUID.getId().startsWith(CHANNEL_PREFIX)) {
int channelId = Integer.parseInt(groupId.substring(CHANNEL_PREFIX.length())) - 1;
- if (channelList.size() > 0 && channelId < channelList.size()) {
+ if (!channelList.isEmpty() && channelId < channelList.size()) {
Channel channel = channelList.get(channelId);
if (CHANNEL_ALARM_OPENHAB.equals(channelUID.getIdWithoutGroup())) {
if (channel.getTemp() != 999) {
}
} else if (channelUID.getId().startsWith(CHANNEL_PREFIX)) {
int channelId = Integer.parseInt(groupId.substring(CHANNEL_PREFIX.length())) - 1;
- if (channelList.size() > 0 && channelId < channelList.size()) {
+ if (!channelList.isEmpty() && channelId < channelList.size()) {
Channel channel = channelList.get(channelId);
switch (channelUID.getIdWithoutGroup()) {
case CHANNEL_NAME:
if (channelUID.getId().startsWith(CHANNEL_PREFIX)) {
int channelId = Integer.parseInt(groupId.substring(CHANNEL_PREFIX.length())) - 1;
- if (channelList.size() > 0 && channelId < channelList.size()) {
+ if (!channelList.isEmpty() && channelId < channelList.size()) {
Channel channel = channelList.get(channelId);
switch (channelUID.getIdWithoutGroup()) {
case CHANNEL_NAME:
if (channelUID.getId().startsWith(CHANNEL_PREFIX)) {
int channelId = Integer.parseInt(groupId.substring(CHANNEL_PREFIX.length())) - 1;
- if (channelList.size() > 0 && channelId < channelList.size()) {
+ if (!channelList.isEmpty() && channelId < channelList.size()) {
Channel channel = channelList.get(channelId);
if (CHANNEL_ALARM_OPENHAB.equals(channelUID.getIdWithoutGroup())) {
if (channel.getTemp() != 999) {
public boolean isValid() { // a valid configuration must be initialized
// and contain at least one function
- return (isInitialized && (archives.size() > 0));
+ return isInitialized && !archives.isEmpty();
}
@Override