Use Collection.isEmpty (#10525)

Fixes 47 SAT UseCollectionIsEmpty findings.

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2021-04-15 21:00:47 +02:00 committed by GitHub
parent 7a22d65406
commit 1633c705a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 67 additions and 68 deletions

View File

@ -611,7 +611,7 @@ public class AccountServlet extends HttpServlet {
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>");

View File

@ -212,7 +212,7 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
}
Set<SmartHomeDevice> supportedChildren = SmartHomeDeviceHandler.getSupportedSmartHomeDevices(shg,
deviceList);
if (supportedChildren.size() == 0) {
if (supportedChildren.isEmpty()) {
// No children with an supported interface
continue;
}

View File

@ -347,7 +347,7 @@ public class SocketChannelSession implements SocketSession {
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;
}

View File

@ -137,7 +137,7 @@ public class AVMFritzButtonHandler extends DeviceHandler {
}
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())

View File

@ -87,7 +87,7 @@ public class ComfoAirHandler extends BaseThingHandler {
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);
}

View File

@ -82,17 +82,17 @@ public class HotWaterHandler extends DraytonWiserThingHandler<HotWaterData> {
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 {

View File

@ -240,7 +240,7 @@ public enum CosemObjectType {
* @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 */

View File

@ -153,7 +153,7 @@ public class EcobeeDiscoveryService extends AbstractDiscoveryService implements
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;
}

View File

@ -213,37 +213,39 @@ public class EnturNoHandler extends BaseThingHandler {
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);

View File

@ -168,7 +168,7 @@ public class HDPowerViewJUnitTests {
@Nullable
List<ShadeData> shadesData = shadesX.shadeData;
assertNotNull(shadesData);
assertTrue(shadesData.size() > 0);
assertTrue(!shadesData.isEmpty());
@Nullable
ShadeData shadeData;
shadeData = shadesData.get(0);
@ -198,7 +198,7 @@ public class HDPowerViewJUnitTests {
@Nullable
List<Scene> scenesData = scenes.sceneData;
assertNotNull(scenesData);
assertTrue(scenesData.size() > 0);
assertTrue(!scenesData.isEmpty());
@Nullable
Scene sceneZero = scenesData.get(0);
assertNotNull(sceneZero);

View File

@ -252,9 +252,9 @@ public class BiweeklyPresentableCalendarTest {
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"));

View File

@ -187,7 +187,7 @@ public abstract class JablotronAlarmHandler extends BaseThingHandler {
}
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
if (events != null && events.size() > 0) {
if (events != null && !events.isEmpty()) {
JablotronHistoryDataEvent event = events.get(0);
updateLastEvent(event);
}
@ -221,7 +221,7 @@ public abstract class JablotronAlarmHandler extends BaseThingHandler {
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:

View File

@ -12,9 +12,7 @@
*/
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;
@ -181,7 +179,7 @@ public class JablotronJa100FHandler extends JablotronAlarmHandler {
// update events
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
if (events != null && events.size() > 0) {
if (events != null && !events.isEmpty()) {
JablotronHistoryDataEvent event = events.get(0);
updateLastEvent(event);
}

View File

@ -12,9 +12,7 @@
*/
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;
@ -199,7 +197,7 @@ public class JablotronJa100Handler extends JablotronAlarmHandler {
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 {

View File

@ -487,7 +487,7 @@ public class LxServerHandler extends BaseThingHandler implements LxServerHandler
state.setStateValue(update.getValue());
});
if (perStateUuid.size() == 0) {
if (perStateUuid.isEmpty()) {
logger.debug("[{}] State update UUID={} has empty controls table", debugId, update.getUuid());
}
} else {

View File

@ -17,10 +17,10 @@ import static org.openhab.binding.miio.internal.MiIoBindingConstants.BINDING_ID;
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;
@ -108,8 +108,8 @@ public class BasicChannelTypeProvider implements ChannelTypeProvider {
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());

View File

@ -19,10 +19,10 @@ import java.io.IOException;
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;
@ -471,8 +471,8 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
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 {
@ -485,8 +485,8 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
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);
}
}

View File

@ -264,7 +264,7 @@ public class MiIoUnsupportedHandler extends MiIoAbstractHandler {
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));

View File

@ -180,7 +180,7 @@ public class RRMapDraw {
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());

View File

@ -166,7 +166,7 @@ public class ReadmeHelper {
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) -> {

View File

@ -243,7 +243,7 @@ public class NeoHubHandler extends BaseBridgeHandler {
@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;

View File

@ -299,7 +299,7 @@ public class NetatmoBridgeHandler extends BaseBridgeHandler {
.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();
}

View File

@ -131,7 +131,7 @@ public class ThermostatHandler extends BaseThingHandler {
*/
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<>();

View File

@ -262,7 +262,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
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) {
@ -319,7 +319,7 @@ public class RemoteopenhabBridgeHandler extends BaseBridgeHandler
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));

View File

@ -158,7 +158,7 @@ public class RemoteopenhabThingHandler extends BaseThingHandler implements Remot
.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) {

View File

@ -80,17 +80,18 @@ public class SenseBoxAPIConnection {
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));
}

View File

@ -949,7 +949,7 @@ public class ShellyBaseHandler extends BaseThingHandler implements ShellyDeviceL
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));

View File

@ -492,7 +492,7 @@ public class ShellyLightHandler extends ShellyBaseHandler {
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);

View File

@ -130,7 +130,7 @@ public class PhonebookProfileFactory implements ProfileFactory, ProfileTypeProvi
thingName + " - " + phonebook.getName()))
.collect(Collectors.toList());
if (parameterOptions.size() > 0) {
if (!parameterOptions.isEmpty()) {
parameterOptions.add(new ParameterOption(thingUid, thingName));
}

View File

@ -375,7 +375,7 @@ public class UpnpXMLParser {
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));

View File

@ -243,7 +243,7 @@ public class VigiCruesHandler extends BaseThingHandler {
}
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);
}

View File

@ -92,7 +92,7 @@ public class Status extends VocAnswer {
}
public boolean aFailedBulb() {
return bulbFailures.size() > 0;
return !bulbFailures.isEmpty();
}
/*

View File

@ -91,7 +91,7 @@ public class WlanThermoEsp32CommandHandler {
}
} 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:
@ -176,7 +176,7 @@ public class WlanThermoEsp32CommandHandler {
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:
@ -283,7 +283,7 @@ public class WlanThermoEsp32CommandHandler {
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) {

View File

@ -81,7 +81,7 @@ public class WlanThermoNanoV1CommandHandler {
}
} 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:
@ -165,7 +165,7 @@ public class WlanThermoNanoV1CommandHandler {
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:
@ -266,7 +266,7 @@ public class WlanThermoNanoV1CommandHandler {
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) {

View File

@ -671,7 +671,7 @@ public class RRD4jPersistenceService implements QueryablePersistenceService {
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