Add or update annotation attribute

Apache 2.0

Some annotations accept arguments. This recipe sets an existing argument to the specified value, or adds the argument if it is not already set.

org.openrewrite.java.AddOrUpdateAnnotationAttribute

Required

The fully qualified name of the annotation.

Optional

The name of attribute to change. If omitted defaults to 'value'.

The value to set the attribute to. If the attribute is an array, provide values separated by comma to add multiple attributes at once. Set to null to remove the attribute.

The current value of the attribute, this can be used to filter where the change is applied. Set to null for wildcard behavior.

addOnlyBoolean

If true, disables upgrading existing annotation attribute values, thus the recipe will only add the attribute if it does not already exist. If omitted or false, the recipe adds the attribute if missing or updates its value if present.

appendArrayBoolean

If the attribute is an array and attribute is present, setting this option to true will append the value(s). Duplicate values will not be added. If omitted or false, the recipe will replace the existing value(s) with the new value(s).

mod run . --recipe=org.openrewrite.java.AddOrUpdateAnnotationAttribute \ -P annotationType=org.junit.Test

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.