import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import net.pterodactylus.xdcc.util.io.BandwidthCountingInputStream;
import net.pterodactylus.xdcc.util.io.BandwidthCountingOutputStream;
-import com.google.common.base.Optional;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.common.io.Closeables;
private String nickname = null;
/** The username. */
- private Optional<String> username = Optional.absent();
+ private Optional<String> username = Optional.empty();
/** The real name. */
- private Optional<String> realName = Optional.absent();
+ private Optional<String> realName = Optional.empty();
/** The optional password for the connection. */
- private Optional<String> password = Optional.absent();
+ private Optional<String> password = Optional.empty();
/** The connection handler. */
private ConnectionHandler connectionHandler;
@Override
public Connection username(String username) {
- this.username = Optional.fromNullable(username);
+ this.username = Optional.ofNullable(username);
return this;
}
@Override
public Connection realName(String realName) {
- this.realName = Optional.fromNullable(realName);
+ this.realName = Optional.ofNullable(realName);
return this;
}
@Override
public Connection password(String password) {
- this.password = Optional.fromNullable(password);
+ this.password = Optional.ofNullable(password);
return this;
}
//
/**
- * Returns an item from the list, or {@link Optional#absent()} if the list is
+ * Returns an item from the list, or {@link Optional#empty()} if the list is
* shorter than required for the given index.
*
* @param list
* @param <T>
* The type of the list items
* @return This list item wrapped in an {@link Optional}, or {@link
- * Optional#absent()} if the list is not long enough
+ * Optional#empty()} if the list is not long enough
*/
private static <T> Optional<T> getOptional(List<T> list, int index) {
if (index < list.size()) {
- return Optional.fromNullable(list.get(index));
+ return Optional.ofNullable(list.get(index));
}
- return Optional.absent();
+ return Optional.empty();
}
/** Handles input and output for the connection. */