Interface VariantManager

  • All Known Implementing Classes:
    VariantManagerImpl

    public interface VariantManager
    This class provides methods to manage variants of the network (create and remove a variant, set the working variant, etc).

    WARNING: Variant management is not thread safe and should never be done will an other thread read from or write to an already existing variant. The classical pattern for multi-variant processing is to pre-allocate variants and call allowVariantMultiThreadAccess(boolean) to allow multi-thread access on main thread, work on variants from other threads (be carefull to only write concurrently attributes flagged as dependent to variant in the Javadoc) and then remove variants from main thread once work is over.

    Author:
    Geoffroy Jamgotchian
    • Method Detail

      • getVariantIds

        Collection<String> getVariantIds()
        Get the variant id list.
        Returns:
        the variant id list
      • getWorkingVariantId

        String getWorkingVariantId()
        Get the working variant.
        Returns:
        the id of the working variant
      • setWorkingVariant

        void setWorkingVariant​(String variantId)
        Set the working variant.
        Parameters:
        variantId - the id of the working variant
        Throws:
        PowsyblException - if the variant is not found
      • cloneVariant

        void cloneVariant​(String sourceVariantId,
                          List<String> targetVariantIds)
        Create a new variant by cloning an existing one.
        Parameters:
        sourceVariantId - the source variant id
        targetVariantIds - the target variant id list (the ones that will be created)
        Throws:
        PowsyblException - if the source variant is not found or if a variant with an id of targetStateIds already exists
      • cloneVariant

        void cloneVariant​(String sourceVariantId,
                          List<String> targetVariantIds,
                          boolean mayOverwrite)
        Create or overwrite a variant by cloning an existing one.
        Parameters:
        sourceVariantId - the source variant id
        targetVariantIds - the target variant id list (the ones that will be created/overwritten)
        mayOverwrite - indicates if the target can be overwritten when it already exists
        Throws:
        PowsyblException - if a variant with an id of targetVariantIds already exists and the mayOverwrite parameter is set to false
      • cloneVariant

        void cloneVariant​(String sourceVariantId,
                          String targetVariantId)
        Create a new variant by cloning an existing one.
        Parameters:
        sourceVariantId - the source variant id
        targetVariantId - the target variant id (the one that will be created)
        Throws:
        PowsyblException - if the source variant is not found or if a variant with the id targetVariantId already exists
      • cloneVariant

        void cloneVariant​(String sourceVariantId,
                          String targetVariantId,
                          boolean mayOverwrite)
        Create or overwrite a variant by cloning an existing one.
        Parameters:
        sourceVariantId - the source variant id
        targetVariantId - the target variant id list (the one that will be created/overwritten)
        mayOverwrite - indicates if the target can be overwritten when it already exists
        Throws:
        PowsyblException - * if a variant with the id of targetVariantId already exists and * the mayOverwrite parameter is set to false
      • removeVariant

        void removeVariant​(String variantId)
        Remove a variant.
        Parameters:
        variantId - the id of the variant to remove
      • allowVariantMultiThreadAccess

        void allowVariantMultiThreadAccess​(boolean allow)
        Allows variants to be accessed simulaneously by different threads. When this options is activated, the working variant can have a different value for each thread.
        Parameters:
        allow -
      • isVariantMultiThreadAccessAllowed

        boolean isVariantMultiThreadAccessAllowed()
        Get the allowed multithread access state .
        Returns:
        a boolean to check if the variantManager is allowed to be accessed simulaneously by different threads.