Annotation Type Optional
-
@Retention(RUNTIME) @Target(PARAMETER) public @interface Optional
When present on a constructor parameter, indicates that the specified dependency is optional. If the dependency cannot be resolved then a
null
value will be injected instead.Use of this annotation is not encouraged, it should be used with caution. Optional dependencies make it harder to reason about the dependency graph. Making a dependency optional does not break dependency cycles, use
Provider
instead.- Author:
- cdivilly