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

devonfw / IDEasy / 22284264868

22 Feb 2026 08:00PM UTC coverage: 70.75% (+0.3%) from 70.474%
22284264868

Pull #1714

github

web-flow
Merge 98f01421f into 379acdc9d
Pull Request #1714: #404: #1713: advanced logging

4063 of 6346 branches covered (64.02%)

Branch coverage included in aggregate %.

10636 of 14430 relevant lines covered (73.71%)

3.1 hits per line

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

41.18
cli/src/main/java/com/devonfw/tools/ide/variable/AbstractVariableDefinitionList.java
1
package com.devonfw.tools.ide.variable;
2

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

8
import org.slf4j.Logger;
9
import org.slf4j.LoggerFactory;
10

11
import com.devonfw.tools.ide.context.IdeContext;
12

13
/**
14
 * Abstract base implementation of {@link VariableDefinition} for a variable with the {@link #getValueType() value type} {@link List}.
15
 */
16
public abstract class AbstractVariableDefinitionList<E> extends AbstractVariableDefinition<List<E>> {
17

18
  private static final Logger LOG = LoggerFactory.getLogger(AbstractVariableDefinitionList.class);
4✔
19

20
  /**
21
   * The constructor.
22
   *
23
   * @param name the {@link #getName() variable name}.
24
   */
25
  public AbstractVariableDefinitionList(String name) {
26

27
    super(name);
×
28
  }
×
29

30
  /**
31
   * The constructor.
32
   *
33
   * @param name the {@link #getName() variable name}.
34
   * @param legacyName the {@link #getLegacyName() legacy name}.
35
   */
36
  public AbstractVariableDefinitionList(String name, String legacyName) {
37

38
    super(name, legacyName);
4✔
39
  }
1✔
40

41
  /**
42
   * The constructor.
43
   *
44
   * @param name the {@link #getName() variable name}.
45
   * @param legacyName the {@link #getLegacyName() legacy name}.
46
   * @param defaultValueFactory the factory {@link Function} for the {@link #getDefaultValue(IdeContext) default value}.
47
   */
48
  public AbstractVariableDefinitionList(String name, String legacyName,
49
      Function<IdeContext, List<E>> defaultValueFactory) {
50

51
    super(name, legacyName, defaultValueFactory);
5✔
52
  }
1✔
53

54
  /**
55
   * The constructor.
56
   *
57
   * @param name the {@link #getName() variable name}.
58
   * @param legacyName the {@link #getLegacyName() legacy name}.
59
   * @param defaultValueFactory the factory {@link Function} for the {@link #getDefaultValue(IdeContext) default value}.
60
   * @param forceDefaultValue the {@link #isForceDefaultValue() forceDefaultValue} flag.
61
   */
62
  public AbstractVariableDefinitionList(String name, String legacyName,
63
      Function<IdeContext, List<E>> defaultValueFactory, boolean forceDefaultValue) {
64

65
    super(name, legacyName, defaultValueFactory, forceDefaultValue);
×
66
  }
×
67

68
  @SuppressWarnings({ "unchecked", "rawtypes" })
69
  @Override
70
  public Class<List<E>> getValueType() {
71

72
    return (Class) List.class;
×
73
  }
74

75
  @Override
76
  public List<E> fromString(String value, IdeContext context) {
77

78
    if (value.isEmpty()) {
3✔
79
      return Collections.emptyList();
2✔
80
    }
81
    return parseList(value, context);
5✔
82
  }
83

84
  protected List<E> parseList(String value, IdeContext context) {
85

86
    String[] items = value.split(",");
4✔
87
    if (items.length == 0) {
3!
88
      return List.of();
×
89
    }
90
    List<E> list = new ArrayList<>(items.length);
6✔
91
    for (String item : items) {
16✔
92
      try {
93
        list.add(parseValue(item.trim(), context));
8✔
94
      } catch (Exception e) {
×
95
        LOG.warn("Invalid value '{}' for element of variable {}", item, getName(), e);
×
96
        return null;
×
97
      }
1✔
98

99
    }
100
    list = Collections.unmodifiableList(list);
3✔
101
    return list;
2✔
102
  }
103

104
  protected abstract E parseValue(String value, IdeContext context);
105

106
  @Override
107
  public String toString(List<E> value, IdeContext context) {
108

109
    if (value == null) {
×
110
      return "";
×
111
    }
112
    StringBuilder sb = new StringBuilder(value.size() * 5);
×
113
    for (E element : value) {
×
114
      if (!sb.isEmpty()) {
×
115
        sb.append(',');
×
116
      }
117
      sb.append(formatValue(element));
×
118
    }
×
119
    return sb.toString();
×
120
  }
121

122
  protected String formatValue(E value) {
123

124
    if (value == null) {
×
125
      return "";
×
126
    }
127
    return value.toString();
×
128
  }
129
}
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