When we should use Supplier in Java 8?
I’ll go through a scenario where we should use Supplier<LocalDate> instead of LocalDate. Code that directly makes calls to static methods like LocalDate.now() is very difficult to unit test. Consider a scenario where we want to unit test a method getAge() that calculates a person’s age: class Person { final String name; private final LocalDate … Read more