JDeodorant
JDeodorant copied to clipboard
The use of the Java Stream leads to failures in 'Move Method' refactoring.
When using a tool to detect Feature Envy and perform automated refactoring, if the refactored code contains syntax errors, should I attempt to fix them manually?
Before Refactoring:
public class SourceClass {
TargetClass t;
private static class Config { }
private final Config config = new Config();
public void processData() {
new ArrayList<Integer>().stream().filter(this::isPositive).collect(toList());
}
private boolean isPositive(Integer number) {
return number != null && number > 0;
}
}
public class TargetClass{}
After Refactoring:
public class TargetClass {
public void processData(SourceClass sourceClass) {
new ArrayList<Integer>().stream().filter(sourceClass::isPositive).collect(toList());
}
}
Error: The type SourceClass does not define isPositive(Integer) that is applicable here