Add check for injective
Signed-off-by: xul <Xul@students.uni-marburg.de>
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/matching/constraints/DomainSlot.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/matching/constraints/DomainSlot.java
index c59b3af..3746d34 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/matching/constraints/DomainSlot.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/matching/constraints/DomainSlot.java
@@ -15,6 +15,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
@@ -147,9 +148,9 @@
return false;
}
- if (!setValueAndLock()) {
- return false;
- }
+ //if (!setValueAndLock()) {
+ // return false;
+ //}
// Check the variable?
if (!checkedVariables.contains(variable)) {
@@ -158,6 +159,13 @@
return false;
}
+ //Check injective
+ if(injective)
+ {
+ if(!checkInjective(variable, domainMap))
+ return false;
+ }
+
// Check the dangling constraints:
if (dangling) {
for (DanglingConstraint danglingConstraint : variable.danglingConstraints) {
@@ -213,6 +221,34 @@
return true;
}
+
+ /**Check if matching of variables violates injective
+ * @param variable
+ * @param domainMap
+ */
+ private Boolean checkInjective(Variable variable, Map<Variable, DomainSlot> domainMap) {
+
+ if(variable.name.isEmpty())
+ return true;
+
+ for (Entry<Variable, DomainSlot> entry : domainMap.entrySet()) {
+ Variable checkDoaminVariable = entry.getKey();
+ DomainSlot checkDomainSlot = entry.getValue();
+ // If different variables have the same name
+ if (checkDoaminVariable.name.equals(variable.name) && variable != checkDoaminVariable)
+ // And the variables correspond to the same type
+ if (checkDoaminVariable.typeConstraint.type == variable.typeConstraint.type) {
+ // Compare whether their corresponding maps are consistent
+ if (checkDomainSlot.initialized) {
+ if (checkDomainSlot.value != domainMap.get(variable).value) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
/**
* Removes the lock on this domain slot. If the domain contains additional