zoukankan      html  css  js  c++  java
  • IDEA Getter&Setter方法名snake_case转camelCase

    直接贴代码:

    Getter设置:

     1 #if($field.modifierStatic)
     2 static ##
     3 #end
     4 $field.type ##
     5 #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
     6 #if ($field.boolean && $field.primitive)
     7     #if ($StringUtil.startsWithIgnoreCase($name, 'is'))
     8         #set($name = $StringUtil.decapitalize($name))
     9     #else
    10     is##
    11     #end
    12 #else
    13 get##
    14 #end
    15 #set($words = $StringUtil.split($name, "_"))
    16 #set($name = "")
    17 #foreach($word in $words)
    18     #set($name = $name + $StringUtil.capitalize($word))
    19 #end
    20 ${name}() {
    21 return $field.name;
    22 }

    Setter设置:

     1 #set($paramName = $helper.getParamName($field, $project))
     2 #if($field.modifierStatic)
     3 static ##
     4 #end
     5 #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
     6 #set($words = $StringUtil.split($name, "_"))
     7 #set($name = "")
     8 #foreach($word in $words)
     9     #set($name = $name + $StringUtil.capitalize($word))
    10 #end
    11 void set$name($field.type $paramName) {
    12 #if ($field.name == $paramName)
    13     #if (!$field.modifierStatic)
    14     this.##
    15     #else
    16         $classname.##
    17     #end
    18 #end
    19 $field.name = $paramName;
    20 }

    选择自定义模板,贴上如上所示代码:

  • 相关阅读:
    Elasticsearch
    区块链 blockchain
    IM协议
    MQ,互联网架构解耦神器
    服务中的 API 网关(API Gateway)
    OSI七层与TCP/IP五层网络架构详解
    JQ input标签限制输入数字或字母
    c:forEach用法
    jquery在线引用
    JSONObject使用方法
  • 原文地址:https://www.cnblogs.com/julygift/p/12693965.html
Copyright © 2011-2022 走看看