Override Object.toString() to recreate the original input line.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 7 Apr 2013 19:51:16 +0000 (21:51 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 7 Apr 2013 19:51:16 +0000 (21:51 +0200)
src/main/java/net/pterodactylus/irc/Reply.java
src/main/java/net/pterodactylus/irc/Source.java

index 742c04c..28add37 100644 (file)
@@ -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
        //
 
index fc9d328..b2f61d4 100644 (file)
@@ -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
        //