idea去除sonarlint扫描Date的问题
重写get和set方法
设置idea的get和set方法
get设置
#if($field.modifierStatic)
static ##
#end
#if($field.date)
$field.type ##
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($field.boolean && $field.primitive)
is##
#else
get##
#end
${name}() {
if(this.$field.name == null){
return null;
}
return ($field.type) this. $field.name .clone();
}
#else
public void delete_get_method_##
$field.name (){}
#end
set设置
#set($paramName = $helper.getParamName($field, $project))
#if($field.modifierStatic)
static ##
#end
#if($field.date)
void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
#if ($field.name == $paramName)
#if (!$field.modifierStatic)
##
#else
$classname.##
#end
#end
if($paramName == null){
this.##
$field.name = null;
return;
}
this.##
$field.name = ($field.type)##
$paramName##
.clone();
}
#else
public void delete_set_method_##
$field.name (){}
#end
删除正则
\n +public void delete_(set|get)_method_[A-Za-z0-9]+\(\) \{\n +\}\n
验证
public class TestGetSet {
private Date date;
private Timestamp timestamp;
private String name;
private Integer count;
public Date getDate() {
if (this.date == null) {
return null;
}
return (Date) this.date.clone();
}
public void setDate(Date date) {
if (date == null) {
this.date = null;
return;
}
this.date = (Date) date.clone();
}
public Timestamp getTimestamp() {
if (this.timestamp == null) {
return null;
}
return (Timestamp) this.timestamp.clone();
}
public void setTimestamp(Timestamp timestamp) {
if (timestamp == null) {
this.timestamp = null;
return;
}
this.timestamp = (Timestamp) timestamp.clone();
}
}
版权声明:本文为soft_z1302原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。