我继承了一个使用 MyBatis 的代码库。SpotBugs 告诉我,SubjectRepositoryQueries
could be refactored into a named _static_ inner class.
我从未遇到过这个术语,我希望有人能解释它究竟要求我做得更好的是什么。看起来它SubjectRepositoryQueries
实际上是命名的(它不是匿名的),并且它已经是静态的。SubjectRepositoryQueries
不能声明私有,因为它在接口内。
@Mapper
public interface SubjectRepositoryService {
@SelectProvider(type = SubjectRepositoryQueries.class, method = "search")
List<Subject> search(SubjectSearch subjectSearch);
static final class SubjectRepositoryQueries {
public String search(final SubjectSearch subjectSearch) {
... some string generation
}
}
}
谢谢!