How to call methods in getter setter template in IntelliJ?

I modified the standard getter setter template from IntelliJ a little so it only sets fields when the passed string is not empty.

How can I call .trim().isEmpty on my $paramName? Below is what I have so far. Instead of printing $paramName.trim().isEmpty() it just returns false.

What do I need to change?

And where can I find documentation on the templates? This doesn't seem to be the same than the live templates.

#set($paramName = $helper.getParamName($field, $project))
#if($field.modifierStatic)
static ##
#end
void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
#if ($field.name == $paramName)
    #if (!$field.modifierStatic)
        #if ($field.string)
        if ($paramName != null && $paramName.trim().isEmpty()) {
            return;
        }
        #end
        this.##
    #else
        $classname.##
    #end
#end
$field.name = $paramName;
}

1 answer

  • answered 2017-01-11 14:23 Moritz Schmitz v. Hülst

    That was easy. Just use a space between $paramName and .trim().isEmpty() and the expression won't be evaluated by IntelliJ.