Ignore chains and states default directories.
[rhynodge.git] / src / main / java / net / pterodactylus / reactor / states / TorrentState.java
index 0855195..f3b3546 100644 (file)
@@ -27,6 +27,7 @@ import net.pterodactylus.reactor.states.TorrentState.TorrentFile;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.utils.URLEncodedUtils;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.collect.Lists;
 
 /**
@@ -38,7 +39,8 @@ import com.google.common.collect.Lists;
 public class TorrentState extends AbstractState implements Iterable<TorrentFile> {
 
        /** The torrent files. */
-       private final List<TorrentFile> files = Lists.newArrayList();
+       @JsonProperty
+       private List<TorrentFile> files = Lists.newArrayList();
 
        //
        // ACCESSORS
@@ -88,17 +90,41 @@ public class TorrentState extends AbstractState implements Iterable<TorrentFile>
        public static class TorrentFile {
 
                /** The name of the file. */
+               @JsonProperty
                private final String name;
 
                /** The size of the file. */
+               @JsonProperty
                private final String size;
 
                /** The magnet URI of the file. */
+               @JsonProperty
                private final String magnetUri;
 
                /** The download URI of the file. */
+               @JsonProperty
                private final String downloadUri;
 
+               /** The number of files in this torrent. */
+               @JsonProperty
+               private final int fileCount;
+
+               /** The number of seeds connected to this torrent. */
+               @JsonProperty
+               private final int seedCount;
+
+               /** The number of leechers connected to this torrent. */
+               @JsonProperty
+               private final int leechCount;
+
+               /**
+                * No-arg constructor for deserialization.
+                */
+               @SuppressWarnings("unused")
+               private TorrentFile() {
+                       this(null, null, null, null, 0, 0, 0);
+               }
+
                /**
                 * Creates a new torrent file.
                 *
@@ -110,12 +136,21 @@ public class TorrentState extends AbstractState implements Iterable<TorrentFile>
                 *            The magnet URI of the file
                 * @param downloadUri
                 *            The download URI of the file
+                * @param fileCount
+                *            The number of files
+                * @param seedCount
+                *            The number of connected seeds
+                * @param leechCount
+                *            The number of connected leechers
                 */
-               public TorrentFile(String name, String size, String magnetUri, String downloadUri) {
+               public TorrentFile(String name, String size, String magnetUri, String downloadUri, int fileCount, int seedCount, int leechCount) {
                        this.name = name;
                        this.size = size;
                        this.magnetUri = magnetUri;
                        this.downloadUri = downloadUri;
+                       this.fileCount = fileCount;
+                       this.seedCount = seedCount;
+                       this.leechCount = leechCount;
                }
 
                //
@@ -159,6 +194,33 @@ public class TorrentState extends AbstractState implements Iterable<TorrentFile>
                        return downloadUri;
                }
 
+               /**
+                * Returns the number of files in this torrent.
+                *
+                * @return The number of files in this torrent
+                */
+               public int fileCount() {
+                       return fileCount;
+               }
+
+               /**
+                * Returns the number of seeds connected to this torrent.
+                *
+                * @return The number of connected seeds
+                */
+               public int seedCount() {
+                       return seedCount;
+               }
+
+               /**
+                * Returns the number of leechers connected to this torrent.
+                *
+                * @return The number of connected leechers
+                */
+               public int leechCount() {
+                       return leechCount;
+               }
+
                //
                // PRIVATE METHODS
                //