Class TrafficAssignmentComponentFactory<T extends TrafficAssignmentComponent<T> & Serializable>

  • 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 Detail

      • TRAFFICCOMPONENT_CREATE

        public static final org.djutils.event.EventType TRAFFICCOMPONENT_CREATE
        event type fired off when a new traffic assignment component is created
      • registeredTrafficAssignmentComponents

        protected static final HashMap<Class<? extends TrafficAssignmentComponent<?>>,​TreeSet<String>> registeredTrafficAssignmentComponents
        Register per traffic assignment component type the derived classes that are supported
    • Constructor Detail

      • TrafficAssignmentComponentFactory

        public TrafficAssignmentComponentFactory​(Class<T> componentSuperType)
        Constructor
        Parameters:
        componentSuperType - super type for this factory
    • 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 constructor
        eventParameters - 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 interface org.djutils.event.EventProducerInterface
        Specified by:
        getSourceId in class org.djutils.event.EventProducer
        Returns:
        this class instance