The Java Collections
class has the following method:
static <T> List<T> nCopies(int n, T o)
I need a similar method, but slightly more generic, which provides n instances of a given class. Something like:
static <T> List<T> nInstances(int n, Supplier<T> supplier)
In particular, if supplier
is Supplier.ofInstance(o)
, we get the same behavior as the nCopies()
method. Is there such a method somewhere in the Guava API?
Thank you.