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; }