-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New builder functions with resolver parameter
- Loading branch information
1 parent
91d737a
commit 9b700b0
Showing
8 changed files
with
83 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package newdicontainer; | ||
|
||
import dicontainer.DiException; | ||
import newdicontainer.annotation.Dependency; | ||
|
||
public interface DiResolver | ||
{ | ||
/** | ||
* Resolve all dependencies and construct a new instance of given type using {@link Dependency}. | ||
* @param type type class | ||
* @return new instance | ||
* @throws DiException if type cannot be resolved | ||
*/ | ||
<T> T resolve(Class<T> type); | ||
|
||
/** | ||
* Resolve all dependencies and construct a new instance of given type using {@link Dependency}. | ||
* @param type type class | ||
* @return new instance, or {@code null} if type cannot be resolved. | ||
*/ | ||
default <T> T resolveOrNull(Class<T> type) | ||
{ | ||
try | ||
{ | ||
return resolve(type); | ||
} | ||
catch(DiException ex) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
10 changes: 7 additions & 3 deletions
10
...wdicontainer/dictionary/DiDictionary.java → ...tainer/dictionary/DependencyRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/main/java/newdicontainer/dictionary/valuetypes/Subtype.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters