Replace annotation

Apache 2.0

Replace an Annotation with another one if the annotation pattern matches. Only fixed parameters can be set in the replacement.

org.openrewrite.java.ReplaceAnnotation

Required

An annotation matcher, expressed as a method pattern to replace.

An annotation template to add instead of original one, will be parsed with JavaTemplate.

Optional

If the annotation's type is defined by a jar within the META-INF/rewrite/classpath directory provide its name here so that it can be loaded. When this parameter is not passed the runtime classpath of the recipe is provided to the parser producing the new annotation. This is necessary when the annotation is not on the runtime classpath of the recipe and isn't in the Java standard library.

mod run . --recipe=org.openrewrite.java.ReplaceAnnotation \ -P annotationPatternToReplace='@org.jetbrains.annotations.NotNull("Test")' \ -P annotationTemplateToInsert='@org.jetbrains.annotations.NotNull("Null not permitted")'

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