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 RoutedServicesLayerImpldeepClone()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 longgenerateId(IdGroupingToken tokenId)Generate id for instances of this class based on the token and class identifierRoutedServicesLayerModifiergetLayerModifier()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 involvedServiceNetworkLayergetParentLayer()The parent layer of this routed services layerRoutedModeServicesgetServicesByMode(Mode mode)The services for a given mode available on this layer.booleanisEmpty()Check if the layer is empty of any routed servicesbooleanisServicesByModeEmpty(Mode mode)Verify if there exist no registered services for a given mode at all at presentIterator<RoutedModeServices>iterator()voidlogInfo(String prefix)invoked by entities inquiring about general information about the layer to display to userslongrecreateManagedIds(IdGroupingToken tokenId)recreate the internal id(s) and set them including the Idable idprotected RoutedModeServicesremoveServicesByMode(RoutedModeServices servicesByMode)Remove a given routed services by modeRoutedServicesLayerImplshallowClone()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:
recreateManagedIdsin 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:
getParentLayerin 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:
isServicesByModeEmptyin 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:
getServicesByModein 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:
getLayerModifierin interfaceRoutedServicesLayer- Returns:
- routed services layer modifier
-
iterator
public Iterator<RoutedModeServices> iterator()
- Specified by:
iteratorin interfaceIterable<RoutedModeServices>
-
logInfo
public void logInfo(String prefix)
invoked by entities inquiring about general information about the layer to display to users- Specified by:
logInfoin 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:
isEmptyin interfaceRoutedServicesLayer- Returns:
- true when empty, false otherwise
-
shallowClone
public RoutedServicesLayerImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClonein interfaceIdAble- Specified by:
shallowClonein interfaceRoutedServicesLayer- Overrides:
shallowClonein 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:
deepClonein interfaceIdAble- Specified by:
deepClonein interfaceRoutedServicesLayer- Overrides:
deepClonein classExternalIdAbleImpl- Returns:
- deep copy of entity
-
-