IDEA添加非空Getter方法模板
阿新 • • 發佈:2018-02-10
urn san () ima turn 類型 help map eric
#if($field.modifierStatic) static ## #end $field.type ## #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) #if ($field.boolean && $field.primitive) is## #else get## #end ${name}() { ## 常用類型 #if($field.isString()) $field.name = Optional.ofNullable($field.name).orElse(""); #elseif($field.isList()) $field.name = Optional.ofNullable($field.name).orElse(new ArrayList<>()); #elseif($field.isSet()) $field.name = Optional.ofNullable($field.name).orElse(new HashSet<>()); #elseif($field.isMap()) $field.name = Optional.ofNullable($field.name).orElse(new HashMap<>()); ## 如果是基本類型,則什麽都不做 #elseif($field.numeric||$field.boolean||$field.byte||$field.char||$field.getTypeName() == "Character") ##用戶自定義類型或以上未包含類型,直接new #else $field.name = Optional.ofNullable($field.name).orElse(new $field.getTypeName()()); #end return $field.name; }
IDEA添加非空Getter方法模板