From 2dd358e3abdf111b8f8c269f317ce402e1aa7993 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 7 Apr 2013 21:51:16 +0200 Subject: [PATCH] Override Object.toString() to recreate the original input line. --- src/main/java/net/pterodactylus/irc/Reply.java | 22 ++++++++++++++++++++++ src/main/java/net/pterodactylus/irc/Source.java | 5 +++++ 2 files changed, 27 insertions(+) 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 // -- 2.7.4