mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method and annotation
This commit is contained in:
@@ -7,7 +7,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 忽略注解,使用此注解的字段等会被忽略,主要用于Bean拷贝、Bean转Map等
|
||||
* 属性忽略注解,使用此注解的字段等会被忽略,主要用于Bean拷贝、Bean转Map等<br>
|
||||
* 此注解应用于字段时,忽略读取和设置属性值,应用于setXXX方法忽略设置值,应用于getXXX忽略读取值
|
||||
*
|
||||
* @author Looly
|
||||
* @since 5.4.2
|
||||
@@ -15,6 +16,6 @@ import java.lang.annotation.Target;
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
public @interface Ignore {
|
||||
public @interface PropIgnore {
|
||||
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.bean;
|
||||
|
||||
import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.core.annotation.Ignore;
|
||||
import cn.hutool.core.annotation.PropIgnore;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||
@@ -566,33 +566,33 @@ public class BeanDesc implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查字段是否被忽略读,通过{@link Ignore} 注解完成,规则为:
|
||||
* 检查字段是否被忽略读,通过{@link PropIgnore} 注解完成,规则为:
|
||||
* <pre>
|
||||
* 1. 在字段上有{@link Ignore} 注解
|
||||
* 2. 在getXXX方法上有{@link Ignore} 注解
|
||||
* 1. 在字段上有{@link PropIgnore} 注解
|
||||
* 2. 在getXXX方法上有{@link PropIgnore} 注解
|
||||
* </pre>
|
||||
*
|
||||
* @return 是否忽略读
|
||||
* @since 5.4.2
|
||||
*/
|
||||
public boolean isIgnoreGet() {
|
||||
return AnnotationUtil.hasAnnotation(this.field, Ignore.class)
|
||||
|| AnnotationUtil.hasAnnotation(this.getter, Ignore.class);
|
||||
return AnnotationUtil.hasAnnotation(this.field, PropIgnore.class)
|
||||
|| AnnotationUtil.hasAnnotation(this.getter, PropIgnore.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查字段是否被忽略写,通过{@link Ignore} 注解完成,规则为:
|
||||
* 检查字段是否被忽略写,通过{@link PropIgnore} 注解完成,规则为:
|
||||
* <pre>
|
||||
* 1. 在字段上有{@link Ignore} 注解
|
||||
* 2. 在setXXX方法上有{@link Ignore} 注解
|
||||
* 1. 在字段上有{@link PropIgnore} 注解
|
||||
* 2. 在setXXX方法上有{@link PropIgnore} 注解
|
||||
* </pre>
|
||||
*
|
||||
* @return 是否忽略写
|
||||
* @since 5.4.2
|
||||
*/
|
||||
public boolean isIgnoreSet() {
|
||||
return AnnotationUtil.hasAnnotation(this.field, Ignore.class)
|
||||
|| AnnotationUtil.hasAnnotation(this.setter, Ignore.class);
|
||||
return AnnotationUtil.hasAnnotation(this.field, PropIgnore.class)
|
||||
|| AnnotationUtil.hasAnnotation(this.setter, PropIgnore.class);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------ Private method start
|
||||
|
Reference in New Issue
Block a user