public class ConfijBuilder<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfijBuilder.ConfijWrapper<T> |
| Modifier | Constructor and Description |
|---|---|
protected |
ConfijBuilder(@NonNull java.lang.reflect.Type forType) |
| Modifier and Type | Method and Description |
|---|---|
<I> ConfijBuilder<T> |
bindValuesForClassWith(ValueMapperInstance<I> valueMapper,
java.lang.Class<I> forClass)
Convenience method to register a
ValueMapperFactory which will only handle a single class. |
ConfijBuilder<T> |
bindValuesWith(ValueMapperFactory valueMapperFactory)
Globally register an additional
ValueMapperFactory. |
T |
build()
Finalize the configuration pipeline and build a single instance of it.
|
ConfijBuilder.ConfijWrapper<T> |
buildWrapper()
Finalize the configuration pipeline and build a single instance holding the most recent configuration.
|
protected void |
lazySetDefaults() |
ConfijBuilder<T> |
loadFrom(ConfijResource... resources)
Read configuration values from these ordered resources (like from FS, git,...).
|
ConfijBuilder<T> |
loadFrom(ConfijResource resource,
ConfijFormat format)
Read configuration values from a well defined source and format.
|
ConfijBuilder<T> |
loadFrom(ConfijSource... source)
Read configuration values from these ordered sources.
|
ConfijBuilder<T> |
loadFrom(java.lang.String... sourceStr)
Read configuration values from these ordered
AnySources. |
ConfijBuilder<T> |
loadFromFirstOf(java.lang.String firstSource,
java.lang.String secondSource,
java.lang.String... otherSources)
Attempt reading configurations from these ordered
AnySources. |
ConfijBuilder<T> |
loadOptionalFrom(java.lang.String... maybeSourceStr)
Attempt reading configurationd from all of these ordered
AnySources. |
protected @NonNull BindingContext |
newBindingContext() |
protected @NonNull NodeBindingContext |
newNodeBindingContext() |
protected @NonNull ConfijPipeline<T> |
newPipeline() |
static <X> ConfijBuilder<X> |
of(java.lang.Class<X> forClass)
The most common constructor to create a new configuration
builder of given type.
|
static <X> ConfijBuilder<X> |
of(GenericType<X> forType)
This constructor is used to pass full generics type information, and
avoid problems with type erasure (that basically removes most
usable type references from runtime Class objects).
|
ConfijBuilder<T> |
reloadPeriodically(@NonNull java.time.Duration duration)
A
PeriodicReloadStrategy with initial delay equal to interval duration |
ConfijBuilder<T> |
reloadStrategy(@NonNull ConfijReloadStrategy reloadStrategy)
define when/how new configurations are loaded.
|
ConfijBuilder<T> |
templatingDisabled()
disables templating (variable substitution), such that your values containing
${variables} just stay as they are. |
ConfijBuilder<T> |
templatingWith(@NonNull ValueResolver valueResolver) |
ConfijBuilder<T> |
validateOnlyWith(@NonNull ConfijValidator<T> validator)
replace the default validation/post-processing steps with this new validator.
|
ConfijBuilder<T> |
validationAllowsNull() |
ConfijBuilder<T> |
validationDisabled()
Explicitly disable all validation/post-processing steps.
|
protected ConfijBuilder(@NonNull
@NonNull java.lang.reflect.Type forType)
protected void lazySetDefaults()
public static <X> ConfijBuilder<X> of(java.lang.Class<X> forClass)
X - the configuration instance typeforClass - the configuration instance classpublic static <X> ConfijBuilder<X> of(GenericType<X> forType)
X - the configuration instance typeforType - type holder classGenericTypepublic ConfijBuilder<T> loadFrom(ConfijSource... source)
loadFrom(String...) isn't good enough.source - list of configuration sourcespublic ConfijBuilder<T> loadFrom(java.lang.String... sourceStr)
AnySources.sourceStr - list of path's to configuration sourcespublic ConfijBuilder<T> loadFrom(ConfijResource... resources)
resources - list of resources (like files,...) to read configurations frompublic ConfijBuilder<T> loadFrom(ConfijResource resource, ConfijFormat format)
loadFrom(ConfijSource...).resource - resource (like files,...) to read configurations fromformat - the actual format which understants the content of resourcepublic ConfijBuilder<T> loadOptionalFrom(java.lang.String... maybeSourceStr)
AnySources.
Read failures are dropped silently.
Usefull for optional configuration, like for tests only.maybeSourceStr - optional sources, reading all of them is attemptedMaybeSourcepublic ConfijBuilder<T> loadFromFirstOf(java.lang.String firstSource, java.lang.String secondSource, java.lang.String... otherSources)
AnySources.
Ignore all configurations before and after the first successful read.
Usefull if a set of configurations should be ignored if another one is present.firstSource - an optional sourcesecondSource - an optional sourceotherSources - more optional sources, only read if not an earlier one existedOrSourcepublic ConfijBuilder<T> validateOnlyWith(@NonNull @NonNull ConfijValidator<T> validator)
ServiceLoaders implementing ConfijValidator.
To combine multiple validators use a MultiValidator.validator - the new validatorpublic ConfijBuilder<T> validationAllowsNull()
public ConfijBuilder<T> validationDisabled()
validateOnlyWith(ConfijValidator)public ConfijBuilder<T> templatingWith(@NonNull @NonNull ValueResolver valueResolver)
public ConfijBuilder<T> templatingDisabled()
${variables} just stay as they are.public ConfijBuilder<T> bindValuesWith(ValueMapperFactory valueMapperFactory)
ValueMapperFactory. This allows for custom classes in your configuration definition.
Same as writing
\@ValueMapper(CustomMapper.class)
interface MyConfigRoot { ... }
valueMapperFactory - the new mapper with highest preferencebindValuesForClassWith(ValueMapperInstance, Class)public <I> ConfijBuilder<T> bindValuesForClassWith(ValueMapperInstance<I> valueMapper, java.lang.Class<I> forClass)
ValueMapperFactory which will only handle a single class.I - the target typevalueMapper - functional interface to convert a string to IforClass - the class of Ipublic ConfijBuilder<T> reloadStrategy(@NonNull @NonNull ConfijReloadStrategy reloadStrategy)
NeverReloadStrategy.reloadStrategy - the new reload strategy to be usedpublic ConfijBuilder<T> reloadPeriodically(@NonNull @NonNull java.time.Duration duration)
PeriodicReloadStrategy with initial delay equal to interval durationduration - time between reload attempts@NonNull protected @NonNull BindingContext newBindingContext()
@NonNull protected @NonNull NodeBindingContext newNodeBindingContext()
@NonNull protected @NonNull ConfijPipeline<T> newPipeline()
public T build()
buildWrapper() instead.public ConfijBuilder.ConfijWrapper<T> buildWrapper()
build() is simpler to use instead.