io.slugstack.rewritejavarecipes.FieldAccessToGetter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rewrite-java-recipes Show documentation
Show all versions of rewrite-java-recipes Show documentation
slugstack-rewrite-java-recipes description from within rewrite-java-recipes
package io.slugstack.rewritejavarecipes;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
/**
* Updates caller references to fields which were accessing the described class
* field directly to use an accessor method rather than the field directly.
*/
// @AllArgsConstructor(onConstructor_=@JsonCreator)
@Data
@EqualsAndHashCode(callSuper = true)
public class FieldAccessToGetter extends Recipe {
private final String declaringClass;
private final String fieldName;
@Override
public String getDisplayName() {
return "Field access to getter";
}
@Override
public String getDescription() {
return "Updates caller references to fields which were accessing the described class field directly to use an accessor method rather than the field directly.";
}
@Override
protected TreeVisitor, ExecutionContext> getVisitor() {
return new FieldAccessToGetterVisitor<>(declaringClass, fieldName);
}
}