java.lang.Object
org.meeuw.configuration.ConfigurationService
- Since:
- 0.7
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddefaultConfiguration(Consumer<Configuration.Builder> consumer) Configures the default configuration object.static Configurationstatic <E extends ConfigurationAspect>
EgetConfigurationAspect(Class<E> clazz) static FixedSizeMap<Class<? extends ConfigurationAspect>,ConfigurationAspect> static voidstatic voidUnsets the configuration thread local, effectively resetting it the default settings.static voidsetConfiguration(Configuration configuration) Sets the given configuration object as a thread localstatic <E extends ConfigurationAspect>
voidwith(Class<E> configurationAspect, UnaryOperator<E> aspect, Runnable r) static <E extends ConfigurationAspect,R>
Rwith(Class<E> configurationAspect, UnaryOperator<E> aspect, Supplier<R> r) static voidwith(Consumer<Configuration.Builder> configuration, Runnable r) static voidwith(Configuration configuration, Runnable r) static <R> Rwith(Configuration configuration, Supplier<R> r) Executes code with a certain configuration
-
Field Details
-
CONFIGURATION
-
-
Method Details
-
defaultConfiguration
Configures the default configuration object.- Parameters:
consumer- the code to configure the new default configuration. it will receive aConfiguration.Builderwith the existing configuration.
-
getConfiguration
- Returns:
- the current (thread local) configuration object
-
setConfiguration
Sets the given configuration object as a thread local- Parameters:
configuration- the new configuration
-
resetToDefaults
public static void resetToDefaults()Unsets the configuration thread local, effectively resetting it the default settings. -
resetToDefaultDefaults
public static void resetToDefaultDefaults() -
getConfigurationAspect
- Type Parameters:
E- The type of the aspect to obtain- Parameters:
clazz- the class of the aspect to obtain- Returns:
- an aspect of the current configuration object
-
with
-
with
public static <E extends ConfigurationAspect,R> R with(Class<E> configurationAspect, UnaryOperator<E> aspect, Supplier<R> r) -
with
public static <E extends ConfigurationAspect> void with(Class<E> configurationAspect, UnaryOperator<E> aspect, Runnable r) -
with
Executes code with a certain configuration -
with
-
newConfigurationMap
public static FixedSizeMap<Class<? extends ConfigurationAspect>,ConfigurationAspect> newConfigurationMap()
-