• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / mybatis-3 / 2571

01 Jan 2025 07:01AM UTC coverage: 87.397% (+0.04%) from 87.359%
2571

Pull #3372

github

web-flow
Merge d02328e9f into d21e71b56
Pull Request #3372: Drop java8 fallback

3518 of 4265 branches covered (82.49%)

15 of 17 new or added lines in 9 files covered. (88.24%)

6 existing lines in 2 files now uncovered.

9369 of 10720 relevant lines covered (87.4%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/apache/ibatis/util/MapUtil.java
1
/*
2
 *    Copyright 2009-2023 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.apache.ibatis.util;
17

18
import java.util.AbstractMap;
19
import java.util.Map;
20
import java.util.Map.Entry;
21
import java.util.function.Function;
22

23
public class MapUtil {
24
  /**
25
   * A temporary workaround for Java 8 specific performance issue JDK-8161372 .<br>
26
   * This class should be removed once we drop Java 8 support.
27
   *
28
   * @see <a href=
29
   *      "https://bugs.openjdk.java.net/browse/JDK-8161372">https://bugs.openjdk.java.net/browse/JDK-8161372</a>
30
   */
31
  public static <K, V> V computeIfAbsent(Map<K, V> map, K key, Function<K, V> mappingFunction) {
UNCOV
32
    V value = map.get(key);
×
UNCOV
33
    if (value != null) {
×
UNCOV
34
      return value;
×
35
    }
UNCOV
36
    return map.computeIfAbsent(key, mappingFunction);
×
37
  }
38

39
  /**
40
   * Map.entry(key, value) alternative for Java 8.
41
   */
42
  public static <K, V> Entry<K, V> entry(K key, V value) {
UNCOV
43
    return new AbstractMap.SimpleImmutableEntry<>(key, value);
×
44
  }
45

46
  private MapUtil() {
47
  }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc