Class ModelImport<M extends IModel>

  • Type Parameters:
    M - the specific type of model
    Direct Known Subclasses:
    ProjectImport

    public class ModelImport<M extends IModel>
    extends java.lang.Object
    Defines model imports and related restrictions.
    Author:
    Holger Eichelberger
    • Field Detail

      • WILDCARD_POSTFIX

        public static final java.lang.String WILDCARD_POSTFIX
        See Also:
        Constant Field Values
      • resolved

        private M extends IModel resolved
      • name

        private java.lang.String name
      • isConflict

        private boolean isConflict
      • isInsert

        private boolean isInsert
    • Constructor Detail

      • ModelImport

        ModelImport()
        Constructor for serialization.
      • ModelImport

        public ModelImport​(java.lang.String name)
        Creates an unrestricted (non-inserting) model import.
        Parameters:
        name - The name of the project to be imported, becomes a wildcard import if name ends with WILDCARD_POSTFIX
      • ModelImport

        public ModelImport​(java.lang.String name,
                           boolean isConflict,
                           IVersionRestriction restriction)
        Creates a (non-inserting) model import instance.
        Parameters:
        name - the name of the model to be import, becomes a wildcard import if name ends with WILDCARD_POSTFIX
        isConflict - does this object represent a conflict or an import
        restriction - the version restriction (or null if absent)
      • ModelImport

        public ModelImport​(java.lang.String name,
                           boolean isConflict,
                           IVersionRestriction restriction,
                           boolean isInsert)
        Creates a model import instance.
        Parameters:
        name - the name of the model to be import, becomes a wildcard import if name ends with WILDCARD_POSTFIX
        isConflict - does this object represent a conflict or an import
        restriction - the version restriction (or null if absent)
        isInsert - whether model elements of the resolved model shall be (virtually) insert at the end of the importing model
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of the model to be imported.
        Returns:
        Name of the import
      • isConflict

        public boolean isConflict()
        Does this object represent an import or a conflict.
        Returns:
        true in case of a conflict, false in case of an import
      • setRestrictions

        public void setRestrictions​(IVersionRestriction restriction)
        Setter for setting the version restrictions.
        Parameters:
        restriction - the version restriction to this import or null if absent.
      • getResolved

        public M getResolved()
        Returns the resolved model instance.
        Returns:
        the resolved instance
      • isResolved

        public boolean isResolved()
        Returns whether the related model was already resolved.
        Returns:
        true if it was resolved, false else
      • isWildcard

        public boolean isWildcard()
        Returns whether the import targets multiple models to be imported.
        Returns:
        true in case of a wildcard import, false else
      • isWildcard

        public static boolean isWildcard​(java.lang.String name)
        Returns whether the given name targets multiple models to be imported.
        Parameters:
        name - the name of the model(s) to be imported
        Returns:
        true in case of a wildcard import, false else
      • isInsert

        public boolean isInsert()
        Returns whether the import aims at inserting elements at the end of the importing model.
        Returns:
        true in case of an inserting import, false else
      • setResolved

        public void setResolved​(M resolved)
                         throws ModelManagementException
        Defines the resolved model instance.
        Parameters:
        resolved - the resolved instance or null
        Throws:
        ModelManagementException - in case of violated model access restrictions
      • evaluateRestrictions

        public boolean evaluateRestrictions​(IRestrictionEvaluationContext context,
                                            Version version)
                                     throws RestrictionEvaluationException
        Evaluates the restrictions against version.
        Parameters:
        context - the output context (interpreted by the respective implementation, e.g., an output visitor in order to continue with the actual indentation, may be null but then false will always be the result)
        version - the version to evaluate against
        Returns:
        true if the restrictions are fulfilled (also if none restrictions were given), false if the restrictions were not fulfilled
        Throws:
        RestrictionEvaluationException - in case of evaluation problems
      • getVersionRestriction

        public IVersionRestriction getVersionRestriction()
        Returns the version restriction.
        Returns:
        the version restriction (may be null)
      • copyVersionRestriction

        public IVersionRestriction copyVersionRestriction​(M model)
                                                   throws RestrictionEvaluationException
        Copies the version restriction.
        Parameters:
        model - the model to instantiate the copied version restriction for
        Returns:
        the copied version restriction or null if no restriction was specified before
        Throws:
        RestrictionEvaluationException - in case of type/structural problems
      • copy

        public ModelImport<M> copy​(java.lang.String modelName)
        Creates a copy of this import.
        Parameters:
        modelName - a new model name, may be null for the original
        Returns:
        the copied instance