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>
infrastructureLayers
track 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 MacroscopicPhysicalNetwork
createNew()
Create a new infrastructure layer (without registering on this class).InfrastructureLayer
get(long id)
Find a entity by its idInfrastructureLayer
get(Mode mode)
Find the layer that supports the passed in mode.Iterator<InfrastructureLayer>
iterator()
return iterator over the available infrastructure layersInfrastructureLayer
register(InfrastructureLayer entity)
Add to the containerMacroscopicPhysicalNetwork
registerNew()
Create a new infrastructure layer and registering on this class.InfrastructureLayer
remove(long id)
Remove by idInfrastructureLayer
remove(InfrastructureLayer entity)
Removeint
size()
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:
remove
in interfaceInfrastructureLayers
- Parameters:
entity
- to remove- Returns:
- removed instance (if any), otherwise null
-
remove
public InfrastructureLayer remove(long id)
Remove by id- Specified by:
remove
in 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:
createNew
in interfaceInfrastructureLayers
- Returns:
- created infrastructure layer
-
iterator
public Iterator<InfrastructureLayer> iterator()
return iterator over the available infrastructure layers- Specified by:
iterator
in interfaceIterable<InfrastructureLayer>
-
register
public InfrastructureLayer register(InfrastructureLayer entity)
Add to the container- Specified by:
register
in 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:
registerNew
in interfaceInfrastructureLayers
- Returns:
- created infrastructure layer
-
size
public int size()
Return number of registered entity- Specified by:
size
in interfaceInfrastructureLayers
- Returns:
- number of registered entity
-
get
public InfrastructureLayer get(long id)
Find a entity by its id- Specified by:
get
in 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:
get
in interfaceInfrastructureLayers
- Parameters:
mode
- to find the layer for- Returns:
- first matching layer
-
-