You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Junichi Yamamoto (JIRA)" <ji...@apache.org> on 2019/06/09 05:01:00 UTC

[jira] [Created] (NETBEANS-2653) Generate toString() with StringBuilder

Junichi Yamamoto created NETBEANS-2653:
------------------------------------------

             Summary: Generate toString() with StringBuilder
                 Key: NETBEANS-2653
                 URL: https://issues.apache.org/jira/browse/NETBEANS-2653
             Project: NetBeans
          Issue Type: Improvement
          Components: java - Editor
    Affects Versions: 11.0
            Reporter: Junichi Yamamoto
            Assignee: Junichi Yamamoto


Currently, the following toString() is inserted using "insert code" feature:
{code:java}
public class NewClass {
    private final String test = "test";
    private final String test2 = "test";
    private final String test3 = "test";

    @Override
    public String toString() {
        // generate toString() with "+" operator
        return "NewClass{" + "test=" + test + ", test2=" + test2 + ", test3=" + test3 + '}';
    }

}
{code}

Add a check box to the panel for using StringBuilder, then insert the following toString(): 
{code:java}
public class NewClass {
    private final String test = "test";
    private final String test2 = "test";
    private final String test3 = "test";

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("NewClass{");
        sb.append("test=").append(test);
        sb.append(", ");
        sb.append("test2=").append(test2);
        sb.append(", ");
        sb.append("test3=").append(test3);
        sb.append('}');
        return sb.toString();
    }

}
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists