Package org.goplanit.component
Class PlanitComponent<T extends PlanitComponent<T> & Serializable>
- java.lang.Object
-
- org.goplanit.component.PlanitComponent<T>
-
- All Implemented Interfaces:
Cloneable,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 protectedPlanitComponent(PlanitComponent<T> other)Copy constructorprotectedPlanitComponent(IdGroupingToken tokenId, Class<?> classType)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract PlanitComponent<T>clone()Create a shallow copy of this entitybooleanequals(Object obj)StringgetComponentType()Collect the component type of this instanceStringgetExternalId()get external id of the entitylonggetId()Collect id of the entityIdGroupingTokengetIdGroupingToken()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.StringgetXmlId()the id exposed to users as the "normal" id in the PLANit native xml formatinthashCode()voidonPlanitComponentEvent(PlanitComponentEvent event)Act upon the provided event.abstract voidreset()All components should be able to reset going back to some representative initial statevoidsetExternalId(String externalId)set the external idvoidsetXmlId(String xmlId)set the external id-
Methods inherited from class java.lang.Object
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
hasExternalId, hasXmlId
-
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)
Copy constructor- Parameters:
other- , to copy
-
-
Method Detail
-
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:
getKnownSupportedEventTypesin 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:
getExternalIdin interfaceExternalIdAble- Returns:
- external id
-
setExternalId
public void setExternalId(String externalId)
set the external id- Specified by:
setExternalIdin 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:
getXmlIdin interfaceExternalIdAble- Returns:
- xmlId
-
setXmlId
public void setXmlId(String xmlId)
set the external id- Specified by:
setXmlIdin interfaceExternalIdAble- Parameters:
xmlId- to set
-
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
-
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:
onPlanitComponentEventin interfacePlanitComponentListener- Parameters:
event- the component is registered for- Throws:
PlanItException- thrown if error during processing of event
-
clone
public abstract PlanitComponent<T> clone()
Create a shallow copy of this entity
-
reset
public abstract void reset()
All components should be able to reset going back to some representative initial state
-
-