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

devonfw / IDEasy / 30243693167

27 Jul 2026 06:44AM UTC coverage: 72.69% (+0.1%) from 72.561%
30243693167

Pull #2073

github

web-flow
Merge 27f1c50ad into dd45e9162
Pull Request #2073: #1676 import extra sdks automatically into ide

5009 of 7614 branches covered (65.79%)

Branch coverage included in aggregate %.

12899 of 17022 relevant lines covered (75.78%)

3.21 hits per line

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

90.48
cli/src/main/java/com/devonfw/tools/ide/tool/extra/ExtraTools.java
1
package com.devonfw.tools.ide.tool.extra;
2

3
import java.util.ArrayList;
4
import java.util.Collections;
5
import java.util.HashMap;
6
import java.util.List;
7
import java.util.Map;
8
import java.util.Map.Entry;
9
import java.util.Set;
10

11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13

14
import com.devonfw.tools.ide.json.JsonObject;
15

16
/**
17
 * {@link ExtraTools} represents the {@code ide-extra-tools.json} file.
18
 */
19
public class ExtraTools implements JsonObject {
20

21
  /** The empty and immutable instance of {@link ExtraTools}. */
22
  public static final ExtraTools EMPTY = new ExtraTools().asImmutable();
5✔
23

24
  private final Map<String, List<ExtraToolInstallation>> tool2installationsMap;
25

26
  private static final Logger LOG = LoggerFactory.getLogger(ExtraTools.class);
4✔
27

28
  /**
29
   * The constructor.
30
   */
31
  public ExtraTools() {
32
    this(new HashMap<>());
5✔
33
  }
1✔
34

35
  private ExtraTools(Map<String, List<ExtraToolInstallation>> tool2installationsMap) {
36
    super();
2✔
37
    this.tool2installationsMap = tool2installationsMap;
3✔
38
  }
1✔
39

40
  /**
41
   * @param tool the {@link com.devonfw.tools.ide.tool.LocalToolCommandlet#getName() name} of the {@link com.devonfw.tools.ide.tool.LocalToolCommandlet}.
42
   * @return the {@link List} of {@link ExtraToolInstallation extra installations}. Will be empty if no extra installation is defined.
43
   */
44
  public List<ExtraToolInstallation> getExtraInstallations(String tool) {
45

46
    List<ExtraToolInstallation> result = this.tool2installationsMap.get(tool);
6✔
47
    if (result == null) {
2!
48
      result = List.of();
×
49
    }
50
    return result;
2✔
51
  }
52

53
  /**
54
   * @param tool the {@link com.devonfw.tools.ide.tool.LocalToolCommandlet#getName() name} of the {@link com.devonfw.tools.ide.tool.LocalToolCommandlet}.
55
   * @param extraInstallation the {@link ExtraToolInstallation} to add.
56
   */
57
  public void addExtraInstallations(String tool, ExtraToolInstallation extraInstallation) {
58

59
    if ((tool != null) && (extraInstallation != null) && tool.equalsIgnoreCase(extraInstallation.name())) {
9!
60
      LOG.warn("Invalid extra installation name '{}' for tool '{}': the extra installation name must not be the same as the tool name.",
4✔
61
          extraInstallation.name(), tool);
2✔
62
      return;
1✔
63
    }
64

65
    List<ExtraToolInstallation> list = this.tool2installationsMap.computeIfAbsent(tool, k -> new ArrayList<>());
11✔
66
    list.add(extraInstallation);
4✔
67
  }
1✔
68

69
  /**
70
   * @return the {@link List} of {@link #getExtraInstallations(String) contained tool names} in ascending order.
71
   */
72
  public List<String> getSortedToolNames() {
73

74
    Set<String> keys = this.tool2installationsMap.keySet();
4✔
75
    if (keys.isEmpty()) {
3✔
76
      return List.of();
2✔
77
    }
78
    List<String> tools = new ArrayList<>(keys);
5✔
79
    Collections.sort(tools);
2✔
80
    return tools;
2✔
81
  }
82

83
  /**
84
   * @return an immutable copy of this {@link ExtraTools}.
85
   */
86
  public ExtraTools asImmutable() {
87

88
    Map<String, List<ExtraToolInstallation>> newMap = new HashMap<>(this.tool2installationsMap.size());
7✔
89
    for (Entry<String, List<ExtraToolInstallation>> entry : this.tool2installationsMap.entrySet()) {
12✔
90
      newMap.put(entry.getKey(), List.copyOf(entry.getValue()));
10✔
91
    }
1✔
92
    Map<String, List<ExtraToolInstallation>> immutableMap = Map.copyOf(newMap);
3✔
93
    return new ExtraTools(immutableMap);
5✔
94
  }
95

96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc