Skip to content

Instantly share code, notes, and snippets.

@ghusta
Created March 18, 2016 11:15
Show Gist options
  • Save ghusta/3328abca814e8d8d727c to your computer and use it in GitHub Desktop.
Save ghusta/3328abca814e8d8d727c to your computer and use it in GitHub Desktop.
Fluent Setter template for IntelliJ
#set($paramName = $helper.getParamName($field, $project))
public ##
#if($field.modifierStatic)
static void ##
#else
$classname ##
#end
with$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
#if ($field.name == $paramName)
#if (!$field.modifierStatic)
this.##
#else
$classname.##
#end
#end
$field.name = $paramName;
#if(!$field.modifierStatic)
return this;
#end
}
@ghusta
Copy link
Author

ghusta commented Mar 18, 2016

Set it in IntelliJ this way :
Generate > Setter
Add a template ("Fluent Setter"), with the content of the template.

More info in this blog (french) : https://guillaumehusta.wordpress.com/2016/03/18/generateur-de-methodes-fluent-en-java-avec-intellij/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment