简体   繁体   English

与Moemoize一起使用的针对番石榴供应商的Sonarlint违规行为

[英]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.

相关问题 番石榴输入/输出供应商和URLConnection - Guava Input/Output Suppliers and URLConnection 如何在方法抛出Checked-Exception时使用Suppliers.memoize - How to use Suppliers.memoize when method throws Checked-Exception 我可以在Eclipse中为SonarLint配置使用的规则集 - Can I configure the used ruleset for SonarLint in Eclipse SonarQube(SonarLint / Sonar-JAVA)不应使用冗余演员表 - SonarQube (SonarLint /Sonar-JAVA) Redundant casts should not be used Sonarlint 提示“重构代码以便使用流管道” - Sonarlint prompting to "Refactor code so that stream pipeline is used" 番石榴的LocalCache无法使用,为什么? - Guava's LocalCache could not be used, why? 使用Guava Iterables时将使用什么Iterable - What Iterable will be used when working with Guava Iterables Guava缓存expireAfterWrite仅适用于使用getIfPresent吗? - Guava Cache expireAfterWrite is only applicable with getIfPresent used? Guava中使用的无锁延迟加载模式是否真的是线程安全的? - Is the lockless lazy loading pattern used in Guava really thread-safe? 是否应该在每次使用番石榴分离器/连接器时创建? - Should Guava Splitters/Joiners be created each time they are used?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM