Package org.goplanit.component
Class PlanitComponent<T extends PlanitComponent<T> & Serializable>
- java.lang.Object
-
- org.goplanit.component.PlanitComponent<T>
-
- All Implemented Interfaces:
Comparable<IdAble>
,EventListener
,PlanitComponentListener
,EventListener
,ExternalIdAble
,IdAble
- Direct Known Subclasses:
AbstractPhysicalCost
,AbstractVirtualCost
,Demands
,FundamentalDiagramComponent
,GapFunction
,InitialPhysicalCost
,LogitChoiceModel
,Network
,NetworkLoading
,NodeModelComponent
,OdPathSets
,PathChoice
,RoutedServices
,Smoothing
,Zoning
public abstract class PlanitComponent<T extends PlanitComponent<T> & Serializable> extends Object implements ExternalIdAble, PlanitComponentListener
PLANit components are the main building blocks to create PLANit applications with.Each component is also a listener for PlanitComponentEvents, upon creation by the component factory each component is automatically registered for these events (at high priority). This allows each component to initialise itself in a flexible way before any user or builder would make changes to its default configuration via the same or other events. It is not mandatory to implement any actions upon receiving such events. Therefore this base class implements an empty notify method which may be overridden by derived implementations if desired.
- Author:
- markr
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PlanitComponent(PlanitComponent<T> other, boolean deepCopy)
Copy constructorprotected
PlanitComponent(IdGroupingToken tokenId, Class<?> classType)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Map<String,String>
collectSettingsAsKeyValueMap()
Provide all the settings of this particular component by name and value, where each value is a string representation of the underlying entityabstract PlanitComponent<T>
deepClone()
deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possibleboolean
equals(Object obj)
String
getComponentType()
Collect the component type of this instanceString
getExternalId()
get external id of the entitylong
getId()
Collect id of the entityIdGroupingToken
getIdGroupingToken()
Collect the id grouping token used to generate ids for entities of this class.PlanitComponentEventType[]
getKnownSupportedEventTypes()
Each component may override this default which indicates it does not support any events, meaning that the component is not notified on any planitcomponent events.String
getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml formatint
hashCode()
void
onPlanitComponentEvent(PlanitComponentEvent event)
Act upon the provided event.abstract void
reset()
All components should be able to reset going back to some representative initial statevoid
setExternalId(String externalId)
set the external idvoid
setXmlId(String xmlId)
set the external idabstract PlanitComponent<T>
shallowClone()
Create a shallow copy of this entity-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.event.EventListener
hasKnownSupportedEventTypes
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, hasExternalId, hasXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, idEquals, idHashCode
-
-
-
-
Constructor Detail
-
PlanitComponent
protected PlanitComponent(IdGroupingToken tokenId, Class<?> classType)
Constructor- Parameters:
tokenId
- , contiguous id generation using this same token for instances of this classclassType
- , the class type this instance belongs to and we are generating an id for
-
PlanitComponent
protected PlanitComponent(PlanitComponent<T> other, boolean deepCopy)
Copy constructor- Parameters:
other
- , to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
shallowClone
public abstract PlanitComponent<T> shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Returns:
- shallow copy of entity
-
deepClone
public abstract PlanitComponent<T> deepClone()
deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possible
-
reset
public abstract void reset()
All components should be able to reset going back to some representative initial state
-
getKnownSupportedEventTypes
public PlanitComponentEventType[] getKnownSupportedEventTypes()
Each component may override this default which indicates it does not support any events, meaning that the component is not notified on any planitcomponent events. Derived classes may override to register for specific events if needed- Specified by:
getKnownSupportedEventTypes
in interfaceEventListener
- Returns:
- default supported event types (none)
-
getId
public long getId()
Collect id of the entity
-
getExternalId
public String getExternalId()
get external id of the entity- Specified by:
getExternalId
in interfaceExternalIdAble
- Returns:
- external id
-
setExternalId
public void setExternalId(String externalId)
set the external id- Specified by:
setExternalId
in interfaceExternalIdAble
- Parameters:
externalId
- to set
-
getXmlId
public String getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml format- Specified by:
getXmlId
in interfaceExternalIdAble
- Returns:
- xmlId
-
setXmlId
public void setXmlId(String xmlId)
set the external id- Specified by:
setXmlId
in interfaceExternalIdAble
- Parameters:
xmlId
- to set
-
onPlanitComponentEvent
public void onPlanitComponentEvent(PlanitComponentEvent event) throws PlanItException
Act upon the provided event. In this base class an empty implementation is provided indicating that it is not madnatory to act upon these events.- Specified by:
onPlanitComponentEvent
in interfacePlanitComponentListener
- Parameters:
event
- the component is registered for- Throws:
PlanItException
- thrown if error during processing of event
-
collectSettingsAsKeyValueMap
public abstract Map<String,String> collectSettingsAsKeyValueMap()
Provide all the settings of this particular component by name and value, where each value is a string representation of the underlying entity- Returns:
- name-value map of all (user configurable) settings
-
getComponentType
public String getComponentType()
Collect the component type of this instance- Returns:
- PLANit component type
-
getIdGroupingToken
public IdGroupingToken getIdGroupingToken()
Collect the id grouping token used to generate ids for entities of this class.- Returns:
- id grouping token
-
-