我有以下情况:
public class Controller {
private ModelRepository repository;
public int getModelCount() {
int count = 0;
List<Model> models = repository.getModels();
for (Model model : models) {
if (model.somePredicate()) {
count++;
}
}
return count;
}
}
现在,我想通过使用一些自动 Eclipse 重构将getModelCount
方法移动到内部ModelRepository
,以便最终在控制器中使用它:
public class Controller {
private ModelRepository repository;
public int getModelCount() {
repository.getModelCount();
}
}
这在 Eclipse Indigo 中可行吗?如果是,如何?谢谢!