Package org.planit.network
Class InfraStructureLayersImpl
- java.lang.Object
-
- org.planit.network.InfraStructureLayersImpl
-
- All Implemented Interfaces:
Iterable<InfrastructureLayer>,InfrastructureLayers
public class InfraStructureLayersImpl extends Object implements InfrastructureLayers
Base implementation of the InfrastructureLayers interface- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Long,InfrastructureLayer>infrastructureLayerstrack the registered infrastructure layers
-
Constructor Summary
Constructors Constructor Description InfraStructureLayersImpl(IdGroupingToken groupingId)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MacroscopicPhysicalNetworkcreateNew()Create a new infrastructure layer (without registering on this class).InfrastructureLayerget(long id)Find a entity by its idInfrastructureLayerget(Mode mode)Find the layer that supports the passed in mode.Iterator<InfrastructureLayer>iterator()return iterator over the available infrastructure layersInfrastructureLayerregister(InfrastructureLayer entity)Add to the containerMacroscopicPhysicalNetworkregisterNew()Create a new infrastructure layer and registering on this class.InfrastructureLayerremove(long id)Remove by idInfrastructureLayerremove(InfrastructureLayer entity)Removeintsize()Return number of registered entity-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.network.InfrastructureLayers
getFirst, isEachLayerEmpty, isNoLayers
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
infrastructureLayers
protected final Map<Long,InfrastructureLayer> infrastructureLayers
track the registered infrastructure layers
-
-
Constructor Detail
-
InfraStructureLayersImpl
public InfraStructureLayersImpl(IdGroupingToken groupingId)
Constructor- Parameters:
groupingId- to generated id's for infrastructure layers
-
-
Method Detail
-
remove
public InfrastructureLayer remove(InfrastructureLayer entity)
Remove- Specified by:
removein interfaceInfrastructureLayers- Parameters:
entity- to remove- Returns:
- removed instance (if any), otherwise null
-
remove
public InfrastructureLayer remove(long id)
Remove by id- Specified by:
removein interfaceInfrastructureLayers- Parameters:
id- to remove entity for- Returns:
- removed instance (if any), otherwise null
-
createNew
public MacroscopicPhysicalNetwork createNew()
Create a new infrastructure layer (without registering on this class). Currently we only support macroscopic infrastructure layers so the returned type is the derived classMacroscopicPhysicalNetwork. In future versions the user can choose which type is to be created- Specified by:
createNewin interfaceInfrastructureLayers- Returns:
- created infrastructure layer
-
iterator
public Iterator<InfrastructureLayer> iterator()
return iterator over the available infrastructure layers- Specified by:
iteratorin interfaceIterable<InfrastructureLayer>
-
register
public InfrastructureLayer register(InfrastructureLayer entity)
Add to the container- Specified by:
registerin interfaceInfrastructureLayers- Parameters:
entity- to be registered in this network- Returns:
- entity, in case it overrides an existing entry, the removed entry is returned
-
registerNew
public MacroscopicPhysicalNetwork registerNew()
Create a new infrastructure layer and registering on this class. Currently we only support macroscopic infrastructure layers so the returned type is the derived classMacroscopicPhysicalNetwork. In future versions the user can choose which type is to be created- Specified by:
registerNewin interfaceInfrastructureLayers- Returns:
- created infrastructure layer
-
size
public int size()
Return number of registered entity- Specified by:
sizein interfaceInfrastructureLayers- Returns:
- number of registered entity
-
get
public InfrastructureLayer get(long id)
Find a entity by its id- Specified by:
getin interfaceInfrastructureLayers- Parameters:
id- Id of entity- Returns:
- retrieved entity
-
get
public InfrastructureLayer get(Mode mode)
Find the layer that supports the passed in mode. Since a mode is only allowed to be supported by a single layer, this should yield the correct result. If multiple layers support the same mode for some reason, this method returns the first layer that supports the mode- Specified by:
getin interfaceInfrastructureLayers- Parameters:
mode- to find the layer for- Returns:
- first matching layer
-
-