public class CoreConfigurationBuilder<B extends CoreConfigurationBuilder<B>> extends java.lang.Object implements FluentConfigurationBuilder<B>
Modifier | Constructor and Description |
---|---|
protected |
CoreConfigurationBuilder() |
protected |
CoreConfigurationBuilder(CoreConfigurationBuilder<?> builder,
java.lang.ClassLoader classLoader) |
protected |
CoreConfigurationBuilder(CoreConfigurationBuilder<?> builder,
java.util.Collection<ServiceCreationConfiguration<?,?>> serviceConfigurations) |
protected |
CoreConfigurationBuilder(CoreConfigurationBuilder<?> builder,
java.util.Map<java.lang.String,CacheConfiguration<?,?>> caches) |
Modifier and Type | Method and Description |
---|---|
Configuration |
build()
Builds an instance.
|
CacheConfiguration<?,?> |
getCache(java.lang.String alias)
Return the cache configuration for the given alias.
|
java.lang.ClassLoader |
getClassLoader()
Return the configured classloader instance.
|
<C extends ServiceCreationConfiguration<?,?>> |
getServices(java.lang.Class<C> configurationType)
Return the service creation configurations of the given type.
|
protected B |
newBuilderWith(java.lang.ClassLoader classLoader) |
protected B |
newBuilderWith(java.util.Collection<ServiceCreationConfiguration<?,?>> serviceConfigurations) |
protected B |
newBuilderWith(java.util.Map<java.lang.String,CacheConfiguration<?,?>> caches) |
protected static CoreConfigurationBuilder<?> |
newConfigurationBuilder(Configuration seed)
Create a configuration builder seeded from the given configuration.
|
B |
updateCache(java.lang.String alias,
java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)
Updates the configuration of the identified cache.
|
B |
updateCaches(java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)
Updates the configuration of the all caches.
|
<R,C extends ServiceCreationConfiguration<?,R>> |
updateServices(java.lang.Class<C> clazz,
java.util.function.UnaryOperator<R> update)
Updates all service creation configurations of the given type.
|
B |
withCache(java.lang.String alias,
CacheConfiguration<?,?> config)
Adds the given cache to this configuration.
|
B |
withClassLoader(java.lang.ClassLoader classLoader)
Sets the given class loader as the cache manager classloader
|
B |
withDefaultClassLoader()
Removes any provided class loader returning to default behavior
|
B |
withoutCache(java.lang.String alias)
Removes the given cache from this configuration.
|
<C extends ServiceCreationConfiguration<?,?>> |
withoutServices(java.lang.Class<C> clazz,
java.util.function.Predicate<? super C> predicate)
Removes all service creation configurations of the given type that pass the predicate.
|
B |
withService(ServiceCreationConfiguration<?,?> config)
Adds a service creation configuration to this configuration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getService, withCache, withoutServices, withService
protected CoreConfigurationBuilder()
protected CoreConfigurationBuilder(CoreConfigurationBuilder<?> builder, java.util.Map<java.lang.String,CacheConfiguration<?,?>> caches)
protected CoreConfigurationBuilder(CoreConfigurationBuilder<?> builder, java.util.Collection<ServiceCreationConfiguration<?,?>> serviceConfigurations)
protected CoreConfigurationBuilder(CoreConfigurationBuilder<?> builder, java.lang.ClassLoader classLoader)
protected static CoreConfigurationBuilder<?> newConfigurationBuilder(Configuration seed)
Calling build()
on the returned builder will produce a functionally equivalent configuration to
seed
.
seed
- configuration to duplicatepublic Configuration build()
Builder
build
in interface Builder<Configuration>
public CacheConfiguration<?,?> getCache(java.lang.String alias)
FluentConfigurationBuilder
getCache
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
alias
- cache aliasFluentConfigurationBuilder.withCache(String, CacheConfiguration)
,
FluentConfigurationBuilder.withCache(String, Builder)
,
FluentConfigurationBuilder.updateCache(String, UnaryOperator)
,
FluentConfigurationBuilder.withoutCache(String)
,
FluentConfigurationBuilder.updateCaches(UnaryOperator)
public B withCache(java.lang.String alias, CacheConfiguration<?,?> config)
FluentConfigurationBuilder
This will overwrite any existing configuration for the cache with this alias.
withCache
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
alias
- cache aliasconfig
- cache configurationFluentConfigurationBuilder.getCache(String)
,
FluentConfigurationBuilder.withCache(String, Builder)
,
FluentConfigurationBuilder.updateCache(String, UnaryOperator)
,
FluentConfigurationBuilder.withoutCache(String)
,
FluentConfigurationBuilder.updateCaches(UnaryOperator)
public B withoutCache(java.lang.String alias)
FluentConfigurationBuilder
withoutCache
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
alias
- cache aliasFluentConfigurationBuilder.getCache(String)
,
FluentConfigurationBuilder.withCache(String, CacheConfiguration)
,
FluentConfigurationBuilder.withCache(String, Builder)
,
FluentConfigurationBuilder.updateCache(String, UnaryOperator)
,
FluentConfigurationBuilder.updateCaches(UnaryOperator)
public B updateCache(java.lang.String alias, java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)
FluentConfigurationBuilder
If a cache exists for the given alias then the following process is performed:
update
unary operator.build()
on the resultant builder.alias
then an IllegalStateException
will be thrown.updateCache
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
alias
- cache aliasupdate
- configuration mutation functionFluentConfigurationBuilder.getCache(String)
,
FluentConfigurationBuilder.withCache(String, CacheConfiguration)
,
FluentConfigurationBuilder.withCache(String, Builder)
,
FluentConfigurationBuilder.withoutCache(String)
,
FluentConfigurationBuilder.updateCaches(UnaryOperator)
public B updateCaches(java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)
FluentConfigurationBuilder
For every existing cache the following process is performed:
update
unary operator.build()
on the resultant builder.updateCaches
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
update
- configuration mutation functionFluentConfigurationBuilder.getCache(String)
,
FluentConfigurationBuilder.withCache(String, CacheConfiguration)
,
FluentConfigurationBuilder.withCache(String, Builder)
,
FluentConfigurationBuilder.updateCache(String, UnaryOperator)
,
FluentConfigurationBuilder.withoutCache(String)
public <C extends ServiceCreationConfiguration<?,?>> java.util.Collection<C> getServices(java.lang.Class<C> configurationType)
FluentConfigurationBuilder
getServices
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
C
- configuration typeconfigurationType
- desired configuration typeFluentConfigurationBuilder.getService(Class)
,
FluentConfigurationBuilder.withService(ServiceCreationConfiguration)
,
FluentConfigurationBuilder.withService(Builder)
,
FluentConfigurationBuilder.withoutServices(Class)
,
FluentConfigurationBuilder.withoutServices(Class, Predicate)
,
FluentConfigurationBuilder.updateServices(Class, UnaryOperator)
public B withService(ServiceCreationConfiguration<?,?> config)
FluentConfigurationBuilder
This will remove any existing service creation configurations that are incompatible with the supplied one. This removal is equivalent to the following:
configurations.removeIf(
existing -> !config.compatibleWith(existing) || !existing.compatibleWith(config)
);
withService
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
config
- service creation configurationServiceCreationConfiguration.compatibleWith(ServiceCreationConfiguration)
,
FluentConfigurationBuilder.getService(Class)
,
FluentConfigurationBuilder.getServices(Class)
,
FluentConfigurationBuilder.withService(Builder)
,
FluentConfigurationBuilder.withoutServices(Class)
,
FluentConfigurationBuilder.withoutServices(Class, Predicate)
,
FluentConfigurationBuilder.updateServices(Class, UnaryOperator)
public <C extends ServiceCreationConfiguration<?,?>> B withoutServices(java.lang.Class<C> clazz, java.util.function.Predicate<? super C> predicate)
FluentConfigurationBuilder
withoutServices
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
C
- configuration typeclazz
- service configuration typepredicate
- predicate controlling removalFluentConfigurationBuilder.getService(Class)
,
FluentConfigurationBuilder.getServices(Class)
,
FluentConfigurationBuilder.withService(ServiceCreationConfiguration)
,
FluentConfigurationBuilder.withService(Builder)
,
FluentConfigurationBuilder.withoutServices(Class)
,
FluentConfigurationBuilder.updateServices(Class, UnaryOperator)
public <R,C extends ServiceCreationConfiguration<?,R>> B updateServices(java.lang.Class<C> clazz, java.util.function.UnaryOperator<R> update)
FluentConfigurationBuilder
For each existing service creation configuration instance that is assignment compatible with clazz
the
following process is performed:
ServiceCreationConfiguration.derive()
method.update
unary operator.ServiceCreationConfiguration.build(Object)
method.clazz
then an
IllegalStateException
will be thrown.updateServices
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
R
- configuration detached representation typeC
- service configuration typeclazz
- service creation configuration typeupdate
- configuration mutation functionFluentConfigurationBuilder.getService(Class)
,
FluentConfigurationBuilder.getServices(Class)
,
FluentConfigurationBuilder.withService(ServiceCreationConfiguration)
,
FluentConfigurationBuilder.withService(Builder)
,
FluentConfigurationBuilder.withoutServices(Class)
,
FluentConfigurationBuilder.withoutServices(Class, Predicate)
public java.lang.ClassLoader getClassLoader()
FluentConfigurationBuilder
getClassLoader
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
FluentConfigurationBuilder.withClassLoader(ClassLoader)
,
FluentConfigurationBuilder.withDefaultClassLoader()
public B withClassLoader(java.lang.ClassLoader classLoader)
FluentConfigurationBuilder
withClassLoader
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
classLoader
- cache manager classloaderFluentConfigurationBuilder.getClassLoader()
,
FluentConfigurationBuilder.withDefaultClassLoader()
public B withDefaultClassLoader()
FluentConfigurationBuilder
withDefaultClassLoader
in interface FluentConfigurationBuilder<B extends CoreConfigurationBuilder<B>>
FluentConfigurationBuilder.getClassLoader()
,
FluentConfigurationBuilder.withClassLoader(ClassLoader)
protected B newBuilderWith(java.util.Map<java.lang.String,CacheConfiguration<?,?>> caches)
protected B newBuilderWith(java.util.Collection<ServiceCreationConfiguration<?,?>> serviceConfigurations)
protected B newBuilderWith(java.lang.ClassLoader classLoader)