@ParametersAreNonnullByDefault public abstract class AbstractInMemoryBackend extends AbstractBackend implements InMemoryBackend, ManyValueWithLists, AllReferenceAs<Long>
InMemoryBackend
that provides the default behavior of containers and meta-classes management.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractInMemoryBackend.Sizes
Some statistics about the size of key and values.
|
Modifier and Type | Field and Description |
---|---|
protected static BeanSerializerFactory |
SERIALIZER_FACTORY
The
BeanSerializerFactory to use for creating the BinarySerializer instances. |
Modifier | Constructor and Description |
---|---|
protected |
AbstractInMemoryBackend()
Constructs a new
AbstractInMemoryBackend . |
protected |
AbstractInMemoryBackend(String name)
Constructs a new
AbstractInMemoryBackend with the given name . |
Modifier and Type | Method and Description |
---|---|
Stream<Id> |
allInstancesOf(Set<ClassBean> metaClasses)
Retrieves all instances of the given
metaClasses . |
protected void |
checkFeature(FeatureBean feature)
Checks the specified
feature before using it. |
void |
containerFor(Id id,
SingleFeatureBean container)
Stores the
container for the specified id . |
Optional<SingleFeatureBean> |
containerOf(Id id)
Retrieves the container for the specified
id . |
protected abstract Map<Id,SingleFeatureBean> |
containers()
Returns the map that holds all containers.
|
protected abstract Map<SingleFeatureBean,Object> |
features()
Returns the map that holds single-features.
|
protected abstract Map<Id,ClassBean> |
instances()
Returns the map that holds all instances.
|
void |
internalSave()
Saves all modifications made on this back-end since the last call.
|
boolean |
metaClassFor(Id id,
ClassBean metaClass)
Stores the
metaClass for the specified id . |
Optional<ClassBean> |
metaClassOf(Id id)
Retrieves the meta-class for the specified
id . |
Converter<Id,Long> |
referenceConverter()
Returns the converter used to transform a reference to the desired type.
|
void |
removeContainer(Id id)
Removes the container of the specified
id . |
void |
removeValue(SingleFeatureBean feature)
Removes the value of the specified
feature . |
<V> Optional<V> |
valueFor(SingleFeatureBean feature,
V value)
Defines the
value of the specified feature . |
<V> Optional<V> |
valueOf(SingleFeatureBean feature)
Retrieves the value of the specified
feature . |
allInstancesOf, close, copyTo, internalClose, internalCopyTo, save, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isDistributed, isPersistent
allInstancesOf
addAllValues, addValue, allValuesOf, appendAllValues, appendValue, removeAllValues, removeValue, sizeOfValue, valueFor, valueOf
addAllReferences, addReference, allReferencesOf, appendAllReferences, appendReference, referenceFor, referenceOf, removeAllReferences, removeReference, sizeOfReference
referenceFor, referenceOf, removeReference
addAllValues, addValue, allValuesOf, getOrCreateList, removeAllValues, removeValue, sizeOfValue, valueFor, valueOf
manyReferenceConverter
referenceFor, referenceOf, removeReference
addAllReferences, addReference, allReferencesOf, appendAllReferences, appendReference, referenceFor, referenceOf, removeAllReferences, removeReference, sizeOfReference
@Nonnull protected static final BeanSerializerFactory SERIALIZER_FACTORY
BeanSerializerFactory
to use for creating the BinarySerializer
instances.protected AbstractInMemoryBackend()
AbstractInMemoryBackend
.public void internalSave()
AbstractBackend
internalSave
in class AbstractBackend
@Nonnull protected abstract Map<Id,SingleFeatureBean> containers()
@Nonnull protected abstract Map<Id,ClassBean> instances()
@Nonnull protected abstract Map<SingleFeatureBean,Object> features()
protected void checkFeature(FeatureBean feature)
feature
before using it.feature
- the feature to check@Nonnull public Optional<SingleFeatureBean> containerOf(Id id)
ContainerMapper
id
.containerOf
in interface ContainerMapper
id
- the Id
of the contained elementOptional
containing the container, or Optional.empty()
if the id
has no
defined container.public void containerFor(Id id, SingleFeatureBean container)
ContainerMapper
container
for the specified id
.containerFor
in interface ContainerMapper
id
- the Id
of the contained elementcontainer
- the containing element's container information to storepublic void removeContainer(Id id)
ContainerMapper
id
.
The container must be completely removed, so that a call to ContainerMapper.containerOf(Id)
returns Optional.empty()
.
removeContainer
in interface ContainerMapper
id
- the Id
of the contained element@Nonnull public Optional<ClassBean> metaClassOf(Id id)
ClassMapper
id
.metaClassOf
in interface ClassMapper
id
- the Id
of the elementOptional
containing the meta-class, or Optional.empty()
if the id
has no
defined meta-class.public boolean metaClassFor(Id id, ClassBean metaClass)
ClassMapper
metaClass
for the specified id
.metaClassFor
in interface ClassMapper
id
- the Id
of the elementmetaClass
- the containing element's meta-class information to storetrue
if the meta-class has been defined, false
if the id
already has a meta-class@Nonnull public Stream<Id> allInstancesOf(Set<ClassBean> metaClasses)
ClassMapper
metaClasses
.allInstancesOf
in interface ClassMapper
metaClasses
- the meta-classes to compute the instances ofStream
containing the instances of the metaClasses
@Nonnull public <V> Optional<V> valueOf(SingleFeatureBean feature)
ValueMapper
feature
.valueOf
in interface ValueMapper
V
- the type of valuefeature
- the bean identifying the valueOptional
containing the value, or Optional.empty()
if the feature hasn't any value or
doesn't exist@Nonnull public <V> Optional<V> valueFor(SingleFeatureBean feature, V value)
ValueMapper
value
of the specified feature
.valueFor
in interface ValueMapper
V
- the type of valuefeature
- the bean identifying the valuevalue
- the value to setOptional
containing the previous value of the feature
, or Optional.empty()
if
the feature has no value beforepublic void removeValue(SingleFeatureBean feature)
ValueMapper
feature
.removeValue
in interface ValueMapper
feature
- the bean identifying the value@Nonnull public Converter<Id,Long> referenceConverter()
ReferenceAs
referenceConverter
in interface ReferenceAs<Long>
Copyright © 2013–2019 Atlanmod. All rights reserved.