IDEMPIERE-308 Performance: Replace use of StringBuffer and String concatenation with StringBuilder / Add a helper getName by default in the toString method in X_ class

This commit is contained in:
Carlos Ruiz 2020-03-03 15:04:10 +01:00
parent 4a436c5157
commit 0147b47f31
1 changed files with 10 additions and 4 deletions

View File

@ -238,15 +238,21 @@ public class ModelClassGenerator
.append(" {").append(NL)
.append(" POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());").append(NL)
.append(" return poi;").append(NL)
.append(" }").append(NL)
.append(" }").append(NL);
// initPO
final String sqlCol = "SELECT COUNT(*) FROM AD_Column WHERE AD_Table_ID=? AND ColumnName=? AND IsActive='Y'";
boolean hasName = (DB.getSQLValue(null, sqlCol, AD_Table_ID, "Name") == 1);
// toString()
.append(NL)
start.append(NL)
.append(" public String toString()").append(NL)
.append(" {").append(NL)
.append(" StringBuffer sb = new StringBuffer (\"").append(className).append("[\")").append(NL)
.append(" .append(get_ID()).append(\"]\");").append(NL)
.append(" StringBuilder sb = new StringBuilder (\"").append(className).append("[\")").append(NL)
// TODO: generate getName if there is a Name column -- .append(",Name=").append(getName())
.append(" .append(get_ID())");
if (hasName)
start.append(".append(\",Name=\").append(getName())");
start.append(".append(\"]\");").append(NL)
.append(" return sb.toString();").append(NL)
.append(" }").append(NL)
;