Created
December 14, 2016 15:28
-
-
Save bholota/e234b69eb8f27a048519fd1be7224da8 to your computer and use it in GitHub Desktop.
InteliJ getter/setter template for Jackson properties
This file contains hidden or 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
// JacksonGetter | |
#set($const_name = $helper.getPropertyName($field, $project).toString().replaceAll("([A-Z]+)","\_$1").toUpperCase()) | |
@JsonProperty(${const_name}) | |
@Nullable | |
#if($field.modifierStatic) | |
static ## | |
#end | |
$field.type ## | |
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) | |
#if ($field.boolean && $field.primitive) | |
#if ($StringUtil.startsWithIgnoreCase($name, 'is')) | |
#set($name = $StringUtil.decapitalize($name)) | |
#else | |
is## | |
#end | |
#else | |
get## | |
#end | |
${name}() { | |
return $field.name; | |
} | |
// JacksonSetter | |
#set($const_name = $helper.getPropertyName($field, $project).toString().replaceAll("([A-Z]+)","\_$1").toUpperCase()) | |
@JsonProperty(${const_name}) | |
#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) | |
this.## | |
#else | |
$classname.## | |
#end | |
#end | |
$field.name = $paramName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment