Class MdibStorageImpl
- java.lang.Object
-
- org.somda.sdc.biceps.common.storage.MdibStorageImpl
-
- All Implemented Interfaces:
MdibStorage
public class MdibStorageImpl extends Object implements MdibStorage
Default implementation of MdibStorage.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WriteDescriptionResultapply(MdibVersion mdibVersion, BigInteger mdDescriptionVersion, BigInteger mdStateVersion, MdibDescriptionModifications descriptionModifications)Applies description modifications on this object regardless of any consistency checks.WriteStateResultapply(MdibVersion mdibVersion, BigInteger mdStateVersion, MdibStateModifications stateModifications)Applies state modifications on this object regardless of any consistency checks.<T extends AbstractContextState>
List<T>findContextStatesByType(Class<T> stateClass)Gets all context states of a specific type.<T extends AbstractDescriptor>
Collection<MdibEntity>findEntitiesByType(Class<T> type)Searches all entities that match a specific type.<T extends AbstractDescriptor>
List<MdibEntity>getChildrenByType(String handle, Class<T> type)Resolves the children of a specific type given a parent handle.List<AbstractContextState>getContextStates()Gets all context states.List<AbstractContextState>getContextStates(String descriptorHandle)Finds all context states of a certain descriptor.<T extends AbstractContextState>
List<T>getContextStates(String descriptorHandle, Class<T> stateClass)Finds all context states of a certain descriptor given a state class.Optional<AbstractDescriptor>getDescriptor(String handle)Retrieves a specific abstract descriptor of the hostedMdib.<T extends AbstractDescriptor>
Optional<T>getDescriptor(String handle, Class<T> descrClass)Retrieves a specific descriptor of the hostedMdib.Optional<MdibEntity>getEntity(String handle)Gets anMdibEntityobject with a specific handle.BigIntegergetMdDescriptionVersion()The latest known MD description version.MdibVersiongetMdibVersion()The latest known MDIB version.BigIntegergetMdStateVersion()The latest known MD state version.List<AbstractMultiState>getMultiStates(String descriptorHandle)Finds all multi states of a certain handle.List<MdibEntity>getRootEntities()Gets allMdibEntityobjects that are root elements.Optional<AbstractState>getState(String handle)Retrieves a specific abstract state of the hostedMdib.<T extends AbstractState>
Optional<T>getState(String handle, Class<T> stateClass)Retrieves a specific state of the hostedMdib.
-
-
-
Method Detail
-
getDescriptor
public <T extends AbstractDescriptor> Optional<T> getDescriptor(String handle, Class<T> descrClass)
Description copied from interface:MdibStorageRetrieves a specific descriptor of the hostedMdib.- Specified by:
getDescriptorin interfaceMdibStorage- Type Parameters:
T- any abstract descriptor.- Parameters:
handle- Handle name of the descriptor.descrClass- Class to cast to. If cast fails,Optional.empty()will be returned.- Returns:
Optionalof the requested descriptor orOptional.empty()if not found or something went wrong.
-
getDescriptor
public Optional<AbstractDescriptor> getDescriptor(String handle)
Description copied from interface:MdibStorageRetrieves a specific abstract descriptor of the hostedMdib.- Specified by:
getDescriptorin interfaceMdibStorage- Parameters:
handle- Handle name of the descriptor.- Returns:
Optionalof the requested descriptor orOptional.empty()if not found or something went wrong.
-
getEntity
public Optional<MdibEntity> getEntity(String handle)
Description copied from interface:MdibStorageGets anMdibEntityobject with a specific handle.- Specified by:
getEntityin interfaceMdibStorage- Parameters:
handle- the handle to seek.- Returns:
- the entity of
Optional.empty()if not found.
-
findEntitiesByType
public <T extends AbstractDescriptor> Collection<MdibEntity> findEntitiesByType(Class<T> type)
Description copied from interface:MdibStorageSearches all entities that match a specific type.- Specified by:
findEntitiesByTypein interfaceMdibStorage- Type Parameters:
T- the descriptor type defined by the class.- Parameters:
type- the class to filter for.- Returns:
- a collection of entities where
typematches.
-
getChildrenByType
public <T extends AbstractDescriptor> List<MdibEntity> getChildrenByType(String handle, Class<T> type)
Description copied from interface:MdibStorageResolves the children of a specific type given a parent handle.- Specified by:
getChildrenByTypein interfaceMdibStorage- Type Parameters:
T- the descriptor type defined by the class.- Parameters:
handle- the parent handle of the entity.type- The class to filter for.- Returns:
- a list of children that matches
type(while preserving ordering).
-
getRootEntities
public List<MdibEntity> getRootEntities()
Description copied from interface:MdibStorageGets allMdibEntityobjects that are root elements.- Specified by:
getRootEntitiesin interfaceMdibStorage- Returns:
- the root elements, i.e., entities whose descriptors are of type
MdsDescriptor.
-
getState
public Optional<AbstractState> getState(String handle)
Description copied from interface:MdibStorageRetrieves a specific abstract state of the hostedMdib.- Specified by:
getStatein interfaceMdibStorage- Parameters:
handle- the state or descriptor handle of the state to request (descriptor handle is used in case of single states).- Returns:
Optionalof the requested state orOptional.empty()if not found or something went wrong.
-
getState
public <T extends AbstractState> Optional<T> getState(String handle, Class<T> stateClass)
Description copied from interface:MdibStorageRetrieves a specific state of the hostedMdib.- Specified by:
getStatein interfaceMdibStorage- Type Parameters:
T- any abstract state.- Parameters:
handle- the state or descriptor handle of the state to request (descriptor handle is used in case of single states).stateClass- the class to cast to. If cast fails,Optional.empty()will be returned.- Returns:
Optionalof the requested state orOptional.empty()if not found or something went wrong.
-
getContextStates
public <T extends AbstractContextState> List<T> getContextStates(String descriptorHandle, Class<T> stateClass)
Description copied from interface:MdibStorageFinds all context states of a certain descriptor given a state class.- Specified by:
getContextStatesin interfaceMdibStorage- Type Parameters:
T- any abstract context state.- Parameters:
descriptorHandle- the descriptor handle to seek.stateClass- the class to filter for.- Returns:
- a list of the context states of
descriptorHandle. - See Also:
MdibAccess.getContextStates(String, Class)
-
getContextStates
public List<AbstractContextState> getContextStates(String descriptorHandle)
Description copied from interface:MdibStorageFinds all context states of a certain descriptor.- Specified by:
getContextStatesin interfaceMdibStorage- Parameters:
descriptorHandle- the descriptor handle to seek.- Returns:
- a list of the context states of
descriptorHandle. - See Also:
MdibAccess.getContextStates(String)
-
getMultiStates
public List<AbstractMultiState> getMultiStates(String descriptorHandle)
Description copied from interface:MdibStorageFinds all multi states of a certain handle.- Specified by:
getMultiStatesin interfaceMdibStorage- Parameters:
descriptorHandle- the descriptor handle to seek.- Returns:
- a list of the multi states of
descriptorHandle.
-
getContextStates
public List<AbstractContextState> getContextStates()
Description copied from interface:MdibStorageGets all context states.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibStorage- Returns:
- a list of all context states.
-
findContextStatesByType
public <T extends AbstractContextState> List<T> findContextStatesByType(Class<T> stateClass)
Description copied from interface:MdibStorageGets all context states of a specific type.- Specified by:
findContextStatesByTypein interfaceMdibStorage- Type Parameters:
T- the context type to filter for.- Parameters:
stateClass- the class information to filter for.- Returns:
- a list of all context states with the given type.
-
apply
public WriteDescriptionResult apply(MdibVersion mdibVersion, @Nullable BigInteger mdDescriptionVersion, @Nullable BigInteger mdStateVersion, MdibDescriptionModifications descriptionModifications)
Description copied from interface:MdibStorageApplies description modifications on this object regardless of any consistency checks.Versions are applied without being verified.
- Specified by:
applyin interfaceMdibStorage- Parameters:
mdibVersion- the MDIB version to apply.mdDescriptionVersion- the MD description version to apply. Value null leaves version as is.mdStateVersion- the MD state version to apply. Value null leaves version as is.descriptionModifications- the modifications to apply.- Returns:
- a result set with inserted, updated and deleted entities.
-
apply
public WriteStateResult apply(MdibVersion mdibVersion, @Nullable BigInteger mdStateVersion, MdibStateModifications stateModifications)
Description copied from interface:MdibStorageApplies state modifications on this object regardless of any consistency checks.Versions are applied without being verified.
- Specified by:
applyin interfaceMdibStorage- Parameters:
mdibVersion- the MDIB version to apply.mdStateVersion- the MD state version to apply. Value null leaves version as is.stateModifications- the modifications to apply.- Returns:
- a result set with updated states.
-
getMdibVersion
public MdibVersion getMdibVersion()
Description copied from interface:MdibStorageThe latest known MDIB version.- Specified by:
getMdibVersionin interfaceMdibStorage- Returns:
- the latest known MDIB version.
- See Also:
MdibAccess.getMdibVersion()
-
getMdDescriptionVersion
public BigInteger getMdDescriptionVersion()
Description copied from interface:MdibStorageThe latest known MD description version.- Specified by:
getMdDescriptionVersionin interfaceMdibStorage- Returns:
- the latest known MD description version.
- See Also:
MdibAccess.getMdDescriptionVersion()
-
getMdStateVersion
public BigInteger getMdStateVersion()
Description copied from interface:MdibStorageThe latest known MD state version.- Specified by:
getMdStateVersionin interfaceMdibStorage- Returns:
- The latest known MD state version.
- See Also:
MdibAccess.getMdStateVersion()
-
-