To main content

Eclipse Photon: no StringJoiner Template for toString()

Published by Benjamin Marwell on
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! [caption id="attachment_6144" align="aligncenter" width="630"]Eclipse: toString template DialogEclipse: toString template Dialog[/caption] 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: [caption id="attachment_6145" align="aligncenter" width="908"]IntelliJ StringJoiner Template for toString() method.IntelliJ StringJoiner Template for toString() method.[/caption] 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.