+ /**
+ * Converts a download into the number of seconds left in the transfer at the
+ * current rate.
+ */
+ public static final Function<Download, Optional<Long>> SECONDS_LEFT = new Function<Download, Optional<Long>>() {
+ @Override
+ public Optional<Long> apply(Download download) {
+ DccReceiver dccReceiver = download.dccReceiver();
+ if ((dccReceiver == null) || (dccReceiver.size() == -1) || (dccReceiver.currentRate() == 0)) {
+ return Optional.absent();
+ }
+ long secondsLeft = (dccReceiver.size() - dccReceiver.progress()) / dccReceiver.currentRate();
+ return Optional.of(secondsLeft);
+ }
+ };
+