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

io.slugstack.rewritejavarecipes.FieldAccessToSetter 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 which are directly setting a given field in an
 * instance of the described class to use a setField(..) method instead.
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class FieldAccessToSetter extends Recipe {

    private final String declaringClass;
    private final String fieldName;

    @Override
    public String getDisplayName() {
        return "Field access to setter";
    }

    @Override
    public String getDescription() {
        return "Updates caller references which are directly setting a given field in an instance of the described class to use a setField(..) method instead.";
    }

    @Override
    protected TreeVisitor getVisitor() {
        return new FieldAccessToSetterVisitor<>(declaringClass, fieldName);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy