• 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

10.0
cli/src/main/java/com/devonfw/tools/ide/variable/VariableDefinitionBoolean.java
1
package com.devonfw.tools.ide.variable;
2

3
import java.util.Locale;
4
import java.util.function.Function;
5

6
import com.devonfw.tools.ide.context.IdeContext;
7

8
/**
9
 * Implementation of {@link VariableDefinition} for a variable with the {@link #getValueType() value type} {@link Boolean}.
10
 */
11
public class VariableDefinitionBoolean extends AbstractVariableDefinition<Boolean> {
12

13
  /**
14
   * The constructor.
15
   *
16
   * @param name the {@link #getName() variable name}.
17
   */
18
  public VariableDefinitionBoolean(String name) {
19

20
    super(name);
×
21
  }
×
22

23
  /**
24
   * The constructor.
25
   *
26
   * @param name the {@link #getName() variable name}.
27
   * @param legacyName the {@link #getLegacyName() legacy name}.
28
   */
29
  public VariableDefinitionBoolean(String name, String legacyName) {
30

31
    super(name, legacyName);
×
32
  }
×
33

34
  /**
35
   * The constructor.
36
   *
37
   * @param name the {@link #getName() variable name}.
38
   * @param legacyName the {@link #getLegacyName() legacy name}.
39
   * @param defaultValueFactory the factory {@link Function} for the {@link #getDefaultValue(IdeContext) default value}.
40
   */
41
  public VariableDefinitionBoolean(String name, String legacyName, Function<IdeContext, Boolean> defaultValueFactory) {
42

43
    super(name, legacyName, defaultValueFactory);
5✔
44
  }
1✔
45

46
  /**
47
   * The constructor.
48
   *
49
   * @param name the {@link #getName() variable name}.
50
   * @param legacyName the {@link #getLegacyName() legacy name}.
51
   * @param defaultValueFactory the factory {@link Function} for the {@link #getDefaultValue(IdeContext) default value}.
52
   * @param forceDefaultValue the {@link #isForceDefaultValue() forceDefaultValue} flag.
53
   */
54
  public VariableDefinitionBoolean(String name, String legacyName, Function<IdeContext, Boolean> defaultValueFactory, boolean forceDefaultValue) {
55

56
    super(name, legacyName, defaultValueFactory, forceDefaultValue);
×
57
  }
×
58

59
  /**
60
   * The constructor.
61
   *
62
   * @param name the {@link #getName() variable name}.
63
   * @param legacyName the {@link #getLegacyName() legacy name}.
64
   * @param defaultValueFactory the factory {@link Function} for the {@link #getDefaultValue(IdeContext) default value}.
65
   * @param forceDefaultValue the {@link #isForceDefaultValue() forceDefaultValue} flag.
66
   * @param export the {@link #isExport() export} flag.
67
   */
68
  public VariableDefinitionBoolean(String name, String legacyName, Function<IdeContext, Boolean> defaultValueFactory, boolean forceDefaultValue,
69
      boolean export) {
70

71
    super(name, legacyName, defaultValueFactory, forceDefaultValue, export);
×
72
  }
×
73

74
  @Override
75
  public Class<Boolean> getValueType() {
76

77
    return Boolean.class;
×
78
  }
79

80
  @Override
81
  public Boolean fromString(String value, IdeContext context) {
82

83
    String lower = value.trim().toLowerCase(Locale.ROOT);
×
84
    return switch (lower) {
×
85
      case "true", "yes" -> Boolean.TRUE;
×
86
      case "false", "no" -> Boolean.FALSE;
×
87
      default -> {
88
        context.warning("Variable {} has invalid boolean value {} - using false as fallback");
×
89
        yield Boolean.FALSE;
×
90
      }
91
    };
92
  }
93

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