Interface IModelComparator
-
- All Known Implementing Classes:
EMFModelComparator
,IgnoreCaseComparator
public interface IModelComparator
Interface for a model comparator. They compare entire models and return a set of relevant differences, if any exist. Comparators may only be able to compare certain models, based on various criteria.
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_POINT_ID
static String
OPTION_MODEL_CLONE_DIRECTORY
Ifconfigure(Map)
is called with this key set to a File or a String, the model clones needed by the comparator should be created in that directory.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canCompare(IModel expectedModel, IModel obtainedModel)
Checks if the comparator can compare these two models.Object
compare(IModel expectedModel, IModel obtainedModel)
Returns an object with the differences between this model andotherModel
.void
configure(Map<String,Object> options)
Configures the model comparator with the specified options.default File
saveDeltaToFile(Object delta, File basename)
Saves the provided delta (as produced bycompare(IModel, IModel)
to a file with the provided basename.
-
-
-
Field Detail
-
OPTION_MODEL_CLONE_DIRECTORY
static final String OPTION_MODEL_CLONE_DIRECTORY
Ifconfigure(Map)
is called with this key set to a File or a String, the model clones needed by the comparator should be created in that directory.- See Also:
- Constant Field Values
-
EXTENSION_POINT_ID
static final String EXTENSION_POINT_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
canCompare
boolean canCompare(IModel expectedModel, IModel obtainedModel)
Checks if the comparator can compare these two models.- Returns:
true
ifcompare(IModel, IModel)
should finish successfully, and false otherwise.
-
compare
Object compare(IModel expectedModel, IModel obtainedModel) throws Exception
Returns an object with the differences between this model andotherModel
. If there are no differences, returnsnull
. The exact configuration of the comparison depends on the model. For instance, unique identifiers (such as XMI IDs) may be ignored if the main object of these comparisons is to test model transformations. These tend to produce different unique identifiers each time they are run.- Throws:
IllegalArgumentException
- The models cannot be compared: for instance, they use incompatible drivers.Exception
- There was some other kind of problem when performing the comparison.
-
configure
void configure(Map<String,Object> options)
Configures the model comparator with the specified options. At least theOPTION_MODEL_CLONE_DIRECTORY
option should be honored, if models are being frozen into clones before performing the comparison.- Throws:
IllegalArgumentException
- One of the options has an invalid value is or not available.
-
saveDeltaToFile
default File saveDeltaToFile(Object delta, File basename) throws IOException
Saves the provided delta (as produced bycompare(IModel, IModel)
to a file with the provided basename. The actual extension will be picked by this component.- Parameters:
delta
- Detected model difference (e.g. a Comparison when using EMF Compare).basename
- File with the desired basename (extension to be picked by comparator).- Returns:
- File where the delta has been saved, after adding the extension.
- Throws:
IOException
- There was a problem writing to the file.
-
-