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

devonfw / IDEasy / 9907372175

12 Jul 2024 11:49AM UTC coverage: 61.142% (-0.02%) from 61.162%
9907372175

push

github

hohwille
fixed tests

1997 of 3595 branches covered (55.55%)

Branch coverage included in aggregate %.

5296 of 8333 relevant lines covered (63.55%)

2.8 hits per line

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

85.71
cli/src/main/java/com/devonfw/tools/ide/tool/PluginMaps.java
1
package com.devonfw.tools.ide.tool;
2

3
import java.util.Collection;
4
import java.util.Collections;
5
import java.util.HashMap;
6
import java.util.Map;
7

8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.tool.ide.PluginDescriptor;
10

11
/**
12
 * A wrapper class for holding two maps of plugin descriptors: one keyed by plugin ID and the other keyed by plugin name.
13
 */
14
public class PluginMaps {
15

16
  private final Map<String, PluginDescriptor> mapById;
17
  private final Map<String, PluginDescriptor> mapByName;
18

19

20
  private final IdeContext context;
21

22
  /**
23
   * The constructor.
24
   *
25
   * @param context the {@link IdeContext}.
26
   */
27
  public PluginMaps(IdeContext context) {
28
    super();
2✔
29
    this.context = context;
3✔
30
    this.mapById = new HashMap<>();
5✔
31
    this.mapByName = new HashMap<>();
5✔
32
  }
1✔
33

34
  /**
35
   * @return the {@link PluginDescriptor} for the given {@link PluginDescriptor#getId() ID} or {@code null} if not found.
36
   */
37
  public PluginDescriptor getById(String id) {
38
    return this.mapById.get(id);
×
39
  }
40

41
  /**
42
   * @return the {@link PluginDescriptor} for the given {@link PluginDescriptor#getName() name} or {@code null} if not found.
43
   */
44
  public PluginDescriptor getByName(String name) {
45
    return this.mapByName.get(name);
6✔
46
  }
47

48
  /**
49
   * @return the immutable {@link Collection} of {@link PluginDescriptor}s configured for this IDE tool.
50
   */
51
  public Collection<PluginDescriptor> getPlugins() {
52

53
    Map<String, PluginDescriptor> map = this.mapById;
3✔
54
    if (map.isEmpty()) {
3!
55
      map = this.mapByName; // potentially plugins for this tool have no ID
3✔
56
    }
57
    return Collections.unmodifiableCollection(map.values());
4✔
58
  }
59

60
  /**
61
   * Registers a {@link PluginDescriptor} to this map.
62
   */
63
  protected void add(PluginDescriptor descriptor) {
64
    put(descriptor.getName(), descriptor, this.mapByName);
7✔
65
    String id = descriptor.getId();
3✔
66
    if ((id != null) && !id.isEmpty()) {
5!
67
      put(id, descriptor, this.mapById);
6✔
68
    }
69
  }
1✔
70

71
  public void put(String key, PluginDescriptor descriptor, Map<String, PluginDescriptor> map) {
72
    PluginDescriptor duplicate = map.put(key, descriptor);
6✔
73
    if (duplicate != null) {
2✔
74
      this.context.info("Plugin with key {} was {} but got overridden by {}", key, duplicate, descriptor);
18✔
75
    }
76
  }
1✔
77
}
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