X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Frhynodge%2Fstates%2FTorrentState.java;h=c0ba68aefddc029e12bbf6ce9835eb835d31716d;hb=2043167af2768e03603504c94ca6550dd25d2560;hp=c4c3e0bfcd2367f377294ed2b43bcb8979eb0e14;hpb=6ec36ef950c23c135bf0e112d932c5b7068189b8;p=rhynodge.git diff --git a/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java b/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java index c4c3e0b..c0ba68a 100644 --- a/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java +++ b/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java @@ -18,6 +18,8 @@ package net.pterodactylus.rhynodge.states; import java.nio.charset.Charset; +import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -42,11 +44,37 @@ public class TorrentState extends AbstractState implements Iterable @JsonProperty private List files = Lists.newArrayList(); + /** + * Creates a new torrent state without torrent files. + */ + public TorrentState() { + this(Collections. emptySet()); + } + + /** + * Creates a new torrent state containing the given torrent files. + * + * @param torrentFiles + * The torrent files + */ + public TorrentState(Collection torrentFiles) { + files.addAll(torrentFiles); + } + // // ACCESSORS // /** + * Returns all torrent files of this state. + * + * @return All torrent files of this state + */ + public Collection torrentFiles() { + return Collections.unmodifiableList(files); + } + + /** * Adds a torrent file to this state. * * @param torrentFile @@ -262,7 +290,7 @@ public class TorrentState extends AbstractState implements Iterable List parameters = URLEncodedUtils.parse(magnetUri.substring("magnet:?".length()), Charset.forName("UTF-8")); for (NameValuePair parameter : parameters) { if (parameter.getName().equals("xt")) { - return parameter.getValue(); + return parameter.getValue().toLowerCase(); } } return null;