toString() Generation Settings dialog
Settings tab
| Item | Description |
|---|---|
| Use fully qualified class name in code generation ($classname) | If this checkbox is selected, the dumped classnames will include their package names. (The $classname variable in the Velocity templates) |
| Enable getters in code generation ($method) | If this checkbox is selected, the code generator will have $methods variable in the Velocity Macro Language.
See example 2. |
| Move caret to the generated method | If this checkbox is selected, the caret scrolls to the generated toString() method. |
| Sort elements | If this checkbox is selected, the members are sorted in the selected order (ascending or descending). |
| When method already exists | In this section, choose the default conflict resolution policy:
|
| Where to insert? | In this section, choose the place to insert the generated toString() method. The possible options are:
|
| Exclude | In this section, select the checkboxes next to the elements to be excluded from the toString() method generation:
|
Templates tab
Use this page to view and manage the list of Velocity templates to be used for the toString() method generation.
Templates toolbar
| Item | Description |
|---|---|
| Click this button to create a new entry to the list of available templates. When the new entry is added, create the corresponding template. | |
| Click this button to delete the selected user-created entry from the list of available patterns. Note that pre-defined templates cannot be deleted. | |
| Click this button to create a copy of an existing template. |
Variables used in Velocity templates
| Variable | Returns | Description |
|---|---|---|
| $classname | String | The name of a class (can be qualified classname, if this is selected in the settings). |
| $FQClassname | String | @deprecated (use $class.qualifiedName) - The fully qualified name of the class |
| $fields | java.util.List | List of FieldElement objects |
| $methods | java.util.List | List of MethodElement objects |
| $members | java.util.List | List of both FieldElement and MethodElement objects |
| $member | Element | The Element object |
| $member.accessor | String | The accessor of a field or method. For a field it is $field.name and for a method it is $method.methodName. |
| $member.typeName | String | The classname of the type (Object, String, List etc.) |
| $member.typeQualifiedName | String | The qualified classname of the type (java.lang.Object, java.lang.String, java.uti.List etc.) |
| $member.array | boolean | Checks if the type is an array type (either a primitive array or object array). |
| $member.primitiveArray | boolean | Checks if the type is a primitive array type (int[], short[], float[] etc.) |
| $member.objectArray | boolean | Checks if the type is an Object array type (Object[], String[] etc.). |
| $member.stringArray | boolean | Checks if the type is a String array type (String[]) |
| $member.collection | boolean | Checks if the type is assignable from java.util.Collection. |
| $member.list | boolean | Checks if the type is assignable from java.util.List |
| $member.map | boolean | Checks if the type is assignable from java.util.Map |
| $member.set | boolean | Checks if the type is assignable from java.util.Set |
| $member.primitive | boolean | Checks if the type is a primitive type (int, char, float etc.) |
| $member.modifierStatic | boolean | Does the type have a static modifier? |
| $member.modifierPublic | boolean | Does the type have a public modifier? |
| $member.modifierProtected | boolean | Does the type have a protected modifier? |
| $member.modifierPackageLocal | boolean | Does the type have a package-local modifier? |
| $member.modifierPrivate | boolean | Does the type have a private modifier? |
| $member.modifierFinal | boolean | Does the type have a final modifier? |
| $member.string | boolean | Is the type assignable from java.lang.String? |
| $member.numeric | boolean | Is the type assignable from java.lang.Numeric or a primitive type of byte, short, int, long, float, double? |
| $member.object | boolean | Is the type assignable from java.lang.Object? |
| $member.date | boolean | Is the type assignable from java.util.Date? |
| $member.calendar | boolean | Is the type assignable from java.util.Calendar? |
| $member.boolean | boolean | Is the type assignable from java.lang.Boolean or a primitive boolean? |
| $field | FieldElement | The FieldElement object |
| $field.name | String | The name of a field. |
| $field.modifierTransient | boolean | Does the field have a transient modifier? |
| $field.modifierVolatile | boolean | Does the field have a volatile modifier? |
| $field.constant | boolean | Is the field a constant type? (has static modifier and its name is in UPPERCASE only) |
| $field.matchName(regexp) | boolean | Performs a regular expression matching on a field name. |
| $field.enum | boolean | Is this field a enum type? |
| $method | MethodElement | The MethodElement object |
| $method.name | String | This variable returns one of the following:
|
| $method.methodName | String | The name of the method (getFoo). |
| $method.fieldName | String | The name of the field this getter method covers - null if the method is not a getter for a field |
| $method.modifierAbstract | boolean | Is this method an abstract method? |
| $method.modifierSynchronized | boolean | Is this method a synchronized method? |
| $method.returnTypeVoid | boolean | Is this method a void method (does not return anything) ? |
| $method.getter | boolean | Is this a getter method? |
| $method.matchName(regexp) | boolean | Performs a regular expression matching on the method name. |
| $method.deprecated | boolean | Is this method deprecated? |
| $class | ClassElement | The ClassElement object |
| $class.name | String | The name of the class |
| $class.matchName(regexp) | boolean | Performs a regular expression matching on the classname. |
| $class.qualifiedName | String | The fully qualified name of the class |
| $class.hasSuper | boolean | Does the class have a superclass? (extends another class - note extending java.lang.Object is not considered having a superclass) |
| $class.superName | String | The name of the superclass (empty if no superclass) |
| $class.superQualifiedName | String | The fully qualified name of the superclass (empty if no superclass) |
| $class.isImplements("interfaceName") | boolean | Checks if the class implements the given interface. Checking names of several interfaces can be done by separating the names with commas. |
| $class.implementNames | String[] | Returns the class names of the interfaces the class implements. An empty array is returned, if the class does not implement any interfaces. |
| $class.isExtends("className") | boolean | Checks if the class extends any of the given class names. Chcecking several class names can be done by separating the names with commas. |
| $class.exception | boolean | Is this class an exception class (extends Throwable)? |
| $class.deprecated | boolean | Is this class deprecated? |
| $class.enum | boolean | Is this class an enum class? |
| $class.abstract | boolean | Is this class abstract? |
| Output variables | The output variables are possible in the Velocity Template (variables are stored in the Velocity Context): Output parameters will be available for the Generate action after the Velocity context has been executed and act upon. | |
| $autoImportPackages | String | Packagenames that should automatically be imported. Use comma to separate packagenames. |