|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=RUNTIME) @Target(value={PARAMETER,METHOD,FIELD}) @Documented public @interface Optional
Annotation to denote that something is optional.
@Optional
@Service
would allow a service to not have been declared and the field will be null.
Optionality is not the default in Qi4j, and if injections, property values and parameters in methods are not
non-null, the Qi4j runtime will throw an ConstraintViolationException
, indicating
which field/property/parameter in which composite and mixin the problem has been detected.
Example;
@Optional @Service
MyService service; // If no MyService instance is declared and visible to this service injection point
// the 'service' field will be null.
@Service
YourService other; // If no YourService instance is declared and visible to this service injection point
// the Qi4j runtime will throw a ConstraintViolationException.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |