I inherited a codebase that uses MyBatis. SpotBugs is telling me that that SubjectRepositoryQueries
could be refactored into a named _static_ inner class.
I've never encountered this term, I was hoping someone could explain what exactly it's asking me to do better. It would seem that SubjectRepositoryQueries
is in fact named (it's not anonymous), and it's already static. SubjectRepositoryQueries
can't be declared private because it's inside an interface.
@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
}
}
}
Thanks!
It's unclear what the specific warning means. If your only goal is to remove the warning then given that your inner class isn't implementing an interface, you can simply convert it to a static method.
@Mapper
public interface SubjectRepositoryService {
//...
static String search(final SubjectSearch subjectSearch) {
//... some string generation
}
}