org.somda.sdc.biceps.common.access.MdibAccess Maven / Gradle / Ivy
Show all versions of biceps Show documentation
package org.somda.sdc.biceps.common.access;
import org.somda.sdc.biceps.common.MdibEntity;
import org.somda.sdc.biceps.model.participant.AbstractContextState;
import org.somda.sdc.biceps.model.participant.AbstractDescriptor;
import org.somda.sdc.biceps.model.participant.AbstractState;
import org.somda.sdc.biceps.model.participant.MdibVersion;
import java.math.BigInteger;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
/**
* Read access to an MDIB storage.
*/
public interface MdibAccess {
/**
* The 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.
*
* @return the latest known MDIB version.
*/
MdibVersion getMdibVersion();
/**
* The 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.
*
* @return the latest known MD description version.
*/
BigInteger getMdDescriptionVersion();
/**
* The 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.
*
* @return The latest known MD state version.
*/
BigInteger getMdStateVersion();
/**
* Retrieves a specific descriptor of the hosted {@link org.somda.sdc.biceps.model.participant.Mdib}.
*
* @param handle Handle name of the descriptor.
* @param descrClass Class to cast to. If cast fails, {@link Optional#empty()} will be returned.
* @param any descriptor type.
* @return {@link Optional} of the requested descriptor or {@link Optional#empty()} if not found or something
* went wrong.
*/
Optional getDescriptor(String handle, Class descrClass);
/**
* Retrieves a specific abstract descriptor of the hosted {@link org.somda.sdc.biceps.model.participant.Mdib}.
*
* @param handle Handle name of the descriptor.
* @return {@link Optional} of the requested descriptor or {@link Optional#empty()} if not found or something
* went wrong.
*/
Optional getDescriptor(String handle);
/**
* Gets an {@link MdibEntity} object with a specific handle.
*
* @param handle the handle to seek.
* @return the entity of {@link Optional#empty()} if not found.
*/
Optional getEntity(String handle);
/**
* Searches all entities that match a specific type.
*
* @param type the class to filter for.
* @param the descriptor type defined by the class.
* @return a collection of entities where {@code type} matches.
*/
Collection findEntitiesByType(Class type);
/**
* Resolves the children of a specific type given a parent handle.
*
* @param handle the parent handle of the entity.
* @param type The class to filter for.
* @param the descriptor type defined by the class.
* @return a list of children that matches {@code type} (while preserving ordering).
*/
List getChildrenByType(String handle, Class type);
/**
* Gets all {@link MdibEntity} objects that are root elements.
*
* @return the root elements, i.e., entities whose descriptors are of type
* {@link org.somda.sdc.biceps.model.participant.MdsDescriptor}.
*/
List getRootEntities();
/**
* Retrieves a specific abstract state of the hosted {@link org.somda.sdc.biceps.model.participant.Mdib}.
*
* @param handle the state or descriptor handle of the state to request (descriptor handle is used in case of
* single states).
* @return {@link Optional} of the requested state or {@link Optional#empty()} if not found or something
* went wrong.
*/
Optional getState(String handle);
/**
* Retrieves a specific state of the hosted {@link org.somda.sdc.biceps.model.participant.Mdib}.
*
* @param handle the state or descriptor handle of the state to request (descriptor handle is used in case of
* single states).
* @param stateClass the class to cast to. If cast fails, {@link Optional#empty()} will be returned.
* @param any state type.
* @return {@link Optional} of the requested state or {@link Optional#empty()} if not found or something
* went wrong.
*/
Optional getState(String handle, Class stateClass);
/**
* Finds 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.
*
* @param descriptorHandle the descriptor handle to seek.
* @param stateClass the class to filter for.
* @param any context state type.
* @return a list of the context states of {@code descriptorHandle}.
*/
List getContextStates(String descriptorHandle, Class stateClass);
/**
* Finds all context states of a certain descriptor.
*
* Attention: collections may be created on function call, hence be careful with performance issues.
*
* @param descriptorHandle the descriptor handle to seek.
* @return a list of the context states of {@code descriptorHandle}.
*/
List getContextStates(String descriptorHandle);
/**
* Gets all context states.
*
* Attention: collections may be created on function call, hence be careful with performance issues.
*
* @return a list of all context states.
*/
List getContextStates();
/**
* Gets all context states of a specific type.
*
* Attention: collections may be created on function call, hence be careful with performance issues.
*
* @param stateClass the class information to filter for.
* @param the type to filter for.
* @return a list of all context states of the specific type.
*/
List findContextStatesByType(Class stateClass);
}