Created
April 23, 2015 17:26
-
-
Save delphyne/f71b3b56a68a0ef73e92 to your computer and use it in GitHub Desktop.
IntelliJ Generate Setters for Guava Optionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set ($paramName = $helper.getParamName($field, $project)) | |
#set ($isOptional = $field.typeQualifiedName.startsWith('com.google.common.base.Optional<')) | |
#if ($isOptional) | |
#set ($paramType = $field.typeQualifiedName.replaceAll(".*?<(.*)>$", "$1")) | |
#else | |
#set ($paramType = $field.typeQualifiedName) | |
#end | |
public ## | |
#if($field.modifierStatic) | |
static void ## | |
#else | |
$classname ## | |
#end | |
set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($paramType $paramName) { | |
#if ($field.name == $paramName) | |
#if (!$field.modifierStatic) | |
this.## | |
#else | |
$classname.## | |
#end | |
#end | |
$field.name = ## | |
#if ($isOptional) | |
Optional.fromNullable( ## | |
#end | |
$paramName ## | |
#if ($isOptional) | |
) ## | |
#end | |
; | |
#if(!$field.modifierStatic) | |
return this; | |
#end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given the following class:
Generates the following setters: