@Target(value={FIELD,PARAMETER}) @Retention(value=RUNTIME) @Documented public @interface NullSafe
null value, even though such value is a valid assignment
on the mule DSL.
This annotation is intended to be used alongside Optional
(the concept itself doesn't make sense for required parameters). When
the annotated parameter is resolved to a null value, the runtime
will create a default instance of such parameter to prevent a null variable.
This behaviour is implemented slightly different depending on the parameter type:
Collection and Map: an empty collection/map is createddefaultImplementingType.Optional Parameter fields with a default value will be assigned
to such default. E.g.:
public class HelloWorld {| Modifier and Type | Optional Element and Description |
|---|---|
Class<?> |
defaultImplementingType
Declares the default
Type that will be instantiated if the NullSafe
mechanism is triggered on a non-instantiable type |
public abstract Class<?> defaultImplementingType
Type that will be instantiated if the NullSafe
mechanism is triggered on a non-instantiable typeType to be used when creating the default instanceCopyright © 2017 MuleSoft, Inc.. All rights reserved.