C
- the "self"-type of this Config
@ParametersAreNonnullByDefault public class BaseConfig<C extends BaseConfig<C>> extends Object implements Config
Config
that creates and manages common configuration that are available for all back-end
implementations. It also provides all methods for building and querying a configuration.
All features are all optional: configuration can be created using all or none of them.
Modifier and Type | Field and Description |
---|---|
static String |
BASE_PREFIX
The base prefix for all internal options key related to the NeoEMF behavior.
|
Constructor and Description |
---|
BaseConfig()
Constructs a new
BaseConfig with default settings. |
Modifier and Type | Method and Description |
---|---|
C |
addListener(StoreListener listener)
Adds a store listener in this configuration.
|
<T> C |
addOption(String key,
T value)
Adds a key/value in this configuration.
|
C |
addStore(Store store)
Adds a feature defined by the given
store in this configuration. |
C |
autoSave()
Adds the
autoSave feature in this configuration. |
C |
autoSave(long chunk)
Adds the
autoSave feature, with a defined chunk , in this configuration. |
C |
cacheContainers()
Adds the
cache-containers feature in this configuration. |
C |
cacheFeatures()
Adds the
cache-features feature in this configuration. |
C |
cacheMetaClasses()
Adds the
cache-metaclasses feature in this configuration. |
C |
cacheSizes()
Adds the
cache-sizes feature in this configuration. |
protected static String |
createKey(String... segments)
Creates a new key from the given
segments . |
String |
getMapping()
Returns the defined mapping.
|
String |
getName()
Returns the name of the
BackendFactory associated with this configuration. |
Map<String,?> |
getOptions()
Returns all defined options.
|
Set<Store> |
getStores()
Returns a set of all defined
Store . |
String |
getVariant()
Returns the variant of the
BackendFactory binding. |
protected Predicate<String> |
isPersistentKey()
Returns a
Predicate used to filter the options to be saved in a configuration file, in order to retrieve
them in a future execution. |
protected Predicate<String> |
isReadOnlyKey()
Returns a
Predicate used to filter read-only keys. |
C |
log()
Adds the
log feature in this configuration. |
C |
log(Level level)
Adds the
log feature, with a defined level , in this configuration. |
C |
merge(ImmutableConfig config)
Merges the given
config in this configuration. |
C |
merge(Map<String,?> map)
Merges the given
map in this configuration. |
C |
readOnly()
Adds the
read-only feature in this configuration. |
C |
recordStats(StoreStats stats)
Adds the
stats feature in this configuration. |
void |
save(Path directory)
Saves this configuration in the
directory . |
C |
setMapping(String mappingType)
Defines the mapping to use for the created
Backend . |
protected C |
setMappingWithCheck(String mappingType,
boolean checkConflict)
Defines the mapping to use for the created
Backend . |
Map<String,?> |
toMap()
Returns a immutable map view of this configuration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exists, forName, forScheme, load
getOption, getOptions, hasOption, isReadOnly
public static final String BASE_PREFIX
public BaseConfig()
BaseConfig
with default settings.
NOTE: This implementation is intended to configure a Store
'
chain. The created configuration is not associated with any BackendFactory
,
so it cannot be used to configure a Backend
. Use the specific
implementation for this.
@Nonnull protected static String createKey(String... segments)
segments
. Each segment will be delimited by a dot.segments
- the segments of the keypublic void save(Path directory) throws IOException
ImmutableConfig
directory
.save
in interface ImmutableConfig
directory
- the directory where to store the configurationIOException
- if an I/O error occurs during the saving@Nonnull public final Map<String,?> toMap()
ImmutableConfig
toMap
in interface ImmutableConfig
Resource.load(Map)
,
Resource.save(Map)
@Nonnull public String getName()
ImmutableConfig
BackendFactory
associated with this configuration.getName
in interface ImmutableConfig
BackendFactory.name()
@Nonnull public String getVariant()
ImmutableConfig
BackendFactory
binding.getVariant
in interface ImmutableConfig
@Nonnull public String getMapping()
ImmutableConfig
getMapping
in interface ImmutableConfig
@Nonnull public C setMapping(String mappingType)
Config
Backend
.setMapping
in interface Config
mappingType
- the class name of the mapping to use@Nonnull public <T> C addOption(String key, T value)
Config
@Nonnull public C addStore(Store store)
Config
store
in this configuration.@Nonnull public C cacheFeatures()
Config
cache-features
feature in this configuration.cacheFeatures
in interface Config
@Nonnull public C cacheContainers()
Config
cache-containers
feature in this configuration.cacheContainers
in interface Config
@Nonnull public C cacheMetaClasses()
Config
cache-metaclasses
feature in this configuration.cacheMetaClasses
in interface Config
@Nonnull public C cacheSizes()
Config
cache-sizes
feature in this configuration.cacheSizes
in interface Config
@Nonnull public C readOnly()
Config
read-only
feature in this configuration.@Nonnull public C autoSave()
Config
autoSave
feature in this configuration.@Nonnull public C autoSave(long chunk)
Config
autoSave
feature, with a defined chunk
, in this configuration.
WARNING: When chunk
is zero, the store will be saved at each call.
@Nonnull public C addListener(StoreListener listener)
Config
addListener
in interface Config
listener
- the sotre listener to add@Nonnull public C log()
Config
log
feature in this configuration.@Nonnull public C log(Level level)
Config
log
feature, with a defined level
, in this configuration.@Nonnull public C recordStats(StoreStats stats)
Config
stats
feature in this configuration.recordStats
in interface Config
stats
- the stats that will be updated@Nonnull public Map<String,?> getOptions()
ImmutableConfig
getOptions
in interface ImmutableConfig
@Nonnull public Set<Store> getStores()
ImmutableConfig
Store
.getStores
in interface ImmutableConfig
@Nonnull public C merge(Map<String,?> map)
Config
map
in this configuration. All options defined in the map
will be added to this
configuration, with conflict checking.merge
in interface Config
map
- the map representation of this configurationImmutableConfig.toMap()
@Nonnull public final C merge(ImmutableConfig config)
Config
config
in this configuration. All options defined in the config
will be added to
this configuration, with conflict checking.@Nonnull @OverridingMethodsMustInvokeSuper protected Predicate<String> isPersistentKey()
Predicate
used to filter the options to be saved in a configuration file, in order to retrieve
them in a future execution.
By default, only the options related to a back-end are saved.
save(Path)
@Nonnull @OverridingMethodsMustInvokeSuper protected Predicate<String> isReadOnlyKey()
Predicate
used to filter read-only keys. These keys can not be modified after their first
declaration.addOption(String, Object)
@Nonnull protected final C setMappingWithCheck(String mappingType, boolean checkConflict)
Backend
. If the mapping has
already been defined and checkConflict == false
, then it will be erased by the new.mappingType
- the type name of the mapping to usecheckConflict
- true
if the mappingType
must be compared with the current mapping to check
collisionCopyright © 2013–2019 Atlanmod. All rights reserved.