Contact Us 1-800-596-4880

Core Annotations (dw::Core)

Annotation Definition Description

AnnotationTarget

@AnnotationTarget(targets: Array<"Function" | "Parameter" | "Variable" | "Import" | "Type" | "Version" | "Namespace" | "KeyType" | "TypeExpression" | "Expression" | "Annotation">)

Annotation that limits the application of an annotation. An example is @AnnotationTarget(targets = ["Function", "Variable"]), which limits the scope of the annotation annotation TailRec() to functions and variables. If no AnnotationTarget is specified, an annotation can apply to any valid target.

Annotation Targets:

  • Parameter: For function parameters.

  • Function: For function definitions.

  • Variable: For variable definitions.

  • Import: For import definitions.

Deprecated

@Deprecated(since: String, replacement: String)

Annotation that marks a function as deprecated.

Introduced in DataWeave version 2.4.0.

DesignOnlyType

@DesignOnlyType()

Annotation that marks a parameter type as design only to indicate that the field type is validated only at design time. At runtime, only minimal type validation takes place. This annotation is useful for performance, especially with complex Object types.

Experimental

@Experimental()

Annotation that identifies a feature as experimental and subject to change or removal in the future.

Introduced in DataWeave version 2.4.0.

GlobalDescription

@GlobalDescription()

Annotation used to identify the function description to use for the function’s documentation. This annotation is useful for selecting the correct function description when the function is overloaded.

Introduced in DataWeave version 2.4.0.

Interceptor

@Interceptor(interceptorFunction: String | (annotationArgs: Object, targetFunctionName: String, args: Array<Any>, callback: (args: Array<Any>) -> Any) -> Any)

Annotation that marks another annotation as an Interceptor so that the marked annotation will wrap an annotated function with an interceptorFunction. An example is the RuntimePrivilege annotation, which is annotated by @Interceptor(interceptorFunction = "@native system::SecurityManagerCheckFunctionValue"). The readUrl function definition is annotated by @RuntimePrivilege(requires = "Resource").

Experimental: This experimental feature is subject to change or removal from future versions of DataWeave.

Internal

@Internal(permits: Array<String>)

Annotation that marks a function as internal and not to be used.

_Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later._

Experimental: This experimental feature is subject to change or removal from future versions of DataWeave.

Labels

@Labels(labels: Array<String>)

Annotation for labeling a function or variable definition so that it becomes more easy to discover. An example is @Labels(labels =["append", "concat"]).

Introduced in DataWeave version 2.4.0.

Lazy

@Lazy()

Annotation that marks a variable declaration for lazy initialization.

Introduced in DataWeave version 2.3.0.

Metadata

@Metadata(key: String)

Annotation used to mark annotations that represent metadata.

Introduced in DataWeave version 2.8.0.

RuntimePrivilege

@RuntimePrivilege(requires: String)

Annotation used to indicate that a function requires runtime privileges to execute. An example is @RuntimePrivilege(requires = "Resource"), which annotates the readUrl function definition.

Since

@Since(version: String)

Annotation that identifies the DataWeave version in which the annotated functionality was introduced. An example is @Since(version = "2.4.0").

Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.

StreamCapable

@StreamCapable()

Annotation that marks a parameter as stream capable, which means that this field will consume an array of objects in a forward-only manner. Examples of functions with @StreamCapable fields are map, mapObject, and pluck.

TailRec

@TailRec()

Annotation that marks a function as tail recursive. If a function with this annotation is not tail recursive, the function will fail.

UntrustedCode

@UntrustedCode(privileges: Array<String>)

Annotation that marks a script as untrusted, which means that the script has no privileges. For example, such a script cannot gain access to environment variables or read a resource from a URL.

Experimental: This experimental feature is subject to change or removal from future versions of DataWeave.