Skip to content

Eclipse Photon: no StringJoiner Template for toString()

Eclipse Photon finally ships with a toString()  template configurator.

Sadly, this dialog has some major limitations: It is not possible to configure the templates as freely as you like. Instead, they will be checked for type safety. This brings along another restriction: The selected builder class needs to have a public constructor with a single object (or string) argument. Yikes!

Eclipse: toString template Dialog
Eclipse: toString template Dialog

I have no clue, why someone had the idea that a builder class needs to have a public constructor with a single object argument. Instead, IntelliJ IDEA shows us how it’s done correctly: You can freely insert any Java Code you like, including nested conditions:

IntelliJ StringJoiner Template for toString() method.
IntelliJ StringJoiner Template for toString() method.

As you can see, IntelliJ has no such restrictions. It is very easy to include such a template. I waited for more than 10 years for eclipse to ship a template configuration dialog for toString()  methods. Now it’s here. But it does not help much.

IntelliJ StringJoiner Template for toString() methods

By the way: The template you can see in above screenshot can be found right here on Github as gist.

Published inHow TosProgramming / Codingsoftware showcase

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *