public static enum TypeDependency.Kind extends Enum<TypeDependency.Kind>
| Enum Constant and Description |
|---|
MULTIPLE
All available implementations of the type (matching the
TypeQualifier) are injected |
OPTIONAL
The dependency is injected if available, otherwise a null value is
supplied.
|
PROVIDER
The dependency is injected via a
Provider instance, resolving of
the dependency is deferred until Provider.get() is invoked. |
REQUIRED
The default injection kind, one instance of the required dependency must
be available or else instantiation of the type is abandoned and
TypeDependencyNotAvailableException is raised |
| Modifier and Type | Method and Description |
|---|---|
static TypeDependency.Kind |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static TypeDependency.Kind[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final TypeDependency.Kind MULTIPLE
TypeQualifier) are injected
@Inject
SomeType(final Iterable<SomeOtherType> providers) {
...
}
public static final TypeDependency.Kind OPTIONAL
MULTIPLE
or PROVIDER injections
@Inject
SomeType(final @Optional SomeOtherType provider) {
...
}
Optional annotation to indicate
the dependency is optionalpublic static final TypeDependency.Kind PROVIDER
Provider instance, resolving of
the dependency is deferred until Provider.get() is invoked. This
can be used for lazy initialization and to break cyclic dependencies
@Inject
SomeType(final Provider<SomeOtherType> provider) {
...
}
Provider declaration
to receive the matching Providerpublic static final TypeDependency.Kind REQUIRED
TypeDependencyNotAvailableException is raised
@Inject
SomeType(final SomeOtherType provider) {
...
}
Optional annotation to indicate
the dependency is optionalpublic static TypeDependency.Kind[] values()
for (TypeDependency.Kind c : TypeDependency.Kind.values()) System.out.println(c);
public static TypeDependency.Kind valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is null