Package org.somda.sdc.biceps.common
Class MdibEntityImpl
- java.lang.Object
-
- org.somda.sdc.biceps.common.MdibEntityImpl
-
- All Implemented Interfaces:
MdibEntity
public class MdibEntityImpl extends Object implements MdibEntity
Default implementation ofMdibEntity.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.somda.sdc.biceps.common.MdibEntity
MdibEntity.StateAlternative<T>
-
-
Method Summary
All Methods Instance Methods Concrete 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
public MdibVersion getLastChanged()
Description copied from interface:MdibEntityGets the MDIB version of the entity where it has been changed the last time.- Specified by:
getLastChangedin interfaceMdibEntity- Returns:
- an MDIB version.
-
getChildren
public List<String> getChildren()
Description copied from interface:MdibEntityObtain a read-only list of the MDIB entity's child handles.- Specified by:
getChildrenin interfaceMdibEntity- Returns:
- readable list of children currently associated with the entity.
-
getDescriptor
public AbstractDescriptor getDescriptor()
Description copied from interface:MdibEntityObtain the entity's descriptor.- Specified by:
getDescriptorin interfaceMdibEntity- Returns:
- descriptor information currently associated with the entity.
-
getDescriptor
public <T extends AbstractDescriptor> Optional<T> getDescriptor(Class<T> theClass)
Description copied from interface:MdibEntityObtains the entity's descriptor as a given type.- Specified by:
getDescriptorin interfaceMdibEntity- Type Parameters:
T- the descriptor class type.- Parameters:
theClass- the class to cast.- Returns:
- descriptor information currently associated with the entity.
-
getHandle
public String getHandle()
Description copied from interface:MdibEntityUnique name to identify the entity.Short-hand for
getDescriptor().getHandle()- Specified by:
getHandlein interfaceMdibEntity- Returns:
- the entity's unique handle.
-
getParent
public Optional<String> getParent()
Description copied from interface:MdibEntityObtains the entity's parent handle.- Specified by:
getParentin interfaceMdibEntity- Returns:
- the handle of the parent if known, otherwise Optional.empty().
-
getStates
public List<AbstractState> getStates()
Description copied from interface:MdibEntityObtains a copy of the MDIB entity's state list.- Specified by:
getStatesin interfaceMdibEntity- Returns:
- list of states currently associated with the entity.
-
getStates
public <T extends AbstractState> List<T> getStates(Class<T> theClass)
Description copied from interface:MdibEntityObtains the list of states cast to a specific type.- Specified by:
getStatesin interfaceMdibEntity- 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
public <T extends AbstractState> Optional<T> getFirstState(Class<T> theClass)
Description copied from interface:MdibEntityObtains the first state if available.This function is useful to retrieve single state information.
- Specified by:
getFirstStatein interfaceMdibEntity- 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
public MdibEntity.StateAlternative<List<AbstractMultiState>> doIfSingleState(Consumer<AbstractState> consumer)
Description copied from interface:MdibEntityConvenience method to execute code if en entity hosts a single-state.- Specified by:
doIfSingleStatein interfaceMdibEntity- 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
public MdibEntity.StateAlternative<AbstractState> doIfMultiState(Consumer<List<AbstractMultiState>> consumer)
Description copied from interface:MdibEntityConvenience method to execute code if en entity hosts a multi-state.- Specified by:
doIfMultiStatein interfaceMdibEntity- 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
public Class<? extends AbstractDescriptor> getDescriptorClass()
Description copied from interface:MdibEntityGets the descriptor class.Short-hand for
getDescriptor().getClass().- Specified by:
getDescriptorClassin interfaceMdibEntity- Returns:
- the descriptor class of the entity.
-
getStateClass
public Class<? extends AbstractState> getStateClass()
Description copied from interface:MdibEntityGets the state class.- Specified by:
getStateClassin interfaceMdibEntity- Returns:
- the state class of the entity.
-
-