Package org.planit.trafficassignment
Class TrafficAssignmentComponentFactory<T extends TrafficAssignmentComponent<T> & Serializable>
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.planit.trafficassignment.TrafficAssignmentComponentFactory<T>
-
- Type Parameters:
T
- generic type of a type traffic assignment component for which we construct the eligible derived classes by class name
- All Implemented Interfaces:
Serializable
,org.djutils.event.EventProducerInterface
public class TrafficAssignmentComponentFactory<T extends TrafficAssignmentComponent<T> & Serializable> extends org.djutils.event.EventProducer implements Serializable
Generic factory class for registered subclasses of predefined traffic assignment components, so it does not create instances of T but of sublcasses of T.- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<T>
componentSuperType
instance of the super component class this factory creates subclass instances forprotected static HashMap<Class<? extends TrafficAssignmentComponent<?>>,TreeSet<String>>
registeredTrafficAssignmentComponents
Register per traffic assignment component type the derived classes that are supportedstatic org.djutils.event.EventType
TRAFFICCOMPONENT_CREATE
event type fired off when a new traffic assignment component is created
-
Constructor Summary
Constructors Constructor Description TrafficAssignmentComponentFactory(Class<T> componentSuperType)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
create(String trafficAssignmentComponentClassName, Object[] constructorParameters)
Create traffic assignment componentT
create(String trafficAssignmentComponentClassName, Object[] constructorParameters, Object... eventParameters)
Create traffic assignment componentSerializable
getSourceId()
sourceId provides information of the source of an event fired from this class instancestatic void
registerTrafficAssignmentComponentType(Class<? extends TrafficAssignmentComponent<?>> trafficAssignmentComponent)
Register a component type that one can choose for the given traffic component-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Field Detail
-
TRAFFICCOMPONENT_CREATE
public static final org.djutils.event.EventType TRAFFICCOMPONENT_CREATE
event type fired off when a new traffic assignment component is created
-
componentSuperType
protected final Class<T extends TrafficAssignmentComponent<T> & Serializable> componentSuperType
instance of the super component class this factory creates subclass instances for
-
registeredTrafficAssignmentComponents
protected static final HashMap<Class<? extends TrafficAssignmentComponent<?>>,TreeSet<String>> registeredTrafficAssignmentComponents
Register per traffic assignment component type the derived classes that are supported
-
-
Method Detail
-
registerTrafficAssignmentComponentType
public static void registerTrafficAssignmentComponentType(Class<? extends TrafficAssignmentComponent<?>> trafficAssignmentComponent) throws PlanItException
Register a component type that one can choose for the given traffic component- Parameters:
trafficAssignmentComponent
- TrafficAssignmentComponent to be registered- Throws:
PlanItException
- thrown if there is an error
-
create
public T create(String trafficAssignmentComponentClassName, Object[] constructorParameters) throws PlanItException
Create traffic assignment component- Parameters:
trafficAssignmentComponentClassName
- the derived class name of the traffic assignment component (without packages)constructorParameters
- parameters to pass to the constructor- Returns:
- the created TrafficAssignmentComponent
- Throws:
PlanItException
- thrown if there is an error
-
create
public T create(String trafficAssignmentComponentClassName, Object[] constructorParameters, Object... eventParameters) throws PlanItException
Create traffic assignment component- Parameters:
trafficAssignmentComponentClassName
- the derived class name of the traffic assignment component (without packages)constructorParameters
- parameters to pass to the constructoreventParameters
- object array which contains any data required to create the component- Returns:
- the created TrafficAssignmentComponent
- Throws:
PlanItException
- thrown if there is an error
-
getSourceId
public Serializable getSourceId()
sourceId provides information of the source of an event fired from this class instance- Specified by:
getSourceId
in interfaceorg.djutils.event.EventProducerInterface
- Specified by:
getSourceId
in classorg.djutils.event.EventProducer
- Returns:
- this class instance
-
-