Interface InstanceSupplier
public interface InstanceSupplier
A supplier of instances of objects.
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classASupplierimplementation that supplies new instances of a class each time itsSupplier.get()method is called.static classASupplierimplementation that supplies the same singleton instance of a value each time itsSupplier.get()method is called. - 
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> Supplier<T> Create anSupplierthat supplies a new instances of the specified Class.static <T> Supplier<T> Create anSupplierthat supplies a singleton of the specified Class.static <T> Supplier<T> singleton(T instance) Create aSupplierthat supplies a singleton. 
- 
Method Details
- 
singleton
Create aSupplierthat supplies a singleton.- Type Parameters:
 T- the type of instance supplied- Parameters:
 instance- the singleton instance to supply- Returns:
 - the singleton instance
 - Throws:
 NullPointerException- if the instance parameter is null
 - 
singleton
Create anSupplierthat supplies a singleton of the specified Class.The Class provided must have a no-args default constructor.
- Type Parameters:
 T- the type of instance supplied- Parameters:
 cls- the Class of the singleton instance to supply- Returns:
 - the singleton instance of the specified Class
 - Throws:
 NullPointerException- if the class is null
 - 
create
Create anSupplierthat supplies a new instances of the specified Class.The Class provided must have a no-args default constructor.
A new instance of the specified Class is created for every call to
Supplier.get().- Type Parameters:
 T- the type of instance supplied- Parameters:
 cls- the Class of the singleton instance to supply- Returns:
 - the singleton instance of the specified Class
 - Throws:
 NullPointerException- if the class is null
 
 -