Provide toString() for replaying messages
This commit is contained in:
parent
9d14725c37
commit
24efe6a3d4
@ -3,6 +3,8 @@ package dslab;
|
||||
import dslab.exception.MissingInputException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Message {
|
||||
private ArrayList<Email> to = new ArrayList<>();
|
||||
@ -31,6 +33,12 @@ public class Message {
|
||||
to.add(email);
|
||||
}
|
||||
|
||||
public String printTo() {
|
||||
if (this.to.isEmpty())
|
||||
return null;
|
||||
return this.to.stream().map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public ArrayList<Email> getTo() {
|
||||
return to;
|
||||
}
|
||||
@ -62,4 +70,12 @@ public class Message {
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "from " + getFrom().toString() + "\n" +
|
||||
"to " + printTo() + "\n" +
|
||||
"subject " + getSubject() + "\n" +
|
||||
"data " + getData() + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user