From: David ‘Bombe’ Roden Date: Sat, 6 Apr 2013 12:43:10 +0000 (+0200) Subject: Use a source in the reply. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=08dd8bd4381baf688ee883f4189c76c002a04a9d;p=xudocci.git Use a source in the reply. --- diff --git a/src/main/java/net/pterodactylus/irc/Reply.java b/src/main/java/net/pterodactylus/irc/Reply.java index 417a7a1..742c04c 100644 --- a/src/main/java/net/pterodactylus/irc/Reply.java +++ b/src/main/java/net/pterodactylus/irc/Reply.java @@ -32,7 +32,7 @@ import com.google.common.base.Optional; public class Reply { /** The source of the reply. */ - private final Optional source; + private final Optional source; /** The command of the reply (may be numeric). */ private final String command; @@ -50,7 +50,7 @@ public class Reply { * @param parameters * The parameters of the reply */ - private Reply(Optional source, String command, List parameters) { + private Reply(Optional source, String command, List parameters) { this.source = source; this.command = command; this.parameters = parameters; @@ -65,7 +65,7 @@ public class Reply { * * @return The source of the reply, or {@link Optional#absent()} */ - public Optional source() { + public Optional source() { return source; } @@ -102,9 +102,9 @@ public class Reply { String remainingLine = line; /* parse source. */ - Optional source = Optional.absent(); + Optional source = Optional.absent(); if (remainingLine.startsWith(":")) { - source = Optional.of(getFirstWord(remainingLine).substring(1)); + source = Optional.of(Source.parseSource(getFirstWord(remainingLine).substring(1))); remainingLine = removeFirstWord(remainingLine); } diff --git a/src/test/java/net/pterodactylus/irc/ReplyTest.java b/src/test/java/net/pterodactylus/irc/ReplyTest.java index 9d84c54..4ea7157 100644 --- a/src/test/java/net/pterodactylus/irc/ReplyTest.java +++ b/src/test/java/net/pterodactylus/irc/ReplyTest.java @@ -38,7 +38,7 @@ public class ReplyTest { reply = Reply.parseLine("NOTICE AUTH :*** Processing your connection"); assertThat(reply, notNullValue()); - assertThat(reply.source(), is(Optional.absent())); + assertThat(reply.source(), is(Optional.absent())); assertThat(reply.command(), is("NOTICE")); assertThat(reply.parameters(), hasSize(2)); assertThat(reply.parameters().get(0), is("AUTH")); @@ -46,7 +46,7 @@ public class ReplyTest { reply = Reply.parseLine(":ParaDMON!services@paraphysics.services PRIVMSG QshelTier :\u0001VERSION\u0001"); assertThat(reply, notNullValue()); - assertThat(reply.source(), is(Optional.of("ParaDMON!services@paraphysics.services"))); + assertThat(reply.source(), is(Optional.of(Source.parseSource("ParaDMON!services@paraphysics.services")))); assertThat(reply.command(), is("PRIVMSG")); assertThat(reply.parameters(), hasSize(2)); assertThat(reply.parameters().get(0), is("QshelTier"));