io.codemodder.remediation.LegacyFixCandidateSearcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codemodder-base Show documentation
Show all versions of codemodder-base Show documentation
Base framework for writing codemods in Java
package io.codemodder.remediation;
import com.github.javaparser.ast.CompilationUnit;
import io.codemodder.codetf.DetectorRule;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
/** Searches for potential fix locations in the source code. */
@Deprecated
public interface LegacyFixCandidateSearcher {
/** Searches for potential fix locations in the source code. */
LegacyFixCandidateSearchResults search(
CompilationUnit cu,
String path,
DetectorRule rule,
List issuesForFile,
Function getKey,
Function getStartLine,
Function getEndLine,
Function getColumn);
/** Builder for {@link LegacyFixCandidateSearcher}. */
final class Builder {
private String methodName;
private final List> methodMatchers;
public Builder() {
this.methodMatchers = new ArrayList<>();
}
public Builder withMethodName(final String methodName) {
this.methodName = Objects.requireNonNull(methodName);
return this;
}
public Builder withMatcher(final Predicate methodMatcher) {
this.methodMatchers.add(Objects.requireNonNull(methodMatcher));
return this;
}
public LegacyFixCandidateSearcher build() {
return new DefaultLegacyFixCandidateSearcher<>(methodName, List.copyOf(methodMatchers));
}
}
}