diff --git a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java index f52b9ced4f3..954d0330322 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java @@ -97,28 +97,30 @@ */ public class MapperAnnotationBuilder { - private final Set> sqlAnnotationTypes = new HashSet>(); - private final Set> sqlProviderAnnotationTypes = new HashSet>(); + private static final Set> SQL_ANNOTATION_TYPES = new HashSet<>(); + private static final Set> SQL_PROVIDER_ANNOTATION_TYPES = new HashSet<>(); private final Configuration configuration; private final MapperBuilderAssistant assistant; private final Class type; + static { + SQL_ANNOTATION_TYPES.add(Select.class); + SQL_ANNOTATION_TYPES.add(Insert.class); + SQL_ANNOTATION_TYPES.add(Update.class); + SQL_ANNOTATION_TYPES.add(Delete.class); + + SQL_PROVIDER_ANNOTATION_TYPES.add(SelectProvider.class); + SQL_PROVIDER_ANNOTATION_TYPES.add(InsertProvider.class); + SQL_PROVIDER_ANNOTATION_TYPES.add(UpdateProvider.class); + SQL_PROVIDER_ANNOTATION_TYPES.add(DeleteProvider.class); + } + public MapperAnnotationBuilder(Configuration configuration, Class type) { String resource = type.getName().replace('.', '/') + ".java (best guess)"; this.assistant = new MapperBuilderAssistant(configuration, resource); this.configuration = configuration; this.type = type; - - sqlAnnotationTypes.add(Select.class); - sqlAnnotationTypes.add(Insert.class); - sqlAnnotationTypes.add(Update.class); - sqlAnnotationTypes.add(Delete.class); - - sqlProviderAnnotationTypes.add(SelectProvider.class); - sqlProviderAnnotationTypes.add(InsertProvider.class); - sqlProviderAnnotationTypes.add(UpdateProvider.class); - sqlProviderAnnotationTypes.add(DeleteProvider.class); } public void parse() { @@ -516,11 +518,11 @@ private SqlCommandType getSqlCommandType(Method method) { } private Class getSqlAnnotationType(Method method) { - return chooseAnnotationType(method, sqlAnnotationTypes); + return chooseAnnotationType(method, SQL_ANNOTATION_TYPES); } private Class getSqlProviderAnnotationType(Method method) { - return chooseAnnotationType(method, sqlProviderAnnotationTypes); + return chooseAnnotationType(method, SQL_PROVIDER_ANNOTATION_TYPES); } private Class chooseAnnotationType(Method method, Set> types) {