Package cc.carm.lib.configuration.source
Class ConfigurationFactory<SOURCE extends ConfigureSource<?,?,SOURCE>,HOLDER extends ConfigurationHolder<SOURCE>,SELF>
java.lang.Object
cc.carm.lib.configuration.source.ConfigurationFactory<SOURCE,HOLDER,SELF>
- Type Parameters:
SOURCE- TheConfigureSourcetypeHOLDER- TheConfigurationHoldertype.SELF- Self builder, for further implement support.
public abstract class ConfigurationFactory<SOURCE extends ConfigureSource<?,?,SOURCE>,HOLDER extends ConfigurationHolder<SOURCE>,SELF>
extends Object
ConfigurationFactory, used to create configuration holder.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @NotNull ValueAdapterRegistryprotected @NotNull ConfigExceptionHandlerprotected @NotNull ConfigurationInitializerprotected @NotNull Map<String, ConfigurationMetaHolder> protected @NotNull ConfigurationOptionHolder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> SELFadapter(@NotNull ValueAdapter<T> adapter) <FROM,TO> SELF adapter(@NotNull ValueType<FROM> from, @NotNull ValueType<TO> to, @NotNull DataFunction<FROM, TO> parser, @NotNull DataFunction<TO, FROM> serializer) <T> SELFadapter(@NotNull ValueType<T> type, @NotNull ValueParser<T> parser) <T> SELFadapter(@NotNull ValueType<T> type, @NotNull ValueSerializer<T> serializer) <T> SELFadapter(@NotNull ValueType<T> type, @NotNull ValueSerializer<T> serializer, @NotNull ValueParser<T> parser) <FROM,TO> SELF adapter(@NotNull Class<FROM> from, @NotNull Class<TO> to, @NotNull DataFunction<FROM, TO> parser, @NotNull DataFunction<TO, FROM> serializer) <T> SELFadapter(@NotNull Class<T> type, @NotNull ValueSerializer<T> serializer, @NotNull ValueParser<T> parser) adapter(Consumer<ValueAdapterRegistry> adapterRegistryConsumer) adapters(ValueAdapterRegistry adapters) abstract HOLDERbuild()Build the configuration holder.exceptionally(@NotNull ConfigExceptionHandler handler) initializer(ConfigurationInitializer initializer) initializer(Consumer<ConfigurationInitializer> initializerConsumer) <M,A extends Annotation>
SELFmetaAnnotation(@NotNull Class<A> annotation, @NotNull ConfigurationMetadata<M> metadata, @NotNull Function<A, M> extractor) Register a new annotation for metadata to the configuration loadermetadata(@Nullable String path, @NotNull ConfigurationMetaHolder meta) metadata(@Nullable String path, @NotNull Consumer<ConfigurationMetaHolder> handler) metadata(@NotNull Map<String, ConfigurationMetaHolder> metadata) metadata(@NotNull Consumer<Map<String, ConfigurationMetaHolder>> handler) <O> SELFoption(ConfigurationOption<O> type, Consumer<O> modifier) <O> SELFoption(ConfigurationOption<O> type, Supplier<O> value) <O> SELFoption(ConfigurationOption<O> type, O value) option(Consumer<ConfigurationOptionHolder> modifier) options(ConfigurationOptionHolder options) pathGenerator(PathGenerator generator) Supply the base path generator for this configuration holderprotected abstract SELFself()<A extends Annotation>
SELFvalidAnnotation(@NotNull Class<A> annotation, @NotNull Function<A, ValueValidator<Object>> builder) Register a new annotation forValueValidatorto the configuration loader
-
Field Details
-
adapters
-
options
-
metadata
-
initializer
-
exceptionHandler
-
-
Constructor Details
-
ConfigurationFactory
protected ConfigurationFactory()
-
-
Method Details
-
self
-
adapters
-
adapter
-
adapter
-
adapter
public <T> SELF adapter(@NotNull @NotNull ValueType<T> type, @NotNull @NotNull ValueSerializer<T> serializer) -
adapter
public <T> SELF adapter(@NotNull @NotNull ValueType<T> type, @NotNull @NotNull ValueParser<T> parser) -
adapter
public <FROM,TO> SELF adapter(@NotNull @NotNull Class<FROM> from, @NotNull @NotNull Class<TO> to, @NotNull @NotNull DataFunction<FROM, TO> parser, @NotNull @NotNull DataFunction<TO, FROM> serializer) -
adapter
public <FROM,TO> SELF adapter(@NotNull @NotNull ValueType<FROM> from, @NotNull @NotNull ValueType<TO> to, @NotNull @NotNull DataFunction<FROM, TO> parser, @NotNull @NotNull DataFunction<TO, FROM> serializer) -
adapter
public <T> SELF adapter(@NotNull @NotNull ValueType<T> type, @NotNull @NotNull ValueSerializer<T> serializer, @NotNull @NotNull ValueParser<T> parser) -
adapter
public <T> SELF adapter(@NotNull @NotNull Class<T> type, @NotNull @NotNull ValueSerializer<T> serializer, @NotNull @NotNull ValueParser<T> parser) -
options
-
option
-
option
-
option
-
option
-
metadata
-
metadata
-
metadata
public SELF metadata(@Nullable @Nullable String path, @NotNull @NotNull ConfigurationMetaHolder meta) -
metadata
public SELF metadata(@Nullable @Nullable String path, @NotNull @NotNull Consumer<ConfigurationMetaHolder> handler) -
initializer
-
initializer
-
exceptionally
-
pathGenerator
Supply the base path generator for this configuration holder- Parameters:
generator-PathGenerator- Returns:
- this
-
metaAnnotation
public <M,A extends Annotation> SELF metaAnnotation(@NotNull @NotNull Class<A> annotation, @NotNull @NotNull ConfigurationMetadata<M> metadata, @NotNull @NotNull Function<A, M> extractor) Register a new annotation for metadata to the configuration loader- Type Parameters:
M- The metadata typeA- The annotation type- Parameters:
annotation- TheAnnotationmetadata- TheConfigurationMetadatatypeextractor- TheFunctionto extract the metadata from the annotation- Returns:
- this
-
validAnnotation
public <A extends Annotation> SELF validAnnotation(@NotNull @NotNull Class<A> annotation, @NotNull @NotNull Function<A, ValueValidator<Object>> builder) Register a new annotation forValueValidatorto the configuration loader- Type Parameters:
A- The annotation type- Parameters:
annotation- TheAnnotationbuilder- TheFunctionto build theValueValidatorfrom the annotation- Returns:
- this
-
build
Build the configuration holder.- Returns:
- The configuration holder
-