X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Frhynodge%2Fstates%2FTorrentState.java;h=c0ba68aefddc029e12bbf6ce9835eb835d31716d;hb=124d65271bb6db7b9065b6567b7d806f266a7384;hp=ddcd518fbca7e8591be89d807ae7813a10a3050c;hpb=9766f632a60067480b162f9e509b0406aa871f13;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 ddcd518..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