From: David ‘Bombe’ Roden Date: Mon, 23 Feb 2015 05:34:46 +0000 (+0100) Subject: Use Optional from java.util, not Guava X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f96ea38946952e2a06ccc0d64a92e346b8761f85;p=xudocci.git Use Optional from java.util, not Guava --- diff --git a/src/main/java/net/pterodactylus/irc/DefaultConnection.java b/src/main/java/net/pterodactylus/irc/DefaultConnection.java index cca6aed..8fe4c4b 100644 --- a/src/main/java/net/pterodactylus/irc/DefaultConnection.java +++ b/src/main/java/net/pterodactylus/irc/DefaultConnection.java @@ -32,6 +32,7 @@ import java.io.UnsupportedEncodingException; 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; @@ -63,7 +64,6 @@ import net.pterodactylus.irc.util.RandomNickname; 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; @@ -107,13 +107,13 @@ public class DefaultConnection extends AbstractExecutionThreadService implements private String nickname = null; /** The username. */ - private Optional username = Optional.absent(); + private Optional username = Optional.empty(); /** The real name. */ - private Optional realName = Optional.absent(); + private Optional realName = Optional.empty(); /** The optional password for the connection. */ - private Optional password = Optional.absent(); + private Optional password = Optional.empty(); /** The connection handler. */ private ConnectionHandler connectionHandler; @@ -167,19 +167,19 @@ public class DefaultConnection extends AbstractExecutionThreadService implements @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; } @@ -367,7 +367,7 @@ public class DefaultConnection extends AbstractExecutionThreadService implements // /** - * 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 @@ -377,13 +377,13 @@ public class DefaultConnection extends AbstractExecutionThreadService implements * @param * 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 Optional getOptional(List 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. */ diff --git a/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java b/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java index 00b088a..3d99a7f 100644 --- a/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java +++ b/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java @@ -17,11 +17,11 @@ package net.pterodactylus.irc.event; +import java.util.Optional; + import net.pterodactylus.irc.Connection; import net.pterodactylus.irc.Source; -import com.google.common.base.Optional; - /** * Event that notifies a listener that a client has left a channel. * diff --git a/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java b/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java index 54b4f67..58c1ca2 100644 --- a/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java +++ b/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java @@ -1,10 +1,10 @@ package net.pterodactylus.irc.event; +import java.util.Optional; + import net.pterodactylus.irc.Connection; import net.pterodactylus.irc.Source; -import com.google.common.base.Optional; - /** * Event that signals that a client was kicked from a channel. * diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index 99c5ab6..bfad867 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -747,7 +747,7 @@ public class Core extends AbstractExecutionThreadService { "Kicked from %s by %s: %s", kickedFromChannel.channel(), kickedFromChannel.kicker(), - kickedFromChannel.reason().or("") + kickedFromChannel.reason().orElse("") ))); } }