From: David ‘Bombe’ Roden Date: Thu, 5 Sep 2013 04:49:33 +0000 (+0200) Subject: Add method to return all connected networks. X-Git-Url: https://git.pterodactylus.net/?p=xudocci.git;a=commitdiff_plain;h=c8396748e78e3faa9316d7de6b6a8c58e584f1c1 Add method to return all connected networks. --- diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index b157851..d13b486 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -70,6 +70,7 @@ import net.pterodactylus.xdcc.data.Network; import net.pterodactylus.xdcc.data.Pack; import net.pterodactylus.xdcc.data.Server; +import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; @@ -168,6 +169,20 @@ public class Core extends AbstractExecutionThreadService { } /** + * Returns all connected networks. + * + * @return All connected networks + */ + public Collection connectedNetworks() { + return Lists.newArrayList(Optional.presentInstances(FluentIterable.from(networkConnections.values()).transform(new Function>() { + @Override + public Optional apply(Connection connection) { + return getNetwork(connection); + } + }))); + } + + /** * Returns all configured channels. Due to various circumstances, configured * channels might not actually be joined. *