package net.pterodactylus.xdcc.data;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.OutputStream;
+import java.net.InetAddress;
import net.pterodactylus.irc.DccReceiver;
/** The name of the file being downloaded. */
private String filename;
+ /** The size of the file being downloaded. */
+ private long filesize;
+
+ /** The remote address. */
+ private InetAddress remoteAddress;
+
/** The output stream. */
private OutputStream outputStream;
* The pack being downloaded
*/
public Download(Bot bot, Pack pack) {
- this.bot = bot;
- this.pack = pack;
+ this.bot = checkNotNull(bot, "bot must not be null");
+ this.pack = checkNotNull(pack, "pack must not be null");
}
//
}
/**
+ * Returns the size of the file.
+ *
+ * @return The size of the file
+ */
+ public long filesize() {
+ return filesize;
+ }
+
+ /**
+ * Returns the remote address to download from.
+ *
+ * @return The remote address to download from
+ */
+ public InetAddress remoteAddress() {
+ return remoteAddress;
+ }
+
+ /**
* The output stream that writes to the file.
*
* @return The output stream
}
/**
+ * Sets the size of the download.
+ *
+ * @param filesize
+ * The size of the download
+ * @return This download
+ */
+ public Download filesize(long filesize) {
+ this.filesize = filesize;
+ return this;
+ }
+
+ /**
+ * Sets the remote address of the download.
+ *
+ * @param remoteAddress
+ * The remote address of the download
+ * @return This download
+ */
+ public Download remoteAddress(InetAddress remoteAddress) {
+ this.remoteAddress = remoteAddress;
+ return this;
+ }
+
+ /**
* Sets the output stream the download is being written to
*
* @param outputStream
return this;
}
+ //
+ // OBJECT METHODS
+ //
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Download)) {
+ return false;
+ }
+ Download download = (Download) object;
+ return bot().equals(download.bot()) && pack().equals(download.pack());
+ }
+
+ @Override
+ public int hashCode() {
+ return bot().hashCode() ^ pack().hashCode();
+ }
+
}