-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support explictly null set in model(poc) #31
base: java-sdk-2.18.2-2025-01-06T07-06-06.523Z
Are you sure you want to change the base?
Conversation
cca0cbd
to
cf610d6
Compare
cf610d6
to
fd11665
Compare
if (!field.canAccess(value)) { | ||
field.setAccessible(true); | ||
} | ||
fieldValue = field.get(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥 private field 还需要被序列化?我看常见的做法是只处理 public getter/setter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我试了一下,发现 getter 来获取其实不太方便,因为 getter 本质还是一个 function,没法准确的通过是否以 get 开头就是 getter 的逻辑来推断一个方法一定是 getter。。。
感觉通过 private field + annotation 判断的方法更加稳妥一点。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以看看 beanutils getProperty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emmm,看了一下,是能解决如何推断 getter,但是我还需要 annotation 的 value orz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不过我现在想我是不是该放弃反射,给每个类单独生成一个 Adapter
private final static String IS_PRESENT = "_isPresent_"; | ||
|
||
public static class ConditionalNullablePojo { | ||
protected Set<String> _isPresent_ = new HashSet<String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 _isPresent_
是故意的吗,这个名字看着有点怪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
避免和潜在的可能字段冲突,用 _ 当 prefix 过滤一层,在自己这边不在 api 参数中定义 _ 前缀的字段
add ConditionalNullablePojo and type adapter
self test serialize and deserialize