Support before/after templating as seen in Google Refaster.
Allows you to defined one or more @BeforeTemplate
annotated methods and a single @AfterTemplate
method.
package foo;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
public class UseStringIsEmpty {
@BeforeTemplate
boolean before(String s) {
return s.length() > 0;
}
@AfterTemplate
boolean after(String s) {
return !s.isEmpty();
}
}
This results in a recipe that can be used to transform code that matches the @BeforeTemplate
to the @AfterTemplate
.
Annotation processors can take options to customize their behavior. Options are passed to the annotation processor via the -A
flag.
By default, the annotation processor will add a @javax.annotation.Generated
annotation to the generated classes, compatible with Java 8.
On newer Java version you'd perhaps want to pass in the following option:
-Arewrite.generatedAnnotation=jakarta.annotation.Generated
We appreciate all types of contributions. See the contributing guide for detailed instructions on how to get started.