Class BaseReaderImpl<T>

    • Field Detail

      • sourceIdTrackerMap

        protected final Map<Class<?>,​MapWrapper<?,​?>> sourceIdTrackerMap
        track PLANit entities by something else than their internal id via this map
    • Constructor Detail

      • BaseReaderImpl

        protected BaseReaderImpl()
        Constructor
    • Method Detail

      • registerBySourceId

        protected <V> void registerBySourceId​(V obj)
                                       throws PlanItException
        Stores an object by its source Id, after checking whether the external Id is a duplicate
        Type Parameters:
        V - type of object being stored
        Parameters:
        obj - object being stored by its class signature, assuming ithat is the identifier it is registered under
        Throws:
        PlanItException - thrown if error
      • registerBySourceId

        protected <U,​V> void registerBySourceId​(Class<U> theClazz,
                                                      V obj)
                                               throws PlanItException
        Stores an object by its source Id, after checking whether the external Id is a duplicate
        Type Parameters:
        U - type of object being stored
        V - value to store
        Parameters:
        theClazz - class to identify the correct container
        obj - object being stored
        Throws:
        PlanItException - thrown if duplicate or not possible to register due to lack of initialised container
      • initialiseSourceIdMap

        protected <K,​V> void initialiseSourceIdMap​(Class<V> clazz,
                                                         Function<V,​K> valueToKey)
        register a new source id tracker (empty) where a function is used to extract the source id from the entity and the class is used unique identifier for the underlying tracking container
        Type Parameters:
        K - key type used
        V - value type used
        Parameters:
        clazz - identifier in container of containers
        valueToKey - function mapping value to key
      • initialiseSourceIdMap

        protected <K,​V> void initialiseSourceIdMap​(Class<V> clazz,
                                                         Function<V,​K> valueToKey,
                                                         Iterable<V> addToSourceIdMap)
        register a new source id tracker (empty) where a function is used to extract the source id from the entity and the class is used unique identifier for the underlying tracking container
        Type Parameters:
        K - key type used
        V - value type used
        Parameters:
        clazz - identifier in container of containers
        valueToKey - function mapping value to key
        addToSourceIdMap - add all entities in iterable to the newly created source id map upon creation
      • getSourceIdContainer

        protected <V> MapWrapper<?,​V> getSourceIdContainer​(Class<V> clazz)
        access to the container with sourceIds
        Type Parameters:
        V - value of the container
        Parameters:
        clazz - to collect container for
        Returns:
        the source id map wrapper, null if not present
      • getBySourceId

        protected <V,​K> V getBySourceId​(Class<V> clazz,
                                              K key)
        Get an entry by its source id
        Type Parameters:
        V - return type
        K - key to find it by
        Parameters:
        clazz - class identifier for selecting the correct container tracker
        key - the actual key to use
        Returns:
        value found, null if not present