-
Notifications
You must be signed in to change notification settings - Fork 2
/
CheflingFactory.java
26 lines (22 loc) · 1.07 KB
/
CheflingFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.cookingfox.chefling.api;
import com.cookingfox.chefling.api.exception.ContainerException;
/**
* The factory defines one method that is used to create an instance of the generic type. A factory
* is generally used when the type can not be resolved by the container, for example when its
* constructor parameters are of a primitive type (boolean, int). Using a factory is more efficient
* than mapping an instance directly, because it will only be called once it is requested.
*
* @param <T> Hints at the type of object the factory should create.
*/
public interface CheflingFactory<T> {
/**
* Factory method that will create an instance of the generic type. The current container
* instance is provided, so that it can be used to request other dependencies. It is up to the
* developer to return an instance of the correct type.
*
* @param container The current container instance.
* @return An instance of the generic type.
* @throws ContainerException when an error occurs.
*/
T createInstance(CheflingContainer container);
}