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
35 changed files with 67 additions and 68 deletions

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) {