toString 方法在eclipse中生成如下:
StringBuilder builder = new StringBuilder();
builder.append("Person [");
if (firstName != null)
builder.append("firstName=").append(firstName).append(", ");
if (lastName != null)
builder.append("lastName=").append(lastName).
if (title != null)
builder.append("title=").append(title).append(", ");
if (car != null)
builder.append("car=").append(car).append(", ");
builder.append("]");
他们为什么不使用更短的形式,例如
builder.append("firstName=" + firstName + ", ");
是为了节省String
创作时间吗?
如何将模板更改为这种格式?
${object.className} [${member.name()}=${member.value}, ${otherMembers}]