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

devonfw / IDEasy / 42916857669

10 Nov 2026 10:41PM UTC coverage: 75.192% (-0.06%) from 75.25%
42916857669

push

github

web-flow
#2409: implemented advanced approach for expression functions (#2775)

6330 of 9333 branches covered (67.82%)

Branch coverage included in aggregate %.

16244 of 20689 relevant lines covered (78.52%)

3.38 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/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.AskSecretFunction;
7
import com.devonfw.tools.ide.expression.ask.AskVariableFunction;
8
import com.devonfw.tools.ide.expression.os.IfLinuxFunction;
9
import com.devonfw.tools.ide.expression.os.IfMacFunction;
10
import com.devonfw.tools.ide.expression.os.IfUnixFunction;
11
import com.devonfw.tools.ide.expression.os.IfWindowsFunction;
12
import com.devonfw.tools.ide.expression.path.PathFunction;
13

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

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

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

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

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

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

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

45
  /**
46
   * @param name the {@link ExpressionFunction#getName() name} of the requested function.
47
   * @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
48
   *     expression is then left untouched.
49
   */
50
  public ExpressionFunction getFunction(String name) {
51

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

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

60
    return DEFAULT;
2 ✔
61
  }
62

63
  private static ExpressionFunctionManager createDefault() {
64

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

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