Shouldn't generate toString in Groovy class use Groovy

This is the generated toString for my Hand Groovy class from IDEA 12

  @Override   public String toString() {     return "Hand{" +         "playerSeat=" + playerSeat +         ',}';   }



As you can see this is Java not Groovy. 1) There is a semi-colon. 2) String concatentaion with "+" and 3) Doesn't use triple quotes if you need multiline Strings.

I could have sworn this used to work, or that in one previous version of IntelliJ it didn't work, then got fixed, and now not working.

I of course, can simply fix the code now, but it should still work.

Thanks

Mark
0

I've created corresponding feature request - IDEA-97720.

Denis

0

Could you provide an example of what your ideal Groovy toString() method would look like? How should an array or collection be handled for example?

Bas

0

Well the question for the collection is non-relevant. So to speak


  @Override
  public String toString() {
    return "Account: """birthday=${birthday}
        , anotherProperty=${anotherProperty}
        , email=${email}
        , someCollection=${someCollection}
        , username=${username}"""
  }



If you can go and write a loop for a collection, you can do it as simple as

someCollection.each{ it.toString()}

Hope that helps.

Mark

0

请先登录再写评论。