Revised toString method in Group and changed id to final in Contact
This commit is contained in:
parent
7a795e320b
commit
28fb3e9d25
@ -15,7 +15,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
public abstract class Contact implements Serializable {
|
||||
|
||||
private long id;
|
||||
private final long id;
|
||||
private String name;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
@ -2,6 +2,7 @@ package envoy.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
@ -57,12 +58,10 @@ public class Group extends Contact {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Group[id=" + getId() + ",name=" + getName() + ",memberIDs=[");
|
||||
memberIDs.forEach(id -> { sb.append(id); sb.append(", "); });
|
||||
// deleting the final ", "
|
||||
sb.delete(sb.length() - 2, sb.length());
|
||||
sb.append("]]");
|
||||
return sb.toString();
|
||||
var joiner = new StringJoiner(",", "Group[id=", "]");
|
||||
joiner.add("id=" + getId());
|
||||
joiner.add("name=" + getName());
|
||||
joiner.add("memberIDs=" + getMemberIDs());
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user