Package org.goplanit.service.routed
Class RoutedServicesLayerImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.service.routed.RoutedServicesLayerImpl
-
- All Implemented Interfaces:
Comparable<IdAble>
,Iterable<RoutedModeServices>
,ExternalIdAble
,IdAble
,ManagedId
,RoutedServicesLayer
public class RoutedServicesLayerImpl extends ExternalIdAbleImpl implements RoutedServicesLayer
Implementation of the RoutedServicesLayer interface- Author:
- markr
-
-
Field Summary
-
Fields inherited from interface org.goplanit.utils.service.routed.RoutedServicesLayer
ROUTED_SERVICES_LAYER_ID_CLASS
-
-
Constructor Summary
Constructors Constructor Description RoutedServicesLayerImpl(RoutedServicesLayerImpl other, boolean deepCopy, ManagedIdDeepCopyMapper<RoutedService> routedServiceMapper)
Copy constructorRoutedServicesLayerImpl(IdGroupingToken tokenId, ServiceNetworkLayer parentLayer)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RoutedServicesLayerImpl
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.protected static long
generateId(IdGroupingToken tokenId)
Generate id for instances of this class based on the token and class identifierRoutedServicesLayerModifier
getLayerModifier()
Routed services have an additional modifier options to provided integrated utilities for changing the routed services in a way that updates all attached managed routed and service network elements involvedServiceNetworkLayer
getParentLayer()
The parent layer of this routed services layerRoutedModeServices
getServicesByMode(Mode mode)
The services for a given mode available on this layer.boolean
isEmpty()
Check if the layer is empty of any routed servicesboolean
isServicesByModeEmpty(Mode mode)
Verify if there exist no registered services for a given mode at all at presentIterator<RoutedModeServices>
iterator()
void
logInfo(String prefix)
invoked by entities inquiring about general information about the layer to display to userslong
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idprotected RoutedModeServices
removeServicesByMode(RoutedModeServices servicesByMode)
Remove a given routed services by modeRoutedServicesLayerImpl
shallowClone()
Create a shallow copy of this entity-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.goplanit.utils.service.routed.RoutedServicesLayer
getIdClass, getSupportedModes, getSupportedModesWithServices, resetChildManagedIdEntities
-
-
-
-
Constructor Detail
-
RoutedServicesLayerImpl
public RoutedServicesLayerImpl(IdGroupingToken tokenId, ServiceNetworkLayer parentLayer)
Constructor- Parameters:
tokenId
- to use for id generationparentLayer
- the parent layer these routed services are built upon
-
RoutedServicesLayerImpl
public RoutedServicesLayerImpl(RoutedServicesLayerImpl other, boolean deepCopy, ManagedIdDeepCopyMapper<RoutedService> routedServiceMapper)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwiseroutedServiceMapper
- to use for tracking mapping between original and copied entity (may be null)
-
-
Method Detail
-
generateId
protected static long generateId(IdGroupingToken tokenId)
Generate id for instances of this class based on the token and class identifier- Parameters:
tokenId
- to use- Returns:
- generated id
-
removeServicesByMode
protected RoutedModeServices removeServicesByMode(RoutedModeServices servicesByMode)
Remove a given routed services by mode- Parameters:
servicesByMode
- to remove- Returns:
- removed entry (if any)
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIds
in interfaceManagedId
- Parameters:
tokenId
- to use (may be null in case managed id entity does not rely on token to recreate its managed id(s))- Returns:
- the updated internal id
-
getParentLayer
public final ServiceNetworkLayer getParentLayer()
The parent layer of this routed services layer- Specified by:
getParentLayer
in interfaceRoutedServicesLayer
- Returns:
- parent layer
-
isServicesByModeEmpty
public boolean isServicesByModeEmpty(Mode mode)
Verify if there exist no registered services for a given mode at all at present- Specified by:
isServicesByModeEmpty
in interfaceRoutedServicesLayer
- Parameters:
mode
- to check- Returns:
- true when no single routed service by mode exists, false otherwise
-
getServicesByMode
public RoutedModeServices getServicesByMode(Mode mode)
The services for a given mode available on this layer. If no services are yet available an empty instance is created and registered. It is expected that each routed service across all modes on the layer has a unique internal id, so internal ids do not restart at zero per mode- Specified by:
getServicesByMode
in interfaceRoutedServicesLayer
- Parameters:
mode
- to obtain services for- Returns:
- services by mode, empty instance if none have been registered yet
-
getLayerModifier
public RoutedServicesLayerModifier getLayerModifier()
Routed services have an additional modifier options to provided integrated utilities for changing the routed services in a way that updates all attached managed routed and service network elements involved- Specified by:
getLayerModifier
in interfaceRoutedServicesLayer
- Returns:
- routed services layer modifier
-
iterator
public Iterator<RoutedModeServices> iterator()
- Specified by:
iterator
in interfaceIterable<RoutedModeServices>
-
logInfo
public void logInfo(String prefix)
invoked by entities inquiring about general information about the layer to display to users- Specified by:
logInfo
in interfaceRoutedServicesLayer
- Parameters:
prefix
- optional prefix to include in each line of logging
-
isEmpty
public boolean isEmpty()
Check if the layer is empty of any routed services- Specified by:
isEmpty
in interfaceRoutedServicesLayer
- Returns:
- true when empty, false otherwise
-
shallowClone
public RoutedServicesLayerImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceRoutedServicesLayer
- Overrides:
shallowClone
in classExternalIdAbleImpl
- Returns:
- shallow copy of entity
-
deepClone
public RoutedServicesLayerImpl deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceRoutedServicesLayer
- Overrides:
deepClone
in classExternalIdAbleImpl
- Returns:
- deep copy of entity
-
-