ThorbenKuck / ThorbenKuck/WireDI
[Feature]: Support Nullable injection points
@ThorbenKuck is already working on this.
Since Jul 15, 2023.
- Dominant language
- Java
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Type of feature request
Extension of an existing feature
What kind of feature would you like to see
Currently all injection points are not nullable. This means that every injection point is required to be present.
There are some esoteric, or non-standard use cases where you'd like to support Nullable Injection Points. Meaning that the injection process does not fail if the IOC container cannot find a matching bean instance for the type.
For this feature, all injections points should be able to support @Nullable. If @Nullable is present on any injection point, instead of failing on wiring, it should inject null.
Code Examples
@Wire
public class MyExample {
@Inject
@Nullable
private MyClass myClass;
public MyExample(@Nullable MyClass myClass) {
}
@Inject
public void inject(@Nullable MyClass myClass) {
}
}
Feature Design
The annotation processor should provide Identifiable Provider instances, that injects null, if the injection point is not present.. Should look something like this in the IdentifiableProvider:
MyClass parameter0 = wireRepository.tryGet(MyClass.class).orElse(null)
Note: Qualifiers should still work with this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.