Skip to content

Commit 321e917

Browse files
committed
add footer annotation
1 parent bea49b8 commit 321e917

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

core/src/main/java/net/j4c0b3y/api/config/ConfigDocument.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ public String dump(@NotNull DumperSettings settings) {
7575
.map(line -> "# " + line + "\n")
7676
.collect(Collectors.joining());
7777

78-
return header + (!header.isEmpty() ? "\n" : "") + content;
78+
String footer = config.getFooter()
79+
.stream()
80+
.map(line -> "# " + line + "\n")
81+
.collect(Collectors.joining());
82+
83+
return header + (!header.isEmpty() ? "\n" : "") + content + "\n" + footer;
7984
}
8085

8186
/**

core/src/main/java/net/j4c0b3y/api/config/StaticConfig.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ public List<String> getHeader() {
120120
return Arrays.asList(header.value());
121121
}
122122

123+
/**
124+
* @return The footer to be shown at the bottom of the document file.
125+
*/
126+
public List<String> getFooter() {
127+
Footer footer = getClass().getAnnotation(Footer.class);
128+
if (footer == null) return Collections.emptyList();
129+
130+
return Arrays.asList(footer.value());
131+
}
132+
123133
/**
124134
* Creates, relocates and loads the document keys into the static fields.
125135
*/
@@ -488,9 +498,21 @@ private String getRoute(Key key, String name) {
488498
protected @interface Hidden {
489499
}
490500

501+
/**
502+
* Adds a header comment to the top of the config document.
503+
*/
491504
@Retention(RetentionPolicy.RUNTIME)
492505
@Target({ElementType.TYPE})
493506
public @interface Header {
494507
String[] value();
495508
}
509+
510+
/**
511+
* Adds a footer comment to the bottom of the config document.
512+
*/
513+
@Retention(RetentionPolicy.RUNTIME)
514+
@Target({ElementType.TYPE})
515+
public @interface Footer {
516+
String[] value();
517+
}
496518
}

0 commit comments

Comments
 (0)