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

devonfw / IDEasy / 45830565225

26 Nov 2026 01:35PM UTC coverage: 75.636% (+0.04%) from 75.597%
45830565225

Pull #2935

github

web-flow
Merge 7a01d32e3 into da39ba59d
Pull Request #2935: #2908: add @ask-mvn-secret expression function

6608 of 9691 branches covered (68.19%)

Branch coverage included in aggregate %.

17041 of 21576 relevant lines covered (78.98%)

3.41 hits per line

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

90.91
cli/src/main/java/com/devonfw/tools/ide/expression/ExpressionFunctionManager.java
1
package com.devonfw.tools.ide.expression;
2

3
import java.util.HashMap;
4
import java.util.Map;
5

6
import com.devonfw.tools.ide.expression.ask.AskMvnSecretFunction;
7
import com.devonfw.tools.ide.expression.ask.AskSecretFunction;
8
import com.devonfw.tools.ide.expression.ask.AskVariableFunction;
9
import com.devonfw.tools.ide.expression.os.IfLinuxFunction;
10
import com.devonfw.tools.ide.expression.os.IfMacFunction;
11
import com.devonfw.tools.ide.expression.os.IfUnixFunction;
12
import com.devonfw.tools.ide.expression.os.IfWindowsFunction;
13
import com.devonfw.tools.ide.expression.path.PathFunction;
14

15
/**
16
 * Manager where all {@link ExpressionFunction}s are registered so they can be looked up by {@link #getFunction(String) name} while an expression is resolved.
17
 * <p>
18
 * With new IDEasy releases additional functions can simply be registered here.
19
 */
20
public class ExpressionFunctionManager {
21

22
  private static final ExpressionFunctionManager DEFAULT = createDefault();
3 ✔
23

24
  private final Map<String, ExpressionFunction> functions;
25

26
  /**
27
   * The constructor.
28
   */
29
  public ExpressionFunctionManager() {
30

31
    super();
2 ✔
32
    this.functions = new HashMap<>();
5 ✔
33
  }
1 ✔
34

35
  /**
36
   * @param function the {@link ExpressionFunction} to register.
37
   */
38
  public void register(ExpressionFunction function) {
39

40
    ExpressionFunction duplicate = this.functions.put(function.getName(), function);
8 ✔
41
    if (duplicate != null) {
2 !
42
      throw new IllegalStateException("Duplicate expression function @" + function.getName());
×
43
    }
44
  }
1 ✔
45

46
  /**
47
   * @param name the {@link ExpressionFunction#getName() name} of the requested function.
48
   * @return the {@link ExpressionFunction} or {@code null} if no function is registered for the given name. A {@code null} result is not an error: the
49
   *     expression is then left untouched.
50
   */
51
  public ExpressionFunction getFunction(String name) {
52

53
    return this.functions.get(name);
6 ✔
54
  }
55

56
  /**
57
   * @return the default instance with all standard functions registered.
58
   */
59
  public static ExpressionFunctionManager get() {
60

61
    return DEFAULT;
2 ✔
62
  }
63

64
  private static ExpressionFunctionManager createDefault() {
65

66
    ExpressionFunctionManager manager = new ExpressionFunctionManager();
4 ✔
67
    manager.register(new PathFunction());
5 ✔
68
    manager.register(new AskVariableFunction());
5 ✔
69
    manager.register(new AskSecretFunction());
5 ✔
70
    manager.register(new AskMvnSecretFunction());
5 ✔
71
    manager.register(new IfLinuxFunction());
5 ✔
72
    manager.register(new IfMacFunction());
5 ✔
73
    manager.register(new IfUnixFunction());
5 ✔
74
    manager.register(new IfWindowsFunction());
5 ✔
75
    return manager;
2 ✔
76
  }
77

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