Class ModelImport<M extends IModel>
- java.lang.Object
-
- net.ssehub.easy.basics.modelManagement.ModelImport<M>
-
- Type Parameters:
M- the specific type of model
- Direct Known Subclasses:
ProjectImport
public class ModelImport<M extends IModel> extends java.lang.ObjectDefines model imports and related restrictions.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleanisConflictprivate booleanisInsertprivate java.lang.Stringnameprivate Mresolvedprivate IVersionRestrictionrestrictionstatic java.lang.StringWILDCARD_POSTFIX
-
Constructor Summary
Constructors Constructor Description ModelImport()Constructor for serialization.ModelImport(java.lang.String name)Creates an unrestricted (non-inserting) model import.ModelImport(java.lang.String name, boolean isConflict, IVersionRestriction restriction)Creates a (non-inserting) model import instance.ModelImport(java.lang.String name, boolean isConflict, IVersionRestriction restriction, boolean isInsert)Creates a model import instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelImport<M>copy(java.lang.String modelName)Creates a copy of this import.IVersionRestrictioncopyVersionRestriction(M model)Copies the version restriction.booleanevaluateRestrictions(IRestrictionEvaluationContext context, Version version)Evaluates the restrictions againstversion.java.lang.StringgetName()Returns the name of the model to be imported.MgetResolved()Returns the resolved model instance.IVersionRestrictiongetVersionRestriction()Returns the version restriction.booleanisConflict()Does this object represent an import or a conflict.booleanisInsert()Returns whether the import aims at inserting elements at the end of the importing model.booleanisResolved()Returns whether the related model was already resolved.booleanisWildcard()Returns whether the import targets multiple models to be imported.static booleanisWildcard(java.lang.String name)Returns whether the given name targets multiple models to be imported.voidsetResolved(M resolved)Defines the resolved model instance.voidsetRestrictions(IVersionRestriction restriction)Setter for setting the version restrictions.
-
-
-
Field Detail
-
WILDCARD_POSTFIX
public static final java.lang.String WILDCARD_POSTFIX
- See Also:
- Constant Field Values
-
name
private java.lang.String name
-
restriction
private IVersionRestriction restriction
-
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 ifnameends withWILDCARD_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 ifnameends withWILDCARD_POSTFIXisConflict- does this object represent a conflict or an importrestriction- 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 ifnameends withWILDCARD_POSTFIXisConflict- does this object represent a conflict or an importrestriction- 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:
truein case of a conflict,falsein case of an import
-
setRestrictions
public void setRestrictions(IVersionRestriction restriction)
Setter for setting the version restrictions.- Parameters:
restriction- the version restriction to this import ornullif 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:
trueif it was resolved,falseelse
-
isWildcard
public boolean isWildcard()
Returns whether the import targets multiple models to be imported.- Returns:
truein case of a wildcard import,falseelse
-
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:
truein case of a wildcard import,falseelse
-
isInsert
public boolean isInsert()
Returns whether the import aims at inserting elements at the end of the importing model.- Returns:
truein case of an inserting import,falseelse
-
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 againstversion.- 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:
trueif the restrictions are fulfilled (also if none restrictions were given),falseif 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
-
-