NetBeans - Generating toString for Java classes

My friend and colleague Shams developed a maven plugin to generate toString and equals method using Eclipse source code manipulation API and since then, being a NetBeans fan, I wanted to develop a similar component using NetBeans API. Though the Java Source API of NetBeans was available in the developer version, but it is finally going to be released with NetBeans 6.1 and one can have a look at it in 6.1Beta release.

So I started doing what I have been wanting to do for a long time :) - develop a NetBeans module to generate toString() for my Java classes. In this endeavour I came up with this open source project. In the generation of toString() I added iteration over array and collection over what Shams did. Users can simply download the NBM file from here and install it into your NetBeans 6.1 installation. To confirm that the installation is successful check the "Source" menu and you should see "Generate toString()" at the top of the list. To see the module in action simply open a Java Source file and choose the menu action and you will see that it will add/replace toString() methods of the classes in the file.

As future works to this plugin I have plans to add it to the context menu in project explorer for Java projects, provide a UI for user to choose what properties should be in toString and whether to replace toString or not. Additionally generate the current toString content in a separate method and invoke it from toString().

I also have plans for further plugins ; lets hope I have enough time for it :). Please create issues in the project to report issues or enhancements. Participation in development is most welcomed.

7 comments:

  1. A newer version of the plugin is available. Please check the site.

    ReplyDelete
  2. Thanks for your efforts. Very Useful

    ReplyDelete
  3. Glad to learn that someone liked it :), Almighty willing I will publish a newer version of the plugin in April or May :). Did you try the java.util.Logger plugin?

    ReplyDelete
  4. Really nice plugin, any chance you will add more functionality (and add the @override tag) ?

    ReplyDelete
  5. @Skjalg
    Yes I have all intentions to add features to it, as soon as I can wrap up my works with the projects that I am currently working with.

    I am not sure what you want me to add regarding the @Override annotation, can you please specify?

    ReplyDelete
  6. i think he just wanna you to add "@Override" annotation in the toString() function

    ReplyDelete

Search