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

devonfw / IDEasy / 24984011544

27 Apr 2026 08:14AM UTC coverage: 70.718% (+0.08%) from 70.641%
24984011544

Pull #1856

github

web-flow
Merge f59d7af1d into 344d6c0f7
Pull Request #1856: #1643 improve ux on syntax error

4403 of 6878 branches covered (64.02%)

Branch coverage included in aggregate %.

11348 of 15395 relevant lines covered (73.71%)

3.12 hits per line

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

58.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
  private Boolean parse(String valueAsString) {
58

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

71
  @Override
72
  public void setValueAsString(String valueAsString, IdeContext context) {
73

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

84
  @Override
85
  protected String getValidValuesErrorHint(IdeContext context, Commandlet commandlet) {
86

87
    return "'true', 'yes', 'false', 'no'";
×
88
  }
89

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

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

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