0

I am using Guava Suppliers to memoize and reload some data after fixed time some in my class. Recently sonarlint started generating warning with message such as 'Java 8 features should be preferred to Guava (squid:S4738)'.

Can anyone tell me i can actually use Java Supplier here in any way to achieve the same functionality?

Code Sample

private final Supplier<Set<Integer>> cache = Suppliers.memoizewithExpiration(fetchData(), 1, TimeUnit.DAYS);
vaibhavvc1092
  • 3,067
  • 4
  • 19
  • 26

1 Answers1

2

Use import java.util.function.Supplier instead of com.google.common.base.Supplier.

Guava's Supplier extends Java's Supplier so it's safe to use.

Olivier Grégoire
  • 33,839
  • 23
  • 96
  • 137