Skip to content

Commit 7760630

Browse files
committed
Remove MapUtil
We no longer support Java 8.
1 parent d21e71b commit 7760630

File tree

9 files changed

+13
-24
lines changed

9 files changed

+13
-24
lines changed

src/main/java/org/apache/ibatis/binding/MapperProxy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import org.apache.ibatis.reflection.ExceptionUtil;
3030
import org.apache.ibatis.session.SqlSession;
31-
import org.apache.ibatis.util.MapUtil;
3231

3332
/**
3433
* @author Clinton Begin
@@ -91,7 +90,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
9190

9291
private MapperMethodInvoker cachedInvoker(Method method) throws Throwable {
9392
try {
94-
return MapUtil.computeIfAbsent(methodCache, method, m -> {
93+
return methodCache.computeIfAbsent(method, m -> {
9594
if (!m.isDefault()) {
9695
return new PlainMethodInvoker(new MapperMethod(mapperInterface, method, sqlSession.getConfiguration()));
9796
}

src/main/java/org/apache/ibatis/cache/TransactionalCacheManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.Map;
2020

2121
import org.apache.ibatis.cache.decorators.TransactionalCache;
22-
import org.apache.ibatis.util.MapUtil;
2322

2423
/**
2524
* @author Clinton Begin
@@ -53,7 +52,7 @@ public void rollback() {
5352
}
5453

5554
private TransactionalCache getTransactionalCache(Cache cache) {
56-
return MapUtil.computeIfAbsent(transactionalCaches, cache, TransactionalCache::new);
55+
return transactionalCaches.computeIfAbsent(cache, TransactionalCache::new);
5756
}
5857

5958
}

src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import javax.sql.DataSource;
3232

3333
import org.apache.ibatis.io.Resources;
34-
import org.apache.ibatis.util.MapUtil;
3534

3635
/**
3736
* @author Clinton Begin
@@ -233,7 +232,7 @@ private Connection doGetConnection(Properties properties) throws SQLException {
233232

234233
private void initializeDriver() throws SQLException {
235234
try {
236-
MapUtil.computeIfAbsent(registeredDrivers, driver, x -> {
235+
registeredDrivers.computeIfAbsent(driver, x -> {
237236
Class<?> driverType;
238237
try {
239238
if (driverClassLoader != null) {

src/main/java/org/apache/ibatis/executor/keygen/Jdbc3KeyGenerator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.ibatis.type.JdbcType;
4242
import org.apache.ibatis.type.TypeHandler;
4343
import org.apache.ibatis.type.TypeHandlerRegistry;
44-
import org.apache.ibatis.util.MapUtil;
4544

4645
/**
4746
* @author Clinton Begin
@@ -156,8 +155,8 @@ private void assignKeysToParamMap(Configuration configuration, ResultSet rs, Res
156155
for (int i = 0; i < keyProperties.length; i++) {
157156
Entry<String, KeyAssigner> entry = getAssignerForParamMap(configuration, rsmd, i + 1, paramMap, keyProperties[i],
158157
keyProperties, true);
159-
Entry<Iterator<?>, List<KeyAssigner>> iteratorPair = MapUtil.computeIfAbsent(assignerMap, entry.getKey(),
160-
k -> MapUtil.entry(collectionize(paramMap.get(k)).iterator(), new ArrayList<>()));
158+
Entry<Iterator<?>, List<KeyAssigner>> iteratorPair = assignerMap.computeIfAbsent(entry.getKey(),
159+
k -> Map.entry(collectionize(paramMap.get(k)).iterator(), new ArrayList<>()));
161160
iteratorPair.getValue().add(entry.getValue());
162161
}
163162
long counter = 0;
@@ -193,7 +192,7 @@ private Entry<String, KeyAssigner> getAssignerForParamMap(Configuration config,
193192
if (keySet.contains(paramName)) {
194193
String argParamName = omitParamName ? null : paramName;
195194
String argKeyProperty = keyProperty.substring(firstDot + 1);
196-
return MapUtil.entry(paramName, new KeyAssigner(config, rsmd, columnPosition, argParamName, argKeyProperty));
195+
return Map.entry(paramName, new KeyAssigner(config, rsmd, columnPosition, argParamName, argKeyProperty));
197196
}
198197
if (singleParam) {
199198
return getAssignerForSingleParam(config, rsmd, columnPosition, paramMap, keyProperty, omitParamName);
@@ -210,7 +209,7 @@ private Entry<String, KeyAssigner> getAssignerForSingleParam(Configuration confi
210209
// Assume 'keyProperty' to be a property of the single param.
211210
String singleParamName = nameOfSingleParam(paramMap);
212211
String argParamName = omitParamName ? null : singleParamName;
213-
return MapUtil.entry(singleParamName, new KeyAssigner(config, rsmd, columnPosition, argParamName, keyProperty));
212+
return Map.entry(singleParamName, new KeyAssigner(config, rsmd, columnPosition, argParamName, keyProperty));
214213
}
215214

216215
private static String nameOfSingleParam(Map<String, ?> paramMap) {

src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
import org.apache.ibatis.type.JdbcType;
6767
import org.apache.ibatis.type.TypeHandler;
6868
import org.apache.ibatis.type.TypeHandlerRegistry;
69-
import org.apache.ibatis.util.MapUtil;
7069

7170
/**
7271
* @author Clinton Begin
@@ -618,7 +617,7 @@ private void addPendingChildRelation(ResultSet rs, MetaObject metaResultObject,
618617
PendingRelation deferLoad = new PendingRelation();
619618
deferLoad.metaObject = metaResultObject;
620619
deferLoad.propertyMapping = parentMapping;
621-
List<PendingRelation> relations = MapUtil.computeIfAbsent(pendingRelations, cacheKey, k -> new ArrayList<>());
620+
List<PendingRelation> relations = pendingRelations.computeIfAbsent(cacheKey, k -> new ArrayList<>());
622621
// issue #255
623622
relations.add(deferLoad);
624623
ResultMapping previous = nextResultMaps.get(parentMapping.getResultSet());
@@ -820,7 +819,7 @@ private boolean applyArgNameBasedConstructorAutoMapping(ResultSetWrapper rsw, Re
820819
constructorArgs.add(value);
821820
final String mapKey = resultMap.getId() + ":" + columnPrefix;
822821
if (!autoMappingsCache.containsKey(mapKey)) {
823-
MapUtil.computeIfAbsent(constructorAutoMappingColumns, mapKey, k -> new ArrayList<>()).add(columnName);
822+
constructorAutoMappingColumns.computeIfAbsent(mapKey, k -> new ArrayList<>()).add(columnName);
824823
}
825824
columnNotFound = false;
826825
foundValues = value != null || foundValues;

src/main/java/org/apache/ibatis/plugin/Plugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.Set;
2525

2626
import org.apache.ibatis.reflection.ExceptionUtil;
27-
import org.apache.ibatis.util.MapUtil;
2827

2928
/**
3029
* @author Clinton Begin
@@ -74,7 +73,7 @@ private static Map<Class<?>, Set<Method>> getSignatureMap(Interceptor intercepto
7473
Signature[] sigs = interceptsAnnotation.value();
7574
Map<Class<?>, Set<Method>> signatureMap = new HashMap<>();
7675
for (Signature sig : sigs) {
77-
Set<Method> methods = MapUtil.computeIfAbsent(signatureMap, sig.type(), k -> new HashSet<>());
76+
Set<Method> methods = signatureMap.computeIfAbsent(sig.type(), k -> new HashSet<>());
7877
try {
7978
Method method = sig.type().getMethod(sig.method(), sig.args());
8079
methods.add(method);

src/main/java/org/apache/ibatis/reflection/DefaultReflectorFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import java.util.concurrent.ConcurrentHashMap;
1919
import java.util.concurrent.ConcurrentMap;
2020

21-
import org.apache.ibatis.util.MapUtil;
22-
2321
public class DefaultReflectorFactory implements ReflectorFactory {
2422
private boolean classCacheEnabled = true;
2523
private final ConcurrentMap<Class<?>, Reflector> reflectorMap = new ConcurrentHashMap<>();
@@ -41,7 +39,7 @@ public void setClassCacheEnabled(boolean classCacheEnabled) {
4139
public Reflector findForClass(Class<?> type) {
4240
if (classCacheEnabled) {
4341
// synchronized (type) removed see issue #461
44-
return MapUtil.computeIfAbsent(reflectorMap, type, Reflector::new);
42+
return reflectorMap.computeIfAbsent(type, Reflector::new);
4543
}
4644
return new Reflector(type);
4745
}

src/main/java/org/apache/ibatis/reflection/Reflector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import org.apache.ibatis.reflection.invoker.MethodInvoker;
4444
import org.apache.ibatis.reflection.invoker.SetFieldInvoker;
4545
import org.apache.ibatis.reflection.property.PropertyNamer;
46-
import org.apache.ibatis.util.MapUtil;
4746

4847
/**
4948
* This class represents a cached set of class definition information that allows for easy mapping between property
@@ -155,7 +154,7 @@ private void addSetMethods(Method[] methods) {
155154

156155
private void addMethodConflict(Map<String, List<Method>> conflictingMethods, String name, Method method) {
157156
if (isValidPropertyName(name)) {
158-
List<Method> list = MapUtil.computeIfAbsent(conflictingMethods, name, k -> new ArrayList<>());
157+
List<Method> list = conflictingMethods.computeIfAbsent(name, k -> new ArrayList<>());
159158
list.add(method);
160159
}
161160
}

src/main/java/org/apache/ibatis/scripting/LanguageDriverRegistry.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import java.util.HashMap;
1919
import java.util.Map;
2020

21-
import org.apache.ibatis.util.MapUtil;
22-
2321
/**
2422
* @author Frank D. Martinez [mnesarco]
2523
*/
@@ -33,7 +31,7 @@ public void register(Class<? extends LanguageDriver> cls) {
3331
if (cls == null) {
3432
throw new IllegalArgumentException("null is not a valid Language Driver");
3533
}
36-
MapUtil.computeIfAbsent(languageDriverMap, cls, k -> {
34+
languageDriverMap.computeIfAbsent(cls, k -> {
3735
try {
3836
return k.getDeclaredConstructor().newInstance();
3937
} catch (Exception ex) {

0 commit comments

Comments
 (0)