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

devonfw / IDEasy / 16074195902

04 Jul 2025 12:50PM UTC coverage: 67.974% (+0.08%) from 67.899%
16074195902

Pull #1406

github

web-flow
Merge 110c4b21c into ba246604e
Pull Request #1406: #1404: change ini file design to preserve comments

3269 of 5212 branches covered (62.72%)

Branch coverage included in aggregate %.

8358 of 11893 relevant lines covered (70.28%)

3.11 hits per line

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

84.21
cli/src/main/java/com/devonfw/tools/ide/io/IniSectionImpl.java
1
package com.devonfw.tools.ide.io;
2

3
import java.util.LinkedHashMap;
4
import java.util.LinkedList;
5
import java.util.List;
6
import java.util.Map;
7

8
/**
9
 * Implementation of {@link IniSection}
10
 */
11
public class IniSectionImpl implements IniSection {
12

13
  private final String name;
14
  private final Map<String, IniProperty> properties;
15
  private final List<IniElement> sectionElements;
16

17
  /**
18
   * creates IniSectionImpl with given name and properties
19
   *
20
   * @param name section name
21
   * @param sectionElements list of elements in section
22
   */
23
  public IniSectionImpl(String name, List<IniElement> sectionElements) {
2✔
24
    this.name = name;
3✔
25
    this.sectionElements = sectionElements;
3✔
26
    this.properties = new LinkedHashMap<>();
5✔
27
    for (IniElement element : sectionElements) {
6!
28
      if (element instanceof IniProperty property) {
×
29
        properties.put(property.getKey(), property);
×
30
      }
31
    }
×
32
  }
1✔
33

34
  /**
35
   * creates IniSectionImpl with given name and empty properties
36
   *
37
   * @param name section name
38
   */
39
  public IniSectionImpl(String name) {
40
    this(name, new LinkedList<>());
6✔
41
  }
1✔
42

43
  @Override
44
  public String getName() {
45
    return name;
3✔
46
  }
47

48
  @Override
49
  public List<String> getPropertyKeys() {
50
    return properties.keySet().stream().toList();
6✔
51
  }
52

53
  @Override
54
  public IniProperty getProperty(String key) {
55
    return properties.get(key);
6✔
56
  }
57

58
  @Override
59
  public void setProperty(String key, String value, int indentLevel) {
60
    IniProperty property = new IniPropertyImpl(key, value, indentLevel);
7✔
61
    sectionElements.add(property);
5✔
62
    properties.put(key, property);
6✔
63
  }
1✔
64

65
  @Override
66
  public void addComment(String comment, int indentLevel) {
67
    sectionElements.add(new IniCommentImpl(comment, indentLevel));
9✔
68
  }
1✔
69

70
  @Override
71
  public int getIndentLevel() {
72
    return 0;
2✔
73
  }
74

75
  @Override
76
  public String toString() {
77
    StringBuilder stringBuilder = new StringBuilder();
4✔
78
    stringBuilder.append("[").append(name).append("]").append("\n");
11✔
79
    for (int i = 0; i < sectionElements.size(); i++) {
9✔
80
      IniElement element = sectionElements.get(i);
6✔
81
      stringBuilder.append("\t".repeat(Math.max(0, element.getIndentLevel())));
9✔
82
      stringBuilder.append(element);
4✔
83
      if (i + 1 < sectionElements.size()) {
7✔
84
        stringBuilder.append("\n");
4✔
85
      }
86
    }
87
    return stringBuilder.toString();
3✔
88
  }
89
}
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