forked from strindberg/intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toStringTemplates.xml
41 lines (41 loc) · 6.6 KB
/
toStringTemplates.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<application>
<component name="ToStringTemplates">
<option name="defaultTempalteName" value="String concat (+)" />
<option name="templates">
<list>
<TemplateResource>
<option name="fileName" value="String concat (+)" />
<option name="template" value="public java.lang.String toString() { #if ( $members.size() > 0 ) #set ( $i = 0 ) return "$classname{" + #foreach( $member in $members ) #if ( $i == 0 ) "## #else ", ## #end #if ( $member.objectArray ) #if ($java_version < 5) $member.name=" + ($member.accessor == null ? null : java.util.Arrays.asList($member.accessor)) + #else $member.name=" + java.util.Arrays.toString($member.accessor) + #end #elseif ( $member.primitiveArray && $java_version >= 5) $member.name=" + java.util.Arrays.toString($member.accessor) + #elseif ( $member.string ) $member.name='" + $member.accessor + '\'' + #else $member.name=" + $member.accessor + #end #set ( $i = $i + 1 ) #end '}'; #else return "$classname{}"; #end }" />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="String concat (+) and super.toString()" />
<option name="template" value="public java.lang.String toString() { #if ( $members.size() > 0 ) #set ( $i = 0 ) return "$classname{" + #foreach( $member in $members ) #if ( $i == 0 ) "## #else ", ## #end #if ( $member.objectArray ) #if ($java_version < 5) $member.name=" + ($member.accessor == null ? null : java.util.Arrays.asList($member.accessor)) + #else $member.name=" + java.util.Arrays.toString($member.accessor) + #end #elseif ( $member.primitiveArray && $java_version >= 5) $member.name=" + java.util.Arrays.toString($member.accessor) + #elseif ( $member.string ) $member.name='" + $member.accessor + '\'' + #else $member.name=" + $member.accessor + #end #set ( $i = $i + 1 ) #end #if ( $class.hasSuper ) "} " + super.toString(); #else '}'; #end #else #if ( $class.hasSuper ) return "$classname{} " + super.toString(); #else return "$classname{}"; #end #end }" />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="StringBuffer" />
<option name="template" value="public java.lang.String toString() { final java.lang.StringBuffer sb = new java.lang.StringBuffer("$classname{"); #set ($i = 0) #foreach ($member in $members) #if ($i == 0) sb.append("## #else sb.append(", ## #end #if ($member.string) $member.name='")## #else $member.name=")## #end #if ($member.primitiveArray) ; if ($member.name == null) ## sb.append("null"); else { sb.append('['); for (int i = 0; i < $member.name .length; ++i) sb.append(i == 0 ? "" : ", ").append($member.name [i]); sb.append(']'); } #elseif ($member.objectArray) .append($member.name == null ? "null" : java.util.Arrays.asList($member.name).toString()); #elseif ($member.string) .append($member.accessor).append('\''); #else .append($member.accessor); #end #set ($i = $i + 1) #end sb.append('}'); return sb.toString(); }" />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="StringBuilder (JDK 1.5)" />
<option name="template" value="public java.lang.String toString() { final java.lang.StringBuilder sb = new java.lang.StringBuilder("$classname{"); #set ($i = 0) #foreach ($member in $members) #if ($i == 0) sb.append("## #else sb.append(", ## #end #if ($member.string) $member.name='")## #else $member.name=")## #end #if ($member.primitiveArray || $member.objectArray) .append(java.util.Arrays.toString($member.name)); #elseif ($member.string) .append($member.accessor).append('\''); #else .append($member.accessor); #end #set ($i = $i + 1) #end sb.append('}'); return sb.toString(); }" />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="ToStringBuilder (Apache commons-lang)" />
<option name="template" value="public java.lang.String toString() { return new org.apache.commons.lang.builder.ToStringBuilder(this) #foreach ($member in $members) .append("$member.name", $member.accessor) #end .toString(); }" />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="ToStringBuilder (Apache commons-lang 3)" />
<option name="template" value="public java.lang.String toString() { return new org.apache.commons.lang3.builder.ToStringBuilder(this) #foreach ($member in $members) .append("$member.name", $member.accessor) #end .toString(); }" />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="Objects.toStringHelper (Guava)" />
<option name="template" value="public java.lang.String toString() { return com.google.common.base.Objects.toStringHelper(this) #foreach ($member in $members) .add("$member.name", $member.accessor) #end .toString(); } " />
</TemplateResource>
<TemplateResource>
<option name="fileName" value="Groovy: String concat (+)" />
<option name="template" value="public java.lang.String toString() { #if ( $members.size() > 0 ) #set ( $i = 0 ) return """\ $classname{ #foreach( $member in $members ) #if ( $i > 0 ), #end #set($d = "$") #if ( $member.objectArray ) $member.name=${d}{java.util.Arrays.toString($member.accessor)}## #elseif ( $member.primitiveArray) $member.name=${d}{java.util.Arrays.toString($member.accessor)}## #elseif ( $member.string ) $member.name='$d$member.accessor'## #else $member.name=$d${member.accessor}## #end #set ( $i = $i + 1 ) #end }""" #else return "$classname{}" #end }" />
</TemplateResource>
</list>
</option>
</component>
</application>