From 87c1c44e68141244d38188be3bf846b45bc03ff7 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 8 Jul 2020 08:11:10 +0530 Subject: [PATCH] Use SetUtils in PluginFactory. --- src/org/kde/kdeconnect/Plugins/PluginFactory.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/org/kde/kdeconnect/Plugins/PluginFactory.java b/src/org/kde/kdeconnect/Plugins/PluginFactory.java index 766ddb53..4a4ab016 100644 --- a/src/org/kde/kdeconnect/Plugins/PluginFactory.java +++ b/src/org/kde/kdeconnect/Plugins/PluginFactory.java @@ -34,6 +34,9 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import static org.apache.commons.collections4.SetUtils.emptyIfNull; +import static org.apache.commons.collections4.SetUtils.unmodifiableSet; + public class PluginFactory { @IndexAnnotated @@ -52,12 +55,8 @@ public class PluginFactory { this.hasSettings = hasSettings; this.supportsDeviceSpecificSettings = supportsDeviceSpecificSettings; this.listenToUnpaired = listenToUnpaired; - HashSet incoming = new HashSet<>(); - if (supportedPacketTypes != null) Collections.addAll(incoming, supportedPacketTypes); - this.supportedPacketTypes = Collections.unmodifiableSet(incoming); - HashSet outgoing = new HashSet<>(); - if (outgoingPacketTypes != null) Collections.addAll(outgoing, outgoingPacketTypes); - this.outgoingPacketTypes = Collections.unmodifiableSet(outgoing); + this.supportedPacketTypes = emptyIfNull(unmodifiableSet(supportedPacketTypes)); + this.outgoingPacketTypes = emptyIfNull(unmodifiableSet(outgoingPacketTypes)); this.instantiableClass = instantiableClass; }