All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.slugstack.rewritejavarecipes.FieldAccessToGetter Maven / Gradle / Ivy

There is a newer version: 0.2.2
Show newest version
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 getVisitor() {
        return new FieldAccessToGetterVisitor<>(declaringClass, fieldName);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy