public final class ConfigCache extends Object
Modifier and Type | Method | Description |
---|---|---|
static <T extends Config> |
add(Object key,
T instance) |
Adds a
Config object into the cache. |
static void |
clear() |
Removes all of the cached instances.
|
static <T extends Config> |
get(Object key) |
Gets from the cache the
Config instance identified by the given key. |
static <T extends Config> |
getOrCreate(Class<? extends T> clazz,
Map<?,?>... imports) |
Gets from the cache or create, an instance of the given class using the given imports.
|
static <T extends Config> |
getOrCreate(Object key,
Class<? extends T> clazz,
Map<?,?>... imports) |
Gets from the cache or create, an instance of the given class using the given imports.
|
static <T extends Config> |
getOrCreate(Factory factory,
Class<? extends T> clazz,
Map<?,?>... imports) |
Gets from the cache or create, an instance of the given class using the given imports.
|
static <T extends Config> |
getOrCreate(Factory factory,
Object key,
Class<? extends T> clazz,
Map<?,?>... imports) |
Gets from the cache or create, an instance of the given class using the given imports.
|
static Set<Object> |
list() |
Lists the key objects for all configuration instances present in the cache.
|
static <T extends Config> |
remove(Object key) |
Removes the cached instance for the given key if it is present.
|
public static <T extends Config> T getOrCreate(Class<? extends T> clazz, Map<?,?>... imports)
ConfigFactory.INSTANCE
.T
- type of the interface.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public static <T extends Config> T getOrCreate(Factory factory, Class<? extends T> clazz, Map<?,?>... imports)
T
- type of the interface.factory
- the factory to use to eventually create the instance.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public static <T extends Config> T getOrCreate(Object key, Class<? extends T> clazz, Map<?,?>... imports)
ConfigFactory.INSTANCE
.T
- type of the interface.key
- the key object to be used to identify the instance in the cache.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public static <T extends Config> T getOrCreate(Factory factory, Object key, Class<? extends T> clazz, Map<?,?>... imports)
T
- type of the interface.factory
- the factory to use to eventually create the instance.key
- the key object to be used to identify the instance in the cache.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public static <T extends Config> T get(Object key)
Config
instance identified by the given key.T
- type of the interface.key
- the key object to be used to identify the instance in the cache.Config
object from the cache if exists, or null
if it doesn't.public static <T extends Config> T add(Object key, T instance)
Config
object into the cache.T
- type of the interface.key
- the key object to be used to identify the instance in the cache.instance
- the instance of the Config
object to be stored into the cache.null
if there was no mapping for the key.public static Set<Object> list()
public static void clear()
public static <T extends Config> T remove(Object key)
Returns previous instance associated to the given key in the cache,
or null
if the cache contained no instance for the given key.
The cache will not contain the instance for the specified key once the call returns.
T
- type of the interface.key
- key whose instance is to be removed from the cache.key
, or
null
if there was no instance for key
.Copyright © 2012–2020 Luigi R. Viggiano. All rights reserved.