Package com.itextpdf.commons.utils
Class DIContainer
java.lang.Object
com.itextpdf.commons.utils.DIContainer
A simple dependency injection container.
The container is thread-safe.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionT getInstance
(Class clazz) Gets an instance of a class.void
Registers an instance for a class.static void
registerDefault
(Class> clazz, Supplier<Object> supplier) Registers a default instance for a class.
-
Constructor Details
-
DIContainer
public DIContainer()Creates a new instance ofDIContainer
.
-
-
Method Details
-
registerDefault
Registers a default instance for a class.- Parameters:
-
clazz
- the class -
supplier
- supplier of the instance
-
register
Registers an instance for a class.- Parameters:
-
clazz
- the class -
inst
- the instance
-
getInstance
Gets an instance of a class.- Type Parameters:
-
T
- the type of the class - Parameters:
-
clazz
- the class - Returns:
- the instance
-