• 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

83.33
cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManager.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.util.Collection;
4

5
import com.devonfw.tools.ide.property.KeywordProperty;
6
import com.devonfw.tools.ide.property.Property;
7
import com.devonfw.tools.ide.tool.ToolCommandlet;
8

9
/**
10
 * Interface to {@link #getCommandlet(Class) get} a {@link Commandlet} instance that is properly initialized.
11
 */
12
public interface CommandletManager {
13

14
  /**
15
   * @param <C> type of the {@link Commandlet}.
16
   * @param commandletType the {@link Class} reflecting the requested {@link Commandlet}.
17
   * @return the requested {@link Commandlet}.
18
   */
19
  <C extends Commandlet> C getCommandlet(Class<C> commandletType);
20

21
  /**
22
   * @param name the {@link Commandlet#getName() name} of the requested {@link Commandlet}.
23
   * @return the requested {@link Commandlet} or {@code null} if not found.
24
   */
25
  Commandlet getCommandlet(String name);
26

27
  /**
28
   * @param keyword the first keyword argument.
29
   * @return a {@link Commandlet} having the first {@link Property} {@link Property#isRequired() required} and a {@link KeywordProperty} with the given
30
   * {@link Property#getName() name} or {@code null} if no such {@link Commandlet} is registered.
31
   */
32
  Commandlet getCommandletByFirstKeyword(String keyword);
33

34
  /**
35
   * @return the {@link Collection} of all registered {@link Commandlet}s.
36
   */
37
  Collection<Commandlet> getCommandlets();
38

39
  /**
40
   * @param name the {@link Commandlet#getName() name} of the requested {@link ToolCommandlet}.
41
   * @return the requested {@link ToolCommandlet} if found.
42
   * @throws IllegalArgumentException if the commandlet with the given name is not a {@link ToolCommandlet}
43
   */
44
  default ToolCommandlet getToolCommandlet(String name) {
45

46
    Commandlet commandlet = getCommandlet(name);
4✔
47
    if (commandlet instanceof ToolCommandlet) {
3✔
48
      return (ToolCommandlet) commandlet;
3✔
49
    }
50
    throw new IllegalArgumentException("The commandlet " + name + " is not a ToolCommandlet!");
6✔
51
  }
52

53
  /**
54
   * @param name the {@link Commandlet#getName() name} of the requested {@link ToolCommandlet}.
55
   * @return the requested {@link ToolCommandlet} or {@code null} if not found.
56
   */
57
  default ToolCommandlet getToolCommandletOrNull(String name) {
58

59
    Commandlet commandlet = getCommandlet(name);
4✔
60
    if (commandlet instanceof ToolCommandlet) {
3!
61
      return (ToolCommandlet) commandlet;
3✔
62
    }
63
    return null;
×
64
  }
65
}
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