public class Reply {
/** The source of the reply. */
- private final Optional<String> source;
+ private final Optional<Source> source;
/** The command of the reply (may be numeric). */
private final String command;
* @param parameters
* The parameters of the reply
*/
- private Reply(Optional<String> source, String command, List<String> parameters) {
+ private Reply(Optional<Source> source, String command, List<String> parameters) {
this.source = source;
this.command = command;
this.parameters = parameters;
*
* @return The source of the reply, or {@link Optional#absent()}
*/
- public Optional<String> source() {
+ public Optional<Source> source() {
return source;
}
String remainingLine = line;
/* parse source. */
- Optional<String> source = Optional.absent();
+ Optional<Source> 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);
}
reply = Reply.parseLine("NOTICE AUTH :*** Processing your connection");
assertThat(reply, notNullValue());
- assertThat(reply.source(), is(Optional.<String>absent()));
+ assertThat(reply.source(), is(Optional.<Source>absent()));
assertThat(reply.command(), is("NOTICE"));
assertThat(reply.parameters(), hasSize(2));
assertThat(reply.parameters().get(0), is("AUTH"));
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"));