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
- TheConfigureSource
typeHOLDER
- TheConfigurationHolder
type.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 ValueAdapterRegistry
protected @NotNull ConfigExceptionHandler
protected @NotNull ConfigurationInitializer
protected @NotNull Map
<String, ConfigurationMetaHolder> protected @NotNull ConfigurationOptionHolder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> SELF
adapter
(@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> SELF
adapter
(@NotNull ValueType<T> type, @NotNull ValueParser<T> parser) <T> SELF
adapter
(@NotNull ValueType<T> type, @NotNull ValueSerializer<T> serializer) <T> SELF
adapter
(@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> SELF
adapter
(@NotNull Class<T> type, @NotNull ValueSerializer<T> serializer, @NotNull ValueParser<T> parser) adapter
(Consumer<ValueAdapterRegistry> adapterRegistryConsumer) adapters
(ValueAdapterRegistry adapters) abstract HOLDER
build()
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> SELF
option
(ConfigurationOption<O> type, Consumer<O> modifier) <O> SELF
option
(ConfigurationOption<O> type, Supplier<O> value) <O> SELF
option
(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 SELF
self()
<A extends Annotation>
SELFvalidAnnotation
(@NotNull Class<A> annotation, @NotNull Function<A, ValueValidator<Object>> builder) Register a new annotation forValueValidator
to 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
- TheAnnotation
metadata
- TheConfigurationMetadata
typeextractor
- TheFunction
to 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 forValueValidator
to the configuration loader- Type Parameters:
A
- The annotation type- Parameters:
annotation
- TheAnnotation
builder
- TheFunction
to build theValueValidator
from the annotation- Returns:
- this
-
build
Build the configuration holder.- Returns:
- The configuration holder
-