Adam Bien's Weblog

Friday Sep 11, 2009

NetBeans Got An Excellent toString Generator

NetBeans 6.8 doesn't come with a toString generator out of the box. The toString generator solved the problem very well. The generator is available from the alt+insert (ctrl+i) pop-up - and so very convenient to use. You can choose between String and StringBuilder based generation. It works as expected: 


public class ToStringTest {

    private String name;
    private int age;
    private Boolean flag;
    private String descripton;

   //was generated
    @Override
    public String toString() {
        return "ToStringTest [" + "age " + age + " " + "descripton " + descripton + " " + "flag " + flag + " " + "name " + name + "]";
    }
}

 

One problem - I didn't found any reference to a NBM file and had to build it manually. It is very easy, but it takes few minutes and is inconvenient. I'm sure, that Simon is already working on a CI solution :-).



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Comments:

Hi Adam,

Nice to see that it does what you expect. We are still working on some features and will have an ever better version soon.

The download of the toString() generator can be found in NetBeans Plugin Portal:
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=21008

Kind Regard,
Simon

Posted by Martinelli Simon on September 11, 2009 at 01:28 PM CEST #

And now there is also a download section on kenai project ;-)

http://kenai.com/projects/nbtostring/downloads

Posted by Simon Martinelli on September 11, 2009 at 01:32 PM CEST #

@Simon,

some pressure seems to help :-). I looked at the code - its nicely done, although the parsing API is bit complex.

have fun!,

adam

Posted by Adam Bien on September 11, 2009 at 05:44 PM CEST #

There is already a toString in Netbeans....
Just Press alt + insert then choose toString!

Posted by Moessi on March 11, 2011 at 03:33 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Meta
My Recent Book
Java One 2009/2011
...the last 150 posts
...the last 10 comments
Links
License