增加ConvertDisabled功能
This commit is contained in:
24
src/org/redkale/convert/ConvertDisabled.java
Normal file
24
src/org/redkale/convert/ConvertDisabled.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.convert;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 序列化时永久禁用该字段, 与ConvertColumn.ignore()的区别在于: ConvertDisabled不能通过ConvertEntity来解禁
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ConvertDisabled {
|
||||
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
if (method.isSynthetic()) continue;
|
||||
if (method.getName().length() < 4) continue;
|
||||
if (!method.getName().startsWith("set")) continue;
|
||||
if (method.getAnnotation(java.beans.Transient.class) != null) continue;
|
||||
if (method.getAnnotation(ConvertDisabled.class) != null) continue;
|
||||
if (method.getParameterTypes().length != 1) continue;
|
||||
if (method.getReturnType() != void.class) continue;
|
||||
if (reversible && (cps == null || !ObjectEncoder.contains(cps, ConvertFactory.readGetSetFieldName(method)))) {
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T
|
||||
if (method.getName().length() < 3) continue;
|
||||
if (method.getName().equals("getClass")) continue;
|
||||
if (!method.getName().startsWith("is") && !method.getName().startsWith("get")) continue;
|
||||
if (method.getAnnotation(java.beans.Transient.class) != null) continue;
|
||||
if (method.getAnnotation(ConvertDisabled.class) != null) continue;
|
||||
if (method.getParameterTypes().length != 0) continue;
|
||||
if (method.getReturnType() == void.class) continue;
|
||||
if (reversible && (cps == null || !contains(cps, ConvertFactory.readGetSetFieldName(method)))) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.redkale.util;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
|
||||
/**
|
||||
* 该类提供类似JSONObject的数据结构,主要用于读取xml配置文件和http-header存储
|
||||
@@ -239,7 +240,7 @@ public abstract class AnyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
@java.beans.Transient
|
||||
@ConvertDisabled
|
||||
public String[] getNames() {
|
||||
Set<String> set = new LinkedHashSet<>();
|
||||
for (Entry en : this.stringEntrys) {
|
||||
|
||||
Reference in New Issue
Block a user