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

devonfw / IDEasy / 29021898039

09 Jul 2026 01:34PM UTC coverage: 72.311% (+0.09%) from 72.225%
29021898039

Pull #2073

github

web-flow
Merge 1b4d02b30 into 365f379a1
Pull Request #2073: #1676 import extra sdks automatically into ide

4903 of 7482 branches covered (65.53%)

Branch coverage included in aggregate %.

12628 of 16762 relevant lines covered (75.34%)

3.19 hits per line

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

85.0
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 com.devonfw.tools.ide.json.JsonObject;
12

13
/**
14
 * {@link ExtraTools} represents the {@code ide-extra-tools.json} file.
15
 */
16
public class ExtraTools implements JsonObject {
17

18
  /** The empty and immutable instance of {@link ExtraTools}. */
19
  public static final ExtraTools EMPTY = new ExtraTools().asImmutable();
6✔
20

21
  private final Map<String, List<ExtraToolInstallation>> tool2installationsMap;
22

23
  /**
24
   * The constructor.
25
   */
26
  public ExtraTools() {
27
    this(new HashMap<>());
5✔
28
  }
1✔
29

30
  private ExtraTools(Map<String, List<ExtraToolInstallation>> tool2installationsMap) {
31
    super();
2✔
32
    this.tool2installationsMap = tool2installationsMap;
3✔
33
  }
1✔
34

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

41
    List<ExtraToolInstallation> result = this.tool2installationsMap.get(tool);
6✔
42
    if (result == null) {
2!
43
      result = List.of();
×
44
    }
45
    return result;
2✔
46
  }
47

48
  /**
49
   * @param tool the {@link com.devonfw.tools.ide.tool.LocalToolCommandlet#getName() name} of the {@link com.devonfw.tools.ide.tool.LocalToolCommandlet}.
50
   * @param extraInstallation the {@link ExtraToolInstallation} to add.
51
   */
52
  public void addExtraInstallations(String tool, ExtraToolInstallation extraInstallation) {
53

54
    if ((tool != null) && (extraInstallation != null) && tool.equalsIgnoreCase(extraInstallation.name())) {
9!
55
      throw new IllegalArgumentException(
3✔
56
          "Invalid extra installation name '" + extraInstallation.name() + "' for tool '" + tool
5✔
57
              + "': the extra installation name must not be the same as the tool name.");
58
    }
59

60
    List<ExtraToolInstallation> list = this.tool2installationsMap.computeIfAbsent(tool, k -> new ArrayList<>());
11✔
61
    list.add(extraInstallation);
4✔
62
  }
1✔
63

64
  /**
65
   * @return the {@link List} of {@link #getExtraInstallations(String) contained tool names} in ascending order.
66
   */
67
  public List<String> getSortedToolNames() {
68

69
    Set<String> keys = this.tool2installationsMap.keySet();
4✔
70
    if (keys.isEmpty()) {
3!
71
      return List.of();
×
72
    }
73
    List<String> tools = new ArrayList<>(keys);
5✔
74
    Collections.sort(tools);
2✔
75
    return tools;
2✔
76
  }
77

78
  /**
79
   * @return an immutable copy of this {@link ExtraTools}.
80
   */
81
  public ExtraTools asImmutable() {
82

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

91
}
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

© 2026 Coveralls, Inc