fix(config-core): write comments and name in writeTo, not serializeOneTo
This commit is contained in:
parent
dddda8b92a
commit
fe2808cf45
|
@ -91,6 +91,12 @@ public interface EntryInfo<T> {
|
|||
*/
|
||||
default <TEx extends Exception, Writer extends SerializeWriter<TEx, Writer>> void writeTo(Writer writer, String translationPrefix) throws TEx, IllegalAccessException {
|
||||
try {
|
||||
String commentText = JfConfigSafe.TRANSLATION_SUPPLIER.apply(translationPrefix + getName() + ".tooltip");
|
||||
if (commentText != null) writer.comment(commentText);
|
||||
if (getValueType().isEnum()) {
|
||||
writer.comment("Valid: [" + Arrays.stream(getValueType().asEnum().options()).map(Objects::toString).collect(Collectors.joining(", ")) + "]");
|
||||
}
|
||||
writer.name(getName());
|
||||
serializeOneTo(getValue(), translationPrefix, writer);
|
||||
} catch (MalformedDataException e) {
|
||||
LibJf.LOGGER.error("Could not write " + getName(), e);
|
||||
|
@ -102,14 +108,6 @@ public interface EntryInfo<T> {
|
|||
}
|
||||
|
||||
default <TEx extends Exception, Writer extends SerializeWriter<TEx, Writer>> void serializeOneTo(T value, String translationPrefix, Writer writer) throws TEx, MalformedDataException {
|
||||
String commentText;
|
||||
if ((commentText = JfConfigSafe.TRANSLATION_SUPPLIER.apply(translationPrefix + getName() + ".tooltip")) != null) {
|
||||
writer.comment(commentText);
|
||||
}
|
||||
if (getValueType().isEnum()) {
|
||||
writer.comment("Valid: [" + Arrays.stream(getValueType().asEnum().options()).map(Objects::toString).collect(Collectors.joining(", ")) + "]");
|
||||
}
|
||||
writer.name(getName());
|
||||
LibJf.MAPPER.getAdapter(getTypeToken()).serialize(value, writer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user