@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class ToStringASTTransformation
extends AbstractASTTransformation
Handles generation of code for the
| Fields inherited from class | Fields |
|---|---|
class AbstractASTTransformation |
RETENTION_CLASSNODE, sourceUnit |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames)Adds toString, printing null values. |
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls)Adds toString with the class name qualified by its package.
|
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage)Adds toString that is computed on every call. |
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache)Adds toString without superclass properties. |
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache, boolean includeSuperProperties)Adds toString including JavaBean getters that have no field.
|
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache, boolean includeSuperProperties, boolean allProperties)Adds toString that skips internal names and superclass fields.
|
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache, boolean includeSuperProperties, boolean allProperties, boolean allNames, boolean includeSuperFields)Adds toString using FormatHelper.toString and
the default delimiters. |
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache, boolean includeSuperProperties, boolean allProperties, boolean allNames, boolean includeSuperFields, boolean pojo, String[] delims)Adds toString, reading properties from this rather
than through getters. |
|
public static void |
createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache, boolean includeSuperProperties, boolean allProperties, boolean allNames, boolean includeSuperFields, boolean pojo, String[] delims, boolean useGetter)Adds toString to cNode, or a private _toString
when a hand-written toString is already declared. |
|
public void |
visit(ASTNode[] nodes, SourceUnit source) |
Adds toString, printing null values. Delegates with
ignoreNulls false.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its value Adds toString with the class name qualified by its package.
Delegates with includePackage true.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null value Adds toString that is computed on every call. Delegates with
cache false.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its package Adds toString without superclass properties. Delegates with
includeSuperProperties false.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its packagecache - store the text in a $to$string field Adds toString including JavaBean getters that have no field.
Delegates with allProperties true.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its packagecache - store the text in a $to$string fieldincludeSuperProperties - include properties declared on superclasses Adds toString that skips internal names and superclass fields.
Delegates with allNames and includeSuperFields false.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its packagecache - store the text in a $to$string fieldincludeSuperProperties - include properties declared on superclassesallProperties - include JavaBean getters that have no field Adds toString using FormatHelper.toString and
the default delimiters. Delegates with pojo false and
delims null.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its packagecache - store the text in a $to$string fieldincludeSuperProperties - include properties declared on superclassesallProperties - include JavaBean getters that have no fieldallNames - keep names that contain $includeSuperFields - include fields declared on superclasses Adds toString, reading properties from this rather
than through getters. Delegates with useGetter false.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its packagecache - store the text in a $to$string fieldincludeSuperProperties - include properties declared on superclassesallProperties - include JavaBean getters that have no fieldallNames - keep names that contain $includeSuperFields - include fields declared on superclassespojo - render each value with toString, printing null as
the text null, instead of FormatHelperdelims - left delimiter, right delimiter, name/value separator,
and field separator; null or any other length uses
(, ), :, and , Adds toString to cNode, or a private _toString
when a hand-written toString is already declared. A stub
placeholder receives this body. An existing generated
toString, or a class that already declares both names, is
left unchanged. The text starts with the class name, or the enum
constant name, then the left delimiter, the selected values, and the
right delimiter. When includes is set, values follow that
order. A value whose static type is this class and that is this
instance is rendered as (this). When cache is true
the text is stored in a private synthetic $to$string field
and computed only while that field is null.
cNode - class that receives toStringincludeSuper - append super.toString()includeFields - include fields as well as propertiesexcludes - names to omit, or nullincludes - names to print, in this order, or nullincludeNames - print each name before its valueignoreNulls - skip a null valueincludePackage - qualify the class name with its package; ignored
for an enum, which prints name()cache - store the text in a $to$string fieldincludeSuperProperties - include properties declared on superclassesallProperties - include JavaBean getters that have no fieldallNames - keep names that contain $includeSuperFields - include fields declared on superclassespojo - render each value with toString, printing null as
the text null, instead of FormatHelperdelims - left delimiter, right delimiter, name/value separator,
and field separator; null or any other length uses
(, ), :, and , useGetter - read each property with its getter; otherwise read
the property on this. A bare field is read directly
either way