Browse Source

移除Maps,调整computeIfAbsent注释.

nieqiuqiu 5 years ago
parent
commit
b7451ae8bb
16 changed files with 104 additions and 115 deletions
  1. 2 2
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/MybatisEnumTypeHandler.java
  2. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableInfoHelper.java
  3. 2 2
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/override/MybatisMapperProxy.java
  4. 72 0
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/CollectionUtils.java
  5. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/GlobalConfigUtils.java
  6. 3 3
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/LambdaUtils.java
  7. 0 80
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/Maps.java
  8. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/ReflectionKit.java
  9. 6 6
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/activerecord/Model.java
  10. 2 2
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/handlers/MybatisEnumTypeHandler.java
  11. 2 2
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/PaginationInnerInterceptor.java
  12. 3 3
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java
  13. 1 2
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/PropertyMapper.java
  14. 3 3
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/SqlRunner.java
  15. 3 4
      mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java
  16. 2 3
      mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java

+ 2 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/MybatisEnumTypeHandler.java

@@ -17,8 +17,8 @@ package com.baomidou.mybatisplus.core.handlers;
 
 import com.baomidou.mybatisplus.annotation.EnumValue;
 import com.baomidou.mybatisplus.annotation.IEnum;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
 import org.apache.ibatis.reflection.DefaultReflectorFactory;
 import org.apache.ibatis.reflection.MetaClass;
 import org.apache.ibatis.reflection.ReflectorFactory;
@@ -87,7 +87,7 @@ public class MybatisEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E
     public static Optional<String> findEnumValueFieldName(Class<?> clazz) {
         if (clazz != null && clazz.isEnum()) {
             String className = clazz.getName();
-            return Optional.ofNullable(Maps.computeIfAbsent(TABLE_METHOD_OF_ENUM_TYPES, className, key -> {
+            return Optional.ofNullable(CollectionUtils.computeIfAbsent(TABLE_METHOD_OF_ENUM_TYPES, className, key -> {
                 Optional<Field> optional = Arrays.stream(clazz.getDeclaredFields())
                     .filter(field -> field.isAnnotationPresent(EnumValue.class))
                     .findFirst();

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableInfoHelper.java

@@ -112,7 +112,7 @@ public class TableInfoHelper {
      * @return 数据库表反射信息
      */
     public synchronized static TableInfo initTableInfo(MapperBuilderAssistant builderAssistant, Class<?> clazz) {
-        return Maps.computeIfAbsent(TABLE_INFO_CACHE, clazz, (key) -> {
+        return CollectionUtils.computeIfAbsent(TABLE_INFO_CACHE, clazz, (key) -> {
             /* 没有获取到缓存信息,则初始化 */
             TableInfo tableInfo = new TableInfo(key);
             GlobalConfig globalConfig;

+ 2 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/override/MybatisMapperProxy.java

@@ -15,7 +15,7 @@
  */
 package com.baomidou.mybatisplus.core.override;
 
-import com.baomidou.mybatisplus.core.toolkit.Maps;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import org.apache.ibatis.binding.MapperProxy;
 import org.apache.ibatis.reflection.ExceptionUtil;
 import org.apache.ibatis.session.SqlSession;
@@ -98,7 +98,7 @@ public class MybatisMapperProxy<T> implements InvocationHandler, Serializable {
     }
 
     private MybatisMapperMethod cachedMapperMethod(Method method) {
-        return Maps.computeIfAbsent(methodCache, method,
+        return CollectionUtils.computeIfAbsent(methodCache, method,
             k -> new MybatisMapperMethod(mapperInterface, method, sqlSession.getConfiguration()));
     }
 

+ 72 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/CollectionUtils.java

@@ -16,7 +16,9 @@
 package com.baomidou.mybatisplus.core.toolkit;
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.function.Function;
 
 /**
  * Collection工具类
@@ -26,6 +28,8 @@ import java.util.Map;
  */
 public class CollectionUtils {
 
+    private static final int MAX_POWER_OF_TWO = 1 << (Integer.SIZE - 2);
+
     /**
      * 校验集合是否为空
      *
@@ -65,4 +69,72 @@ public class CollectionUtils {
     public static boolean isNotEmpty(Map<?, ?> map) {
         return !isEmpty(map);
     }
+
+    /**
+     * 创建默认HashMap
+     *
+     * @param <K> K
+     * @param <V> V
+     * @return HashMap
+     * @see com.google.common.collect.Maps#newHashMap()
+     */
+    public static <K, V> HashMap<K, V> newHashMap() {
+        return new HashMap<>();
+    }
+
+    /**
+     * 根据预期大小创建HashMap.
+     *
+     * @param expectedSize 预期大小
+     * @param <K>          K
+     * @param <V>          V
+     * @return HashMap
+     * @see com.google.common.collect.Maps#newHashMapWithExpectedSize
+     */
+    public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
+        return new HashMap<>(capacity(expectedSize));
+    }
+
+    /**
+     * 用来过渡下Jdk1.8下ConcurrentHashMap的性能bug
+     * https://bugs.openjdk.java.net/browse/JDK-8161372
+     *
+     * @param concurrentHashMap ConcurrentHashMap 没限制类型了,非ConcurrentHashMap就别调用这方法了
+     * @param key               key
+     * @param mappingFunction   function
+     * @param <K>               k
+     * @param <V>               v
+     * @return V
+     * @since 3.3.3
+     */
+    public static <K, V> V computeIfAbsent(Map<K, V> concurrentHashMap, K key, Function<? super K, ? extends V> mappingFunction) {
+        V v = concurrentHashMap.get(key);
+        if (v != null) {
+            return v;
+        }
+        return concurrentHashMap.computeIfAbsent(key, mappingFunction);
+    }
+
+    /**
+     * Returns a capacity that is sufficient to keep the map from being resized as
+     * long as it grows no larger than expectedSize and the load factor is >= its
+     * default (0.75).
+     *
+     * @see com.google.common.collect.Maps#capacity(int)
+     */
+    private static int capacity(int expectedSize) {
+        if (expectedSize < 3) {
+            if (expectedSize < 0) {
+                throw new IllegalArgumentException("expectedSize cannot be negative but was: " + expectedSize);
+            }
+            return expectedSize + 1;
+        }
+        if (expectedSize < MAX_POWER_OF_TWO) {
+            // This is the calculation used in JDK8 to resize when a putAll
+            // happens; it seems to be the most conservative calculation we
+            // can make.  0.75 is the default load factor.
+            return (int) ((float) expectedSize / 0.75F + 1.0F);
+        }
+        return Integer.MAX_VALUE; // any large value
+    }
 }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/GlobalConfigUtils.java

@@ -83,7 +83,7 @@ public class GlobalConfigUtils {
     public static GlobalConfig getGlobalConfig(Configuration configuration) {
         Assert.notNull(configuration, "Error: You need Initialize MybatisConfiguration !");
         final String key = Integer.toHexString(configuration.hashCode());
-        return Maps.computeIfAbsent(GLOBAL_CONFIG, key, k -> defaults());
+        return CollectionUtils.computeIfAbsent(GLOBAL_CONFIG, key, k -> defaults());
     }
 
     public static IKeyGenerator getKeyGenerator(Configuration configuration) {

+ 3 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/LambdaUtils.java

@@ -100,10 +100,10 @@ public final class LambdaUtils {
         Map<String, ColumnCache> map;
 
         if (info.havePK()) {
-            map = Maps.newHashMapWithExpectedSize(info.getFieldList().size() + 1);
+            map = CollectionUtils.newHashMapWithExpectedSize(info.getFieldList().size() + 1);
             map.put(formatKey(info.getKeyProperty()), new ColumnCache(info.getKeyColumn(), info.getKeySqlSelect()));
         } else {
-            map = Maps.newHashMapWithExpectedSize(info.getFieldList().size());
+            map = CollectionUtils.newHashMapWithExpectedSize(info.getFieldList().size());
         }
 
         info.getFieldList().forEach(i ->
@@ -119,7 +119,7 @@ public final class LambdaUtils {
      * @return 缓存 map
      */
     public static Map<String, ColumnCache> getColumnMap(Class<?> clazz) {
-        return Maps.computeIfAbsent(COLUMN_CACHE_MAP, clazz.getName(), key -> {
+        return CollectionUtils.computeIfAbsent(COLUMN_CACHE_MAP, clazz.getName(), key -> {
             TableInfo info = TableInfoHelper.getTableInfo(clazz);
             return info == null ? null : createColumnCacheMap(info);
         });

+ 0 - 80
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/Maps.java

@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.baomidou.mybatisplus.core.toolkit;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Function;
-
-/**
- * com.google.common.collect.Maps
- */
-public final class Maps {
-
-    private static final int MAX_POWER_OF_TWO = 1 << (Integer.SIZE - 2);
-
-
-    public static <K, V> HashMap<K, V> newHashMap() {
-        return new HashMap<>();
-    }
-
-    public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
-        return new HashMap<>(capacity(expectedSize));
-    }
-
-    /**
-     * 用来过渡下Jdk1.8下ConcurrentHashMap的性能bug
-     * https://bugs.openjdk.java.net/browse/JDK-8161372
-     *
-     * @param concurrentHashMap
-     * @param key
-     * @param mappingFunction
-     * @param <K>
-     * @param <V>
-     * @since 3.3.3
-     * @return V
-     */
-    public static <K, V> V computeIfAbsent(Map<K, V> concurrentHashMap, K key, Function<? super K, ? extends V> mappingFunction) {
-        Objects.requireNonNull(concurrentHashMap);
-        V v = concurrentHashMap.get(key);
-        if (v != null) {
-            return v;
-        }
-        return concurrentHashMap.computeIfAbsent(key, mappingFunction);
-    }
-
-    /**
-     * Returns a capacity that is sufficient to keep the map from being resized as
-     * long as it grows no larger than expectedSize and the load factor is >= its
-     * default (0.75).
-     */
-    private static int capacity(int expectedSize) {
-        if (expectedSize < 3) {
-            if (expectedSize < 0) {
-                throw new IllegalArgumentException("expectedSize cannot be negative but was: " + expectedSize);
-            }
-            return expectedSize + 1;
-        }
-        if (expectedSize < MAX_POWER_OF_TWO) {
-            // This is the calculation used in JDK8 to resize when a putAll
-            // happens; it seems to be the most conservative calculation we
-            // can make.  0.75 is the default load factor.
-            return (int) ((float) expectedSize / 0.75F + 1.0F);
-        }
-        return Integer.MAX_VALUE; // any large value
-    }
-}

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/ReflectionKit.java

@@ -214,7 +214,7 @@ public final class ReflectionKit {
         if (Objects.isNull(clazz)) {
             return Collections.emptyList();
         }
-        return Maps.computeIfAbsent(CLASS_FIELD_CACHE, clazz, k -> {
+        return CollectionUtils.computeIfAbsent(CLASS_FIELD_CACHE, clazz, k -> {
             Field[] fields = k.getDeclaredFields();
             List<Field> superFields = new ArrayList<>();
             Class<?> currentClass = k.getSuperclass();

+ 6 - 6
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/activerecord/Model.java

@@ -96,7 +96,7 @@ public abstract class Model<T extends Model<?>> implements Serializable {
      * @param queryWrapper 实体对象封装操作类(可以为 null)
      */
     public boolean delete(Wrapper<T> queryWrapper) {
-        Map<String, Object> map = Maps.newHashMapWithExpectedSize(1);
+        Map<String, Object> map = CollectionUtils.newHashMapWithExpectedSize(1);
         map.put(Constants.WRAPPER, queryWrapper);
         SqlSession sqlSession = sqlSession();
         try {
@@ -112,7 +112,7 @@ public abstract class Model<T extends Model<?>> implements Serializable {
     public boolean updateById() {
         Assert.isFalse(StringUtils.checkValNull(pkVal()), "updateById primaryKey is null.");
         // updateById
-        Map<String, Object> map = Maps.newHashMapWithExpectedSize(1);
+        Map<String, Object> map = CollectionUtils.newHashMapWithExpectedSize(1);
         map.put(Constants.ENTITY, this);
         SqlSession sqlSession = sqlSession();
         try {
@@ -128,7 +128,7 @@ public abstract class Model<T extends Model<?>> implements Serializable {
      * @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句)
      */
     public boolean update(Wrapper<T> updateWrapper) {
-        Map<String, Object> map = Maps.newHashMapWithExpectedSize(2);
+        Map<String, Object> map = CollectionUtils.newHashMapWithExpectedSize(2);
         map.put(Constants.ENTITY, this);
         map.put(Constants.WRAPPER, updateWrapper);
         // update
@@ -180,7 +180,7 @@ public abstract class Model<T extends Model<?>> implements Serializable {
      * @param queryWrapper 实体对象封装操作类(可以为 null)
      */
     public List<T> selectList(Wrapper<T> queryWrapper) {
-        Map<String, Object> map = Maps.newHashMapWithExpectedSize(1);
+        Map<String, Object> map = CollectionUtils.newHashMapWithExpectedSize(1);
         map.put(Constants.WRAPPER, queryWrapper);
         SqlSession sqlSession = sqlSession();
         try {
@@ -206,7 +206,7 @@ public abstract class Model<T extends Model<?>> implements Serializable {
      * @param queryWrapper 实体对象封装操作类(可以为 null)
      */
     public <E extends IPage<T>> E selectPage(E page, Wrapper<T> queryWrapper) {
-        Map<String, Object> map = Maps.newHashMapWithExpectedSize(2);
+        Map<String, Object> map = CollectionUtils.newHashMapWithExpectedSize(2);
         map.put(Constants.WRAPPER, queryWrapper);
         map.put("page", page);
         SqlSession sqlSession = sqlSession();
@@ -224,7 +224,7 @@ public abstract class Model<T extends Model<?>> implements Serializable {
      * @param queryWrapper 实体对象封装操作类(可以为 null)
      */
     public Integer selectCount(Wrapper<T> queryWrapper) {
-        Map<String, Object> map = Maps.newHashMapWithExpectedSize(1);
+        Map<String, Object> map = CollectionUtils.newHashMapWithExpectedSize(1);
         map.put(Constants.WRAPPER, queryWrapper);
         SqlSession sqlSession = sqlSession();
         try {

+ 2 - 2
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/handlers/MybatisEnumTypeHandler.java

@@ -17,8 +17,8 @@ package com.baomidou.mybatisplus.extension.handlers;
 
 import com.baomidou.mybatisplus.annotation.EnumValue;
 import com.baomidou.mybatisplus.annotation.IEnum;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
 import org.apache.ibatis.reflection.DefaultReflectorFactory;
 import org.apache.ibatis.reflection.MetaClass;
 import org.apache.ibatis.reflection.ReflectorFactory;
@@ -127,7 +127,7 @@ public class MybatisEnumTypeHandler<E extends Enum<?>> extends BaseTypeHandler<E
     public static Optional<String> findEnumValueFieldName(Class<?> clazz) {
         if (clazz != null && clazz.isEnum()) {
             String className = clazz.getName();
-            return Optional.ofNullable(Maps.computeIfAbsent(TABLE_METHOD_OF_ENUM_TYPES, className, key -> {
+            return Optional.ofNullable(CollectionUtils.computeIfAbsent(TABLE_METHOD_OF_ENUM_TYPES, className, key -> {
                 Optional<Field> optional = Arrays.stream(clazz.getDeclaredFields())
                     .filter(field -> field.isAnnotationPresent(EnumValue.class))
                     .findFirst();

+ 2 - 2
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/PaginationInnerInterceptor.java

@@ -172,7 +172,7 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
             }
             final Configuration configuration = ms.getConfiguration();
             try {
-                return Maps.computeIfAbsent(countMsCache, countId, key -> configuration.getMappedStatement(key, false));
+                return CollectionUtils.computeIfAbsent(countMsCache, countId, key -> configuration.getMappedStatement(key, false));
             } catch (Exception e) {
                 logger.warn(String.format("can not find this countId: [\"%s\"]", countId));
             }
@@ -183,7 +183,7 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
     protected MappedStatement buildAutoCountMappedStatement(MappedStatement ms) {
         final String countId = ms.getId() + "_mpCount";
         final Configuration configuration = ms.getConfiguration();
-        return Maps.computeIfAbsent(countMsCache, countId, key -> {
+        return CollectionUtils.computeIfAbsent(countMsCache, countId, key -> {
             MappedStatement.Builder builder = new MappedStatement.Builder(configuration, key, ms.getSqlSource(), ms.getSqlCommandType());
             builder.resource(ms.getResource());
             builder.fetchSize(ms.getFetchSize());

+ 3 - 3
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java

@@ -19,7 +19,7 @@ import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ClassUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.dialects.DialectRegistry;
 import com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect;
@@ -72,7 +72,7 @@ public class DialectFactory {
     @Deprecated
     private static IDialect getDialect(DbType dbType, String dialectClazz) {
         //这里需要注意一下,就的版本是把dbType和dialectClazz同时传进来的,所以会存在dbType是一定会有值,dialectClazz可能为空的情况,兼容需要先判断dialectClazz
-        return StringUtils.isBlank(dialectClazz) ? DIALECT_REGISTRY.getDialect(dbType) : Maps.computeIfAbsent(DIALECT_CACHE, dialectClazz, ClassUtils::newInstance);
+        return StringUtils.isBlank(dialectClazz) ? DIALECT_REGISTRY.getDialect(dbType) : CollectionUtils.computeIfAbsent(DIALECT_CACHE, dialectClazz, ClassUtils::newInstance);
     }
 
     /**
@@ -83,7 +83,7 @@ public class DialectFactory {
      * @since 3.3.1
      */
     public static IDialect getDialect(String dialectClazz) {
-        return Maps.computeIfAbsent(DIALECT_CACHE, dialectClazz, ClassUtils::newInstance);
+        return CollectionUtils.computeIfAbsent(DIALECT_CACHE, dialectClazz, ClassUtils::newInstance);
     }
     
     public static IDialect getDialect(DbType dbType) {

+ 1 - 2
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/PropertyMapper.java

@@ -16,7 +16,6 @@
 package com.baomidou.mybatisplus.extension.toolkit;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.AccessLevel;
@@ -73,7 +72,7 @@ public class PropertyMapper {
         if (CollectionUtils.isEmpty(inner)) {
             return Collections.emptyMap();
         }
-        Map<String, Properties> map = Maps.newHashMap();
+        Map<String, Properties> map = CollectionUtils.newHashMap();
         inner.forEach(i -> {
             Properties p = new Properties();
             String key = i.substring(6) + StringPool.COLON;

+ 3 - 3
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/SqlRunner.java

@@ -17,8 +17,8 @@ package com.baomidou.mybatisplus.extension.toolkit;
 
 import com.baomidou.mybatisplus.core.assist.ISqlRunner;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import org.apache.ibatis.logging.Log;
 import org.apache.ibatis.logging.LogFactory;
@@ -108,7 +108,7 @@ public class SqlRunner implements ISqlRunner {
      * @return ignore
      */
     private Map<String, String> sqlMap(String sql, Object... args) {
-        Map<String, String> sqlMap = Maps.newHashMapWithExpectedSize(1);
+        Map<String, String> sqlMap = CollectionUtils.newHashMapWithExpectedSize(1);
         sqlMap.put(SQL, StringUtils.sqlArgsFill(sql, args));
         return sqlMap;
     }
@@ -122,7 +122,7 @@ public class SqlRunner implements ISqlRunner {
      * @return ignore
      */
     private Map<String, Object> sqlMap(String sql, IPage page, Object... args) {
-        Map<String, Object> sqlMap = Maps.newHashMapWithExpectedSize(2);
+        Map<String, Object> sqlMap = CollectionUtils.newHashMapWithExpectedSize(2);
         sqlMap.put(PAGE, page);
         sqlMap.put(SQL, StringUtils.sqlArgsFill(sql, args));
         return sqlMap;

+ 3 - 4
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java

@@ -18,7 +18,6 @@ package com.baomidou.mybatisplus.generator.config.builder;
 import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.generator.InjectionConfig;
@@ -231,7 +230,7 @@ public class ConfigBuilder {
      */
     private void handlerPackage(TemplateConfig template, String outputDir, PackageConfig config) {
         // 包信息
-        packageInfo = Maps.newHashMapWithExpectedSize(7);
+        packageInfo = CollectionUtils.newHashMapWithExpectedSize(7);
         packageInfo.put(ConstVal.MODULE_NAME, config.getModuleName());
         packageInfo.put(ConstVal.ENTITY, joinPackage(config.getParent(), config.getEntity()));
         packageInfo.put(ConstVal.MAPPER, joinPackage(config.getParent(), config.getMapper()));
@@ -246,7 +245,7 @@ public class ConfigBuilder {
             pathInfo = configPathInfo;
         } else {
             // 生成路径信息
-            pathInfo = Maps.newHashMapWithExpectedSize(6);
+            pathInfo = CollectionUtils.newHashMapWithExpectedSize(6);
             setPathInfo(pathInfo, template.getEntity(getGlobalConfig().isKotlin()), outputDir, ConstVal.ENTITY_PATH, ConstVal.ENTITY);
             setPathInfo(pathInfo, template.getMapper(), outputDir, ConstVal.MAPPER_PATH, ConstVal.MAPPER);
             setPathInfo(pathInfo, template.getXml(), outputDir, ConstVal.XML_PATH, ConstVal.XML);
@@ -634,7 +633,7 @@ public class ConfigBuilder {
                     // 自定义字段查询
                     String[] fcs = dbQuery.fieldCustom();
                     if (null != fcs) {
-                        Map<String, Object> customMap = Maps.newHashMapWithExpectedSize(fcs.length);
+                        Map<String, Object> customMap = CollectionUtils.newHashMapWithExpectedSize(fcs.length);
                         for (String fc : fcs) {
                             customMap.put(fc, results.getObject(fc));
                         }

+ 2 - 3
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java

@@ -16,7 +16,6 @@
 package com.baomidou.mybatisplus.generator.engine;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Maps;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.generator.InjectionConfig;
@@ -196,11 +195,11 @@ public abstract class AbstractTemplateEngine {
         Map<String, Object> objectMap;
         ConfigBuilder config = getConfigBuilder();
         if (config.getStrategyConfig().isControllerMappingHyphenStyle()) {
-            objectMap = Maps.newHashMapWithExpectedSize(33);
+            objectMap = CollectionUtils.newHashMapWithExpectedSize(33);
             objectMap.put("controllerMappingHyphenStyle", config.getStrategyConfig().isControllerMappingHyphenStyle());
             objectMap.put("controllerMappingHyphen", StringUtils.camelToHyphen(tableInfo.getEntityPath()));
         } else {
-            objectMap = Maps.newHashMapWithExpectedSize(31);
+            objectMap = CollectionUtils.newHashMapWithExpectedSize(31);
         }
         objectMap.put("restControllerStyle", config.getStrategyConfig().isRestControllerStyle());
         objectMap.put("config", config);