@Retention(value=RUNTIME) @Target(value={PARAMETER,METHOD,FIELD}) @Documented public @interface Optional
@Optional
@Service
would allow a service to not have been declared and the field will be null.
Optionality is not the default in Polygene, and if injections, property values and parameters in methods are not
non-null, the Polygene 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 Polygene runtime will throw a ConstraintViolationException.