public enum ServiceCardinality extends Enum<ServiceCardinality>
@Service
annotation's cardinality
attribute.
OPTIONAL
or MANDATORY
. OPTIONAL
does not require the presence of a service, whereas MANDATORY
requires at
least one service to be present, otherwise an exception is thrown.
Collection
or
List
with the type of the injected service as its generic type-argument.
Service.cardinality()
Enum Constant and Description |
---|
AUTO
For unary service injection,
AUTO defaults to MANDATORY . |
MANDATORY
At least one service must be present, otherwise a
ParameterResolutionException is thrown. |
OPTIONAL
If no service is present,
null is injected for unary service injection, and an empty
List is injected for multiple service injection. |
Modifier and Type | Method and Description |
---|---|
static ServiceCardinality |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ServiceCardinality[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ServiceCardinality AUTO
AUTO
defaults to MANDATORY
.
Whereas for multiple service injection, AUTO
defaults to OPTIONAL
.public static final ServiceCardinality OPTIONAL
null
is injected for unary service injection, and an empty
List
is injected for multiple service injection.public static final ServiceCardinality MANDATORY
ParameterResolutionException
is thrown.public static ServiceCardinality[] values()
for (ServiceCardinality c : ServiceCardinality.values()) System.out.println(c);
public static ServiceCardinality 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 nullCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.