Basic Concepts
DepIn is a dependency Injection tool that written in java
Simple usage
The simples usage of this library is:
This way, we create a defaultClass
instance with all dependencies.
Note that we create dependencies of this instance from scratch.
If we want to pass spesific argument to instance's constructor method, we may use:
We use withArgs(Object... args)
chain method for injecting arguments with constructor
There is other ways to instantiate classes. For example, setters. We can simply inject dependencies with setters like this:
Firstly, we need a map to store and match setter and their arguments
And then, we need to describe our setter methods and their arguments
Finally, we can use our map in withSetters(Map<String,Object> setters)
chain method to create instance
We can similarly inject our dependencies directly with fields.
We just use withFields(Map<String,Object> setters)
chain method.
This is inject the spesific fields that named in map with the corresponding object arguments
Last updated