Use Collection.isEmpty (#10525)
Fixes 47 SAT UseCollectionIsEmpty findings. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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) -> {
|
||||
|
||||
Reference in New Issue
Block a user