mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 10:38:19 +08:00
feat(json): Finished json version's provider
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
package cc.carm.lib.configuration.annotation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Footer Comments.
|
||||
* Add a comment to the bottom of the corresponding configuration for easy reading and viewing.
|
||||
* <p>e.g.
|
||||
* <blockquote><pre>
|
||||
* foo: "bar"
|
||||
* # The first line of the comment
|
||||
* # The second line of the comment
|
||||
* </pre></blockquote>
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FooterComment {
|
||||
|
||||
/**
|
||||
* If the content of the note is 0, it will be treated as a blank line.
|
||||
* <p> e.g. <b>{"foo","","bar"}</b>
|
||||
* Will be set as
|
||||
* <blockquote><pre>
|
||||
* foo: "bar"
|
||||
* # foo
|
||||
*
|
||||
* # bar
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @return The content of this comment
|
||||
*/
|
||||
@NotNull
|
||||
String[] value() default "";
|
||||
|
||||
}
|
||||
+10
@@ -1,5 +1,6 @@
|
||||
package cc.carm.lib.configuration.commentable;
|
||||
|
||||
import cc.carm.lib.configuration.annotation.FooterComment;
|
||||
import cc.carm.lib.configuration.annotation.HeaderComment;
|
||||
import cc.carm.lib.configuration.annotation.InlineComment;
|
||||
import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||
@@ -18,6 +19,11 @@ public interface CommentableMetaTypes {
|
||||
*/
|
||||
ConfigurationMetadata<List<String>> HEADER_COMMENTS = ConfigurationMetadata.of(Collections.emptyList());
|
||||
|
||||
/**
|
||||
* Configuration's footer comments
|
||||
*/
|
||||
ConfigurationMetadata<List<String>> FOOTER_COMMENTS = ConfigurationMetadata.of(Collections.emptyList());
|
||||
|
||||
/**
|
||||
* Configuration's {@link InlineComment}
|
||||
*/
|
||||
@@ -33,6 +39,10 @@ public interface CommentableMetaTypes {
|
||||
HeaderComment.class, HEADER_COMMENTS,
|
||||
a -> Arrays.asList(a.value())
|
||||
);
|
||||
initializer.registerAnnotation(
|
||||
FooterComment.class, FOOTER_COMMENTS,
|
||||
a -> Arrays.asList(a.value())
|
||||
);
|
||||
initializer.registerAnnotation(InlineComment.class, INLINE_COMMENT, InlineComment::value);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -4,11 +4,11 @@ import cc.carm.lib.configuration.source.option.ConfigurationOption;
|
||||
|
||||
public interface CommentableOptions {
|
||||
|
||||
/**
|
||||
* Whether to keep modified comments in configuration,
|
||||
* that means we only set comments for values that are not exists in configuration.
|
||||
*/
|
||||
ConfigurationOption<Boolean> KEEP_COMMENTS = ConfigurationOption.of(true);
|
||||
// /**
|
||||
// * Whether to keep modified comments in configuration,
|
||||
// * that means we only set comments for values that are not exists in configuration.
|
||||
// */
|
||||
// ConfigurationOption<Boolean> KEEP_COMMENTS = ConfigurationOption.of(true);
|
||||
|
||||
/**
|
||||
* Whether to comment values name that are not exists in configuration and no default value offered.
|
||||
@@ -19,6 +19,6 @@ public interface CommentableOptions {
|
||||
* # foo:
|
||||
* </pre></blockquote>
|
||||
*/
|
||||
ConfigurationOption<Boolean> COMMENT_NO_DEFAULT = ConfigurationOption.of(true);
|
||||
ConfigurationOption<Boolean> COMMENT_EMPTY_VALUE = ConfigurationOption.of(true);
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
package cc.carm.lib.configuration.source;
|
||||
package cc.carm.lib.configuration.source.file;
|
||||
|
||||
import cc.carm.lib.configuration.source.ConfigurationFactory;
|
||||
import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
package cc.carm.lib.configuration.source;
|
||||
package cc.carm.lib.configuration.source.file;
|
||||
|
||||
import cc.carm.lib.configuration.function.DataFunction;
|
||||
import cc.carm.lib.configuration.option.FileConfigOptions;
|
||||
import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||
import cc.carm.lib.configuration.source.option.FileConfigOptions;
|
||||
import cc.carm.lib.configuration.source.section.ConfigureSection;
|
||||
import cc.carm.lib.configuration.source.section.ConfigureSource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cc.carm.lib.configuration.option;
|
||||
package cc.carm.lib.configuration.source.option;
|
||||
|
||||
import cc.carm.lib.configuration.source.option.ConfigurationOption;
|
||||
|
||||
Reference in New Issue
Block a user