Skip to content
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

建议查询条件构建里面的values 提供Supplier重载 #52

Open
xuqiu opened this issue Aug 25, 2020 · 0 comments
Open

建议查询条件构建里面的values 提供Supplier重载 #52

xuqiu opened this issue Aug 25, 2020 · 0 comments

Comments

@xuqiu
Copy link

xuqiu commented Aug 25, 2020

.in(CollectionUtils.isNotEmpty(statusSet), "status", statusSet.toArray())
比如这个条件, 尽管前面条件里判空了,但是如果statusSet是null仍然会抛出空指针

一般解决这个问题可以用 ==null?null: 这种三元符来解决:
.in(CollectionUtils.isNotEmpty(statusSet), "status", statusSet==null?null:statusSet.toArray())

但是更优雅的方式是提供Supplier参数重载. 这样扩展性也更好:
.in(CollectionUtils.isNotEmpty(statusSet), "status", ()-> statusSet.toArray())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant