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

devonfw / IDEasy / 12752008871

13 Jan 2025 04:48PM UTC coverage: 68.077% (+0.5%) from 67.541%
12752008871

Pull #820

github

web-flow
Merge 3db4692df into 8e971e1a8
Pull Request #820: #759: upgrade settings commandlet

2689 of 4311 branches covered (62.38%)

Branch coverage included in aggregate %.

6946 of 9842 relevant lines covered (70.58%)

3.1 hits per line

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

47.83
cli/src/main/java/com/devonfw/tools/ide/variable/VariableDefinitionStringList.java
1
package com.devonfw.tools.ide.variable;
2

3
import java.util.Collections;
4
import java.util.List;
5
import java.util.function.Function;
6

7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.environment.VariableLine;
9

10
/**
11
 * Implementation of {@link VariableDefinition} for a variable with the {@link #getValueType() value type} {@link String}.
12
 */
13
public class VariableDefinitionStringList extends AbstractVariableDefinition<List<String>> {
14

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

22
    super(name);
×
23
  }
×
24

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

33
    super(name, legacyName);
4✔
34
  }
1✔
35

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

46
    super(name, legacyName, defaultValueFactory);
5✔
47
  }
1✔
48

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

60
    super(name, legacyName, defaultValueFactory, forceDefaultValue);
×
61
  }
×
62

63
  @SuppressWarnings({ "unchecked", "rawtypes" })
64
  @Override
65
  public Class<List<String>> getValueType() {
66

67
    return (Class) List.class;
×
68
  }
69

70
  @Override
71
  public List<String> fromString(String value, IdeContext context) {
72

73
    if (value.isEmpty()) {
3!
74
      return Collections.emptyList();
×
75
    }
76
    List<String> list = VariableLine.parseArray(value);
3✔
77
    list = Collections.unmodifiableList(list);
3✔
78
    return list;
2✔
79
  }
80

81
  private boolean isBashArray(String value) {
82

83
    return value.startsWith("(") && value.endsWith(")");
12!
84
  }
85

86
  @Override
87
  public VariableLine migrateLine(VariableLine line) {
88

89
    line = super.migrateLine(line);
4✔
90
    String value = line.getValue();
3✔
91
    if ((value != null) && isBashArray(value)) {
6!
92
      List<String> list = fromString(value, null);
5✔
93
      line = line.withValue(String.join(", ", list));
6✔
94
    }
95
    return line;
2✔
96
  }
97

98
  @Override
99
  public String toString(List<String> value, IdeContext context) {
100

101
    if (value == null) {
×
102
      return "";
×
103
    }
104
    StringBuilder sb = new StringBuilder(value.size() * 5);
×
105
    for (Object element : value) {
×
106
      if (sb.length() > 0) {
×
107
        sb.append(',');
×
108
      }
109
      sb.append(element);
×
110
    }
×
111
    return sb.toString();
×
112
  }
113
}
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