Reputation: 3652
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;
}
Upvotes: 0
Views: 280
Reputation: 1902
Try to put a space between $param
and .trim().isEmpty()
so the expression won't be evaluated by IntelliJ.
Upvotes: 1