From: David ‘Bombe’ Roden Date: Sun, 7 Apr 2013 19:51:16 +0000 (+0200) Subject: Override Object.toString() to recreate the original input line. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2dd358e3abdf111b8f8c269f317ce402e1aa7993;p=xudocci.git Override Object.toString() to recreate the original input line. --- diff --git a/src/main/java/net/pterodactylus/irc/Reply.java b/src/main/java/net/pterodactylus/irc/Reply.java index 742c04c..28add37 100644 --- a/src/main/java/net/pterodactylus/irc/Reply.java +++ b/src/main/java/net/pterodactylus/irc/Reply.java @@ -88,6 +88,28 @@ public class Reply { } // + // OBJECT METHODS + // + + @Override + public String toString() { + StringBuilder string = new StringBuilder(); + if (source.isPresent()) { + string.append(':').append(source.get()).append(' '); + } + string.append(command); + for (int parameterIndex = 0; parameterIndex < parameters.size(); ++parameterIndex) { + string.append(' '); + String parameter = parameters.get(parameterIndex); + if (parameterIndex == (parameters.size() - 1) && parameter.contains(" ")) { + string.append(':'); + } + string.append(parameter); + } + return string.toString(); + } + + // // STATIC METHODS // diff --git a/src/main/java/net/pterodactylus/irc/Source.java b/src/main/java/net/pterodactylus/irc/Source.java index fc9d328..b2f61d4 100644 --- a/src/main/java/net/pterodactylus/irc/Source.java +++ b/src/main/java/net/pterodactylus/irc/Source.java @@ -105,6 +105,11 @@ public class Source { return true; } + @Override + public String toString() { + return (nick.isPresent() ? nick().get() + "!" : "") + (username().isPresent() ? username.get() + "@" : "") + server; + } + // // STATIC METHODS //