Add container for download data.
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / data / Download.java
1 /*
2  * XdccDownloader - Download.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.xdcc.data;
19
20 import java.io.OutputStream;
21
22 import net.pterodactylus.irc.DccReceiver;
23
24 /**
25  * Information about an ongoing download.
26  *
27  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28  */
29 public class Download {
30
31         /** The bot that is being downloaded from. */
32         private final Bot bot;
33
34         /** The pack that is being downloaded. */
35         private final Pack pack;
36
37         /** The name of the file being downloaded. */
38         private String filename;
39
40         /** The output stream. */
41         private OutputStream outputStream;
42
43         /** The DCC receiver. */
44         private DccReceiver dccReceiver;
45
46         /**
47          * Creates a new download.
48          *
49          * @param bot
50          *              The bot offering the download
51          * @param pack
52          *              The pack being downloaded
53          */
54         public Download(Bot bot, Pack pack) {
55                 this.bot = bot;
56                 this.pack = pack;
57         }
58
59         //
60         // ACCESSORS
61         //
62
63         /**
64          * Returns the bot offering the download.
65          *
66          * @return The bot offering the download
67          */
68         public Bot bot() {
69                 return bot;
70         }
71
72         /**
73          * The pack that is being downloaded.
74          *
75          * @return The pack being downloaded
76          */
77         public Pack pack() {
78                 return pack;
79         }
80
81         /**
82          * The full name of the file being written.
83          *
84          * @return The full name of the file
85          */
86         public String filename() {
87                 return filename;
88         }
89
90         /**
91          * The output stream that writes to the file.
92          *
93          * @return The output stream
94          */
95         public OutputStream outputStream() {
96                 return outputStream;
97         }
98
99         /**
100          * The DCC receiver that is downloading the file
101          *
102          * @return The DCC receiver
103          */
104         public DccReceiver dccReceiver() {
105                 return dccReceiver;
106         }
107
108         //
109         // MUTATORS
110         //
111
112         /**
113          * Sets the full name of the file being downloaded.
114          *
115          * @param filename
116          *              The full name of the file
117          * @return This download
118          */
119         public Download filename(String filename) {
120                 this.filename = filename;
121                 return this;
122         }
123
124         /**
125          * Sets the output stream the download is being written to
126          *
127          * @param outputStream
128          *              The output stream
129          * @return This download
130          */
131         public Download outputStream(OutputStream outputStream) {
132                 this.outputStream = outputStream;
133                 return this;
134         }
135
136         /**
137          * Sets the DCC receiver that downloads the file.
138          *
139          * @param dccReceiver
140          *              The DCC receiver
141          * @return This download
142          */
143         public Download dccReceiver(DccReceiver dccReceiver) {
144                 this.dccReceiver = dccReceiver;
145                 return this;
146         }
147
148 }