Class ReadTransactionImpl
- java.lang.Object
-
- org.somda.sdc.biceps.common.access.ReadTransactionImpl
-
- All Implemented Interfaces:
AutoCloseable,MdibAccess,ReadTransaction
public class ReadTransactionImpl extends Object implements ReadTransaction
Default implementation of ReadTransaction.
-
-
Constructor Summary
Constructors Constructor Description ReadTransactionImpl(MdibStorage mdibStorage, Lock lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Creates an empty default to override AutoCloseable.close().<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 description version.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.
-
-
-
Constructor Detail
-
ReadTransactionImpl
public ReadTransactionImpl(MdibStorage mdibStorage, Lock lock)
-
-
Method Detail
-
close
public void close()
Description copied from interface:ReadTransactionCreates an empty default to override AutoCloseable.close().AutoCloseable.close()throws an exception whereas ReadTransaction is supposed to be no-throw. In order to avoid a boiler plate catch branch that is never visited when usingtry(...)with ReadTransaction, this function overrides theAutoCloseable.close()function without throwing a checked exception.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceReadTransaction- See Also:
AutoCloseable.close()
-
getMdibVersion
public MdibVersion getMdibVersion()
Description copied from interface:MdibAccessThe latest known MDIB version.This object returns the last known MDIB version which in case of remote access may not necessarily reflect the MDIB version of the whole MDIB. For local access the MDIB version reflects the latest state.
- Specified by:
getMdibVersionin interfaceMdibAccess- Returns:
- the latest known MDIB version.
-
getMdDescriptionVersion
public BigInteger getMdDescriptionVersion()
Description copied from interface:MdibAccessThe latest known MD description version.This object returns the last known MDIB version which in case of remote access may be outdated. For local access the MD description version reflects the latest state.
- Specified by:
getMdDescriptionVersionin interfaceMdibAccess- Returns:
- the latest known MD description version.
-
getMdStateVersion
public BigInteger getMdStateVersion()
Description copied from interface:MdibAccessThe latest known MD description version.This object returns the last known MDIB version which in case of remote access may be outdated. For local access the MD description version reflects the latest state.
- Specified by:
getMdStateVersionin interfaceMdibAccess- Returns:
- The latest known MD state version.
-
getDescriptor
public <T extends AbstractDescriptor> Optional<T> getDescriptor(String handle, Class<T> descrClass)
Description copied from interface:MdibAccessRetrieves a specific descriptor of the hostedMdib.- Specified by:
getDescriptorin interfaceMdibAccess- Type Parameters:
T- any descriptor type.- 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:MdibAccessRetrieves a specific abstract descriptor of the hostedMdib.- Specified by:
getDescriptorin interfaceMdibAccess- 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:MdibAccessGets anMdibEntityobject with a specific handle.- Specified by:
getEntityin interfaceMdibAccess- Parameters:
handle- the handle to seek.- Returns:
- the entity of
Optional.empty()if not found.
-
getRootEntities
public List<MdibEntity> getRootEntities()
Description copied from interface:MdibAccessGets allMdibEntityobjects that are root elements.- Specified by:
getRootEntitiesin interfaceMdibAccess- Returns:
- the root elements, i.e., entities whose descriptors are of type
MdsDescriptor.
-
getState
public Optional<AbstractState> getState(String handle)
Description copied from interface:MdibAccessRetrieves a specific abstract state of the hostedMdib.- Specified by:
getStatein interfaceMdibAccess- 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:MdibAccessRetrieves a specific state of the hostedMdib.- Specified by:
getStatein interfaceMdibAccess- Type Parameters:
T- any state type.- 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:MdibAccessFinds all context states of a certain descriptor given a state class.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibAccess- Type Parameters:
T- any context state type.- Parameters:
descriptorHandle- the descriptor handle to seek.stateClass- the class to filter for.- Returns:
- a list of the context states of
descriptorHandle.
-
getContextStates
public List<AbstractContextState> getContextStates(String descriptorHandle)
Description copied from interface:MdibAccessFinds all context states of a certain descriptor.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibAccess- Parameters:
descriptorHandle- the descriptor handle to seek.- Returns:
- a list of the context states of
descriptorHandle.
-
getContextStates
public List<AbstractContextState> getContextStates()
Description copied from interface:MdibAccessGets all context states.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
getContextStatesin interfaceMdibAccess- Returns:
- a list of all context states.
-
findContextStatesByType
public <T extends AbstractContextState> List<T> findContextStatesByType(Class<T> stateClass)
Description copied from interface:MdibAccessGets all context states of a specific type.Attention: collections may be created on function call, hence be careful with performance issues.
- Specified by:
findContextStatesByTypein interfaceMdibAccess- Type Parameters:
T- the type to filter for.- Parameters:
stateClass- the class information to filter for.- Returns:
- a list of all context states of the specific type.
-
findEntitiesByType
public <T extends AbstractDescriptor> Collection<MdibEntity> findEntitiesByType(Class<T> type)
Description copied from interface:MdibAccessSearches all entities that match a specific type.- Specified by:
findEntitiesByTypein interfaceMdibAccess- 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:MdibAccessResolves the children of a specific type given a parent handle.- Specified by:
getChildrenByTypein interfaceMdibAccess- 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).
-
-