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

AuthMe / ConfigMe / 19403665265

16 Nov 2025 09:37AM UTC coverage: 99.278% (-0.1%) from 99.395%
19403665265

push

github

web-flow
#356 - Add Footer Comment Support (#511)

* add footer comment support

* PR review feedback fixes

564 of 578 branches covered (97.58%)

7 of 9 new or added lines in 2 files covered. (77.78%)

1650 of 1662 relevant lines covered (99.28%)

4.6 hits per line

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

87.5
/src/main/java/ch/jalu/configme/configurationdata/CommentsConfiguration.java
1
package ch.jalu.configme.configurationdata;
2

3
import ch.jalu.configme.Comment;
4
import ch.jalu.configme.SettingsHolder;
5
import org.jetbrains.annotations.NotNull;
6
import org.jetbrains.annotations.UnmodifiableView;
7

8
import java.util.Arrays;
9
import java.util.Collections;
10
import java.util.HashMap;
11
import java.util.List;
12
import java.util.Map;
13

14
/**
15
 * Allows to register comments (intended via {@link SettingsHolder#registerComments}).
16
 */
17
public class CommentsConfiguration {
18

19
    private final @NotNull Map<String, List<String>> comments;
20

21
    public static final String FOOTER_KEY = "..FOOTER";
22

23
    /**
24
     * Constructor.
25
     */
26
    public CommentsConfiguration() {
2✔
27
        this.comments = new HashMap<>();
5✔
28
    }
1✔
29

30
    /**
31
     * Constructor.
32
     *
33
     * @param comments map to store comments in
34
     */
35
    public CommentsConfiguration(@NotNull Map<String, List<String>> comments) {
2✔
36
        this.comments = comments;
3✔
37
    }
1✔
38

39
    /**
40
     * Sets the given lines for the provided path, overriding any previously existing comments for the path.
41
     * An entry that is a sole new-line (i.e. "\n") will result in an empty line without any comment marker.
42
     *
43
     * @param path the path to register the comment lines for
44
     * @param commentLines the comment lines to set for the path
45
     */
46
    public void setComment(@NotNull String path, @NotNull String @NotNull ... commentLines) {
47
        List<String> replaced = comments.put(path, Collections.unmodifiableList(Arrays.asList(commentLines)));
9✔
48
        
49
        if (replaced != null) {
2✔
50
            String commentAnnotation = "@" + Comment.class.getSimpleName();
10✔
51
            throw new IllegalStateException("Comments for path '" + path + "' have already been registered. Use "
18✔
52
                + commentAnnotation + " on a property field, or one call to CommentsConfiguration#setComment per path");
53
        }
54
    }
1✔
55

56
    /**
57
     * Returns a read-only view of the map with all comments.
58
     *
59
     * @return map with all comments
60
     */
61
    public @NotNull @UnmodifiableView Map<String, @UnmodifiableView List<String>> getAllComments() {
62
        return Collections.unmodifiableMap(comments);
4✔
63
    }
64

65
    /**
66
     * Adds the given lines as footer comments. They will be written at the end of the configuration file.
67
     *
68
     * @param commentLines the comment lines to add as footer comments
69
     */
70
    public void setFooterComments(@NotNull String... commentLines) {
71
        setComment(FOOTER_KEY, commentLines);
4✔
72
    }
1✔
73

74
    /**
75
     * Adds the given lines as header comments. They will be written at the start of the configuration file.
76
     *
77
     * @param commentLines the comment lines to add as header comments
78
     */
79
    public void setHeaderComments(@NotNull String... commentLines) {
NEW
80
        setComment("", commentLines);
×
NEW
81
    }
×
82

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