Package org.somda.sdc.biceps.common
Interface MdibEntity
-
- All Known Implementing Classes:
MdibEntityImpl
public interface MdibEntityRepresentation of any MDIB object within a containment tree.Any entity contains a list of states, a descriptor and an optional set of children. MdibEntity is an immutable class with read access only.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceMdibEntity.StateAlternative<T>An alternative lambda to be executed.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MdibEntity.StateAlternative<AbstractState>doIfMultiState(Consumer<List<AbstractMultiState>> consumer)Convenience method to execute code if en entity hosts a multi-state.MdibEntity.StateAlternative<List<AbstractMultiState>>doIfSingleState(Consumer<AbstractState> consumer)Convenience method to execute code if en entity hosts a single-state.List<String>getChildren()Obtain a read-only list of the MDIB entity's child handles.AbstractDescriptorgetDescriptor()Obtain the entity's descriptor.<T extends AbstractDescriptor>
Optional<T>getDescriptor(Class<T> theClass)Obtains the entity's descriptor as a given type.Class<? extends AbstractDescriptor>getDescriptorClass()Gets the descriptor class.<T extends AbstractState>
Optional<T>getFirstState(Class<T> theClass)Obtains the first state if available.StringgetHandle()Unique name to identify the entity.MdibVersiongetLastChanged()Gets the MDIB version of the entity where it has been changed the last time.Optional<String>getParent()Obtains the entity's parent handle.Class<? extends AbstractState>getStateClass()Gets the state class.List<AbstractState>getStates()Obtains a copy of the MDIB entity's state list.<T extends AbstractState>
List<T>getStates(Class<T> theClass)Obtains the list of states cast to a specific type.
-
-
-
Method Detail
-
getLastChanged
MdibVersion getLastChanged()
Gets the MDIB version of the entity where it has been changed the last time.- Returns:
- an MDIB version.
-
getChildren
List<String> getChildren()
Obtain a read-only list of the MDIB entity's child handles.- Returns:
- readable list of children currently associated with the entity.
-
getDescriptor
AbstractDescriptor getDescriptor()
Obtain the entity's descriptor.- Returns:
- descriptor information currently associated with the entity.
-
getDescriptor
<T extends AbstractDescriptor> Optional<T> getDescriptor(Class<T> theClass)
Obtains the entity's descriptor as a given type.- Type Parameters:
T- the descriptor class type.- Parameters:
theClass- the class to cast.- Returns:
- descriptor information currently associated with the entity.
-
getHandle
String getHandle()
Unique name to identify the entity.Short-hand for
getDescriptor().getHandle()- Returns:
- the entity's unique handle.
-
getParent
Optional<String> getParent()
Obtains the entity's parent handle.- Returns:
- the handle of the parent if known, otherwise Optional.empty().
-
getStates
List<AbstractState> getStates()
Obtains a copy of the MDIB entity's state list.- Returns:
- list of states currently associated with the entity.
-
getStates
<T extends AbstractState> List<T> getStates(Class<T> theClass)
Obtains the list of states cast to a specific type.- Type Parameters:
T- the state class type.- Parameters:
theClass- the class to cast.- Returns:
- list of cast states currently associated with the entity. Please note that this list is empty either if there is no state available or there is no state available with the given type information.
-
getFirstState
<T extends AbstractState> Optional<T> getFirstState(Class<T> theClass)
Obtains the first state if available.This function is useful to retrieve single state information.
- Type Parameters:
T- the state class type.- Parameters:
theClass- the class to cast.- Returns:
- the cast type of Optional.empty() if there is no first state or a class cast error.
-
doIfSingleState
MdibEntity.StateAlternative<List<AbstractMultiState>> doIfSingleState(Consumer<AbstractState> consumer)
Convenience method to execute code if en entity hosts a single-state.- Parameters:
consumer- lambda that is supposed to be executed if the entity is a single state host.- Returns:
- an alternative to execute if the opposite turns out.
-
doIfMultiState
MdibEntity.StateAlternative<AbstractState> doIfMultiState(Consumer<List<AbstractMultiState>> consumer)
Convenience method to execute code if en entity hosts a multi-state.- Parameters:
consumer- lambda that is supposed to be executed if the entity is a multi-state host.- Returns:
- an alternative to execute if the opposite turns out.
-
getDescriptorClass
Class<? extends AbstractDescriptor> getDescriptorClass()
Gets the descriptor class.Short-hand for
getDescriptor().getClass().- Returns:
- the descriptor class of the entity.
-
getStateClass
Class<? extends AbstractState> getStateClass()
Gets the state class.- Returns:
- the state class of the entity.
-
-