Interface FluentConfigurationBuilder<B extends FluentConfigurationBuilder<?>>
-
- Type Parameters:
B- builder sub-type
- All Superinterfaces:
Builder<Configuration>
public interface FluentConfigurationBuilder<B extends FluentConfigurationBuilder<?>> extends Builder<Configuration>
A fluent builder ofConfigurationinstances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CacheConfiguration<?,?>getCache(java.lang.String alias)Return the cache configuration for the given alias.java.lang.ClassLoadergetClassLoader()Return the configured classloader instance.default <C extends ServiceCreationConfiguration<?,?>>
CgetService(java.lang.Class<C> configurationType)Return the unique service creation configuration of the given type.<C extends ServiceCreationConfiguration<?,?>>
java.util.Collection<C>getServices(java.lang.Class<C> configurationType)Return the service creation configurations of the given type.BupdateCache(java.lang.String alias, java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)Updates the configuration of the identified cache.BupdateCaches(java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)Updates the configuration of the all caches.<R,C extends ServiceCreationConfiguration<?,R>>
BupdateServices(java.lang.Class<C> clazz, java.util.function.UnaryOperator<R> update)Updates all service creation configurations of the given type.default BwithCache(java.lang.String alias, Builder<? extends CacheConfiguration<?,?>> builder)Adds the cache configuration built by a builder to this configuration.BwithCache(java.lang.String alias, CacheConfiguration<?,?> config)Adds the given cache to this configuration.BwithClassLoader(java.lang.ClassLoader classLoader)Sets the given class loader as the cache manager classloaderBwithDefaultClassLoader()Removes any provided class loader returning to default behaviorBwithoutCache(java.lang.String alias)Removes the given cache from this configuration.default BwithoutServices(java.lang.Class<? extends ServiceCreationConfiguration<?,?>> clazz)Removes all service creation configurations of the given type from this configuration.<C extends ServiceCreationConfiguration<?,?>>
BwithoutServices(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.default BwithService(Builder<? extends ServiceCreationConfiguration<?,?>> builder)Adds a service creation configuration built by the given builder to this configuration.BwithService(ServiceCreationConfiguration<?,?> config)Adds a service creation configuration to this configuration.
-
-
-
Method Detail
-
getCache
CacheConfiguration<?,?> getCache(java.lang.String alias)
Return the cache configuration for the given alias.- Parameters:
alias- cache alias- Returns:
- associated cache configuration
- See Also:
withCache(String, CacheConfiguration),withCache(String, Builder),updateCache(String, UnaryOperator),withoutCache(String),updateCaches(UnaryOperator)
-
withCache
B withCache(java.lang.String alias, CacheConfiguration<?,?> config)
Adds the given cache to this configuration.This will overwrite any existing configuration for the cache with this alias.
- Parameters:
alias- cache aliasconfig- cache configuration- Returns:
- an updated builder
- See Also:
getCache(String),withCache(String, Builder),updateCache(String, UnaryOperator),withoutCache(String),updateCaches(UnaryOperator)
-
withCache
default B withCache(java.lang.String alias, Builder<? extends CacheConfiguration<?,?>> builder)
Adds the cache configuration built by a builder to this configuration.This will overwrite any existing configuration for the cache with this alias.
- Parameters:
alias- cache aliasbuilder- cache configuration builder- Returns:
- an updated builder
- See Also:
getCache(String),withCache(String, Builder),updateCache(String, UnaryOperator),withoutCache(String),updateCaches(UnaryOperator)
-
withoutCache
B withoutCache(java.lang.String alias)
Removes the given cache from this configuration.- Parameters:
alias- cache alias- Returns:
- an updated builder
- See Also:
getCache(String),withCache(String, CacheConfiguration),withCache(String, Builder),updateCache(String, UnaryOperator),updateCaches(UnaryOperator)
-
updateCache
B updateCache(java.lang.String alias, java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update) throws java.lang.IllegalArgumentException
Updates the configuration of the identified cache.If a cache exists for the given alias then the following process is performed:
- The configuration is converted to a builder seeded with that configuration.
- The builder is then transformed using the
updateunary operator. - A new configuration is generated by calling
build()on the resultant builder. - The new configuration is associated with the given alias.
aliasthen anIllegalStateExceptionwill be thrown.- Parameters:
alias- cache aliasupdate- configuration mutation function- Returns:
- an updated builder
- Throws:
java.lang.IllegalArgumentException- if no cache configuration exists foralias- See Also:
getCache(String),withCache(String, CacheConfiguration),withCache(String, Builder),withoutCache(String),updateCaches(UnaryOperator)
-
updateCaches
B updateCaches(java.util.function.UnaryOperator<FluentCacheConfigurationBuilder<?,?,?>> update)
Updates the configuration of the all caches.For every existing cache the following process is performed:
- The configuration is converted to a builder seeded with that configuration.
- The builder is then transformed using the
updateunary operator. - A new configuration is generated by calling
build()on the resultant builder. - The new configuration is associated with the given alias.
- Parameters:
update- configuration mutation function- Returns:
- an updated builder
- See Also:
getCache(String),withCache(String, CacheConfiguration),withCache(String, Builder),updateCache(String, UnaryOperator),withoutCache(String)
-
getService
default <C extends ServiceCreationConfiguration<?,?>> C getService(java.lang.Class<C> configurationType) throws java.lang.IllegalArgumentException
Return the unique service creation configuration of the given type.If there are multiple configuration instances of this type (or subtypes) then an
IllegalArgumentExceptionwill be thrown.- Type Parameters:
C- configuration type- Parameters:
configurationType- desired configuration type- Returns:
- the given configuration type
- Throws:
java.lang.IllegalArgumentException- if there are multiple instances of this type- See Also:
getServices(Class),withService(ServiceCreationConfiguration),withService(Builder),withoutServices(Class),withoutServices(Class, Predicate),updateServices(Class, UnaryOperator)
-
getServices
<C extends ServiceCreationConfiguration<?,?>> java.util.Collection<C> getServices(java.lang.Class<C> configurationType)
Return the service creation configurations of the given type.- Type Parameters:
C- configuration type- Parameters:
configurationType- desired configuration type- Returns:
- all services of this type
- See Also:
getService(Class),withService(ServiceCreationConfiguration),withService(Builder),withoutServices(Class),withoutServices(Class, Predicate),updateServices(Class, UnaryOperator)
-
withService
B withService(ServiceCreationConfiguration<?,?> config)
Adds a service creation configuration to this configuration.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) );- Parameters:
config- service creation configuration- Returns:
- an updated builder
- See Also:
ServiceCreationConfiguration.compatibleWith(ServiceCreationConfiguration),getService(Class),getServices(Class),withService(Builder),withoutServices(Class),withoutServices(Class, Predicate),updateServices(Class, UnaryOperator)
-
withService
default B withService(Builder<? extends ServiceCreationConfiguration<?,?>> builder)
Adds a service creation configuration built by the given builder to this configuration.This will remove any existing configurations that are incompatible with the supplied one.
- Parameters:
builder- service creation configuration builder- Returns:
- an updated builder
- See Also:
getService(Class),getServices(Class),withService(ServiceCreationConfiguration),withoutServices(Class),withoutServices(Class, Predicate),updateServices(Class, UnaryOperator)
-
withoutServices
default B withoutServices(java.lang.Class<? extends ServiceCreationConfiguration<?,?>> clazz)
Removes all service creation configurations of the given type from this configuration.- Parameters:
clazz- service configuration type- Returns:
- an updated builder
- See Also:
getService(Class),getServices(Class),withService(ServiceCreationConfiguration),withService(Builder),withoutServices(Class, Predicate),updateServices(Class, UnaryOperator)
-
withoutServices
<C extends ServiceCreationConfiguration<?,?>> B 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.- Type Parameters:
C- configuration type- Parameters:
clazz- service configuration typepredicate- predicate controlling removal- Returns:
- an updated builder
- See Also:
getService(Class),getServices(Class),withService(ServiceCreationConfiguration),withService(Builder),withoutServices(Class),updateServices(Class, UnaryOperator)
-
updateServices
<R,C extends ServiceCreationConfiguration<?,R>> B updateServices(java.lang.Class<C> clazz, java.util.function.UnaryOperator<R> update) throws java.lang.IllegalStateException
Updates all service creation configurations of the given type.For each existing service creation configuration instance that is assignment compatible with
clazzthe following process is performed:- The configuration is converted to its detached representations using the
ServiceCreationConfiguration.derive()method. - The detached representation is transformed using the
updateunary operator. - A new configuration is generated by passing the transformed detached representation to the existing
configurations
ServiceCreationConfiguration.build(Object)method. - The new configuration is added to the builders service configuration set.
clazzthen anIllegalStateExceptionwill be thrown.- Type Parameters:
R- configuration detached representation typeC- service configuration type- Parameters:
clazz- service creation configuration typeupdate- configuration mutation function- Returns:
- an updated builder
- Throws:
java.lang.IllegalStateException- if no configurations of typeCexist- See Also:
getService(Class),getServices(Class),withService(ServiceCreationConfiguration),withService(Builder),withoutServices(Class),withoutServices(Class, Predicate)
- The configuration is converted to its detached representations using the
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Return the configured classloader instance.- Returns:
- configured classloader
- See Also:
withClassLoader(ClassLoader),withDefaultClassLoader()
-
withClassLoader
B withClassLoader(java.lang.ClassLoader classLoader)
Sets the given class loader as the cache manager classloader- Parameters:
classLoader- cache manager classloader- Returns:
- an updated builder
- See Also:
getClassLoader(),withDefaultClassLoader()
-
withDefaultClassLoader
B withDefaultClassLoader()
Removes any provided class loader returning to default behavior- Returns:
- an updated builder
- See Also:
getClassLoader(),withClassLoader(ClassLoader)
-
-