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

devonfw / IDEasy / 26101908636

19 May 2026 01:55PM UTC coverage: 70.982% (+0.003%) from 70.979%
26101908636

Pull #1859

github

web-flow
Merge cf4a7f717 into b4eeee25f
Pull Request #1859: #1392: Smart completions

4472 of 6964 branches covered (64.22%)

Branch coverage included in aggregate %.

11521 of 15567 relevant lines covered (74.01%)

3.14 hits per line

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

74.0
cli/src/main/java/com/devonfw/tools/ide/property/BooleanProperty.java
1
package com.devonfw.tools.ide.property;
2

3
import com.devonfw.tools.ide.cli.CliArguments;
4
import com.devonfw.tools.ide.commandlet.Commandlet;
5
import com.devonfw.tools.ide.completion.CompletionCandidateCollector;
6
import com.devonfw.tools.ide.context.IdeContext;
7

8
/**
9
 * {@link Property} with {@link #getValueType() value type} {@link Boolean}.
10
 */
11
public class BooleanProperty extends Property<Boolean> {
12

13
  /**
14
   * The constructor.
15
   *
16
   * @param name the {@link #getName() property name}.
17
   * @param required the {@link #isRequired() required flag}.
18
   * @param alias the {@link #getAlias() property alias}.
19
   */
20
  public BooleanProperty(String name, boolean required, String alias) {
21

22
    super(name, required, alias);
5✔
23
  }
1✔
24

25
  @Override
26
  public Class<Boolean> getValueType() {
27

28
    return Boolean.class;
×
29
  }
30

31
  /**
32
   * @return the value as primitive boolean.
33
   */
34
  public boolean isTrue() {
35

36
    return Boolean.TRUE.equals(getValue());
5✔
37
  }
38

39
  /**
40
   * @param value the {@link #getValue() value} as primitive boolean.
41
   */
42
  public void setValue(boolean value) {
43

44
    setValue(Boolean.valueOf(value));
4✔
45
  }
1✔
46

47
  @Override
48
  public Boolean parse(String valueAsString, IdeContext context) {
49

50
    Boolean result = parse(valueAsString);
4✔
51
    if (result == null) {
2✔
52
      throw new IllegalArgumentException("Illegal boolean value '" + valueAsString + "' for property " + getName());
8✔
53
    }
54
    return result;
2✔
55
  }
56

57
  @Override
58
  protected void completeValue(String arg, IdeContext contextual, Commandlet commandlet,
59
                               CompletionCandidateCollector collector) {}
1✔
60

61
  private Boolean parse(String valueAsString) {
62

63
    if (valueAsString == null) {
2✔
64
      return null;
2✔
65
    }
66
    valueAsString = valueAsString.toLowerCase();
3✔
67
    if ("true".equals(valueAsString) || "yes".equals(valueAsString)) {
8✔
68
      return Boolean.TRUE;
2✔
69
    } else if ("false".equals(valueAsString) || "no".equals(valueAsString)) {
8✔
70
      return Boolean.FALSE;
2✔
71
    }
72
    return null;
2✔
73
  }
74

75
  @Override
76
  public void setValueAsString(String valueAsString, IdeContext context) {
77

78
    Boolean b;
79
    if (matches(valueAsString)) {
×
80
      // allow e.g. "--force" to enable "--force" option
81
      b = Boolean.TRUE;
×
82
    } else {
83
      b = parse(valueAsString, context);
×
84
    }
85
    setValue(b);
×
86
  }
×
87

88
  @Override
89
  protected boolean applyValue(String argValue, boolean lookahead, CliArguments args, IdeContext context, Commandlet commandlet,
90
      CompletionCandidateCollector collector) {
91

92
    if (lookahead) {
2!
93
      Boolean b = parse(argValue);
4✔
94
      if (b == null) {
2!
95
        setValue(true);
4✔
96
      } else {
97
        setValue(b);
×
98
        args.next();
×
99
      }
100
      return true;
2✔
101
    }
102
    return super.applyValue(argValue, lookahead, args, context, commandlet, collector);
×
103
  }
104

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