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;
+import com.google.common.base.Predicate;
+
/**
* Information about an ongoing download.
*
*/
public class Download {
+ /** Predicate that identifies downloads that have started. */
+ public static final Predicate<Download> FILTER_RUNNING = new Predicate<Download>() {
+
+ @Override
+ public boolean apply(Download download) {
+ return download.dccReceiver() != null;
+ }
+ };
+
/** The bot that is being downloaded from. */
private final Bot bot;
* 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");
}
//
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();
+ }
+
}