Skip to content

Instantly share code, notes, and snippets.

@smilix
Last active April 28, 2016 13:53
Show Gist options
  • Save smilix/9441452fc00d4d9b5391d487ebe848d9 to your computer and use it in GitHub Desktop.
Save smilix/9441452fc00d4d9b5391d487ebe848d9 to your computer and use it in GitHub Desktop.
IntelliJ toString template (uses String.format)
public java.lang.String toString() {
return String.format(
"$classname [##
#set ($i = 0)
#foreach ($member in $members)
#if ($i != 0)
, ##
#end
$member.name=%s##
#set ($i = $i + 1)
#end
]",
#set ($i = 0)
#foreach ($member in $members)
#if ($i != 0)
,
#end
#if ($member.primitiveArray || $member.objectArray)
java.util.Arrays.toString(this.$member.name)##
#else
this.$member.name ##
#end
#set ($i = $i + 1)
#end
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment