[英]Sonarlint Violations for Guava Suppliers used with Memoize
I am using Guava Suppliers to memoize and reload some data after fixed time some in my class. 我正在使用Guava Suppliers在班级中固定时间后记忆和重新加载一些数据。 Recently sonarlint started generating warning with message such as 'Java 8 features should be preferred to Guava (squid:S4738)'.
最近,sonarlint开始生成警告消息,例如“ Guava应该首选Java 8功能(squid:S4738)”。
Can anyone tell me i can actually use Java Supplier here in any way to achieve the same functionality? 谁能告诉我我可以在这里实际使用Java Supplier以实现相同的功能吗?
Code Sample 代码样例
private final Supplier<Set<Integer>> cache = Suppliers.memoizewithExpiration(fetchData(), 1, TimeUnit.DAYS);
Use import java.util.function.Supplier
instead of com.google.common.base.Supplier
. 使用
import java.util.function.Supplier
而不是com.google.common.base.Supplier
。
Guava's Supplier
extends Java's Supplier
so it's safe to use. Guava的
Supplier
扩展了Java的Supplier
因此可以安全使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.