diff options
54 files changed, 9620 insertions, 4603 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin index a3b7b1f2..b3013cf6 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin | |||
Binary files differ | |||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin index 6d50bd9d..56db384c 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin | |||
Binary files differ | |||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeModule.java b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeModule.java index 34f65780..f4d40594 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeModule.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeModule.java | |||
@@ -1,13 +1,13 @@ | |||
1 | /** | 1 | /** |
2 | * generated by Xtext 2.12.0 | 2 | * generated by Xtext 2.12.0 |
3 | */ | 3 | */ |
4 | package hu.bme.mit.inf.dslreasoner.application.ide; | 4 | package hu.bme.mit.inf.dslreasoner.application.ide; |
5 | 5 | ||
6 | import hu.bme.mit.inf.dslreasoner.application.ide.AbstractApplicationConfigurationIdeModule; | 6 | import hu.bme.mit.inf.dslreasoner.application.ide.AbstractApplicationConfigurationIdeModule; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Use this class to register ide components. | 9 | * Use this class to register ide components. |
10 | */ | 10 | */ |
11 | @SuppressWarnings("all") | 11 | @SuppressWarnings("all") |
12 | public class ApplicationConfigurationIdeModule extends AbstractApplicationConfigurationIdeModule { | 12 | public class ApplicationConfigurationIdeModule extends AbstractApplicationConfigurationIdeModule { |
13 | } | 13 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeSetup.java b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeSetup.java index a73d3f1f..2281147c 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeSetup.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/ApplicationConfigurationIdeSetup.java | |||
@@ -1,24 +1,24 @@ | |||
1 | /** | 1 | /** |
2 | * generated by Xtext 2.12.0 | 2 | * generated by Xtext 2.12.0 |
3 | */ | 3 | */ |
4 | package hu.bme.mit.inf.dslreasoner.application.ide; | 4 | package hu.bme.mit.inf.dslreasoner.application.ide; |
5 | 5 | ||
6 | import com.google.inject.Guice; | 6 | import com.google.inject.Guice; |
7 | import com.google.inject.Injector; | 7 | import com.google.inject.Injector; |
8 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationRuntimeModule; | 8 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationRuntimeModule; |
9 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneSetup; | 9 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneSetup; |
10 | import hu.bme.mit.inf.dslreasoner.application.ide.ApplicationConfigurationIdeModule; | 10 | import hu.bme.mit.inf.dslreasoner.application.ide.ApplicationConfigurationIdeModule; |
11 | import org.eclipse.xtext.util.Modules2; | 11 | import org.eclipse.xtext.util.Modules2; |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Initialization support for running Xtext languages as language servers. | 14 | * Initialization support for running Xtext languages as language servers. |
15 | */ | 15 | */ |
16 | @SuppressWarnings("all") | 16 | @SuppressWarnings("all") |
17 | public class ApplicationConfigurationIdeSetup extends ApplicationConfigurationStandaloneSetup { | 17 | public class ApplicationConfigurationIdeSetup extends ApplicationConfigurationStandaloneSetup { |
18 | @Override | 18 | @Override |
19 | public Injector createInjector() { | 19 | public Injector createInjector() { |
20 | ApplicationConfigurationRuntimeModule _applicationConfigurationRuntimeModule = new ApplicationConfigurationRuntimeModule(); | 20 | ApplicationConfigurationRuntimeModule _applicationConfigurationRuntimeModule = new ApplicationConfigurationRuntimeModule(); |
21 | ApplicationConfigurationIdeModule _applicationConfigurationIdeModule = new ApplicationConfigurationIdeModule(); | 21 | ApplicationConfigurationIdeModule _applicationConfigurationIdeModule = new ApplicationConfigurationIdeModule(); |
22 | return Guice.createInjector(Modules2.mixin(_applicationConfigurationRuntimeModule, _applicationConfigurationIdeModule)); | 22 | return Guice.createInjector(Modules2.mixin(_applicationConfigurationRuntimeModule, _applicationConfigurationIdeModule)); |
23 | } | 23 | } |
24 | } | 24 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java index 2a2e1047..872814b8 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java | |||
@@ -1,157 +1,157 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.validation; | 1 | package hu.bme.mit.inf.dslreasoner.application.validation; |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | 3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; |
4 | import java.util.Collections; | 4 | import java.util.Collections; |
5 | import java.util.LinkedList; | 5 | import java.util.LinkedList; |
6 | import java.util.List; | 6 | import java.util.List; |
7 | import org.eclipse.emf.common.util.EList; | 7 | import org.eclipse.emf.common.util.EList; |
8 | import org.eclipse.emf.ecore.EAttribute; | 8 | import org.eclipse.emf.ecore.EAttribute; |
9 | import org.eclipse.emf.ecore.EClass; | 9 | import org.eclipse.emf.ecore.EClass; |
10 | import org.eclipse.emf.ecore.EDataType; | 10 | import org.eclipse.emf.ecore.EDataType; |
11 | import org.eclipse.emf.ecore.EEnum; | 11 | import org.eclipse.emf.ecore.EEnum; |
12 | import org.eclipse.emf.ecore.EEnumLiteral; | 12 | import org.eclipse.emf.ecore.EEnumLiteral; |
13 | import org.eclipse.emf.ecore.EReference; | 13 | import org.eclipse.emf.ecore.EReference; |
14 | import org.eclipse.emf.ecore.EcorePackage; | 14 | import org.eclipse.emf.ecore.EcorePackage; |
15 | import org.eclipse.xtend2.lib.StringConcatenation; | 15 | import org.eclipse.xtend2.lib.StringConcatenation; |
16 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | 16 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
17 | import org.eclipse.xtext.xbase.lib.Extension; | 17 | import org.eclipse.xtext.xbase.lib.Extension; |
18 | 18 | ||
19 | @SuppressWarnings("all") | 19 | @SuppressWarnings("all") |
20 | public class MetamodelValidator { | 20 | public class MetamodelValidator { |
21 | public LinkedList<String> validateMetamodel(final EcoreMetamodelDescriptor descriptor) { | 21 | public LinkedList<String> validateMetamodel(final EcoreMetamodelDescriptor descriptor) { |
22 | final LinkedList<String> errors = new LinkedList<String>(); | 22 | final LinkedList<String> errors = new LinkedList<String>(); |
23 | this.allSupertypesAreIncluded(descriptor.getClasses(), errors); | 23 | this.allSupertypesAreIncluded(descriptor.getClasses(), errors); |
24 | this.allEnumTypesareIncluded(descriptor.getEnums(), descriptor.getLiterals(), errors); | 24 | this.allEnumTypesareIncluded(descriptor.getEnums(), descriptor.getLiterals(), errors); |
25 | this.referenceEndpointsAreIncluded(descriptor.getClasses(), descriptor.getReferences(), errors); | 25 | this.referenceEndpointsAreIncluded(descriptor.getClasses(), descriptor.getReferences(), errors); |
26 | this.attributeSourcePontIsIncluded(descriptor.getClasses(), descriptor.getAttributes(), errors); | 26 | this.attributeSourcePontIsIncluded(descriptor.getClasses(), descriptor.getAttributes(), errors); |
27 | this.attributeTargetIsSupported(descriptor.getAttributes(), errors); | 27 | this.attributeTargetIsSupported(descriptor.getAttributes(), errors); |
28 | return errors; | 28 | return errors; |
29 | } | 29 | } |
30 | 30 | ||
31 | private boolean supportedEDataType(final EDataType dataType) { | 31 | private boolean supportedEDataType(final EDataType dataType) { |
32 | @Extension | 32 | @Extension |
33 | final EcorePackage l = EcorePackage.eINSTANCE; | 33 | final EcorePackage l = EcorePackage.eINSTANCE; |
34 | EDataType _eInt = l.getEInt(); | 34 | EDataType _eInt = l.getEInt(); |
35 | EDataType _eBoolean = l.getEBoolean(); | 35 | EDataType _eBoolean = l.getEBoolean(); |
36 | EDataType _eString = l.getEString(); | 36 | EDataType _eString = l.getEString(); |
37 | EDataType _eDouble = l.getEDouble(); | 37 | EDataType _eDouble = l.getEDouble(); |
38 | EDataType _eFloat = l.getEFloat(); | 38 | EDataType _eFloat = l.getEFloat(); |
39 | return Collections.<EDataType>unmodifiableList(CollectionLiterals.<EDataType>newArrayList(_eInt, _eBoolean, _eString, _eDouble, _eFloat)).contains(dataType); | 39 | return Collections.<EDataType>unmodifiableList(CollectionLiterals.<EDataType>newArrayList(_eInt, _eBoolean, _eString, _eDouble, _eFloat)).contains(dataType); |
40 | } | 40 | } |
41 | 41 | ||
42 | public void allSupertypesAreIncluded(final List<EClass> classes, final List<String> errors) { | 42 | public void allSupertypesAreIncluded(final List<EClass> classes, final List<String> errors) { |
43 | for (final EClass c : classes) { | 43 | for (final EClass c : classes) { |
44 | EList<EClass> _eSuperTypes = c.getESuperTypes(); | 44 | EList<EClass> _eSuperTypes = c.getESuperTypes(); |
45 | for (final EClass s : _eSuperTypes) { | 45 | for (final EClass s : _eSuperTypes) { |
46 | boolean _contains = classes.contains(s); | 46 | boolean _contains = classes.contains(s); |
47 | boolean _not = (!_contains); | 47 | boolean _not = (!_contains); |
48 | if (_not) { | 48 | if (_not) { |
49 | StringConcatenation _builder = new StringConcatenation(); | 49 | StringConcatenation _builder = new StringConcatenation(); |
50 | _builder.append("Metamodel contains \""); | 50 | _builder.append("Metamodel contains \""); |
51 | String _name = c.getName(); | 51 | String _name = c.getName(); |
52 | _builder.append(_name); | 52 | _builder.append(_name); |
53 | _builder.append("\" but not contains its supertype \""); | 53 | _builder.append("\" but not contains its supertype \""); |
54 | String _name_1 = s.getName(); | 54 | String _name_1 = s.getName(); |
55 | _builder.append(_name_1); | 55 | _builder.append(_name_1); |
56 | _builder.append("\"!"); | 56 | _builder.append("\"!"); |
57 | errors.add(_builder.toString()); | 57 | errors.add(_builder.toString()); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | public void allEnumTypesareIncluded(final List<EEnum> enums, final List<EEnumLiteral> literals, final List<String> errors) { | 63 | public void allEnumTypesareIncluded(final List<EEnum> enums, final List<EEnumLiteral> literals, final List<String> errors) { |
64 | for (final EEnumLiteral l : literals) { | 64 | for (final EEnumLiteral l : literals) { |
65 | boolean _contains = enums.contains(l.getEEnum()); | 65 | boolean _contains = enums.contains(l.getEEnum()); |
66 | boolean _not = (!_contains); | 66 | boolean _not = (!_contains); |
67 | if (_not) { | 67 | if (_not) { |
68 | StringConcatenation _builder = new StringConcatenation(); | 68 | StringConcatenation _builder = new StringConcatenation(); |
69 | _builder.append("Metamodel contains literal \""); | 69 | _builder.append("Metamodel contains literal \""); |
70 | String _name = l.getName(); | 70 | String _name = l.getName(); |
71 | _builder.append(_name); | 71 | _builder.append(_name); |
72 | _builder.append("\" but does not contains enum \""); | 72 | _builder.append("\" but does not contains enum \""); |
73 | String _name_1 = l.getEEnum().getName(); | 73 | String _name_1 = l.getEEnum().getName(); |
74 | _builder.append(_name_1); | 74 | _builder.append(_name_1); |
75 | _builder.append("\"!"); | 75 | _builder.append("\"!"); |
76 | errors.add(_builder.toString()); | 76 | errors.add(_builder.toString()); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public void referenceEndpointsAreIncluded(final List<EClass> classes, final List<EReference> references, final List<String> errors) { | 81 | public void referenceEndpointsAreIncluded(final List<EClass> classes, final List<EReference> references, final List<String> errors) { |
82 | for (final EReference reference : references) { | 82 | for (final EReference reference : references) { |
83 | { | 83 | { |
84 | final EClass src = reference.getEContainingClass(); | 84 | final EClass src = reference.getEContainingClass(); |
85 | boolean _contains = classes.contains(src); | 85 | boolean _contains = classes.contains(src); |
86 | boolean _not = (!_contains); | 86 | boolean _not = (!_contains); |
87 | if (_not) { | 87 | if (_not) { |
88 | StringConcatenation _builder = new StringConcatenation(); | 88 | StringConcatenation _builder = new StringConcatenation(); |
89 | _builder.append("Metamodel contains reference \""); | 89 | _builder.append("Metamodel contains reference \""); |
90 | String _name = reference.getName(); | 90 | String _name = reference.getName(); |
91 | _builder.append(_name); | 91 | _builder.append(_name); |
92 | _builder.append("\" but does not contains its source type \""); | 92 | _builder.append("\" but does not contains its source type \""); |
93 | String _name_1 = src.getName(); | 93 | String _name_1 = src.getName(); |
94 | _builder.append(_name_1); | 94 | _builder.append(_name_1); |
95 | _builder.append("\"!"); | 95 | _builder.append("\"!"); |
96 | errors.add(_builder.toString()); | 96 | errors.add(_builder.toString()); |
97 | } | 97 | } |
98 | final EClass trg = reference.getEReferenceType(); | 98 | final EClass trg = reference.getEReferenceType(); |
99 | boolean _contains_1 = classes.contains(trg); | 99 | boolean _contains_1 = classes.contains(trg); |
100 | boolean _not_1 = (!_contains_1); | 100 | boolean _not_1 = (!_contains_1); |
101 | if (_not_1) { | 101 | if (_not_1) { |
102 | StringConcatenation _builder_1 = new StringConcatenation(); | 102 | StringConcatenation _builder_1 = new StringConcatenation(); |
103 | _builder_1.append("Metamodel contains reference \""); | 103 | _builder_1.append("Metamodel contains reference \""); |
104 | String _name_2 = reference.getName(); | 104 | String _name_2 = reference.getName(); |
105 | _builder_1.append(_name_2); | 105 | _builder_1.append(_name_2); |
106 | _builder_1.append("\" but does not contains its target type \""); | 106 | _builder_1.append("\" but does not contains its target type \""); |
107 | String _name_3 = trg.getName(); | 107 | String _name_3 = trg.getName(); |
108 | _builder_1.append(_name_3); | 108 | _builder_1.append(_name_3); |
109 | _builder_1.append("\"!"); | 109 | _builder_1.append("\"!"); |
110 | errors.add(_builder_1.toString()); | 110 | errors.add(_builder_1.toString()); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | public void attributeSourcePontIsIncluded(final List<EClass> classes, final List<EAttribute> attributes, final List<String> errors) { | 116 | public void attributeSourcePontIsIncluded(final List<EClass> classes, final List<EAttribute> attributes, final List<String> errors) { |
117 | for (final EAttribute attribute : attributes) { | 117 | for (final EAttribute attribute : attributes) { |
118 | { | 118 | { |
119 | final Class<?> src = attribute.getContainerClass(); | 119 | final Class<?> src = attribute.getContainerClass(); |
120 | boolean _contains = classes.contains(src); | 120 | boolean _contains = classes.contains(src); |
121 | boolean _not = (!_contains); | 121 | boolean _not = (!_contains); |
122 | if (_not) { | 122 | if (_not) { |
123 | StringConcatenation _builder = new StringConcatenation(); | 123 | StringConcatenation _builder = new StringConcatenation(); |
124 | _builder.append("Metamodel contains attribute \""); | 124 | _builder.append("Metamodel contains attribute \""); |
125 | String _name = attribute.getName(); | 125 | String _name = attribute.getName(); |
126 | _builder.append(_name); | 126 | _builder.append(_name); |
127 | _builder.append("\" but does not contains its source type \""); | 127 | _builder.append("\" but does not contains its source type \""); |
128 | String _name_1 = src.getName(); | 128 | String _name_1 = src.getName(); |
129 | _builder.append(_name_1); | 129 | _builder.append(_name_1); |
130 | _builder.append("\"!"); | 130 | _builder.append("\"!"); |
131 | errors.add(_builder.toString()); | 131 | errors.add(_builder.toString()); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | public void attributeTargetIsSupported(final List<EAttribute> attributes, final List<String> errors) { | 137 | public void attributeTargetIsSupported(final List<EAttribute> attributes, final List<String> errors) { |
138 | for (final EAttribute attribute : attributes) { | 138 | for (final EAttribute attribute : attributes) { |
139 | { | 139 | { |
140 | final EDataType trg = attribute.getEAttributeType(); | 140 | final EDataType trg = attribute.getEAttributeType(); |
141 | boolean _supportedEDataType = this.supportedEDataType(trg); | 141 | boolean _supportedEDataType = this.supportedEDataType(trg); |
142 | boolean _not = (!_supportedEDataType); | 142 | boolean _not = (!_supportedEDataType); |
143 | if (_not) { | 143 | if (_not) { |
144 | StringConcatenation _builder = new StringConcatenation(); | 144 | StringConcatenation _builder = new StringConcatenation(); |
145 | _builder.append("Metamodels contains attribute \""); | 145 | _builder.append("Metamodels contains attribute \""); |
146 | String _name = attribute.getName(); | 146 | String _name = attribute.getName(); |
147 | _builder.append(_name); | 147 | _builder.append(_name); |
148 | _builder.append("\" with unsupported type \""); | 148 | _builder.append("\" with unsupported type \""); |
149 | String _name_1 = trg.getName(); | 149 | String _name_1 = trg.getName(); |
150 | _builder.append(_name_1); | 150 | _builder.append(_name_1); |
151 | _builder.append("\"!"); | 151 | _builder.append("\"!"); |
152 | errors.add(_builder.toString()); | 152 | errors.add(_builder.toString()); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } | 157 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java index 567551f1..0b5b8f03 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java | |||
@@ -1,86 +1,86 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.validation; | 1 | package hu.bme.mit.inf.dslreasoner.application.validation; |
2 | 2 | ||
3 | import com.google.common.collect.Iterables; | 3 | import com.google.common.collect.Iterables; |
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; |
5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | 5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; |
6 | import java.util.Collections; | 6 | import java.util.Collections; |
7 | import java.util.LinkedList; | 7 | import java.util.LinkedList; |
8 | import java.util.List; | 8 | import java.util.List; |
9 | import java.util.Set; | 9 | import java.util.Set; |
10 | import org.eclipse.emf.common.util.EList; | 10 | import org.eclipse.emf.common.util.EList; |
11 | import org.eclipse.emf.ecore.EAttribute; | 11 | import org.eclipse.emf.ecore.EAttribute; |
12 | import org.eclipse.emf.ecore.EClass; | 12 | import org.eclipse.emf.ecore.EClass; |
13 | import org.eclipse.emf.ecore.EClassifier; | 13 | import org.eclipse.emf.ecore.EClassifier; |
14 | import org.eclipse.emf.ecore.EEnum; | 14 | import org.eclipse.emf.ecore.EEnum; |
15 | import org.eclipse.emf.ecore.EEnumLiteral; | 15 | import org.eclipse.emf.ecore.EEnumLiteral; |
16 | import org.eclipse.emf.ecore.ENamedElement; | 16 | import org.eclipse.emf.ecore.ENamedElement; |
17 | import org.eclipse.emf.ecore.EObject; | 17 | import org.eclipse.emf.ecore.EObject; |
18 | import org.eclipse.emf.ecore.EReference; | 18 | import org.eclipse.emf.ecore.EReference; |
19 | import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern; | 19 | import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern; |
20 | import org.eclipse.xtend2.lib.StringConcatenation; | 20 | import org.eclipse.xtend2.lib.StringConcatenation; |
21 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | 21 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
22 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | 22 | import org.eclipse.xtext.xbase.lib.Functions.Function1; |
23 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | 23 | import org.eclipse.xtext.xbase.lib.IterableExtensions; |
24 | import org.eclipse.xtext.xbase.lib.IteratorExtensions; | 24 | import org.eclipse.xtext.xbase.lib.IteratorExtensions; |
25 | import org.eclipse.xtext.xbase.lib.ListExtensions; | 25 | import org.eclipse.xtext.xbase.lib.ListExtensions; |
26 | import org.eclipse.xtext.xbase.lib.Pair; | 26 | import org.eclipse.xtext.xbase.lib.Pair; |
27 | 27 | ||
28 | @SuppressWarnings("all") | 28 | @SuppressWarnings("all") |
29 | public class QueryAndMetamodelValidator { | 29 | public class QueryAndMetamodelValidator { |
30 | public LinkedList<String> validateQueryAndMetamodel(final EcoreMetamodelDescriptor metamodel, final Pair<ViatraQuerySetDescriptor, Set<Pattern>> viatra) { | 30 | public LinkedList<String> validateQueryAndMetamodel(final EcoreMetamodelDescriptor metamodel, final Pair<ViatraQuerySetDescriptor, Set<Pattern>> viatra) { |
31 | final Set<Pattern> patterns = viatra.getValue(); | 31 | final Set<Pattern> patterns = viatra.getValue(); |
32 | List<EClass> _classes = metamodel.getClasses(); | 32 | List<EClass> _classes = metamodel.getClasses(); |
33 | List<EEnum> _enums = metamodel.getEnums(); | 33 | List<EEnum> _enums = metamodel.getEnums(); |
34 | Iterable<EClassifier> _plus = Iterables.<EClassifier>concat(_classes, _enums); | 34 | Iterable<EClassifier> _plus = Iterables.<EClassifier>concat(_classes, _enums); |
35 | List<EEnumLiteral> _literals = metamodel.getLiterals(); | 35 | List<EEnumLiteral> _literals = metamodel.getLiterals(); |
36 | Iterable<ENamedElement> _plus_1 = Iterables.<ENamedElement>concat(_plus, _literals); | 36 | Iterable<ENamedElement> _plus_1 = Iterables.<ENamedElement>concat(_plus, _literals); |
37 | List<EAttribute> _attributes = metamodel.getAttributes(); | 37 | List<EAttribute> _attributes = metamodel.getAttributes(); |
38 | Iterable<ENamedElement> _plus_2 = Iterables.<ENamedElement>concat(_plus_1, _attributes); | 38 | Iterable<ENamedElement> _plus_2 = Iterables.<ENamedElement>concat(_plus_1, _attributes); |
39 | List<EReference> _references = metamodel.getReferences(); | 39 | List<EReference> _references = metamodel.getReferences(); |
40 | final Set<ENamedElement> elementsInMetamodel = IterableExtensions.<ENamedElement>toSet(Iterables.<ENamedElement>concat(_plus_2, _references)); | 40 | final Set<ENamedElement> elementsInMetamodel = IterableExtensions.<ENamedElement>toSet(Iterables.<ENamedElement>concat(_plus_2, _references)); |
41 | final LinkedList<String> errors = new LinkedList<String>(); | 41 | final LinkedList<String> errors = new LinkedList<String>(); |
42 | for (final Pattern pattern : patterns) { | 42 | for (final Pattern pattern : patterns) { |
43 | { | 43 | { |
44 | final Iterable<ENamedElement> elements = this.getReferredNamedElements(pattern); | 44 | final Iterable<ENamedElement> elements = this.getReferredNamedElements(pattern); |
45 | for (final ENamedElement element : elements) { | 45 | for (final ENamedElement element : elements) { |
46 | boolean _contains = elementsInMetamodel.contains(element); | 46 | boolean _contains = elementsInMetamodel.contains(element); |
47 | boolean _not = (!_contains); | 47 | boolean _not = (!_contains); |
48 | if (_not) { | 48 | if (_not) { |
49 | StringConcatenation _builder = new StringConcatenation(); | 49 | StringConcatenation _builder = new StringConcatenation(); |
50 | _builder.append("Pattern \""); | 50 | _builder.append("Pattern \""); |
51 | String _name = pattern.getName(); | 51 | String _name = pattern.getName(); |
52 | _builder.append(_name); | 52 | _builder.append(_name); |
53 | _builder.append("\" refers to an element \""); | 53 | _builder.append("\" refers to an element \""); |
54 | _builder.append(element); | 54 | _builder.append(element); |
55 | _builder.append("\" that is not included to the selected metamodel!"); | 55 | _builder.append("\" that is not included to the selected metamodel!"); |
56 | errors.add(_builder.toString()); | 56 | errors.add(_builder.toString()); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | return errors; | 61 | return errors; |
62 | } | 62 | } |
63 | 63 | ||
64 | public Iterable<ENamedElement> getReferredNamedElements(final Pattern pattern) { | 64 | public Iterable<ENamedElement> getReferredNamedElements(final Pattern pattern) { |
65 | final List<EObject> elements = IteratorExtensions.<EObject>toList(pattern.eAllContents()); | 65 | final List<EObject> elements = IteratorExtensions.<EObject>toList(pattern.eAllContents()); |
66 | final Function1<EObject, Iterable<ENamedElement>> _function = (EObject element) -> { | 66 | final Function1<EObject, Iterable<ENamedElement>> _function = (EObject element) -> { |
67 | final EList<EReference> references = element.eClass().getEAllReferences(); | 67 | final EList<EReference> references = element.eClass().getEAllReferences(); |
68 | final Function1<EReference, Iterable<ENamedElement>> _function_1 = (EReference r) -> { | 68 | final Function1<EReference, Iterable<ENamedElement>> _function_1 = (EReference r) -> { |
69 | boolean _isMany = r.isMany(); | 69 | boolean _isMany = r.isMany(); |
70 | if (_isMany) { | 70 | if (_isMany) { |
71 | Object _eGet = element.eGet(r); | 71 | Object _eGet = element.eGet(r); |
72 | return Iterables.<ENamedElement>filter(((List<?>) _eGet), ENamedElement.class); | 72 | return Iterables.<ENamedElement>filter(((List<?>) _eGet), ENamedElement.class); |
73 | } else { | 73 | } else { |
74 | final Object value = element.eGet(r); | 74 | final Object value = element.eGet(r); |
75 | if ((value instanceof ENamedElement)) { | 75 | if ((value instanceof ENamedElement)) { |
76 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList(((ENamedElement)value))); | 76 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList(((ENamedElement)value))); |
77 | } else { | 77 | } else { |
78 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList()); | 78 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList()); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | }; | 81 | }; |
82 | return Iterables.<ENamedElement>filter((Iterables.<ENamedElement>concat(ListExtensions.<EReference, Iterable<ENamedElement>>map(references, _function_1))), ENamedElement.class); | 82 | return Iterables.<ENamedElement>filter((Iterables.<ENamedElement>concat(ListExtensions.<EReference, Iterable<ENamedElement>>map(references, _function_1))), ENamedElement.class); |
83 | }; | 83 | }; |
84 | return Iterables.<ENamedElement>concat(ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function)); | 84 | return Iterables.<ENamedElement>concat(ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function)); |
85 | } | 85 | } |
86 | } | 86 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java index e617a132..59a09906 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java | |||
@@ -1,16 +1,16 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.valueconverter; | 1 | package hu.bme.mit.inf.dslreasoner.application.valueconverter; |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.application.valueconverter.QualifiedNameValueConverter; | 3 | import hu.bme.mit.inf.dslreasoner.application.valueconverter.QualifiedNameValueConverter; |
4 | import org.eclipse.xtext.common.services.DefaultTerminalConverters; | 4 | import org.eclipse.xtext.common.services.DefaultTerminalConverters; |
5 | import org.eclipse.xtext.conversion.IValueConverter; | 5 | import org.eclipse.xtext.conversion.IValueConverter; |
6 | import org.eclipse.xtext.conversion.ValueConverter; | 6 | import org.eclipse.xtext.conversion.ValueConverter; |
7 | 7 | ||
8 | @SuppressWarnings("all") | 8 | @SuppressWarnings("all") |
9 | public class ApplicationConfigurationValueConverterService extends DefaultTerminalConverters { | 9 | public class ApplicationConfigurationValueConverterService extends DefaultTerminalConverters { |
10 | private final QualifiedNameValueConverter converter2 = new QualifiedNameValueConverter(); | 10 | private final QualifiedNameValueConverter converter2 = new QualifiedNameValueConverter(); |
11 | 11 | ||
12 | @ValueConverter(rule = "QualifiedName") | 12 | @ValueConverter(rule = "QualifiedName") |
13 | public IValueConverter<String> QualifiedName() { | 13 | public IValueConverter<String> QualifiedName() { |
14 | return this.converter2; | 14 | return this.converter2; |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/ErrorPredicate.java b/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/ErrorPredicate.java deleted file mode 100644 index c8e49d48..00000000 --- a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/ErrorPredicate.java +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /** | ||
2 | * generated by Xtext 2.18.0.M3 | ||
3 | */ | ||
4 | package org.eclipse.viatra.solver.language.solverLanguage; | ||
5 | |||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * A representation of the model object '<em><b>Error Predicate</b></em>'. | ||
10 | * <!-- end-user-doc --> | ||
11 | * | ||
12 | * <p> | ||
13 | * The following features are supported: | ||
14 | * </p> | ||
15 | * <ul> | ||
16 | * <li>{@link org.eclipse.viatra.solver.language.solverLanguage.ErrorPredicate#getName <em>Name</em>}</li> | ||
17 | * </ul> | ||
18 | * | ||
19 | * @see org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage#getErrorPredicate() | ||
20 | * @model | ||
21 | * @generated | ||
22 | */ | ||
23 | public interface ErrorPredicate extends Predicate | ||
24 | { | ||
25 | /** | ||
26 | * Returns the value of the '<em><b>Name</b></em>' attribute. | ||
27 | * <!-- begin-user-doc --> | ||
28 | * <!-- end-user-doc --> | ||
29 | * @return the value of the '<em>Name</em>' attribute. | ||
30 | * @see #setName(String) | ||
31 | * @see org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage#getErrorPredicate_Name() | ||
32 | * @model | ||
33 | * @generated | ||
34 | */ | ||
35 | String getName(); | ||
36 | |||
37 | /** | ||
38 | * Sets the value of the '{@link org.eclipse.viatra.solver.language.solverLanguage.ErrorPredicate#getName <em>Name</em>}' attribute. | ||
39 | * <!-- begin-user-doc --> | ||
40 | * <!-- end-user-doc --> | ||
41 | * @param value the new value of the '<em>Name</em>' attribute. | ||
42 | * @see #getName() | ||
43 | * @generated | ||
44 | */ | ||
45 | void setName(String value); | ||
46 | |||
47 | } // ErrorPredicate | ||
diff --git a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/PredicateSymbol.java b/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/PredicateSymbol.java deleted file mode 100644 index 0f1d0c47..00000000 --- a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/PredicateSymbol.java +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /** | ||
2 | * generated by Xtext 2.18.0.M3 | ||
3 | */ | ||
4 | package org.eclipse.viatra.solver.language.solverLanguage; | ||
5 | |||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * A representation of the model object '<em><b>Predicate Symbol</b></em>'. | ||
10 | * <!-- end-user-doc --> | ||
11 | * | ||
12 | * <p> | ||
13 | * The following features are supported: | ||
14 | * </p> | ||
15 | * <ul> | ||
16 | * <li>{@link org.eclipse.viatra.solver.language.solverLanguage.PredicateSymbol#getSymbol <em>Symbol</em>}</li> | ||
17 | * </ul> | ||
18 | * | ||
19 | * @see org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage#getPredicateSymbol() | ||
20 | * @model | ||
21 | * @generated | ||
22 | */ | ||
23 | public interface PredicateSymbol extends Predicate | ||
24 | { | ||
25 | /** | ||
26 | * Returns the value of the '<em><b>Symbol</b></em>' containment reference. | ||
27 | * <!-- begin-user-doc --> | ||
28 | * <!-- end-user-doc --> | ||
29 | * @return the value of the '<em>Symbol</em>' containment reference. | ||
30 | * @see #setSymbol(ModelSymbol) | ||
31 | * @see org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage#getPredicateSymbol_Symbol() | ||
32 | * @model containment="true" | ||
33 | * @generated | ||
34 | */ | ||
35 | ModelSymbol getSymbol(); | ||
36 | |||
37 | /** | ||
38 | * Sets the value of the '{@link org.eclipse.viatra.solver.language.solverLanguage.PredicateSymbol#getSymbol <em>Symbol</em>}' containment reference. | ||
39 | * <!-- begin-user-doc --> | ||
40 | * <!-- end-user-doc --> | ||
41 | * @param value the new value of the '<em>Symbol</em>' containment reference. | ||
42 | * @see #getSymbol() | ||
43 | * @generated | ||
44 | */ | ||
45 | void setSymbol(ModelSymbol value); | ||
46 | |||
47 | } // PredicateSymbol | ||
diff --git a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/impl/ErrorPredicateImpl.java b/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/impl/ErrorPredicateImpl.java deleted file mode 100644 index f9b0e8c8..00000000 --- a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/impl/ErrorPredicateImpl.java +++ /dev/null | |||
@@ -1,179 +0,0 @@ | |||
1 | /** | ||
2 | * generated by Xtext 2.18.0.M3 | ||
3 | */ | ||
4 | package org.eclipse.viatra.solver.language.solverLanguage.impl; | ||
5 | |||
6 | import org.eclipse.emf.common.notify.Notification; | ||
7 | |||
8 | import org.eclipse.emf.ecore.EClass; | ||
9 | |||
10 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
11 | |||
12 | import org.eclipse.viatra.solver.language.solverLanguage.ErrorPredicate; | ||
13 | import org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage; | ||
14 | |||
15 | /** | ||
16 | * <!-- begin-user-doc --> | ||
17 | * An implementation of the model object '<em><b>Error Predicate</b></em>'. | ||
18 | * <!-- end-user-doc --> | ||
19 | * <p> | ||
20 | * The following features are implemented: | ||
21 | * </p> | ||
22 | * <ul> | ||
23 | * <li>{@link org.eclipse.viatra.solver.language.solverLanguage.impl.ErrorPredicateImpl#getName <em>Name</em>}</li> | ||
24 | * </ul> | ||
25 | * | ||
26 | * @generated | ||
27 | */ | ||
28 | public class ErrorPredicateImpl extends PredicateImpl implements ErrorPredicate | ||
29 | { | ||
30 | /** | ||
31 | * The default value of the '{@link #getName() <em>Name</em>}' attribute. | ||
32 | * <!-- begin-user-doc --> | ||
33 | * <!-- end-user-doc --> | ||
34 | * @see #getName() | ||
35 | * @generated | ||
36 | * @ordered | ||
37 | */ | ||
38 | protected static final String NAME_EDEFAULT = null; | ||
39 | |||
40 | /** | ||
41 | * The cached value of the '{@link #getName() <em>Name</em>}' attribute. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @see #getName() | ||
45 | * @generated | ||
46 | * @ordered | ||
47 | */ | ||
48 | protected String name = NAME_EDEFAULT; | ||
49 | |||
50 | /** | ||
51 | * <!-- begin-user-doc --> | ||
52 | * <!-- end-user-doc --> | ||
53 | * @generated | ||
54 | */ | ||
55 | protected ErrorPredicateImpl() | ||
56 | { | ||
57 | super(); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @generated | ||
64 | */ | ||
65 | @Override | ||
66 | protected EClass eStaticClass() | ||
67 | { | ||
68 | return SolverLanguagePackage.Literals.ERROR_PREDICATE; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * <!-- begin-user-doc --> | ||
73 | * <!-- end-user-doc --> | ||
74 | * @generated | ||
75 | */ | ||
76 | @Override | ||
77 | public String getName() | ||
78 | { | ||
79 | return name; | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * <!-- begin-user-doc --> | ||
84 | * <!-- end-user-doc --> | ||
85 | * @generated | ||
86 | */ | ||
87 | @Override | ||
88 | public void setName(String newName) | ||
89 | { | ||
90 | String oldName = name; | ||
91 | name = newName; | ||
92 | if (eNotificationRequired()) | ||
93 | eNotify(new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.ERROR_PREDICATE__NAME, oldName, name)); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * <!-- begin-user-doc --> | ||
98 | * <!-- end-user-doc --> | ||
99 | * @generated | ||
100 | */ | ||
101 | @Override | ||
102 | public Object eGet(int featureID, boolean resolve, boolean coreType) | ||
103 | { | ||
104 | switch (featureID) | ||
105 | { | ||
106 | case SolverLanguagePackage.ERROR_PREDICATE__NAME: | ||
107 | return getName(); | ||
108 | } | ||
109 | return super.eGet(featureID, resolve, coreType); | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * <!-- begin-user-doc --> | ||
114 | * <!-- end-user-doc --> | ||
115 | * @generated | ||
116 | */ | ||
117 | @Override | ||
118 | public void eSet(int featureID, Object newValue) | ||
119 | { | ||
120 | switch (featureID) | ||
121 | { | ||
122 | case SolverLanguagePackage.ERROR_PREDICATE__NAME: | ||
123 | setName((String)newValue); | ||
124 | return; | ||
125 | } | ||
126 | super.eSet(featureID, newValue); | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * <!-- begin-user-doc --> | ||
131 | * <!-- end-user-doc --> | ||
132 | * @generated | ||
133 | */ | ||
134 | @Override | ||
135 | public void eUnset(int featureID) | ||
136 | { | ||
137 | switch (featureID) | ||
138 | { | ||
139 | case SolverLanguagePackage.ERROR_PREDICATE__NAME: | ||
140 | setName(NAME_EDEFAULT); | ||
141 | return; | ||
142 | } | ||
143 | super.eUnset(featureID); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * <!-- begin-user-doc --> | ||
148 | * <!-- end-user-doc --> | ||
149 | * @generated | ||
150 | */ | ||
151 | @Override | ||
152 | public boolean eIsSet(int featureID) | ||
153 | { | ||
154 | switch (featureID) | ||
155 | { | ||
156 | case SolverLanguagePackage.ERROR_PREDICATE__NAME: | ||
157 | return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); | ||
158 | } | ||
159 | return super.eIsSet(featureID); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * <!-- begin-user-doc --> | ||
164 | * <!-- end-user-doc --> | ||
165 | * @generated | ||
166 | */ | ||
167 | @Override | ||
168 | public String toString() | ||
169 | { | ||
170 | if (eIsProxy()) return super.toString(); | ||
171 | |||
172 | StringBuilder result = new StringBuilder(super.toString()); | ||
173 | result.append(" (name: "); | ||
174 | result.append(name); | ||
175 | result.append(')'); | ||
176 | return result.toString(); | ||
177 | } | ||
178 | |||
179 | } //ErrorPredicateImpl | ||
diff --git a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/impl/PredicateSymbolImpl.java b/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/impl/PredicateSymbolImpl.java deleted file mode 100644 index f49c6701..00000000 --- a/Application/org.eclipse.viatra.solver.language/src-gen/org/eclipse/viatra/solver/language/solverLanguage/impl/PredicateSymbolImpl.java +++ /dev/null | |||
@@ -1,196 +0,0 @@ | |||
1 | /** | ||
2 | * generated by Xtext 2.18.0.M3 | ||
3 | */ | ||
4 | package org.eclipse.viatra.solver.language.solverLanguage.impl; | ||
5 | |||
6 | import org.eclipse.emf.common.notify.Notification; | ||
7 | import org.eclipse.emf.common.notify.NotificationChain; | ||
8 | |||
9 | import org.eclipse.emf.ecore.EClass; | ||
10 | import org.eclipse.emf.ecore.InternalEObject; | ||
11 | |||
12 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
13 | |||
14 | import org.eclipse.viatra.solver.language.solverLanguage.ModelSymbol; | ||
15 | import org.eclipse.viatra.solver.language.solverLanguage.PredicateSymbol; | ||
16 | import org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage; | ||
17 | |||
18 | /** | ||
19 | * <!-- begin-user-doc --> | ||
20 | * An implementation of the model object '<em><b>Predicate Symbol</b></em>'. | ||
21 | * <!-- end-user-doc --> | ||
22 | * <p> | ||
23 | * The following features are implemented: | ||
24 | * </p> | ||
25 | * <ul> | ||
26 | * <li>{@link org.eclipse.viatra.solver.language.solverLanguage.impl.PredicateSymbolImpl#getSymbol <em>Symbol</em>}</li> | ||
27 | * </ul> | ||
28 | * | ||
29 | * @generated | ||
30 | */ | ||
31 | public class PredicateSymbolImpl extends PredicateImpl implements PredicateSymbol | ||
32 | { | ||
33 | /** | ||
34 | * The cached value of the '{@link #getSymbol() <em>Symbol</em>}' containment reference. | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @see #getSymbol() | ||
38 | * @generated | ||
39 | * @ordered | ||
40 | */ | ||
41 | protected ModelSymbol symbol; | ||
42 | |||
43 | /** | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @generated | ||
47 | */ | ||
48 | protected PredicateSymbolImpl() | ||
49 | { | ||
50 | super(); | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * <!-- begin-user-doc --> | ||
55 | * <!-- end-user-doc --> | ||
56 | * @generated | ||
57 | */ | ||
58 | @Override | ||
59 | protected EClass eStaticClass() | ||
60 | { | ||
61 | return SolverLanguagePackage.Literals.PREDICATE_SYMBOL; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * <!-- begin-user-doc --> | ||
66 | * <!-- end-user-doc --> | ||
67 | * @generated | ||
68 | */ | ||
69 | @Override | ||
70 | public ModelSymbol getSymbol() | ||
71 | { | ||
72 | return symbol; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * <!-- begin-user-doc --> | ||
77 | * <!-- end-user-doc --> | ||
78 | * @generated | ||
79 | */ | ||
80 | public NotificationChain basicSetSymbol(ModelSymbol newSymbol, NotificationChain msgs) | ||
81 | { | ||
82 | ModelSymbol oldSymbol = symbol; | ||
83 | symbol = newSymbol; | ||
84 | if (eNotificationRequired()) | ||
85 | { | ||
86 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL, oldSymbol, newSymbol); | ||
87 | if (msgs == null) msgs = notification; else msgs.add(notification); | ||
88 | } | ||
89 | return msgs; | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * <!-- begin-user-doc --> | ||
94 | * <!-- end-user-doc --> | ||
95 | * @generated | ||
96 | */ | ||
97 | @Override | ||
98 | public void setSymbol(ModelSymbol newSymbol) | ||
99 | { | ||
100 | if (newSymbol != symbol) | ||
101 | { | ||
102 | NotificationChain msgs = null; | ||
103 | if (symbol != null) | ||
104 | msgs = ((InternalEObject)symbol).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL, null, msgs); | ||
105 | if (newSymbol != null) | ||
106 | msgs = ((InternalEObject)newSymbol).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL, null, msgs); | ||
107 | msgs = basicSetSymbol(newSymbol, msgs); | ||
108 | if (msgs != null) msgs.dispatch(); | ||
109 | } | ||
110 | else if (eNotificationRequired()) | ||
111 | eNotify(new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL, newSymbol, newSymbol)); | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * <!-- begin-user-doc --> | ||
116 | * <!-- end-user-doc --> | ||
117 | * @generated | ||
118 | */ | ||
119 | @Override | ||
120 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) | ||
121 | { | ||
122 | switch (featureID) | ||
123 | { | ||
124 | case SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL: | ||
125 | return basicSetSymbol(null, msgs); | ||
126 | } | ||
127 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * <!-- begin-user-doc --> | ||
132 | * <!-- end-user-doc --> | ||
133 | * @generated | ||
134 | */ | ||
135 | @Override | ||
136 | public Object eGet(int featureID, boolean resolve, boolean coreType) | ||
137 | { | ||
138 | switch (featureID) | ||
139 | { | ||
140 | case SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL: | ||
141 | return getSymbol(); | ||
142 | } | ||
143 | return super.eGet(featureID, resolve, coreType); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * <!-- begin-user-doc --> | ||
148 | * <!-- end-user-doc --> | ||
149 | * @generated | ||
150 | */ | ||
151 | @Override | ||
152 | public void eSet(int featureID, Object newValue) | ||
153 | { | ||
154 | switch (featureID) | ||
155 | { | ||
156 | case SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL: | ||
157 | setSymbol((ModelSymbol)newValue); | ||
158 | return; | ||
159 | } | ||
160 | super.eSet(featureID, newValue); | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * <!-- begin-user-doc --> | ||
165 | * <!-- end-user-doc --> | ||
166 | * @generated | ||
167 | */ | ||
168 | @Override | ||
169 | public void eUnset(int featureID) | ||
170 | { | ||
171 | switch (featureID) | ||
172 | { | ||
173 | case SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL: | ||
174 | setSymbol((ModelSymbol)null); | ||
175 | return; | ||
176 | } | ||
177 | super.eUnset(featureID); | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * <!-- begin-user-doc --> | ||
182 | * <!-- end-user-doc --> | ||
183 | * @generated | ||
184 | */ | ||
185 | @Override | ||
186 | public boolean eIsSet(int featureID) | ||
187 | { | ||
188 | switch (featureID) | ||
189 | { | ||
190 | case SolverLanguagePackage.PREDICATE_SYMBOL__SYMBOL: | ||
191 | return symbol != null; | ||
192 | } | ||
193 | return super.eIsSet(featureID); | ||
194 | } | ||
195 | |||
196 | } //PredicateSymbolImpl | ||
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/META-INF/MANIFEST.MF b/Domains/Examples/ModelGenExampleFAM_plugin/META-INF/MANIFEST.MF index f1f5d18c..077e646b 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/META-INF/MANIFEST.MF +++ b/Domains/Examples/ModelGenExampleFAM_plugin/META-INF/MANIFEST.MF | |||
@@ -7,16 +7,16 @@ Bundle-ClassPath: . | |||
7 | Bundle-Vendor: %providerName | 7 | Bundle-Vendor: %providerName |
8 | Bundle-Localization: plugin | 8 | Bundle-Localization: plugin |
9 | Export-Package: functionalarchitecture, | 9 | Export-Package: functionalarchitecture, |
10 | functionalarchitecture.impl, | 10 | functionalarchitecture.impl, |
11 | functionalarchitecture.util, | 11 | functionalarchitecture.util, |
12 | hu.bme.mit.inf.dslreasoner.domains.transima.fam | 12 | hu.bme.mit.inf.dslreasoner.domains.transima.fam |
13 | Require-Bundle: ModelGenExampleFAM_plugin, | 13 | Require-Bundle: ModelGenExampleFAM_plugin, |
14 | org.eclipse.viatra.addon.querybasedfeatures.runtime, | 14 | org.eclipse.viatra.addon.querybasedfeatures.runtime, |
15 | org.eclipse.viatra.query.runtime, | 15 | org.eclipse.viatra.query.runtime, |
16 | org.apache.log4j;bundle-version="1.2.15", | 16 | org.apache.log4j;bundle-version="1.2.15", |
17 | com.google.guava;bundle-version="15.0.0", | 17 | com.google.guava;bundle-version="15.0.0", |
18 | org.eclipse.core.runtime, | 18 | org.eclipse.core.runtime, |
19 | org.eclipse.emf.ecore;visibility:=reexport | 19 | org.eclipse.emf.ecore;visibility:=reexport |
20 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | 20 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
21 | Bundle-ActivationPolicy: lazy | 21 | Bundle-ActivationPolicy: lazy |
22 | Automatic-Module-Name: ModelGenExampleFAM_plugin | 22 | Automatic-Module-Name: ModelGenExampleFAM_plugin |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/model/FamMetamodel.ecore b/Domains/Examples/ModelGenExampleFAM_plugin/model/FamMetamodel.ecore index d8331ba8..9654ba41 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/model/FamMetamodel.ecore +++ b/Domains/Examples/ModelGenExampleFAM_plugin/model/FamMetamodel.ecore | |||
@@ -1,69 +1,69 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="functionalarchitecture" nsURI="http://www.inf.mit.bme.hu/viatrasolver/example/fam" | 3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="functionalarchitecture" nsURI="http://www.inf.mit.bme.hu/viatrasolver/example/fam" |
4 | nsPrefix="functionalarchitecture"> | 4 | nsPrefix="functionalarchitecture"> |
5 | <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> | 5 | <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> |
6 | <details key="settingDelegates" value="org.eclipse.viatra.query.querybasedfeature"/> | 6 | <details key="settingDelegates" value="org.eclipse.viatra.query.querybasedfeature"/> |
7 | </eAnnotations> | 7 | </eAnnotations> |
8 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalElement" abstract="true"> | 8 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalElement" abstract="true"> |
9 | <eStructuralFeatures xsi:type="ecore:EReference" name="interface" eType="#//FunctionalInterface" | 9 | <eStructuralFeatures xsi:type="ecore:EReference" name="interface" eType="#//FunctionalInterface" |
10 | containment="true" eOpposite="#//FunctionalInterface/element"/> | 10 | containment="true" eOpposite="#//FunctionalInterface/element"/> |
11 | <eStructuralFeatures xsi:type="ecore:EReference" name="model" lowerBound="1" eType="#//FunctionalArchitectureModel" | 11 | <eStructuralFeatures xsi:type="ecore:EReference" name="model" lowerBound="1" eType="#//FunctionalArchitectureModel" |
12 | volatile="true" transient="true" derived="true"> | 12 | volatile="true" transient="true" derived="true"> |
13 | <eAnnotations source="org.eclipse.viatra.query.querybasedfeature"> | 13 | <eAnnotations source="org.eclipse.viatra.query.querybasedfeature"> |
14 | <details key="patternFQN" value="hu.bme.mit.inf.dslreasoner.domains.transima.fam.model"/> | 14 | <details key="patternFQN" value="hu.bme.mit.inf.dslreasoner.domains.transima.fam.model"/> |
15 | </eAnnotations> | 15 | </eAnnotations> |
16 | </eStructuralFeatures> | 16 | </eStructuralFeatures> |
17 | <eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//Function" | 17 | <eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//Function" |
18 | eOpposite="#//Function/subElements"/> | 18 | eOpposite="#//Function/subElements"/> |
19 | </eClassifiers> | 19 | </eClassifiers> |
20 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalArchitectureModel"> | 20 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalArchitectureModel"> |
21 | <eStructuralFeatures xsi:type="ecore:EReference" name="rootElements" upperBound="-1" | 21 | <eStructuralFeatures xsi:type="ecore:EReference" name="rootElements" upperBound="-1" |
22 | eType="#//FunctionalElement" containment="true"/> | 22 | eType="#//FunctionalElement" containment="true"/> |
23 | </eClassifiers> | 23 | </eClassifiers> |
24 | <eClassifiers xsi:type="ecore:EClass" name="Function" eSuperTypes="#//FunctionalElement"> | 24 | <eClassifiers xsi:type="ecore:EClass" name="Function" eSuperTypes="#//FunctionalElement"> |
25 | <eStructuralFeatures xsi:type="ecore:EReference" name="subElements" upperBound="-1" | 25 | <eStructuralFeatures xsi:type="ecore:EReference" name="subElements" upperBound="-1" |
26 | eType="#//FunctionalElement" containment="true" eOpposite="#//FunctionalElement/parent"/> | 26 | eType="#//FunctionalElement" containment="true" eOpposite="#//FunctionalElement/parent"/> |
27 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="#//FunctionType" | 27 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="#//FunctionType" |
28 | changeable="false" volatile="true" transient="true" derived="true"> | 28 | changeable="false" volatile="true" transient="true" derived="true"> |
29 | <eAnnotations source="org.eclipse.viatra.query.querybasedfeature"> | 29 | <eAnnotations source="org.eclipse.viatra.query.querybasedfeature"> |
30 | <details key="patternFQN" value="hu.bme.mit.inf.dslreasoner.domains.transima.fam.type"/> | 30 | <details key="patternFQN" value="hu.bme.mit.inf.dslreasoner.domains.transima.fam.type"/> |
31 | </eAnnotations> | 31 | </eAnnotations> |
32 | </eStructuralFeatures> | 32 | </eStructuralFeatures> |
33 | </eClassifiers> | 33 | </eClassifiers> |
34 | <eClassifiers xsi:type="ecore:EClass" name="FAMTerminator"> | 34 | <eClassifiers xsi:type="ecore:EClass" name="FAMTerminator"> |
35 | <eStructuralFeatures xsi:type="ecore:EReference" name="data" eType="#//FunctionalData" | 35 | <eStructuralFeatures xsi:type="ecore:EReference" name="data" eType="#//FunctionalData" |
36 | eOpposite="#//FunctionalData/terminator"/> | 36 | eOpposite="#//FunctionalData/terminator"/> |
37 | </eClassifiers> | 37 | </eClassifiers> |
38 | <eClassifiers xsi:type="ecore:EClass" name="InformationLink"> | 38 | <eClassifiers xsi:type="ecore:EClass" name="InformationLink"> |
39 | <eStructuralFeatures xsi:type="ecore:EReference" name="from" eType="#//FunctionalOutput" | 39 | <eStructuralFeatures xsi:type="ecore:EReference" name="from" eType="#//FunctionalOutput" |
40 | eOpposite="#//FunctionalOutput/outgoingLinks"/> | 40 | eOpposite="#//FunctionalOutput/outgoingLinks"/> |
41 | <eStructuralFeatures xsi:type="ecore:EReference" name="to" lowerBound="1" eType="#//FunctionalInput" | 41 | <eStructuralFeatures xsi:type="ecore:EReference" name="to" lowerBound="1" eType="#//FunctionalInput" |
42 | eOpposite="#//FunctionalInput/IncomingLinks"/> | 42 | eOpposite="#//FunctionalInput/IncomingLinks"/> |
43 | </eClassifiers> | 43 | </eClassifiers> |
44 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalInterface"> | 44 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalInterface"> |
45 | <eStructuralFeatures xsi:type="ecore:EReference" name="data" upperBound="-1" eType="#//FunctionalData" | 45 | <eStructuralFeatures xsi:type="ecore:EReference" name="data" upperBound="-1" eType="#//FunctionalData" |
46 | containment="true" eOpposite="#//FunctionalData/interface"/> | 46 | containment="true" eOpposite="#//FunctionalData/interface"/> |
47 | <eStructuralFeatures xsi:type="ecore:EReference" name="element" eType="#//FunctionalElement" | 47 | <eStructuralFeatures xsi:type="ecore:EReference" name="element" eType="#//FunctionalElement" |
48 | eOpposite="#//FunctionalElement/interface"/> | 48 | eOpposite="#//FunctionalElement/interface"/> |
49 | </eClassifiers> | 49 | </eClassifiers> |
50 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalInput" eSuperTypes="#//FunctionalData"> | 50 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalInput" eSuperTypes="#//FunctionalData"> |
51 | <eStructuralFeatures xsi:type="ecore:EReference" name="IncomingLinks" upperBound="-1" | 51 | <eStructuralFeatures xsi:type="ecore:EReference" name="IncomingLinks" upperBound="-1" |
52 | eType="#//InformationLink" eOpposite="#//InformationLink/to"/> | 52 | eType="#//InformationLink" eOpposite="#//InformationLink/to"/> |
53 | </eClassifiers> | 53 | </eClassifiers> |
54 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalOutput" eSuperTypes="#//FunctionalData"> | 54 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalOutput" eSuperTypes="#//FunctionalData"> |
55 | <eStructuralFeatures xsi:type="ecore:EReference" name="outgoingLinks" upperBound="-1" | 55 | <eStructuralFeatures xsi:type="ecore:EReference" name="outgoingLinks" upperBound="-1" |
56 | eType="#//InformationLink" containment="true" eOpposite="#//InformationLink/from"/> | 56 | eType="#//InformationLink" containment="true" eOpposite="#//InformationLink/from"/> |
57 | </eClassifiers> | 57 | </eClassifiers> |
58 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalData" abstract="true"> | 58 | <eClassifiers xsi:type="ecore:EClass" name="FunctionalData" abstract="true"> |
59 | <eStructuralFeatures xsi:type="ecore:EReference" name="terminator" eType="#//FAMTerminator" | 59 | <eStructuralFeatures xsi:type="ecore:EReference" name="terminator" eType="#//FAMTerminator" |
60 | containment="true" eOpposite="#//FAMTerminator/data"/> | 60 | containment="true" eOpposite="#//FAMTerminator/data"/> |
61 | <eStructuralFeatures xsi:type="ecore:EReference" name="interface" eType="#//FunctionalInterface" | 61 | <eStructuralFeatures xsi:type="ecore:EReference" name="interface" eType="#//FunctionalInterface" |
62 | eOpposite="#//FunctionalInterface/data"/> | 62 | eOpposite="#//FunctionalInterface/data"/> |
63 | </eClassifiers> | 63 | </eClassifiers> |
64 | <eClassifiers xsi:type="ecore:EEnum" name="FunctionType"> | 64 | <eClassifiers xsi:type="ecore:EEnum" name="FunctionType"> |
65 | <eLiterals name="Root"/> | 65 | <eLiterals name="Root"/> |
66 | <eLiterals name="Intermediate" value="1"/> | 66 | <eLiterals name="Intermediate" value="1"/> |
67 | <eLiterals name="Leaf" value="2"/> | 67 | <eLiterals name="Leaf" value="2"/> |
68 | </eClassifiers> | 68 | </eClassifiers> |
69 | </ecore:EPackage> | 69 | </ecore:EPackage> |
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml b/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml index 3dce57aa..213ec0ed 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml +++ b/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml | |||
@@ -1,24 +1,24 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><plugin> | 1 | <?xml version="1.0" encoding="UTF-8"?><plugin> |
2 | <extension id="extension.derived.hu.bme.mit.inf.dslreasoner.domains.transima.fam.model" point="org.eclipse.viatra.query.runtime.base.wellbehaving.derived.features"> | 2 | <extension id="extension.derived.hu.bme.mit.inf.dslreasoner.domains.transima.fam.model" point="org.eclipse.viatra.query.runtime.base.wellbehaving.derived.features"> |
3 | <wellbehaving-derived-feature classifier-name="FunctionalElement" feature-name="model" package-nsUri="http://www.inf.mit.bme.hu/viatrasolver/example/fam"/> | 3 | <wellbehaving-derived-feature classifier-name="FunctionalElement" feature-name="model" package-nsUri="http://www.inf.mit.bme.hu/viatrasolver/example/fam"/> |
4 | </extension> | 4 | </extension> |
5 | <extension id="extension.derived.hu.bme.mit.inf.dslreasoner.domains.transima.fam.type" point="org.eclipse.viatra.query.runtime.base.wellbehaving.derived.features"> | 5 | <extension id="extension.derived.hu.bme.mit.inf.dslreasoner.domains.transima.fam.type" point="org.eclipse.viatra.query.runtime.base.wellbehaving.derived.features"> |
6 | <wellbehaving-derived-feature classifier-name="Function" feature-name="type" package-nsUri="http://www.inf.mit.bme.hu/viatrasolver/example/fam"/> | 6 | <wellbehaving-derived-feature classifier-name="Function" feature-name="type" package-nsUri="http://www.inf.mit.bme.hu/viatrasolver/example/fam"/> |
7 | </extension> | 7 | </extension> |
8 | <extension point="org.eclipse.emf.ecore.generated_package"> | 8 | <extension point="org.eclipse.emf.ecore.generated_package"> |
9 | <!-- @generated FamMetamodel --> | 9 | <!-- @generated FamMetamodel --> |
10 | <package class="functionalarchitecture.FunctionalarchitecturePackage" genModel="model/FamMetamodel.genmodel" uri="http://www.inf.mit.bme.hu/viatrasolver/example/fam"/> | 10 | <package class="functionalarchitecture.FunctionalarchitecturePackage" genModel="model/FamMetamodel.genmodel" uri="http://www.inf.mit.bme.hu/viatrasolver/example/fam"/> |
11 | </extension> | 11 | </extension> |
12 | <extension id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" point="org.eclipse.viatra.query.runtime.queryspecification"> | 12 | <extension id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" point="org.eclipse.viatra.query.runtime.queryspecification"> |
13 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns"> | 13 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns" id="hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns"> |
14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.terminatorAndInformation"/> | 14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.terminatorAndInformation"/> |
15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.type"/> | 15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.type"/> |
16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.rootElements"/> | 16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.rootElements"/> |
17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.parent"/> | 17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.parent"/> |
18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.model"/> | 18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.model"/> |
19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasRoot"/> | 19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasRoot"/> |
20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasInt"/> | 20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasInt"/> |
21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasLeaf"/> | 21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.transima.fam.hasLeaf"/> |
22 | </group> | 22 | </group> |
23 | </extension> | 23 | </extension> |
24 | </plugin> | 24 | </plugin> |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF index 41726ae6..5fb85170 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF | |||
@@ -6,19 +6,19 @@ Bundle-Version: 1.0.0.qualifier | |||
6 | Bundle-ClassPath: . | 6 | Bundle-ClassPath: . |
7 | Bundle-Vendor: %providerName | 7 | Bundle-Vendor: %providerName |
8 | Bundle-Localization: plugin | 8 | Bundle-Localization: plugin |
9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.alloyexamples, | 9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.alloyexamples, |
10 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem, | 10 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem, |
11 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.impl, | 11 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.impl, |
12 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.util, | 12 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.util, |
13 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.util | 13 | hu.bme.mit.inf.dslreasoner.domains.alloyexamples.util |
14 | Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, | 14 | Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, |
15 | org.eclipse.viatra.query.runtime, | 15 | org.eclipse.viatra.query.runtime, |
16 | org.eclipse.core.runtime, | 16 | org.eclipse.core.runtime, |
17 | org.eclipse.emf.ecore;visibility:=reexport, | 17 | org.eclipse.emf.ecore;visibility:=reexport, |
18 | org.eclipse.emf.emfstore.common, | 18 | org.eclipse.emf.emfstore.common, |
19 | com.google.guava, | 19 | com.google.guava, |
20 | org.eclipse.xtext.xbase.lib, | 20 | org.eclipse.xtext.xbase.lib, |
21 | org.eclipse.xtend.lib, | 21 | org.eclipse.xtend.lib, |
22 | org.eclipse.xtend.lib.macro | 22 | org.eclipse.xtend.lib.macro |
23 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | 23 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
24 | Bundle-ActivationPolicy: lazy | 24 | Bundle-ActivationPolicy: lazy |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/model/FileSytem.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/model/FileSytem.ecore index c928d2b0..87ba7135 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/model/FileSytem.ecore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/model/FileSytem.ecore | |||
@@ -1,32 +1,32 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Filesystem" nsURI="FS" nsPrefix="FS"> | 3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Filesystem" nsURI="FS" nsPrefix="FS"> |
4 | <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> | 4 | <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> |
5 | <details key="settingDelegates" value="org.eclipse.viatra.query.querybasedfeature"/> | 5 | <details key="settingDelegates" value="org.eclipse.viatra.query.querybasedfeature"/> |
6 | </eAnnotations> | 6 | </eAnnotations> |
7 | <eClassifiers xsi:type="ecore:EClass" name="FileSystem"> | 7 | <eClassifiers xsi:type="ecore:EClass" name="FileSystem"> |
8 | <eStructuralFeatures xsi:type="ecore:EReference" name="root" lowerBound="1" eType="#//Dir" | 8 | <eStructuralFeatures xsi:type="ecore:EReference" name="root" lowerBound="1" eType="#//Dir" |
9 | containment="true"/> | 9 | containment="true"/> |
10 | <eStructuralFeatures xsi:type="ecore:EReference" name="live" upperBound="-1" eType="#//FSObject" | 10 | <eStructuralFeatures xsi:type="ecore:EReference" name="live" upperBound="-1" eType="#//FSObject" |
11 | changeable="false" volatile="true" transient="true" derived="true"> | 11 | changeable="false" volatile="true" transient="true" derived="true"> |
12 | <eAnnotations source="org.eclipse.viatra.query.querybasedfeature"> | 12 | <eAnnotations source="org.eclipse.viatra.query.querybasedfeature"> |
13 | <details key="patternFQN" value="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live"/> | 13 | <details key="patternFQN" value="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live"/> |
14 | </eAnnotations> | 14 | </eAnnotations> |
15 | </eStructuralFeatures> | 15 | </eStructuralFeatures> |
16 | </eClassifiers> | 16 | </eClassifiers> |
17 | <eClassifiers xsi:type="ecore:EClass" name="FSObject" abstract="true"> | 17 | <eClassifiers xsi:type="ecore:EClass" name="FSObject" abstract="true"> |
18 | <eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//Dir" | 18 | <eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//Dir" |
19 | eOpposite="#//Dir/contents"/> | 19 | eOpposite="#//Dir/contents"/> |
20 | </eClassifiers> | 20 | </eClassifiers> |
21 | <eClassifiers xsi:type="ecore:EClass" name="Dir" eSuperTypes="#//FSObject"> | 21 | <eClassifiers xsi:type="ecore:EClass" name="Dir" eSuperTypes="#//FSObject"> |
22 | <eStructuralFeatures xsi:type="ecore:EReference" name="contents" upperBound="-1" | 22 | <eStructuralFeatures xsi:type="ecore:EReference" name="contents" upperBound="-1" |
23 | eType="#//FSObject" containment="true" eOpposite="#//FSObject/parent"/> | 23 | eType="#//FSObject" containment="true" eOpposite="#//FSObject/parent"/> |
24 | </eClassifiers> | 24 | </eClassifiers> |
25 | <eClassifiers xsi:type="ecore:EClass" name="File" eSuperTypes="#//FSObject"/> | 25 | <eClassifiers xsi:type="ecore:EClass" name="File" eSuperTypes="#//FSObject"/> |
26 | <eClassifiers xsi:type="ecore:EClass" name="Model"> | 26 | <eClassifiers xsi:type="ecore:EClass" name="Model"> |
27 | <eStructuralFeatures xsi:type="ecore:EReference" name="filesystems" lowerBound="1" | 27 | <eStructuralFeatures xsi:type="ecore:EReference" name="filesystems" lowerBound="1" |
28 | eType="#//FileSystem" containment="true"/> | 28 | eType="#//FileSystem" containment="true"/> |
29 | <eStructuralFeatures xsi:type="ecore:EReference" name="otherFSObjects" upperBound="-1" | 29 | <eStructuralFeatures xsi:type="ecore:EReference" name="otherFSObjects" upperBound="-1" |
30 | eType="#//FSObject" containment="true"/> | 30 | eType="#//FSObject" containment="true"/> |
31 | </eClassifiers> | 31 | </eClassifiers> |
32 | </ecore:EPackage> | 32 | </ecore:EPackage> |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml index 576aa06e..d7fd112a 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml | |||
@@ -1,26 +1,26 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- | 1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- |
2 | --><plugin> | 2 | --><plugin> |
3 | <extension point="org.eclipse.emf.ecore.generated_package"> | 3 | <extension point="org.eclipse.emf.ecore.generated_package"> |
4 | <!-- @generated FileSytem --> | 4 | <!-- @generated FileSytem --> |
5 | <package class="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FilesystemPackage" genModel="model/FileSytem.genmodel" uri="FS"/> | 5 | <package class="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FilesystemPackage" genModel="model/FileSytem.genmodel" uri="FS"/> |
6 | </extension> | 6 | </extension> |
7 | <extension id="extension.derived.hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live" point="org.eclipse.viatra.query.runtime.base.wellbehaving.derived.features"> | 7 | <extension id="extension.derived.hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live" point="org.eclipse.viatra.query.runtime.base.wellbehaving.derived.features"> |
8 | <wellbehaving-derived-feature classifier-name="FileSystem" feature-name="live" package-nsUri="FS"/> | 8 | <wellbehaving-derived-feature classifier-name="FileSystem" feature-name="live" package-nsUri="FS"/> |
9 | </extension> | 9 | </extension> |
10 | <extension id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore" point="org.eclipse.viatra.query.runtime.queryspecification"> | 10 | <extension id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore" point="org.eclipse.viatra.query.runtime.queryspecification"> |
11 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore" id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore"> | 11 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore" id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore"> |
12 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.directSupertype"/> | 12 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.directSupertype"/> |
13 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.loopInInheritence"/> | 13 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.loopInInheritence"/> |
14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.opposite"/> | 14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.opposite"/> |
15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.oppositeDifferentClass"/> | 15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.oppositeDifferentClass"/> |
16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.nonSymmetricOpposite"/> | 16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.nonSymmetricOpposite"/> |
17 | </group> | 17 | </group> |
18 | </extension> | 18 | </extension> |
19 | <extension id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem" point="org.eclipse.viatra.query.runtime.queryspecification"> | 19 | <extension id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem" point="org.eclipse.viatra.query.runtime.queryspecification"> |
20 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem" id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem"> | 20 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem" id="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem"> |
21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.patternContent"/> | 21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.patternContent"/> |
22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live"/> | 22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live"/> |
23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive"/> | 23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive"/> |
24 | </group> | 24 | </group> |
25 | </extension> | 25 | </extension> |
26 | </plugin> | 26 | </plugin> |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore index 9d608403..52338993 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore | |||
@@ -34,3 +34,11 @@ | |||
34 | /OppositeMatcher.java | 34 | /OppositeMatcher.java |
35 | /PatternContentMatch.java | 35 | /PatternContentMatch.java |
36 | /PatternContentMatcher.java | 36 | /PatternContentMatcher.java |
37 | /.ContentInNotLive.java._trace | ||
38 | /.DirectSupertype.java._trace | ||
39 | /.Live.java._trace | ||
40 | /.LoopInInheritence.java._trace | ||
41 | /.NonSymmetricOpposite.java._trace | ||
42 | /.Opposite.java._trace | ||
43 | /.OppositeDifferentClass.java._trace | ||
44 | /.PatternContent.java._trace | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java new file mode 100644 index 00000000..ef0aaaf3 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java | |||
@@ -0,0 +1,752 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/FileSystem.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Live; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * {@literal @}Constraint(key={child}, severity="error", message="error") | ||
52 | * pattern contentInNotLive(parent : Dir, child: FSObject) { | ||
53 | * Dir.contents(parent,child); | ||
54 | * neg find live(_,parent); | ||
55 | * } or { | ||
56 | * Dir.contents(parent,child); | ||
57 | * neg find live(_,child); | ||
58 | * } | ||
59 | * </pre></code> | ||
60 | * | ||
61 | * @see Matcher | ||
62 | * @see Match | ||
63 | * | ||
64 | */ | ||
65 | @SuppressWarnings("all") | ||
66 | public final class ContentInNotLive extends BaseGeneratedEMFQuerySpecification<ContentInNotLive.Matcher> { | ||
67 | /** | ||
68 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive pattern, | ||
69 | * to be used in conjunction with {@link Matcher}. | ||
70 | * | ||
71 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
72 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
73 | * usable to represent a match of the pattern in the result of a query, | ||
74 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
75 | * | ||
76 | * @see Matcher | ||
77 | * | ||
78 | */ | ||
79 | public static abstract class Match extends BasePatternMatch { | ||
80 | private Dir fParent; | ||
81 | |||
82 | private FSObject fChild; | ||
83 | |||
84 | private static List<String> parameterNames = makeImmutableList("parent", "child"); | ||
85 | |||
86 | private Match(final Dir pParent, final FSObject pChild) { | ||
87 | this.fParent = pParent; | ||
88 | this.fChild = pChild; | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final String parameterName) { | ||
93 | switch(parameterName) { | ||
94 | case "parent": return this.fParent; | ||
95 | case "child": return this.fChild; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public Object get(final int index) { | ||
102 | switch(index) { | ||
103 | case 0: return this.fParent; | ||
104 | case 1: return this.fChild; | ||
105 | default: return null; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | public Dir getParent() { | ||
110 | return this.fParent; | ||
111 | } | ||
112 | |||
113 | public FSObject getChild() { | ||
114 | return this.fChild; | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public boolean set(final String parameterName, final Object newValue) { | ||
119 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
120 | if ("parent".equals(parameterName) ) { | ||
121 | this.fParent = (Dir) newValue; | ||
122 | return true; | ||
123 | } | ||
124 | if ("child".equals(parameterName) ) { | ||
125 | this.fChild = (FSObject) newValue; | ||
126 | return true; | ||
127 | } | ||
128 | return false; | ||
129 | } | ||
130 | |||
131 | public void setParent(final Dir pParent) { | ||
132 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
133 | this.fParent = pParent; | ||
134 | } | ||
135 | |||
136 | public void setChild(final FSObject pChild) { | ||
137 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
138 | this.fChild = pChild; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String patternName() { | ||
143 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive"; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public List<String> parameterNames() { | ||
148 | return ContentInNotLive.Match.parameterNames; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public Object[] toArray() { | ||
153 | return new Object[]{fParent, fChild}; | ||
154 | } | ||
155 | |||
156 | @Override | ||
157 | public ContentInNotLive.Match toImmutable() { | ||
158 | return isMutable() ? newMatch(fParent, fChild) : this; | ||
159 | } | ||
160 | |||
161 | @Override | ||
162 | public String prettyPrint() { | ||
163 | StringBuilder result = new StringBuilder(); | ||
164 | result.append("\"parent\"=" + prettyPrintValue(fParent) + ", "); | ||
165 | result.append("\"child\"=" + prettyPrintValue(fChild)); | ||
166 | return result.toString(); | ||
167 | } | ||
168 | |||
169 | @Override | ||
170 | public int hashCode() { | ||
171 | return Objects.hash(fParent, fChild); | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public boolean equals(final Object obj) { | ||
176 | if (this == obj) | ||
177 | return true; | ||
178 | if (obj == null) { | ||
179 | return false; | ||
180 | } | ||
181 | if ((obj instanceof ContentInNotLive.Match)) { | ||
182 | ContentInNotLive.Match other = (ContentInNotLive.Match) obj; | ||
183 | return Objects.equals(fParent, other.fParent) && Objects.equals(fChild, other.fChild); | ||
184 | } else { | ||
185 | // this should be infrequent | ||
186 | if (!(obj instanceof IPatternMatch)) { | ||
187 | return false; | ||
188 | } | ||
189 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
190 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | @Override | ||
195 | public ContentInNotLive specification() { | ||
196 | return ContentInNotLive.instance(); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns an empty, mutable match. | ||
201 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
202 | * | ||
203 | * @return the empty match. | ||
204 | * | ||
205 | */ | ||
206 | public static ContentInNotLive.Match newEmptyMatch() { | ||
207 | return new Mutable(null, null); | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * Returns a mutable (partial) match. | ||
212 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
213 | * | ||
214 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
215 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
216 | * @return the new, mutable (partial) match object. | ||
217 | * | ||
218 | */ | ||
219 | public static ContentInNotLive.Match newMutableMatch(final Dir pParent, final FSObject pChild) { | ||
220 | return new Mutable(pParent, pChild); | ||
221 | } | ||
222 | |||
223 | /** | ||
224 | * Returns a new (partial) match. | ||
225 | * This can be used e.g. to call the matcher with a partial match. | ||
226 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
227 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
228 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
229 | * @return the (partial) match object. | ||
230 | * | ||
231 | */ | ||
232 | public static ContentInNotLive.Match newMatch(final Dir pParent, final FSObject pChild) { | ||
233 | return new Immutable(pParent, pChild); | ||
234 | } | ||
235 | |||
236 | private static final class Mutable extends ContentInNotLive.Match { | ||
237 | Mutable(final Dir pParent, final FSObject pChild) { | ||
238 | super(pParent, pChild); | ||
239 | } | ||
240 | |||
241 | @Override | ||
242 | public boolean isMutable() { | ||
243 | return true; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | private static final class Immutable extends ContentInNotLive.Match { | ||
248 | Immutable(final Dir pParent, final FSObject pChild) { | ||
249 | super(pParent, pChild); | ||
250 | } | ||
251 | |||
252 | @Override | ||
253 | public boolean isMutable() { | ||
254 | return false; | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | /** | ||
260 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive pattern, | ||
261 | * providing pattern-specific query methods. | ||
262 | * | ||
263 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
264 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
265 | * | ||
266 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
267 | * | ||
268 | * <p>Original source: | ||
269 | * <code><pre> | ||
270 | * {@literal @}Constraint(key={child}, severity="error", message="error") | ||
271 | * pattern contentInNotLive(parent : Dir, child: FSObject) { | ||
272 | * Dir.contents(parent,child); | ||
273 | * neg find live(_,parent); | ||
274 | * } or { | ||
275 | * Dir.contents(parent,child); | ||
276 | * neg find live(_,child); | ||
277 | * } | ||
278 | * </pre></code> | ||
279 | * | ||
280 | * @see Match | ||
281 | * @see ContentInNotLive | ||
282 | * | ||
283 | */ | ||
284 | public static class Matcher extends BaseMatcher<ContentInNotLive.Match> { | ||
285 | /** | ||
286 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
287 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
288 | * | ||
289 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * | ||
292 | */ | ||
293 | public static ContentInNotLive.Matcher on(final ViatraQueryEngine engine) { | ||
294 | // check if matcher already exists | ||
295 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
296 | if (matcher == null) { | ||
297 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
298 | } | ||
299 | return matcher; | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * @return an initialized matcher | ||
305 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
306 | * | ||
307 | */ | ||
308 | public static ContentInNotLive.Matcher create() { | ||
309 | return new Matcher(); | ||
310 | } | ||
311 | |||
312 | private static final int POSITION_PARENT = 0; | ||
313 | |||
314 | private static final int POSITION_CHILD = 1; | ||
315 | |||
316 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ContentInNotLive.Matcher.class); | ||
317 | |||
318 | /** | ||
319 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
320 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
321 | * | ||
322 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
323 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
324 | * | ||
325 | */ | ||
326 | private Matcher() { | ||
327 | super(querySpecification()); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
332 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
333 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
334 | * @return matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Collection<ContentInNotLive.Match> getAllMatches(final Dir pParent, final FSObject pChild) { | ||
338 | return rawStreamAllMatches(new Object[]{pParent, pChild}).collect(Collectors.toSet()); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
343 | * </p> | ||
344 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
345 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
346 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
347 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
348 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
349 | * @return a stream of matches represented as a Match object. | ||
350 | * | ||
351 | */ | ||
352 | public Stream<ContentInNotLive.Match> streamAllMatches(final Dir pParent, final FSObject pChild) { | ||
353 | return rawStreamAllMatches(new Object[]{pParent, pChild}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
358 | * Neither determinism nor randomness of selection is guaranteed. | ||
359 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
360 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
361 | * @return a match represented as a Match object, or null if no match is found. | ||
362 | * | ||
363 | */ | ||
364 | public Optional<ContentInNotLive.Match> getOneArbitraryMatch(final Dir pParent, final FSObject pChild) { | ||
365 | return rawGetOneArbitraryMatch(new Object[]{pParent, pChild}); | ||
366 | } | ||
367 | |||
368 | /** | ||
369 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
370 | * under any possible substitution of the unspecified parameters (if any). | ||
371 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
372 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
373 | * @return true if the input is a valid (partial) match of the pattern. | ||
374 | * | ||
375 | */ | ||
376 | public boolean hasMatch(final Dir pParent, final FSObject pChild) { | ||
377 | return rawHasMatch(new Object[]{pParent, pChild}); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
382 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
383 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
384 | * @return the number of pattern matches found. | ||
385 | * | ||
386 | */ | ||
387 | public int countMatches(final Dir pParent, final FSObject pChild) { | ||
388 | return rawCountMatches(new Object[]{pParent, pChild}); | ||
389 | } | ||
390 | |||
391 | /** | ||
392 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
393 | * Neither determinism nor randomness of selection is guaranteed. | ||
394 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
395 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
396 | * @param processor the action that will process the selected match. | ||
397 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
398 | * | ||
399 | */ | ||
400 | public boolean forOneArbitraryMatch(final Dir pParent, final FSObject pChild, final Consumer<? super ContentInNotLive.Match> processor) { | ||
401 | return rawForOneArbitraryMatch(new Object[]{pParent, pChild}, processor); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * Returns a new (partial) match. | ||
406 | * This can be used e.g. to call the matcher with a partial match. | ||
407 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
408 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
409 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
410 | * @return the (partial) match object. | ||
411 | * | ||
412 | */ | ||
413 | public ContentInNotLive.Match newMatch(final Dir pParent, final FSObject pChild) { | ||
414 | return ContentInNotLive.Match.newMatch(pParent, pChild); | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * Retrieve the set of values that occur in matches for parent. | ||
419 | * @return the Set of all values or empty set if there are no matches | ||
420 | * | ||
421 | */ | ||
422 | protected Stream<Dir> rawStreamAllValuesOfparent(final Object[] parameters) { | ||
423 | return rawStreamAllValues(POSITION_PARENT, parameters).map(Dir.class::cast); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * Retrieve the set of values that occur in matches for parent. | ||
428 | * @return the Set of all values or empty set if there are no matches | ||
429 | * | ||
430 | */ | ||
431 | public Set<Dir> getAllValuesOfparent() { | ||
432 | return rawStreamAllValuesOfparent(emptyArray()).collect(Collectors.toSet()); | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * Retrieve the set of values that occur in matches for parent. | ||
437 | * @return the Set of all values or empty set if there are no matches | ||
438 | * | ||
439 | */ | ||
440 | public Stream<Dir> streamAllValuesOfparent() { | ||
441 | return rawStreamAllValuesOfparent(emptyArray()); | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * Retrieve the set of values that occur in matches for parent. | ||
446 | * </p> | ||
447 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
448 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
449 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
450 | * | ||
451 | * @return the Stream of all values or empty set if there are no matches | ||
452 | * | ||
453 | */ | ||
454 | public Stream<Dir> streamAllValuesOfparent(final ContentInNotLive.Match partialMatch) { | ||
455 | return rawStreamAllValuesOfparent(partialMatch.toArray()); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * Retrieve the set of values that occur in matches for parent. | ||
460 | * </p> | ||
461 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
462 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
463 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
464 | * | ||
465 | * @return the Stream of all values or empty set if there are no matches | ||
466 | * | ||
467 | */ | ||
468 | public Stream<Dir> streamAllValuesOfparent(final FSObject pChild) { | ||
469 | return rawStreamAllValuesOfparent(new Object[]{null, pChild}); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * Retrieve the set of values that occur in matches for parent. | ||
474 | * @return the Set of all values or empty set if there are no matches | ||
475 | * | ||
476 | */ | ||
477 | public Set<Dir> getAllValuesOfparent(final ContentInNotLive.Match partialMatch) { | ||
478 | return rawStreamAllValuesOfparent(partialMatch.toArray()).collect(Collectors.toSet()); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Retrieve the set of values that occur in matches for parent. | ||
483 | * @return the Set of all values or empty set if there are no matches | ||
484 | * | ||
485 | */ | ||
486 | public Set<Dir> getAllValuesOfparent(final FSObject pChild) { | ||
487 | return rawStreamAllValuesOfparent(new Object[]{null, pChild}).collect(Collectors.toSet()); | ||
488 | } | ||
489 | |||
490 | /** | ||
491 | * Retrieve the set of values that occur in matches for child. | ||
492 | * @return the Set of all values or empty set if there are no matches | ||
493 | * | ||
494 | */ | ||
495 | protected Stream<FSObject> rawStreamAllValuesOfchild(final Object[] parameters) { | ||
496 | return rawStreamAllValues(POSITION_CHILD, parameters).map(FSObject.class::cast); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Retrieve the set of values that occur in matches for child. | ||
501 | * @return the Set of all values or empty set if there are no matches | ||
502 | * | ||
503 | */ | ||
504 | public Set<FSObject> getAllValuesOfchild() { | ||
505 | return rawStreamAllValuesOfchild(emptyArray()).collect(Collectors.toSet()); | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * Retrieve the set of values that occur in matches for child. | ||
510 | * @return the Set of all values or empty set if there are no matches | ||
511 | * | ||
512 | */ | ||
513 | public Stream<FSObject> streamAllValuesOfchild() { | ||
514 | return rawStreamAllValuesOfchild(emptyArray()); | ||
515 | } | ||
516 | |||
517 | /** | ||
518 | * Retrieve the set of values that occur in matches for child. | ||
519 | * </p> | ||
520 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
521 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
522 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
523 | * | ||
524 | * @return the Stream of all values or empty set if there are no matches | ||
525 | * | ||
526 | */ | ||
527 | public Stream<FSObject> streamAllValuesOfchild(final ContentInNotLive.Match partialMatch) { | ||
528 | return rawStreamAllValuesOfchild(partialMatch.toArray()); | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Retrieve the set of values that occur in matches for child. | ||
533 | * </p> | ||
534 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
535 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
536 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
537 | * | ||
538 | * @return the Stream of all values or empty set if there are no matches | ||
539 | * | ||
540 | */ | ||
541 | public Stream<FSObject> streamAllValuesOfchild(final Dir pParent) { | ||
542 | return rawStreamAllValuesOfchild(new Object[]{pParent, null}); | ||
543 | } | ||
544 | |||
545 | /** | ||
546 | * Retrieve the set of values that occur in matches for child. | ||
547 | * @return the Set of all values or empty set if there are no matches | ||
548 | * | ||
549 | */ | ||
550 | public Set<FSObject> getAllValuesOfchild(final ContentInNotLive.Match partialMatch) { | ||
551 | return rawStreamAllValuesOfchild(partialMatch.toArray()).collect(Collectors.toSet()); | ||
552 | } | ||
553 | |||
554 | /** | ||
555 | * Retrieve the set of values that occur in matches for child. | ||
556 | * @return the Set of all values or empty set if there are no matches | ||
557 | * | ||
558 | */ | ||
559 | public Set<FSObject> getAllValuesOfchild(final Dir pParent) { | ||
560 | return rawStreamAllValuesOfchild(new Object[]{pParent, null}).collect(Collectors.toSet()); | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected ContentInNotLive.Match tupleToMatch(final Tuple t) { | ||
565 | try { | ||
566 | return ContentInNotLive.Match.newMatch((Dir) t.get(POSITION_PARENT), (FSObject) t.get(POSITION_CHILD)); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected ContentInNotLive.Match arrayToMatch(final Object[] match) { | ||
575 | try { | ||
576 | return ContentInNotLive.Match.newMatch((Dir) match[POSITION_PARENT], (FSObject) match[POSITION_CHILD]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | @Override | ||
584 | protected ContentInNotLive.Match arrayToMatchMutable(final Object[] match) { | ||
585 | try { | ||
586 | return ContentInNotLive.Match.newMutableMatch((Dir) match[POSITION_PARENT], (FSObject) match[POSITION_CHILD]); | ||
587 | } catch(ClassCastException e) { | ||
588 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
589 | return null; | ||
590 | } | ||
591 | } | ||
592 | |||
593 | /** | ||
594 | * @return the singleton instance of the query specification of this pattern | ||
595 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
596 | * | ||
597 | */ | ||
598 | public static IQuerySpecification<ContentInNotLive.Matcher> querySpecification() { | ||
599 | return ContentInNotLive.instance(); | ||
600 | } | ||
601 | } | ||
602 | |||
603 | private ContentInNotLive() { | ||
604 | super(GeneratedPQuery.INSTANCE); | ||
605 | } | ||
606 | |||
607 | /** | ||
608 | * @return the singleton instance of the query specification | ||
609 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
610 | * | ||
611 | */ | ||
612 | public static ContentInNotLive instance() { | ||
613 | try{ | ||
614 | return LazyHolder.INSTANCE; | ||
615 | } catch (ExceptionInInitializerError err) { | ||
616 | throw processInitializerError(err); | ||
617 | } | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | protected ContentInNotLive.Matcher instantiate(final ViatraQueryEngine engine) { | ||
622 | return ContentInNotLive.Matcher.on(engine); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public ContentInNotLive.Matcher instantiate() { | ||
627 | return ContentInNotLive.Matcher.create(); | ||
628 | } | ||
629 | |||
630 | @Override | ||
631 | public ContentInNotLive.Match newEmptyMatch() { | ||
632 | return ContentInNotLive.Match.newEmptyMatch(); | ||
633 | } | ||
634 | |||
635 | @Override | ||
636 | public ContentInNotLive.Match newMatch(final Object... parameters) { | ||
637 | return ContentInNotLive.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject) parameters[1]); | ||
638 | } | ||
639 | |||
640 | /** | ||
641 | * Inner class allowing the singleton instance of {@link ContentInNotLive} to be created | ||
642 | * <b>not</b> at the class load time of the outer class, | ||
643 | * but rather at the first call to {@link ContentInNotLive#instance()}. | ||
644 | * | ||
645 | * <p> This workaround is required e.g. to support recursion. | ||
646 | * | ||
647 | */ | ||
648 | private static class LazyHolder { | ||
649 | private static final ContentInNotLive INSTANCE = new ContentInNotLive(); | ||
650 | |||
651 | /** | ||
652 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
653 | * This initialization order is required to support indirect recursion. | ||
654 | * | ||
655 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
656 | * | ||
657 | */ | ||
658 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
659 | |||
660 | public static Object ensureInitialized() { | ||
661 | INSTANCE.ensureInitializedInternal(); | ||
662 | return null; | ||
663 | } | ||
664 | } | ||
665 | |||
666 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
667 | private static final ContentInNotLive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
668 | |||
669 | private final PParameter parameter_parent = new PParameter("parent", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "Dir")), PParameterDirection.INOUT); | ||
670 | |||
671 | private final PParameter parameter_child = new PParameter("child", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FSObject")), PParameterDirection.INOUT); | ||
672 | |||
673 | private final List<PParameter> parameters = Arrays.asList(parameter_parent, parameter_child); | ||
674 | |||
675 | private GeneratedPQuery() { | ||
676 | super(PVisibility.PUBLIC); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public String getFullyQualifiedName() { | ||
681 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive"; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public List<String> getParameterNames() { | ||
686 | return Arrays.asList("parent","child"); | ||
687 | } | ||
688 | |||
689 | @Override | ||
690 | public List<PParameter> getParameters() { | ||
691 | return parameters; | ||
692 | } | ||
693 | |||
694 | @Override | ||
695 | public Set<PBody> doGetContainedBodies() { | ||
696 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
697 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
698 | { | ||
699 | PBody body = new PBody(this); | ||
700 | PVariable var_parent = body.getOrCreateVariableByName("parent"); | ||
701 | PVariable var_child = body.getOrCreateVariableByName("child"); | ||
702 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
703 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
704 | new TypeConstraint(body, Tuples.flatTupleOf(var_child), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
705 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
706 | new ExportedParameter(body, var_parent, parameter_parent), | ||
707 | new ExportedParameter(body, var_child, parameter_child) | ||
708 | )); | ||
709 | // Dir.contents(parent,child) | ||
710 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
711 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
712 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "Dir", "contents"))); | ||
713 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
714 | new Equality(body, var__virtual_0_, var_child); | ||
715 | // neg find live(_,parent) | ||
716 | new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_parent), Live.instance().getInternalQueryRepresentation()); | ||
717 | bodies.add(body); | ||
718 | } | ||
719 | { | ||
720 | PBody body = new PBody(this); | ||
721 | PVariable var_parent = body.getOrCreateVariableByName("parent"); | ||
722 | PVariable var_child = body.getOrCreateVariableByName("child"); | ||
723 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
724 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
725 | new TypeConstraint(body, Tuples.flatTupleOf(var_child), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
726 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
727 | new ExportedParameter(body, var_parent, parameter_parent), | ||
728 | new ExportedParameter(body, var_child, parameter_child) | ||
729 | )); | ||
730 | // Dir.contents(parent,child) | ||
731 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
732 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
733 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "Dir", "contents"))); | ||
734 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
735 | new Equality(body, var__virtual_0_, var_child); | ||
736 | // neg find live(_,child) | ||
737 | new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_child), Live.instance().getInternalQueryRepresentation()); | ||
738 | bodies.add(body); | ||
739 | } | ||
740 | { | ||
741 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
742 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
743 | new ParameterReference("child") | ||
744 | })); | ||
745 | annotation.addAttribute("severity", "error"); | ||
746 | annotation.addAttribute("message", "error"); | ||
747 | addAnnotation(annotation); | ||
748 | } | ||
749 | return bodies; | ||
750 | } | ||
751 | } | ||
752 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/DirectSupertype.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/DirectSupertype.java new file mode 100644 index 00000000..72c31e34 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/DirectSupertype.java | |||
@@ -0,0 +1,703 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import org.apache.log4j.Logger; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
38 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
39 | |||
40 | /** | ||
41 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
42 | * | ||
43 | * <p>Original source: | ||
44 | * <code><pre> | ||
45 | * pattern directSupertype(a: EClass, b:EClass) { | ||
46 | * EClass.eSuperTypes(a,b); | ||
47 | * } | ||
48 | * </pre></code> | ||
49 | * | ||
50 | * @see Matcher | ||
51 | * @see Match | ||
52 | * | ||
53 | */ | ||
54 | @SuppressWarnings("all") | ||
55 | public final class DirectSupertype extends BaseGeneratedEMFQuerySpecification<DirectSupertype.Matcher> { | ||
56 | /** | ||
57 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.directSupertype pattern, | ||
58 | * to be used in conjunction with {@link Matcher}. | ||
59 | * | ||
60 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
61 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
62 | * usable to represent a match of the pattern in the result of a query, | ||
63 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
64 | * | ||
65 | * @see Matcher | ||
66 | * | ||
67 | */ | ||
68 | public static abstract class Match extends BasePatternMatch { | ||
69 | private EClass fA; | ||
70 | |||
71 | private EClass fB; | ||
72 | |||
73 | private static List<String> parameterNames = makeImmutableList("a", "b"); | ||
74 | |||
75 | private Match(final EClass pA, final EClass pB) { | ||
76 | this.fA = pA; | ||
77 | this.fB = pB; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | switch(parameterName) { | ||
83 | case "a": return this.fA; | ||
84 | case "b": return this.fB; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fA; | ||
93 | case 1: return this.fB; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public EClass getA() { | ||
99 | return this.fA; | ||
100 | } | ||
101 | |||
102 | public EClass getB() { | ||
103 | return this.fB; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("a".equals(parameterName) ) { | ||
110 | this.fA = (EClass) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | if ("b".equals(parameterName) ) { | ||
114 | this.fB = (EClass) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | public void setA(final EClass pA) { | ||
121 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
122 | this.fA = pA; | ||
123 | } | ||
124 | |||
125 | public void setB(final EClass pB) { | ||
126 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
127 | this.fB = pB; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public String patternName() { | ||
132 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.directSupertype"; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public List<String> parameterNames() { | ||
137 | return DirectSupertype.Match.parameterNames; | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public Object[] toArray() { | ||
142 | return new Object[]{fA, fB}; | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public DirectSupertype.Match toImmutable() { | ||
147 | return isMutable() ? newMatch(fA, fB) : this; | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public String prettyPrint() { | ||
152 | StringBuilder result = new StringBuilder(); | ||
153 | result.append("\"a\"=" + prettyPrintValue(fA) + ", "); | ||
154 | result.append("\"b\"=" + prettyPrintValue(fB)); | ||
155 | return result.toString(); | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | public int hashCode() { | ||
160 | return Objects.hash(fA, fB); | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public boolean equals(final Object obj) { | ||
165 | if (this == obj) | ||
166 | return true; | ||
167 | if (obj == null) { | ||
168 | return false; | ||
169 | } | ||
170 | if ((obj instanceof DirectSupertype.Match)) { | ||
171 | DirectSupertype.Match other = (DirectSupertype.Match) obj; | ||
172 | return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB); | ||
173 | } else { | ||
174 | // this should be infrequent | ||
175 | if (!(obj instanceof IPatternMatch)) { | ||
176 | return false; | ||
177 | } | ||
178 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
179 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | @Override | ||
184 | public DirectSupertype specification() { | ||
185 | return DirectSupertype.instance(); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Returns an empty, mutable match. | ||
190 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
191 | * | ||
192 | * @return the empty match. | ||
193 | * | ||
194 | */ | ||
195 | public static DirectSupertype.Match newEmptyMatch() { | ||
196 | return new Mutable(null, null); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a mutable (partial) match. | ||
201 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
202 | * | ||
203 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
204 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
205 | * @return the new, mutable (partial) match object. | ||
206 | * | ||
207 | */ | ||
208 | public static DirectSupertype.Match newMutableMatch(final EClass pA, final EClass pB) { | ||
209 | return new Mutable(pA, pB); | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * Returns a new (partial) match. | ||
214 | * This can be used e.g. to call the matcher with a partial match. | ||
215 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
216 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
217 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
218 | * @return the (partial) match object. | ||
219 | * | ||
220 | */ | ||
221 | public static DirectSupertype.Match newMatch(final EClass pA, final EClass pB) { | ||
222 | return new Immutable(pA, pB); | ||
223 | } | ||
224 | |||
225 | private static final class Mutable extends DirectSupertype.Match { | ||
226 | Mutable(final EClass pA, final EClass pB) { | ||
227 | super(pA, pB); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return true; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | private static final class Immutable extends DirectSupertype.Match { | ||
237 | Immutable(final EClass pA, final EClass pB) { | ||
238 | super(pA, pB); | ||
239 | } | ||
240 | |||
241 | @Override | ||
242 | public boolean isMutable() { | ||
243 | return false; | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.directSupertype pattern, | ||
250 | * providing pattern-specific query methods. | ||
251 | * | ||
252 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
253 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
254 | * | ||
255 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
256 | * | ||
257 | * <p>Original source: | ||
258 | * <code><pre> | ||
259 | * pattern directSupertype(a: EClass, b:EClass) { | ||
260 | * EClass.eSuperTypes(a,b); | ||
261 | * } | ||
262 | * </pre></code> | ||
263 | * | ||
264 | * @see Match | ||
265 | * @see DirectSupertype | ||
266 | * | ||
267 | */ | ||
268 | public static class Matcher extends BaseMatcher<DirectSupertype.Match> { | ||
269 | /** | ||
270 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
271 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
272 | * | ||
273 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
274 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
275 | * | ||
276 | */ | ||
277 | public static DirectSupertype.Matcher on(final ViatraQueryEngine engine) { | ||
278 | // check if matcher already exists | ||
279 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
280 | if (matcher == null) { | ||
281 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
282 | } | ||
283 | return matcher; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
288 | * @return an initialized matcher | ||
289 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
290 | * | ||
291 | */ | ||
292 | public static DirectSupertype.Matcher create() { | ||
293 | return new Matcher(); | ||
294 | } | ||
295 | |||
296 | private static final int POSITION_A = 0; | ||
297 | |||
298 | private static final int POSITION_B = 1; | ||
299 | |||
300 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(DirectSupertype.Matcher.class); | ||
301 | |||
302 | /** | ||
303 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
304 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
305 | * | ||
306 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
307 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
308 | * | ||
309 | */ | ||
310 | private Matcher() { | ||
311 | super(querySpecification()); | ||
312 | } | ||
313 | |||
314 | /** | ||
315 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
316 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
317 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
318 | * @return matches represented as a Match object. | ||
319 | * | ||
320 | */ | ||
321 | public Collection<DirectSupertype.Match> getAllMatches(final EClass pA, final EClass pB) { | ||
322 | return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet()); | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
327 | * </p> | ||
328 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
329 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
330 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
331 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
332 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
333 | * @return a stream of matches represented as a Match object. | ||
334 | * | ||
335 | */ | ||
336 | public Stream<DirectSupertype.Match> streamAllMatches(final EClass pA, final EClass pB) { | ||
337 | return rawStreamAllMatches(new Object[]{pA, pB}); | ||
338 | } | ||
339 | |||
340 | /** | ||
341 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
342 | * Neither determinism nor randomness of selection is guaranteed. | ||
343 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
344 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
345 | * @return a match represented as a Match object, or null if no match is found. | ||
346 | * | ||
347 | */ | ||
348 | public Optional<DirectSupertype.Match> getOneArbitraryMatch(final EClass pA, final EClass pB) { | ||
349 | return rawGetOneArbitraryMatch(new Object[]{pA, pB}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
354 | * under any possible substitution of the unspecified parameters (if any). | ||
355 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
356 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
357 | * @return true if the input is a valid (partial) match of the pattern. | ||
358 | * | ||
359 | */ | ||
360 | public boolean hasMatch(final EClass pA, final EClass pB) { | ||
361 | return rawHasMatch(new Object[]{pA, pB}); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
366 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
367 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
368 | * @return the number of pattern matches found. | ||
369 | * | ||
370 | */ | ||
371 | public int countMatches(final EClass pA, final EClass pB) { | ||
372 | return rawCountMatches(new Object[]{pA, pB}); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
377 | * Neither determinism nor randomness of selection is guaranteed. | ||
378 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
379 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
380 | * @param processor the action that will process the selected match. | ||
381 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
382 | * | ||
383 | */ | ||
384 | public boolean forOneArbitraryMatch(final EClass pA, final EClass pB, final Consumer<? super DirectSupertype.Match> processor) { | ||
385 | return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor); | ||
386 | } | ||
387 | |||
388 | /** | ||
389 | * Returns a new (partial) match. | ||
390 | * This can be used e.g. to call the matcher with a partial match. | ||
391 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
392 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
393 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
394 | * @return the (partial) match object. | ||
395 | * | ||
396 | */ | ||
397 | public DirectSupertype.Match newMatch(final EClass pA, final EClass pB) { | ||
398 | return DirectSupertype.Match.newMatch(pA, pB); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for a. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | protected Stream<EClass> rawStreamAllValuesOfa(final Object[] parameters) { | ||
407 | return rawStreamAllValues(POSITION_A, parameters).map(EClass.class::cast); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * Retrieve the set of values that occur in matches for a. | ||
412 | * @return the Set of all values or empty set if there are no matches | ||
413 | * | ||
414 | */ | ||
415 | public Set<EClass> getAllValuesOfa() { | ||
416 | return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Retrieve the set of values that occur in matches for a. | ||
421 | * @return the Set of all values or empty set if there are no matches | ||
422 | * | ||
423 | */ | ||
424 | public Stream<EClass> streamAllValuesOfa() { | ||
425 | return rawStreamAllValuesOfa(emptyArray()); | ||
426 | } | ||
427 | |||
428 | /** | ||
429 | * Retrieve the set of values that occur in matches for a. | ||
430 | * </p> | ||
431 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
432 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
433 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
434 | * | ||
435 | * @return the Stream of all values or empty set if there are no matches | ||
436 | * | ||
437 | */ | ||
438 | public Stream<EClass> streamAllValuesOfa(final DirectSupertype.Match partialMatch) { | ||
439 | return rawStreamAllValuesOfa(partialMatch.toArray()); | ||
440 | } | ||
441 | |||
442 | /** | ||
443 | * Retrieve the set of values that occur in matches for a. | ||
444 | * </p> | ||
445 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
446 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
447 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
448 | * | ||
449 | * @return the Stream of all values or empty set if there are no matches | ||
450 | * | ||
451 | */ | ||
452 | public Stream<EClass> streamAllValuesOfa(final EClass pB) { | ||
453 | return rawStreamAllValuesOfa(new Object[]{null, pB}); | ||
454 | } | ||
455 | |||
456 | /** | ||
457 | * Retrieve the set of values that occur in matches for a. | ||
458 | * @return the Set of all values or empty set if there are no matches | ||
459 | * | ||
460 | */ | ||
461 | public Set<EClass> getAllValuesOfa(final DirectSupertype.Match partialMatch) { | ||
462 | return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet()); | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * Retrieve the set of values that occur in matches for a. | ||
467 | * @return the Set of all values or empty set if there are no matches | ||
468 | * | ||
469 | */ | ||
470 | public Set<EClass> getAllValuesOfa(final EClass pB) { | ||
471 | return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet()); | ||
472 | } | ||
473 | |||
474 | /** | ||
475 | * Retrieve the set of values that occur in matches for b. | ||
476 | * @return the Set of all values or empty set if there are no matches | ||
477 | * | ||
478 | */ | ||
479 | protected Stream<EClass> rawStreamAllValuesOfb(final Object[] parameters) { | ||
480 | return rawStreamAllValues(POSITION_B, parameters).map(EClass.class::cast); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * Retrieve the set of values that occur in matches for b. | ||
485 | * @return the Set of all values or empty set if there are no matches | ||
486 | * | ||
487 | */ | ||
488 | public Set<EClass> getAllValuesOfb() { | ||
489 | return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet()); | ||
490 | } | ||
491 | |||
492 | /** | ||
493 | * Retrieve the set of values that occur in matches for b. | ||
494 | * @return the Set of all values or empty set if there are no matches | ||
495 | * | ||
496 | */ | ||
497 | public Stream<EClass> streamAllValuesOfb() { | ||
498 | return rawStreamAllValuesOfb(emptyArray()); | ||
499 | } | ||
500 | |||
501 | /** | ||
502 | * Retrieve the set of values that occur in matches for b. | ||
503 | * </p> | ||
504 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
505 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
506 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
507 | * | ||
508 | * @return the Stream of all values or empty set if there are no matches | ||
509 | * | ||
510 | */ | ||
511 | public Stream<EClass> streamAllValuesOfb(final DirectSupertype.Match partialMatch) { | ||
512 | return rawStreamAllValuesOfb(partialMatch.toArray()); | ||
513 | } | ||
514 | |||
515 | /** | ||
516 | * Retrieve the set of values that occur in matches for b. | ||
517 | * </p> | ||
518 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
519 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
520 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
521 | * | ||
522 | * @return the Stream of all values or empty set if there are no matches | ||
523 | * | ||
524 | */ | ||
525 | public Stream<EClass> streamAllValuesOfb(final EClass pA) { | ||
526 | return rawStreamAllValuesOfb(new Object[]{pA, null}); | ||
527 | } | ||
528 | |||
529 | /** | ||
530 | * Retrieve the set of values that occur in matches for b. | ||
531 | * @return the Set of all values or empty set if there are no matches | ||
532 | * | ||
533 | */ | ||
534 | public Set<EClass> getAllValuesOfb(final DirectSupertype.Match partialMatch) { | ||
535 | return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet()); | ||
536 | } | ||
537 | |||
538 | /** | ||
539 | * Retrieve the set of values that occur in matches for b. | ||
540 | * @return the Set of all values or empty set if there are no matches | ||
541 | * | ||
542 | */ | ||
543 | public Set<EClass> getAllValuesOfb(final EClass pA) { | ||
544 | return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet()); | ||
545 | } | ||
546 | |||
547 | @Override | ||
548 | protected DirectSupertype.Match tupleToMatch(final Tuple t) { | ||
549 | try { | ||
550 | return DirectSupertype.Match.newMatch((EClass) t.get(POSITION_A), (EClass) t.get(POSITION_B)); | ||
551 | } catch(ClassCastException e) { | ||
552 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
553 | return null; | ||
554 | } | ||
555 | } | ||
556 | |||
557 | @Override | ||
558 | protected DirectSupertype.Match arrayToMatch(final Object[] match) { | ||
559 | try { | ||
560 | return DirectSupertype.Match.newMatch((EClass) match[POSITION_A], (EClass) match[POSITION_B]); | ||
561 | } catch(ClassCastException e) { | ||
562 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
563 | return null; | ||
564 | } | ||
565 | } | ||
566 | |||
567 | @Override | ||
568 | protected DirectSupertype.Match arrayToMatchMutable(final Object[] match) { | ||
569 | try { | ||
570 | return DirectSupertype.Match.newMutableMatch((EClass) match[POSITION_A], (EClass) match[POSITION_B]); | ||
571 | } catch(ClassCastException e) { | ||
572 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
573 | return null; | ||
574 | } | ||
575 | } | ||
576 | |||
577 | /** | ||
578 | * @return the singleton instance of the query specification of this pattern | ||
579 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
580 | * | ||
581 | */ | ||
582 | public static IQuerySpecification<DirectSupertype.Matcher> querySpecification() { | ||
583 | return DirectSupertype.instance(); | ||
584 | } | ||
585 | } | ||
586 | |||
587 | private DirectSupertype() { | ||
588 | super(GeneratedPQuery.INSTANCE); | ||
589 | } | ||
590 | |||
591 | /** | ||
592 | * @return the singleton instance of the query specification | ||
593 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
594 | * | ||
595 | */ | ||
596 | public static DirectSupertype instance() { | ||
597 | try{ | ||
598 | return LazyHolder.INSTANCE; | ||
599 | } catch (ExceptionInInitializerError err) { | ||
600 | throw processInitializerError(err); | ||
601 | } | ||
602 | } | ||
603 | |||
604 | @Override | ||
605 | protected DirectSupertype.Matcher instantiate(final ViatraQueryEngine engine) { | ||
606 | return DirectSupertype.Matcher.on(engine); | ||
607 | } | ||
608 | |||
609 | @Override | ||
610 | public DirectSupertype.Matcher instantiate() { | ||
611 | return DirectSupertype.Matcher.create(); | ||
612 | } | ||
613 | |||
614 | @Override | ||
615 | public DirectSupertype.Match newEmptyMatch() { | ||
616 | return DirectSupertype.Match.newEmptyMatch(); | ||
617 | } | ||
618 | |||
619 | @Override | ||
620 | public DirectSupertype.Match newMatch(final Object... parameters) { | ||
621 | return DirectSupertype.Match.newMatch((org.eclipse.emf.ecore.EClass) parameters[0], (org.eclipse.emf.ecore.EClass) parameters[1]); | ||
622 | } | ||
623 | |||
624 | /** | ||
625 | * Inner class allowing the singleton instance of {@link DirectSupertype} to be created | ||
626 | * <b>not</b> at the class load time of the outer class, | ||
627 | * but rather at the first call to {@link DirectSupertype#instance()}. | ||
628 | * | ||
629 | * <p> This workaround is required e.g. to support recursion. | ||
630 | * | ||
631 | */ | ||
632 | private static class LazyHolder { | ||
633 | private static final DirectSupertype INSTANCE = new DirectSupertype(); | ||
634 | |||
635 | /** | ||
636 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
637 | * This initialization order is required to support indirect recursion. | ||
638 | * | ||
639 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
640 | * | ||
641 | */ | ||
642 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
643 | |||
644 | public static Object ensureInitialized() { | ||
645 | INSTANCE.ensureInitializedInternal(); | ||
646 | return null; | ||
647 | } | ||
648 | } | ||
649 | |||
650 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
651 | private static final DirectSupertype.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
652 | |||
653 | private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EClass")), PParameterDirection.INOUT); | ||
654 | |||
655 | private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EClass")), PParameterDirection.INOUT); | ||
656 | |||
657 | private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b); | ||
658 | |||
659 | private GeneratedPQuery() { | ||
660 | super(PVisibility.PUBLIC); | ||
661 | } | ||
662 | |||
663 | @Override | ||
664 | public String getFullyQualifiedName() { | ||
665 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.directSupertype"; | ||
666 | } | ||
667 | |||
668 | @Override | ||
669 | public List<String> getParameterNames() { | ||
670 | return Arrays.asList("a","b"); | ||
671 | } | ||
672 | |||
673 | @Override | ||
674 | public List<PParameter> getParameters() { | ||
675 | return parameters; | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | public Set<PBody> doGetContainedBodies() { | ||
680 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
681 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
682 | { | ||
683 | PBody body = new PBody(this); | ||
684 | PVariable var_a = body.getOrCreateVariableByName("a"); | ||
685 | PVariable var_b = body.getOrCreateVariableByName("b"); | ||
686 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); | ||
687 | new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); | ||
688 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
689 | new ExportedParameter(body, var_a, parameter_a), | ||
690 | new ExportedParameter(body, var_b, parameter_b) | ||
691 | )); | ||
692 | // EClass.eSuperTypes(a,b) | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); | ||
694 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
695 | new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass", "eSuperTypes"))); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); | ||
697 | new Equality(body, var__virtual_0_, var_b); | ||
698 | bodies.add(body); | ||
699 | } | ||
700 | return bodies; | ||
701 | } | ||
702 | } | ||
703 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Live.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Live.java new file mode 100644 index 00000000..3f2448aa --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Live.java | |||
@@ -0,0 +1,741 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/FileSystem.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FileSystem; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.PatternContent; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
43 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
44 | |||
45 | /** | ||
46 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
47 | * | ||
48 | * <p>Original source: | ||
49 | * <code><pre> | ||
50 | * {@literal @}QueryBasedFeature | ||
51 | * pattern live(this: FileSystem, l: FSObject) { | ||
52 | * FileSystem.root(this,l); | ||
53 | * } or { | ||
54 | * FileSystem.root(this,root); | ||
55 | * find patternContent+(root,l); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class Live extends BaseGeneratedEMFQuerySpecification<Live.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private FileSystem fThis; | ||
79 | |||
80 | private FSObject fL; | ||
81 | |||
82 | private static List<String> parameterNames = makeImmutableList("this", "l"); | ||
83 | |||
84 | private Match(final FileSystem pThis, final FSObject pL) { | ||
85 | this.fThis = pThis; | ||
86 | this.fL = pL; | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final String parameterName) { | ||
91 | switch(parameterName) { | ||
92 | case "this": return this.fThis; | ||
93 | case "l": return this.fL; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final int index) { | ||
100 | switch(index) { | ||
101 | case 0: return this.fThis; | ||
102 | case 1: return this.fL; | ||
103 | default: return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public FileSystem getThis() { | ||
108 | return this.fThis; | ||
109 | } | ||
110 | |||
111 | public FSObject getL() { | ||
112 | return this.fL; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public boolean set(final String parameterName, final Object newValue) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | if ("this".equals(parameterName) ) { | ||
119 | this.fThis = (FileSystem) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | if ("l".equals(parameterName) ) { | ||
123 | this.fL = (FSObject) newValue; | ||
124 | return true; | ||
125 | } | ||
126 | return false; | ||
127 | } | ||
128 | |||
129 | public void setThis(final FileSystem pThis) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fThis = pThis; | ||
132 | } | ||
133 | |||
134 | public void setL(final FSObject pL) { | ||
135 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
136 | this.fL = pL; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String patternName() { | ||
141 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live"; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public List<String> parameterNames() { | ||
146 | return Live.Match.parameterNames; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Object[] toArray() { | ||
151 | return new Object[]{fThis, fL}; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public Live.Match toImmutable() { | ||
156 | return isMutable() ? newMatch(fThis, fL) : this; | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public String prettyPrint() { | ||
161 | StringBuilder result = new StringBuilder(); | ||
162 | result.append("\"this\"=" + prettyPrintValue(fThis) + ", "); | ||
163 | result.append("\"l\"=" + prettyPrintValue(fL)); | ||
164 | return result.toString(); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public int hashCode() { | ||
169 | return Objects.hash(fThis, fL); | ||
170 | } | ||
171 | |||
172 | @Override | ||
173 | public boolean equals(final Object obj) { | ||
174 | if (this == obj) | ||
175 | return true; | ||
176 | if (obj == null) { | ||
177 | return false; | ||
178 | } | ||
179 | if ((obj instanceof Live.Match)) { | ||
180 | Live.Match other = (Live.Match) obj; | ||
181 | return Objects.equals(fThis, other.fThis) && Objects.equals(fL, other.fL); | ||
182 | } else { | ||
183 | // this should be infrequent | ||
184 | if (!(obj instanceof IPatternMatch)) { | ||
185 | return false; | ||
186 | } | ||
187 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
188 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | @Override | ||
193 | public Live specification() { | ||
194 | return Live.instance(); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Returns an empty, mutable match. | ||
199 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
200 | * | ||
201 | * @return the empty match. | ||
202 | * | ||
203 | */ | ||
204 | public static Live.Match newEmptyMatch() { | ||
205 | return new Mutable(null, null); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * Returns a mutable (partial) match. | ||
210 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
211 | * | ||
212 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
213 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
214 | * @return the new, mutable (partial) match object. | ||
215 | * | ||
216 | */ | ||
217 | public static Live.Match newMutableMatch(final FileSystem pThis, final FSObject pL) { | ||
218 | return new Mutable(pThis, pL); | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * Returns a new (partial) match. | ||
223 | * This can be used e.g. to call the matcher with a partial match. | ||
224 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
225 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
226 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
227 | * @return the (partial) match object. | ||
228 | * | ||
229 | */ | ||
230 | public static Live.Match newMatch(final FileSystem pThis, final FSObject pL) { | ||
231 | return new Immutable(pThis, pL); | ||
232 | } | ||
233 | |||
234 | private static final class Mutable extends Live.Match { | ||
235 | Mutable(final FileSystem pThis, final FSObject pL) { | ||
236 | super(pThis, pL); | ||
237 | } | ||
238 | |||
239 | @Override | ||
240 | public boolean isMutable() { | ||
241 | return true; | ||
242 | } | ||
243 | } | ||
244 | |||
245 | private static final class Immutable extends Live.Match { | ||
246 | Immutable(final FileSystem pThis, final FSObject pL) { | ||
247 | super(pThis, pL); | ||
248 | } | ||
249 | |||
250 | @Override | ||
251 | public boolean isMutable() { | ||
252 | return false; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | /** | ||
258 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live pattern, | ||
259 | * providing pattern-specific query methods. | ||
260 | * | ||
261 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
262 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
263 | * | ||
264 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
265 | * | ||
266 | * <p>Original source: | ||
267 | * <code><pre> | ||
268 | * {@literal @}QueryBasedFeature | ||
269 | * pattern live(this: FileSystem, l: FSObject) { | ||
270 | * FileSystem.root(this,l); | ||
271 | * } or { | ||
272 | * FileSystem.root(this,root); | ||
273 | * find patternContent+(root,l); | ||
274 | * } | ||
275 | * </pre></code> | ||
276 | * | ||
277 | * @see Match | ||
278 | * @see Live | ||
279 | * | ||
280 | */ | ||
281 | public static class Matcher extends BaseMatcher<Live.Match> { | ||
282 | /** | ||
283 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
284 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
285 | * | ||
286 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
287 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
288 | * | ||
289 | */ | ||
290 | public static Live.Matcher on(final ViatraQueryEngine engine) { | ||
291 | // check if matcher already exists | ||
292 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
293 | if (matcher == null) { | ||
294 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
295 | } | ||
296 | return matcher; | ||
297 | } | ||
298 | |||
299 | /** | ||
300 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
301 | * @return an initialized matcher | ||
302 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
303 | * | ||
304 | */ | ||
305 | public static Live.Matcher create() { | ||
306 | return new Matcher(); | ||
307 | } | ||
308 | |||
309 | private static final int POSITION_THIS = 0; | ||
310 | |||
311 | private static final int POSITION_L = 1; | ||
312 | |||
313 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Live.Matcher.class); | ||
314 | |||
315 | /** | ||
316 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
317 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
318 | * | ||
319 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
320 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
321 | * | ||
322 | */ | ||
323 | private Matcher() { | ||
324 | super(querySpecification()); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
329 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
330 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
331 | * @return matches represented as a Match object. | ||
332 | * | ||
333 | */ | ||
334 | public Collection<Live.Match> getAllMatches(final FileSystem pThis, final FSObject pL) { | ||
335 | return rawStreamAllMatches(new Object[]{pThis, pL}).collect(Collectors.toSet()); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
340 | * </p> | ||
341 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
342 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
343 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
344 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
345 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
346 | * @return a stream of matches represented as a Match object. | ||
347 | * | ||
348 | */ | ||
349 | public Stream<Live.Match> streamAllMatches(final FileSystem pThis, final FSObject pL) { | ||
350 | return rawStreamAllMatches(new Object[]{pThis, pL}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
355 | * Neither determinism nor randomness of selection is guaranteed. | ||
356 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
357 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
358 | * @return a match represented as a Match object, or null if no match is found. | ||
359 | * | ||
360 | */ | ||
361 | public Optional<Live.Match> getOneArbitraryMatch(final FileSystem pThis, final FSObject pL) { | ||
362 | return rawGetOneArbitraryMatch(new Object[]{pThis, pL}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
367 | * under any possible substitution of the unspecified parameters (if any). | ||
368 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
369 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
370 | * @return true if the input is a valid (partial) match of the pattern. | ||
371 | * | ||
372 | */ | ||
373 | public boolean hasMatch(final FileSystem pThis, final FSObject pL) { | ||
374 | return rawHasMatch(new Object[]{pThis, pL}); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
379 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
380 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
381 | * @return the number of pattern matches found. | ||
382 | * | ||
383 | */ | ||
384 | public int countMatches(final FileSystem pThis, final FSObject pL) { | ||
385 | return rawCountMatches(new Object[]{pThis, pL}); | ||
386 | } | ||
387 | |||
388 | /** | ||
389 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
390 | * Neither determinism nor randomness of selection is guaranteed. | ||
391 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
392 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
393 | * @param processor the action that will process the selected match. | ||
394 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
395 | * | ||
396 | */ | ||
397 | public boolean forOneArbitraryMatch(final FileSystem pThis, final FSObject pL, final Consumer<? super Live.Match> processor) { | ||
398 | return rawForOneArbitraryMatch(new Object[]{pThis, pL}, processor); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Returns a new (partial) match. | ||
403 | * This can be used e.g. to call the matcher with a partial match. | ||
404 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
405 | * @param pThis the fixed value of pattern parameter this, or null if not bound. | ||
406 | * @param pL the fixed value of pattern parameter l, or null if not bound. | ||
407 | * @return the (partial) match object. | ||
408 | * | ||
409 | */ | ||
410 | public Live.Match newMatch(final FileSystem pThis, final FSObject pL) { | ||
411 | return Live.Match.newMatch(pThis, pL); | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | * Retrieve the set of values that occur in matches for this. | ||
416 | * @return the Set of all values or empty set if there are no matches | ||
417 | * | ||
418 | */ | ||
419 | protected Stream<FileSystem> rawStreamAllValuesOfthis(final Object[] parameters) { | ||
420 | return rawStreamAllValues(POSITION_THIS, parameters).map(FileSystem.class::cast); | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * Retrieve the set of values that occur in matches for this. | ||
425 | * @return the Set of all values or empty set if there are no matches | ||
426 | * | ||
427 | */ | ||
428 | public Set<FileSystem> getAllValuesOfthis() { | ||
429 | return rawStreamAllValuesOfthis(emptyArray()).collect(Collectors.toSet()); | ||
430 | } | ||
431 | |||
432 | /** | ||
433 | * Retrieve the set of values that occur in matches for this. | ||
434 | * @return the Set of all values or empty set if there are no matches | ||
435 | * | ||
436 | */ | ||
437 | public Stream<FileSystem> streamAllValuesOfthis() { | ||
438 | return rawStreamAllValuesOfthis(emptyArray()); | ||
439 | } | ||
440 | |||
441 | /** | ||
442 | * Retrieve the set of values that occur in matches for this. | ||
443 | * </p> | ||
444 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
445 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
446 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
447 | * | ||
448 | * @return the Stream of all values or empty set if there are no matches | ||
449 | * | ||
450 | */ | ||
451 | public Stream<FileSystem> streamAllValuesOfthis(final Live.Match partialMatch) { | ||
452 | return rawStreamAllValuesOfthis(partialMatch.toArray()); | ||
453 | } | ||
454 | |||
455 | /** | ||
456 | * Retrieve the set of values that occur in matches for this. | ||
457 | * </p> | ||
458 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
459 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
460 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
461 | * | ||
462 | * @return the Stream of all values or empty set if there are no matches | ||
463 | * | ||
464 | */ | ||
465 | public Stream<FileSystem> streamAllValuesOfthis(final FSObject pL) { | ||
466 | return rawStreamAllValuesOfthis(new Object[]{null, pL}); | ||
467 | } | ||
468 | |||
469 | /** | ||
470 | * Retrieve the set of values that occur in matches for this. | ||
471 | * @return the Set of all values or empty set if there are no matches | ||
472 | * | ||
473 | */ | ||
474 | public Set<FileSystem> getAllValuesOfthis(final Live.Match partialMatch) { | ||
475 | return rawStreamAllValuesOfthis(partialMatch.toArray()).collect(Collectors.toSet()); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Retrieve the set of values that occur in matches for this. | ||
480 | * @return the Set of all values or empty set if there are no matches | ||
481 | * | ||
482 | */ | ||
483 | public Set<FileSystem> getAllValuesOfthis(final FSObject pL) { | ||
484 | return rawStreamAllValuesOfthis(new Object[]{null, pL}).collect(Collectors.toSet()); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * Retrieve the set of values that occur in matches for l. | ||
489 | * @return the Set of all values or empty set if there are no matches | ||
490 | * | ||
491 | */ | ||
492 | protected Stream<FSObject> rawStreamAllValuesOfl(final Object[] parameters) { | ||
493 | return rawStreamAllValues(POSITION_L, parameters).map(FSObject.class::cast); | ||
494 | } | ||
495 | |||
496 | /** | ||
497 | * Retrieve the set of values that occur in matches for l. | ||
498 | * @return the Set of all values or empty set if there are no matches | ||
499 | * | ||
500 | */ | ||
501 | public Set<FSObject> getAllValuesOfl() { | ||
502 | return rawStreamAllValuesOfl(emptyArray()).collect(Collectors.toSet()); | ||
503 | } | ||
504 | |||
505 | /** | ||
506 | * Retrieve the set of values that occur in matches for l. | ||
507 | * @return the Set of all values or empty set if there are no matches | ||
508 | * | ||
509 | */ | ||
510 | public Stream<FSObject> streamAllValuesOfl() { | ||
511 | return rawStreamAllValuesOfl(emptyArray()); | ||
512 | } | ||
513 | |||
514 | /** | ||
515 | * Retrieve the set of values that occur in matches for l. | ||
516 | * </p> | ||
517 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
518 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
519 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
520 | * | ||
521 | * @return the Stream of all values or empty set if there are no matches | ||
522 | * | ||
523 | */ | ||
524 | public Stream<FSObject> streamAllValuesOfl(final Live.Match partialMatch) { | ||
525 | return rawStreamAllValuesOfl(partialMatch.toArray()); | ||
526 | } | ||
527 | |||
528 | /** | ||
529 | * Retrieve the set of values that occur in matches for l. | ||
530 | * </p> | ||
531 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
532 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
533 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
534 | * | ||
535 | * @return the Stream of all values or empty set if there are no matches | ||
536 | * | ||
537 | */ | ||
538 | public Stream<FSObject> streamAllValuesOfl(final FileSystem pThis) { | ||
539 | return rawStreamAllValuesOfl(new Object[]{pThis, null}); | ||
540 | } | ||
541 | |||
542 | /** | ||
543 | * Retrieve the set of values that occur in matches for l. | ||
544 | * @return the Set of all values or empty set if there are no matches | ||
545 | * | ||
546 | */ | ||
547 | public Set<FSObject> getAllValuesOfl(final Live.Match partialMatch) { | ||
548 | return rawStreamAllValuesOfl(partialMatch.toArray()).collect(Collectors.toSet()); | ||
549 | } | ||
550 | |||
551 | /** | ||
552 | * Retrieve the set of values that occur in matches for l. | ||
553 | * @return the Set of all values or empty set if there are no matches | ||
554 | * | ||
555 | */ | ||
556 | public Set<FSObject> getAllValuesOfl(final FileSystem pThis) { | ||
557 | return rawStreamAllValuesOfl(new Object[]{pThis, null}).collect(Collectors.toSet()); | ||
558 | } | ||
559 | |||
560 | @Override | ||
561 | protected Live.Match tupleToMatch(final Tuple t) { | ||
562 | try { | ||
563 | return Live.Match.newMatch((FileSystem) t.get(POSITION_THIS), (FSObject) t.get(POSITION_L)); | ||
564 | } catch(ClassCastException e) { | ||
565 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
566 | return null; | ||
567 | } | ||
568 | } | ||
569 | |||
570 | @Override | ||
571 | protected Live.Match arrayToMatch(final Object[] match) { | ||
572 | try { | ||
573 | return Live.Match.newMatch((FileSystem) match[POSITION_THIS], (FSObject) match[POSITION_L]); | ||
574 | } catch(ClassCastException e) { | ||
575 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
576 | return null; | ||
577 | } | ||
578 | } | ||
579 | |||
580 | @Override | ||
581 | protected Live.Match arrayToMatchMutable(final Object[] match) { | ||
582 | try { | ||
583 | return Live.Match.newMutableMatch((FileSystem) match[POSITION_THIS], (FSObject) match[POSITION_L]); | ||
584 | } catch(ClassCastException e) { | ||
585 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
586 | return null; | ||
587 | } | ||
588 | } | ||
589 | |||
590 | /** | ||
591 | * @return the singleton instance of the query specification of this pattern | ||
592 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
593 | * | ||
594 | */ | ||
595 | public static IQuerySpecification<Live.Matcher> querySpecification() { | ||
596 | return Live.instance(); | ||
597 | } | ||
598 | } | ||
599 | |||
600 | private Live() { | ||
601 | super(GeneratedPQuery.INSTANCE); | ||
602 | } | ||
603 | |||
604 | /** | ||
605 | * @return the singleton instance of the query specification | ||
606 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
607 | * | ||
608 | */ | ||
609 | public static Live instance() { | ||
610 | try{ | ||
611 | return LazyHolder.INSTANCE; | ||
612 | } catch (ExceptionInInitializerError err) { | ||
613 | throw processInitializerError(err); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | @Override | ||
618 | protected Live.Matcher instantiate(final ViatraQueryEngine engine) { | ||
619 | return Live.Matcher.on(engine); | ||
620 | } | ||
621 | |||
622 | @Override | ||
623 | public Live.Matcher instantiate() { | ||
624 | return Live.Matcher.create(); | ||
625 | } | ||
626 | |||
627 | @Override | ||
628 | public Live.Match newEmptyMatch() { | ||
629 | return Live.Match.newEmptyMatch(); | ||
630 | } | ||
631 | |||
632 | @Override | ||
633 | public Live.Match newMatch(final Object... parameters) { | ||
634 | return Live.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FileSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject) parameters[1]); | ||
635 | } | ||
636 | |||
637 | /** | ||
638 | * Inner class allowing the singleton instance of {@link Live} to be created | ||
639 | * <b>not</b> at the class load time of the outer class, | ||
640 | * but rather at the first call to {@link Live#instance()}. | ||
641 | * | ||
642 | * <p> This workaround is required e.g. to support recursion. | ||
643 | * | ||
644 | */ | ||
645 | private static class LazyHolder { | ||
646 | private static final Live INSTANCE = new Live(); | ||
647 | |||
648 | /** | ||
649 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
650 | * This initialization order is required to support indirect recursion. | ||
651 | * | ||
652 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
653 | * | ||
654 | */ | ||
655 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
656 | |||
657 | public static Object ensureInitialized() { | ||
658 | INSTANCE.ensureInitializedInternal(); | ||
659 | return null; | ||
660 | } | ||
661 | } | ||
662 | |||
663 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
664 | private static final Live.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
665 | |||
666 | private final PParameter parameter_this = new PParameter("this", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FileSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FileSystem")), PParameterDirection.INOUT); | ||
667 | |||
668 | private final PParameter parameter_l = new PParameter("l", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FSObject")), PParameterDirection.INOUT); | ||
669 | |||
670 | private final List<PParameter> parameters = Arrays.asList(parameter_this, parameter_l); | ||
671 | |||
672 | private GeneratedPQuery() { | ||
673 | super(PVisibility.PUBLIC); | ||
674 | } | ||
675 | |||
676 | @Override | ||
677 | public String getFullyQualifiedName() { | ||
678 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.live"; | ||
679 | } | ||
680 | |||
681 | @Override | ||
682 | public List<String> getParameterNames() { | ||
683 | return Arrays.asList("this","l"); | ||
684 | } | ||
685 | |||
686 | @Override | ||
687 | public List<PParameter> getParameters() { | ||
688 | return parameters; | ||
689 | } | ||
690 | |||
691 | @Override | ||
692 | public Set<PBody> doGetContainedBodies() { | ||
693 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
694 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
695 | { | ||
696 | PBody body = new PBody(this); | ||
697 | PVariable var_this = body.getOrCreateVariableByName("this"); | ||
698 | PVariable var_l = body.getOrCreateVariableByName("l"); | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_this), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FileSystem"))); | ||
700 | new TypeConstraint(body, Tuples.flatTupleOf(var_l), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
701 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
702 | new ExportedParameter(body, var_this, parameter_this), | ||
703 | new ExportedParameter(body, var_l, parameter_l) | ||
704 | )); | ||
705 | // FileSystem.root(this,l) | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var_this), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FileSystem"))); | ||
707 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
708 | new TypeConstraint(body, Tuples.flatTupleOf(var_this, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "FileSystem", "root"))); | ||
709 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
710 | new Equality(body, var__virtual_0_, var_l); | ||
711 | bodies.add(body); | ||
712 | } | ||
713 | { | ||
714 | PBody body = new PBody(this); | ||
715 | PVariable var_this = body.getOrCreateVariableByName("this"); | ||
716 | PVariable var_l = body.getOrCreateVariableByName("l"); | ||
717 | PVariable var_root = body.getOrCreateVariableByName("root"); | ||
718 | new TypeConstraint(body, Tuples.flatTupleOf(var_this), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FileSystem"))); | ||
719 | new TypeConstraint(body, Tuples.flatTupleOf(var_l), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
720 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
721 | new ExportedParameter(body, var_this, parameter_this), | ||
722 | new ExportedParameter(body, var_l, parameter_l) | ||
723 | )); | ||
724 | // FileSystem.root(this,root) | ||
725 | new TypeConstraint(body, Tuples.flatTupleOf(var_this), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FileSystem"))); | ||
726 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
727 | new TypeConstraint(body, Tuples.flatTupleOf(var_this, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "FileSystem", "root"))); | ||
728 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
729 | new Equality(body, var__virtual_0_, var_root); | ||
730 | // find patternContent+(root,l) | ||
731 | new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_root, var_l), PatternContent.instance().getInternalQueryRepresentation()); | ||
732 | bodies.add(body); | ||
733 | } | ||
734 | { | ||
735 | PAnnotation annotation = new PAnnotation("QueryBasedFeature"); | ||
736 | addAnnotation(annotation); | ||
737 | } | ||
738 | return bodies; | ||
739 | } | ||
740 | } | ||
741 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/LoopInInheritence.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/LoopInInheritence.java new file mode 100644 index 00000000..f81b989c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/LoopInInheritence.java | |||
@@ -0,0 +1,558 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.DirectSupertype; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * {@literal @}Constraint(key={a}, severity="error", message="error") | ||
48 | * pattern loopInInheritence(a: EClass) { | ||
49 | * find directSupertype+(a,a); | ||
50 | * } | ||
51 | * </pre></code> | ||
52 | * | ||
53 | * @see Matcher | ||
54 | * @see Match | ||
55 | * | ||
56 | */ | ||
57 | @SuppressWarnings("all") | ||
58 | public final class LoopInInheritence extends BaseGeneratedEMFQuerySpecification<LoopInInheritence.Matcher> { | ||
59 | /** | ||
60 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.loopInInheritence pattern, | ||
61 | * to be used in conjunction with {@link Matcher}. | ||
62 | * | ||
63 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
64 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
65 | * usable to represent a match of the pattern in the result of a query, | ||
66 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
67 | * | ||
68 | * @see Matcher | ||
69 | * | ||
70 | */ | ||
71 | public static abstract class Match extends BasePatternMatch { | ||
72 | private EClass fA; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("a"); | ||
75 | |||
76 | private Match(final EClass pA) { | ||
77 | this.fA = pA; | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public Object get(final String parameterName) { | ||
82 | switch(parameterName) { | ||
83 | case "a": return this.fA; | ||
84 | default: return null; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | public Object get(final int index) { | ||
90 | switch(index) { | ||
91 | case 0: return this.fA; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public EClass getA() { | ||
97 | return this.fA; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public boolean set(final String parameterName, final Object newValue) { | ||
102 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
103 | if ("a".equals(parameterName) ) { | ||
104 | this.fA = (EClass) newValue; | ||
105 | return true; | ||
106 | } | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public void setA(final EClass pA) { | ||
111 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
112 | this.fA = pA; | ||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public String patternName() { | ||
117 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.loopInInheritence"; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public List<String> parameterNames() { | ||
122 | return LoopInInheritence.Match.parameterNames; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public Object[] toArray() { | ||
127 | return new Object[]{fA}; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public LoopInInheritence.Match toImmutable() { | ||
132 | return isMutable() ? newMatch(fA) : this; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String prettyPrint() { | ||
137 | StringBuilder result = new StringBuilder(); | ||
138 | result.append("\"a\"=" + prettyPrintValue(fA)); | ||
139 | return result.toString(); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public int hashCode() { | ||
144 | return Objects.hash(fA); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public boolean equals(final Object obj) { | ||
149 | if (this == obj) | ||
150 | return true; | ||
151 | if (obj == null) { | ||
152 | return false; | ||
153 | } | ||
154 | if ((obj instanceof LoopInInheritence.Match)) { | ||
155 | LoopInInheritence.Match other = (LoopInInheritence.Match) obj; | ||
156 | return Objects.equals(fA, other.fA); | ||
157 | } else { | ||
158 | // this should be infrequent | ||
159 | if (!(obj instanceof IPatternMatch)) { | ||
160 | return false; | ||
161 | } | ||
162 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
163 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public LoopInInheritence specification() { | ||
169 | return LoopInInheritence.instance(); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Returns an empty, mutable match. | ||
174 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
175 | * | ||
176 | * @return the empty match. | ||
177 | * | ||
178 | */ | ||
179 | public static LoopInInheritence.Match newEmptyMatch() { | ||
180 | return new Mutable(null); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns a mutable (partial) match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
188 | * @return the new, mutable (partial) match object. | ||
189 | * | ||
190 | */ | ||
191 | public static LoopInInheritence.Match newMutableMatch(final EClass pA) { | ||
192 | return new Mutable(pA); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns a new (partial) match. | ||
197 | * This can be used e.g. to call the matcher with a partial match. | ||
198 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
199 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
200 | * @return the (partial) match object. | ||
201 | * | ||
202 | */ | ||
203 | public static LoopInInheritence.Match newMatch(final EClass pA) { | ||
204 | return new Immutable(pA); | ||
205 | } | ||
206 | |||
207 | private static final class Mutable extends LoopInInheritence.Match { | ||
208 | Mutable(final EClass pA) { | ||
209 | super(pA); | ||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public boolean isMutable() { | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | private static final class Immutable extends LoopInInheritence.Match { | ||
219 | Immutable(final EClass pA) { | ||
220 | super(pA); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.loopInInheritence pattern, | ||
232 | * providing pattern-specific query methods. | ||
233 | * | ||
234 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
235 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
236 | * | ||
237 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
238 | * | ||
239 | * <p>Original source: | ||
240 | * <code><pre> | ||
241 | * {@literal @}Constraint(key={a}, severity="error", message="error") | ||
242 | * pattern loopInInheritence(a: EClass) { | ||
243 | * find directSupertype+(a,a); | ||
244 | * } | ||
245 | * </pre></code> | ||
246 | * | ||
247 | * @see Match | ||
248 | * @see LoopInInheritence | ||
249 | * | ||
250 | */ | ||
251 | public static class Matcher extends BaseMatcher<LoopInInheritence.Match> { | ||
252 | /** | ||
253 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
254 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
255 | * | ||
256 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
257 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
258 | * | ||
259 | */ | ||
260 | public static LoopInInheritence.Matcher on(final ViatraQueryEngine engine) { | ||
261 | // check if matcher already exists | ||
262 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
263 | if (matcher == null) { | ||
264 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
265 | } | ||
266 | return matcher; | ||
267 | } | ||
268 | |||
269 | /** | ||
270 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
271 | * @return an initialized matcher | ||
272 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
273 | * | ||
274 | */ | ||
275 | public static LoopInInheritence.Matcher create() { | ||
276 | return new Matcher(); | ||
277 | } | ||
278 | |||
279 | private static final int POSITION_A = 0; | ||
280 | |||
281 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(LoopInInheritence.Matcher.class); | ||
282 | |||
283 | /** | ||
284 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
285 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
286 | * | ||
287 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * | ||
290 | */ | ||
291 | private Matcher() { | ||
292 | super(querySpecification()); | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
297 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
298 | * @return matches represented as a Match object. | ||
299 | * | ||
300 | */ | ||
301 | public Collection<LoopInInheritence.Match> getAllMatches(final EClass pA) { | ||
302 | return rawStreamAllMatches(new Object[]{pA}).collect(Collectors.toSet()); | ||
303 | } | ||
304 | |||
305 | /** | ||
306 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
307 | * </p> | ||
308 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
309 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
310 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
311 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
312 | * @return a stream of matches represented as a Match object. | ||
313 | * | ||
314 | */ | ||
315 | public Stream<LoopInInheritence.Match> streamAllMatches(final EClass pA) { | ||
316 | return rawStreamAllMatches(new Object[]{pA}); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
321 | * Neither determinism nor randomness of selection is guaranteed. | ||
322 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
323 | * @return a match represented as a Match object, or null if no match is found. | ||
324 | * | ||
325 | */ | ||
326 | public Optional<LoopInInheritence.Match> getOneArbitraryMatch(final EClass pA) { | ||
327 | return rawGetOneArbitraryMatch(new Object[]{pA}); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
332 | * under any possible substitution of the unspecified parameters (if any). | ||
333 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
334 | * @return true if the input is a valid (partial) match of the pattern. | ||
335 | * | ||
336 | */ | ||
337 | public boolean hasMatch(final EClass pA) { | ||
338 | return rawHasMatch(new Object[]{pA}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
343 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
344 | * @return the number of pattern matches found. | ||
345 | * | ||
346 | */ | ||
347 | public int countMatches(final EClass pA) { | ||
348 | return rawCountMatches(new Object[]{pA}); | ||
349 | } | ||
350 | |||
351 | /** | ||
352 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
353 | * Neither determinism nor randomness of selection is guaranteed. | ||
354 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
355 | * @param processor the action that will process the selected match. | ||
356 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
357 | * | ||
358 | */ | ||
359 | public boolean forOneArbitraryMatch(final EClass pA, final Consumer<? super LoopInInheritence.Match> processor) { | ||
360 | return rawForOneArbitraryMatch(new Object[]{pA}, processor); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Returns a new (partial) match. | ||
365 | * This can be used e.g. to call the matcher with a partial match. | ||
366 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
367 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
368 | * @return the (partial) match object. | ||
369 | * | ||
370 | */ | ||
371 | public LoopInInheritence.Match newMatch(final EClass pA) { | ||
372 | return LoopInInheritence.Match.newMatch(pA); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Retrieve the set of values that occur in matches for a. | ||
377 | * @return the Set of all values or empty set if there are no matches | ||
378 | * | ||
379 | */ | ||
380 | protected Stream<EClass> rawStreamAllValuesOfa(final Object[] parameters) { | ||
381 | return rawStreamAllValues(POSITION_A, parameters).map(EClass.class::cast); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for a. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | public Set<EClass> getAllValuesOfa() { | ||
390 | return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Retrieve the set of values that occur in matches for a. | ||
395 | * @return the Set of all values or empty set if there are no matches | ||
396 | * | ||
397 | */ | ||
398 | public Stream<EClass> streamAllValuesOfa() { | ||
399 | return rawStreamAllValuesOfa(emptyArray()); | ||
400 | } | ||
401 | |||
402 | @Override | ||
403 | protected LoopInInheritence.Match tupleToMatch(final Tuple t) { | ||
404 | try { | ||
405 | return LoopInInheritence.Match.newMatch((EClass) t.get(POSITION_A)); | ||
406 | } catch(ClassCastException e) { | ||
407 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
408 | return null; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | @Override | ||
413 | protected LoopInInheritence.Match arrayToMatch(final Object[] match) { | ||
414 | try { | ||
415 | return LoopInInheritence.Match.newMatch((EClass) match[POSITION_A]); | ||
416 | } catch(ClassCastException e) { | ||
417 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
418 | return null; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | @Override | ||
423 | protected LoopInInheritence.Match arrayToMatchMutable(final Object[] match) { | ||
424 | try { | ||
425 | return LoopInInheritence.Match.newMutableMatch((EClass) match[POSITION_A]); | ||
426 | } catch(ClassCastException e) { | ||
427 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
428 | return null; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | /** | ||
433 | * @return the singleton instance of the query specification of this pattern | ||
434 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
435 | * | ||
436 | */ | ||
437 | public static IQuerySpecification<LoopInInheritence.Matcher> querySpecification() { | ||
438 | return LoopInInheritence.instance(); | ||
439 | } | ||
440 | } | ||
441 | |||
442 | private LoopInInheritence() { | ||
443 | super(GeneratedPQuery.INSTANCE); | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * @return the singleton instance of the query specification | ||
448 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
449 | * | ||
450 | */ | ||
451 | public static LoopInInheritence instance() { | ||
452 | try{ | ||
453 | return LazyHolder.INSTANCE; | ||
454 | } catch (ExceptionInInitializerError err) { | ||
455 | throw processInitializerError(err); | ||
456 | } | ||
457 | } | ||
458 | |||
459 | @Override | ||
460 | protected LoopInInheritence.Matcher instantiate(final ViatraQueryEngine engine) { | ||
461 | return LoopInInheritence.Matcher.on(engine); | ||
462 | } | ||
463 | |||
464 | @Override | ||
465 | public LoopInInheritence.Matcher instantiate() { | ||
466 | return LoopInInheritence.Matcher.create(); | ||
467 | } | ||
468 | |||
469 | @Override | ||
470 | public LoopInInheritence.Match newEmptyMatch() { | ||
471 | return LoopInInheritence.Match.newEmptyMatch(); | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | public LoopInInheritence.Match newMatch(final Object... parameters) { | ||
476 | return LoopInInheritence.Match.newMatch((org.eclipse.emf.ecore.EClass) parameters[0]); | ||
477 | } | ||
478 | |||
479 | /** | ||
480 | * Inner class allowing the singleton instance of {@link LoopInInheritence} to be created | ||
481 | * <b>not</b> at the class load time of the outer class, | ||
482 | * but rather at the first call to {@link LoopInInheritence#instance()}. | ||
483 | * | ||
484 | * <p> This workaround is required e.g. to support recursion. | ||
485 | * | ||
486 | */ | ||
487 | private static class LazyHolder { | ||
488 | private static final LoopInInheritence INSTANCE = new LoopInInheritence(); | ||
489 | |||
490 | /** | ||
491 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
492 | * This initialization order is required to support indirect recursion. | ||
493 | * | ||
494 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
495 | * | ||
496 | */ | ||
497 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
498 | |||
499 | public static Object ensureInitialized() { | ||
500 | INSTANCE.ensureInitializedInternal(); | ||
501 | return null; | ||
502 | } | ||
503 | } | ||
504 | |||
505 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
506 | private static final LoopInInheritence.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
507 | |||
508 | private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EClass")), PParameterDirection.INOUT); | ||
509 | |||
510 | private final List<PParameter> parameters = Arrays.asList(parameter_a); | ||
511 | |||
512 | private GeneratedPQuery() { | ||
513 | super(PVisibility.PUBLIC); | ||
514 | } | ||
515 | |||
516 | @Override | ||
517 | public String getFullyQualifiedName() { | ||
518 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.loopInInheritence"; | ||
519 | } | ||
520 | |||
521 | @Override | ||
522 | public List<String> getParameterNames() { | ||
523 | return Arrays.asList("a"); | ||
524 | } | ||
525 | |||
526 | @Override | ||
527 | public List<PParameter> getParameters() { | ||
528 | return parameters; | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public Set<PBody> doGetContainedBodies() { | ||
533 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
534 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
535 | { | ||
536 | PBody body = new PBody(this); | ||
537 | PVariable var_a = body.getOrCreateVariableByName("a"); | ||
538 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); | ||
539 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
540 | new ExportedParameter(body, var_a, parameter_a) | ||
541 | )); | ||
542 | // find directSupertype+(a,a) | ||
543 | new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_a, var_a), DirectSupertype.instance().getInternalQueryRepresentation()); | ||
544 | bodies.add(body); | ||
545 | } | ||
546 | { | ||
547 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
548 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
549 | new ParameterReference("a") | ||
550 | })); | ||
551 | annotation.addAttribute("severity", "error"); | ||
552 | annotation.addAttribute("message", "error"); | ||
553 | addAnnotation(annotation); | ||
554 | } | ||
555 | return bodies; | ||
556 | } | ||
557 | } | ||
558 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/NonSymmetricOpposite.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/NonSymmetricOpposite.java new file mode 100644 index 00000000..53725305 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/NonSymmetricOpposite.java | |||
@@ -0,0 +1,718 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Opposite; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.emf.ecore.EReference; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(key={a}, severity="error", message="error") | ||
50 | * pattern nonSymmetricOpposite(a:EReference, b:EReference) { | ||
51 | * find opposite(a,b); | ||
52 | * neg find opposite(b,a); | ||
53 | * } | ||
54 | * </pre></code> | ||
55 | * | ||
56 | * @see Matcher | ||
57 | * @see Match | ||
58 | * | ||
59 | */ | ||
60 | @SuppressWarnings("all") | ||
61 | public final class NonSymmetricOpposite extends BaseGeneratedEMFQuerySpecification<NonSymmetricOpposite.Matcher> { | ||
62 | /** | ||
63 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.nonSymmetricOpposite pattern, | ||
64 | * to be used in conjunction with {@link Matcher}. | ||
65 | * | ||
66 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
67 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
68 | * usable to represent a match of the pattern in the result of a query, | ||
69 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
70 | * | ||
71 | * @see Matcher | ||
72 | * | ||
73 | */ | ||
74 | public static abstract class Match extends BasePatternMatch { | ||
75 | private EReference fA; | ||
76 | |||
77 | private EReference fB; | ||
78 | |||
79 | private static List<String> parameterNames = makeImmutableList("a", "b"); | ||
80 | |||
81 | private Match(final EReference pA, final EReference pB) { | ||
82 | this.fA = pA; | ||
83 | this.fB = pB; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "a": return this.fA; | ||
90 | case "b": return this.fB; | ||
91 | default: return null; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final int index) { | ||
97 | switch(index) { | ||
98 | case 0: return this.fA; | ||
99 | case 1: return this.fB; | ||
100 | default: return null; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public EReference getA() { | ||
105 | return this.fA; | ||
106 | } | ||
107 | |||
108 | public EReference getB() { | ||
109 | return this.fB; | ||
110 | } | ||
111 | |||
112 | @Override | ||
113 | public boolean set(final String parameterName, final Object newValue) { | ||
114 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
115 | if ("a".equals(parameterName) ) { | ||
116 | this.fA = (EReference) newValue; | ||
117 | return true; | ||
118 | } | ||
119 | if ("b".equals(parameterName) ) { | ||
120 | this.fB = (EReference) newValue; | ||
121 | return true; | ||
122 | } | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | public void setA(final EReference pA) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fA = pA; | ||
129 | } | ||
130 | |||
131 | public void setB(final EReference pB) { | ||
132 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
133 | this.fB = pB; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String patternName() { | ||
138 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.nonSymmetricOpposite"; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public List<String> parameterNames() { | ||
143 | return NonSymmetricOpposite.Match.parameterNames; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public Object[] toArray() { | ||
148 | return new Object[]{fA, fB}; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public NonSymmetricOpposite.Match toImmutable() { | ||
153 | return isMutable() ? newMatch(fA, fB) : this; | ||
154 | } | ||
155 | |||
156 | @Override | ||
157 | public String prettyPrint() { | ||
158 | StringBuilder result = new StringBuilder(); | ||
159 | result.append("\"a\"=" + prettyPrintValue(fA) + ", "); | ||
160 | result.append("\"b\"=" + prettyPrintValue(fB)); | ||
161 | return result.toString(); | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | public int hashCode() { | ||
166 | return Objects.hash(fA, fB); | ||
167 | } | ||
168 | |||
169 | @Override | ||
170 | public boolean equals(final Object obj) { | ||
171 | if (this == obj) | ||
172 | return true; | ||
173 | if (obj == null) { | ||
174 | return false; | ||
175 | } | ||
176 | if ((obj instanceof NonSymmetricOpposite.Match)) { | ||
177 | NonSymmetricOpposite.Match other = (NonSymmetricOpposite.Match) obj; | ||
178 | return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB); | ||
179 | } else { | ||
180 | // this should be infrequent | ||
181 | if (!(obj instanceof IPatternMatch)) { | ||
182 | return false; | ||
183 | } | ||
184 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
185 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | @Override | ||
190 | public NonSymmetricOpposite specification() { | ||
191 | return NonSymmetricOpposite.instance(); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * Returns an empty, mutable match. | ||
196 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
197 | * | ||
198 | * @return the empty match. | ||
199 | * | ||
200 | */ | ||
201 | public static NonSymmetricOpposite.Match newEmptyMatch() { | ||
202 | return new Mutable(null, null); | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * Returns a mutable (partial) match. | ||
207 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
208 | * | ||
209 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
210 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
211 | * @return the new, mutable (partial) match object. | ||
212 | * | ||
213 | */ | ||
214 | public static NonSymmetricOpposite.Match newMutableMatch(final EReference pA, final EReference pB) { | ||
215 | return new Mutable(pA, pB); | ||
216 | } | ||
217 | |||
218 | /** | ||
219 | * Returns a new (partial) match. | ||
220 | * This can be used e.g. to call the matcher with a partial match. | ||
221 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
222 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
223 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
224 | * @return the (partial) match object. | ||
225 | * | ||
226 | */ | ||
227 | public static NonSymmetricOpposite.Match newMatch(final EReference pA, final EReference pB) { | ||
228 | return new Immutable(pA, pB); | ||
229 | } | ||
230 | |||
231 | private static final class Mutable extends NonSymmetricOpposite.Match { | ||
232 | Mutable(final EReference pA, final EReference pB) { | ||
233 | super(pA, pB); | ||
234 | } | ||
235 | |||
236 | @Override | ||
237 | public boolean isMutable() { | ||
238 | return true; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | private static final class Immutable extends NonSymmetricOpposite.Match { | ||
243 | Immutable(final EReference pA, final EReference pB) { | ||
244 | super(pA, pB); | ||
245 | } | ||
246 | |||
247 | @Override | ||
248 | public boolean isMutable() { | ||
249 | return false; | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.nonSymmetricOpposite pattern, | ||
256 | * providing pattern-specific query methods. | ||
257 | * | ||
258 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
259 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
260 | * | ||
261 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
262 | * | ||
263 | * <p>Original source: | ||
264 | * <code><pre> | ||
265 | * {@literal @}Constraint(key={a}, severity="error", message="error") | ||
266 | * pattern nonSymmetricOpposite(a:EReference, b:EReference) { | ||
267 | * find opposite(a,b); | ||
268 | * neg find opposite(b,a); | ||
269 | * } | ||
270 | * </pre></code> | ||
271 | * | ||
272 | * @see Match | ||
273 | * @see NonSymmetricOpposite | ||
274 | * | ||
275 | */ | ||
276 | public static class Matcher extends BaseMatcher<NonSymmetricOpposite.Match> { | ||
277 | /** | ||
278 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
279 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
280 | * | ||
281 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * | ||
284 | */ | ||
285 | public static NonSymmetricOpposite.Matcher on(final ViatraQueryEngine engine) { | ||
286 | // check if matcher already exists | ||
287 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
288 | if (matcher == null) { | ||
289 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
290 | } | ||
291 | return matcher; | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
296 | * @return an initialized matcher | ||
297 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
298 | * | ||
299 | */ | ||
300 | public static NonSymmetricOpposite.Matcher create() { | ||
301 | return new Matcher(); | ||
302 | } | ||
303 | |||
304 | private static final int POSITION_A = 0; | ||
305 | |||
306 | private static final int POSITION_B = 1; | ||
307 | |||
308 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NonSymmetricOpposite.Matcher.class); | ||
309 | |||
310 | /** | ||
311 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
312 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
313 | * | ||
314 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
315 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
316 | * | ||
317 | */ | ||
318 | private Matcher() { | ||
319 | super(querySpecification()); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
324 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
325 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
326 | * @return matches represented as a Match object. | ||
327 | * | ||
328 | */ | ||
329 | public Collection<NonSymmetricOpposite.Match> getAllMatches(final EReference pA, final EReference pB) { | ||
330 | return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet()); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
335 | * </p> | ||
336 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
337 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
338 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
339 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
340 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
341 | * @return a stream of matches represented as a Match object. | ||
342 | * | ||
343 | */ | ||
344 | public Stream<NonSymmetricOpposite.Match> streamAllMatches(final EReference pA, final EReference pB) { | ||
345 | return rawStreamAllMatches(new Object[]{pA, pB}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
350 | * Neither determinism nor randomness of selection is guaranteed. | ||
351 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
352 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
353 | * @return a match represented as a Match object, or null if no match is found. | ||
354 | * | ||
355 | */ | ||
356 | public Optional<NonSymmetricOpposite.Match> getOneArbitraryMatch(final EReference pA, final EReference pB) { | ||
357 | return rawGetOneArbitraryMatch(new Object[]{pA, pB}); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
362 | * under any possible substitution of the unspecified parameters (if any). | ||
363 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
364 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
365 | * @return true if the input is a valid (partial) match of the pattern. | ||
366 | * | ||
367 | */ | ||
368 | public boolean hasMatch(final EReference pA, final EReference pB) { | ||
369 | return rawHasMatch(new Object[]{pA, pB}); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
374 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
375 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
376 | * @return the number of pattern matches found. | ||
377 | * | ||
378 | */ | ||
379 | public int countMatches(final EReference pA, final EReference pB) { | ||
380 | return rawCountMatches(new Object[]{pA, pB}); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
385 | * Neither determinism nor randomness of selection is guaranteed. | ||
386 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
387 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
388 | * @param processor the action that will process the selected match. | ||
389 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
390 | * | ||
391 | */ | ||
392 | public boolean forOneArbitraryMatch(final EReference pA, final EReference pB, final Consumer<? super NonSymmetricOpposite.Match> processor) { | ||
393 | return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Returns a new (partial) match. | ||
398 | * This can be used e.g. to call the matcher with a partial match. | ||
399 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
400 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
401 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
402 | * @return the (partial) match object. | ||
403 | * | ||
404 | */ | ||
405 | public NonSymmetricOpposite.Match newMatch(final EReference pA, final EReference pB) { | ||
406 | return NonSymmetricOpposite.Match.newMatch(pA, pB); | ||
407 | } | ||
408 | |||
409 | /** | ||
410 | * Retrieve the set of values that occur in matches for a. | ||
411 | * @return the Set of all values or empty set if there are no matches | ||
412 | * | ||
413 | */ | ||
414 | protected Stream<EReference> rawStreamAllValuesOfa(final Object[] parameters) { | ||
415 | return rawStreamAllValues(POSITION_A, parameters).map(EReference.class::cast); | ||
416 | } | ||
417 | |||
418 | /** | ||
419 | * Retrieve the set of values that occur in matches for a. | ||
420 | * @return the Set of all values or empty set if there are no matches | ||
421 | * | ||
422 | */ | ||
423 | public Set<EReference> getAllValuesOfa() { | ||
424 | return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); | ||
425 | } | ||
426 | |||
427 | /** | ||
428 | * Retrieve the set of values that occur in matches for a. | ||
429 | * @return the Set of all values or empty set if there are no matches | ||
430 | * | ||
431 | */ | ||
432 | public Stream<EReference> streamAllValuesOfa() { | ||
433 | return rawStreamAllValuesOfa(emptyArray()); | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * Retrieve the set of values that occur in matches for a. | ||
438 | * </p> | ||
439 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
440 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
441 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
442 | * | ||
443 | * @return the Stream of all values or empty set if there are no matches | ||
444 | * | ||
445 | */ | ||
446 | public Stream<EReference> streamAllValuesOfa(final NonSymmetricOpposite.Match partialMatch) { | ||
447 | return rawStreamAllValuesOfa(partialMatch.toArray()); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * Retrieve the set of values that occur in matches for a. | ||
452 | * </p> | ||
453 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
454 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
455 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
456 | * | ||
457 | * @return the Stream of all values or empty set if there are no matches | ||
458 | * | ||
459 | */ | ||
460 | public Stream<EReference> streamAllValuesOfa(final EReference pB) { | ||
461 | return rawStreamAllValuesOfa(new Object[]{null, pB}); | ||
462 | } | ||
463 | |||
464 | /** | ||
465 | * Retrieve the set of values that occur in matches for a. | ||
466 | * @return the Set of all values or empty set if there are no matches | ||
467 | * | ||
468 | */ | ||
469 | public Set<EReference> getAllValuesOfa(final NonSymmetricOpposite.Match partialMatch) { | ||
470 | return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet()); | ||
471 | } | ||
472 | |||
473 | /** | ||
474 | * Retrieve the set of values that occur in matches for a. | ||
475 | * @return the Set of all values or empty set if there are no matches | ||
476 | * | ||
477 | */ | ||
478 | public Set<EReference> getAllValuesOfa(final EReference pB) { | ||
479 | return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet()); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Retrieve the set of values that occur in matches for b. | ||
484 | * @return the Set of all values or empty set if there are no matches | ||
485 | * | ||
486 | */ | ||
487 | protected Stream<EReference> rawStreamAllValuesOfb(final Object[] parameters) { | ||
488 | return rawStreamAllValues(POSITION_B, parameters).map(EReference.class::cast); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * Retrieve the set of values that occur in matches for b. | ||
493 | * @return the Set of all values or empty set if there are no matches | ||
494 | * | ||
495 | */ | ||
496 | public Set<EReference> getAllValuesOfb() { | ||
497 | return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet()); | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Retrieve the set of values that occur in matches for b. | ||
502 | * @return the Set of all values or empty set if there are no matches | ||
503 | * | ||
504 | */ | ||
505 | public Stream<EReference> streamAllValuesOfb() { | ||
506 | return rawStreamAllValuesOfb(emptyArray()); | ||
507 | } | ||
508 | |||
509 | /** | ||
510 | * Retrieve the set of values that occur in matches for b. | ||
511 | * </p> | ||
512 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
513 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
514 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
515 | * | ||
516 | * @return the Stream of all values or empty set if there are no matches | ||
517 | * | ||
518 | */ | ||
519 | public Stream<EReference> streamAllValuesOfb(final NonSymmetricOpposite.Match partialMatch) { | ||
520 | return rawStreamAllValuesOfb(partialMatch.toArray()); | ||
521 | } | ||
522 | |||
523 | /** | ||
524 | * Retrieve the set of values that occur in matches for b. | ||
525 | * </p> | ||
526 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
527 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
528 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
529 | * | ||
530 | * @return the Stream of all values or empty set if there are no matches | ||
531 | * | ||
532 | */ | ||
533 | public Stream<EReference> streamAllValuesOfb(final EReference pA) { | ||
534 | return rawStreamAllValuesOfb(new Object[]{pA, null}); | ||
535 | } | ||
536 | |||
537 | /** | ||
538 | * Retrieve the set of values that occur in matches for b. | ||
539 | * @return the Set of all values or empty set if there are no matches | ||
540 | * | ||
541 | */ | ||
542 | public Set<EReference> getAllValuesOfb(final NonSymmetricOpposite.Match partialMatch) { | ||
543 | return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet()); | ||
544 | } | ||
545 | |||
546 | /** | ||
547 | * Retrieve the set of values that occur in matches for b. | ||
548 | * @return the Set of all values or empty set if there are no matches | ||
549 | * | ||
550 | */ | ||
551 | public Set<EReference> getAllValuesOfb(final EReference pA) { | ||
552 | return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet()); | ||
553 | } | ||
554 | |||
555 | @Override | ||
556 | protected NonSymmetricOpposite.Match tupleToMatch(final Tuple t) { | ||
557 | try { | ||
558 | return NonSymmetricOpposite.Match.newMatch((EReference) t.get(POSITION_A), (EReference) t.get(POSITION_B)); | ||
559 | } catch(ClassCastException e) { | ||
560 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
561 | return null; | ||
562 | } | ||
563 | } | ||
564 | |||
565 | @Override | ||
566 | protected NonSymmetricOpposite.Match arrayToMatch(final Object[] match) { | ||
567 | try { | ||
568 | return NonSymmetricOpposite.Match.newMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]); | ||
569 | } catch(ClassCastException e) { | ||
570 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
571 | return null; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | @Override | ||
576 | protected NonSymmetricOpposite.Match arrayToMatchMutable(final Object[] match) { | ||
577 | try { | ||
578 | return NonSymmetricOpposite.Match.newMutableMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]); | ||
579 | } catch(ClassCastException e) { | ||
580 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
581 | return null; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | /** | ||
586 | * @return the singleton instance of the query specification of this pattern | ||
587 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
588 | * | ||
589 | */ | ||
590 | public static IQuerySpecification<NonSymmetricOpposite.Matcher> querySpecification() { | ||
591 | return NonSymmetricOpposite.instance(); | ||
592 | } | ||
593 | } | ||
594 | |||
595 | private NonSymmetricOpposite() { | ||
596 | super(GeneratedPQuery.INSTANCE); | ||
597 | } | ||
598 | |||
599 | /** | ||
600 | * @return the singleton instance of the query specification | ||
601 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
602 | * | ||
603 | */ | ||
604 | public static NonSymmetricOpposite instance() { | ||
605 | try{ | ||
606 | return LazyHolder.INSTANCE; | ||
607 | } catch (ExceptionInInitializerError err) { | ||
608 | throw processInitializerError(err); | ||
609 | } | ||
610 | } | ||
611 | |||
612 | @Override | ||
613 | protected NonSymmetricOpposite.Matcher instantiate(final ViatraQueryEngine engine) { | ||
614 | return NonSymmetricOpposite.Matcher.on(engine); | ||
615 | } | ||
616 | |||
617 | @Override | ||
618 | public NonSymmetricOpposite.Matcher instantiate() { | ||
619 | return NonSymmetricOpposite.Matcher.create(); | ||
620 | } | ||
621 | |||
622 | @Override | ||
623 | public NonSymmetricOpposite.Match newEmptyMatch() { | ||
624 | return NonSymmetricOpposite.Match.newEmptyMatch(); | ||
625 | } | ||
626 | |||
627 | @Override | ||
628 | public NonSymmetricOpposite.Match newMatch(final Object... parameters) { | ||
629 | return NonSymmetricOpposite.Match.newMatch((org.eclipse.emf.ecore.EReference) parameters[0], (org.eclipse.emf.ecore.EReference) parameters[1]); | ||
630 | } | ||
631 | |||
632 | /** | ||
633 | * Inner class allowing the singleton instance of {@link NonSymmetricOpposite} to be created | ||
634 | * <b>not</b> at the class load time of the outer class, | ||
635 | * but rather at the first call to {@link NonSymmetricOpposite#instance()}. | ||
636 | * | ||
637 | * <p> This workaround is required e.g. to support recursion. | ||
638 | * | ||
639 | */ | ||
640 | private static class LazyHolder { | ||
641 | private static final NonSymmetricOpposite INSTANCE = new NonSymmetricOpposite(); | ||
642 | |||
643 | /** | ||
644 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
645 | * This initialization order is required to support indirect recursion. | ||
646 | * | ||
647 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
648 | * | ||
649 | */ | ||
650 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
651 | |||
652 | public static Object ensureInitialized() { | ||
653 | INSTANCE.ensureInitializedInternal(); | ||
654 | return null; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
659 | private static final NonSymmetricOpposite.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
660 | |||
661 | private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT); | ||
664 | |||
665 | private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b); | ||
666 | |||
667 | private GeneratedPQuery() { | ||
668 | super(PVisibility.PUBLIC); | ||
669 | } | ||
670 | |||
671 | @Override | ||
672 | public String getFullyQualifiedName() { | ||
673 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.nonSymmetricOpposite"; | ||
674 | } | ||
675 | |||
676 | @Override | ||
677 | public List<String> getParameterNames() { | ||
678 | return Arrays.asList("a","b"); | ||
679 | } | ||
680 | |||
681 | @Override | ||
682 | public List<PParameter> getParameters() { | ||
683 | return parameters; | ||
684 | } | ||
685 | |||
686 | @Override | ||
687 | public Set<PBody> doGetContainedBodies() { | ||
688 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
689 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
690 | { | ||
691 | PBody body = new PBody(this); | ||
692 | PVariable var_a = body.getOrCreateVariableByName("a"); | ||
693 | PVariable var_b = body.getOrCreateVariableByName("b"); | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
695 | new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
696 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
697 | new ExportedParameter(body, var_a, parameter_a), | ||
698 | new ExportedParameter(body, var_b, parameter_b) | ||
699 | )); | ||
700 | // find opposite(a,b) | ||
701 | new PositivePatternCall(body, Tuples.flatTupleOf(var_a, var_b), Opposite.instance().getInternalQueryRepresentation()); | ||
702 | // neg find opposite(b,a) | ||
703 | new NegativePatternCall(body, Tuples.flatTupleOf(var_b, var_a), Opposite.instance().getInternalQueryRepresentation()); | ||
704 | bodies.add(body); | ||
705 | } | ||
706 | { | ||
707 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
708 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
709 | new ParameterReference("a") | ||
710 | })); | ||
711 | annotation.addAttribute("severity", "error"); | ||
712 | annotation.addAttribute("message", "error"); | ||
713 | addAnnotation(annotation); | ||
714 | } | ||
715 | return bodies; | ||
716 | } | ||
717 | } | ||
718 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Opposite.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Opposite.java new file mode 100644 index 00000000..7689d070 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Opposite.java | |||
@@ -0,0 +1,704 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import org.apache.log4j.Logger; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.EReference; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * pattern opposite(a:EReference, b: EReference) { | ||
47 | * EReference.eOpposite(a,b); | ||
48 | * } | ||
49 | * </pre></code> | ||
50 | * | ||
51 | * @see Matcher | ||
52 | * @see Match | ||
53 | * | ||
54 | */ | ||
55 | @SuppressWarnings("all") | ||
56 | public final class Opposite extends BaseGeneratedEMFQuerySpecification<Opposite.Matcher> { | ||
57 | /** | ||
58 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.opposite pattern, | ||
59 | * to be used in conjunction with {@link Matcher}. | ||
60 | * | ||
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
63 | * usable to represent a match of the pattern in the result of a query, | ||
64 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * | ||
68 | */ | ||
69 | public static abstract class Match extends BasePatternMatch { | ||
70 | private EReference fA; | ||
71 | |||
72 | private EReference fB; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("a", "b"); | ||
75 | |||
76 | private Match(final EReference pA, final EReference pB) { | ||
77 | this.fA = pA; | ||
78 | this.fB = pB; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "a": return this.fA; | ||
85 | case "b": return this.fB; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fA; | ||
94 | case 1: return this.fB; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public EReference getA() { | ||
100 | return this.fA; | ||
101 | } | ||
102 | |||
103 | public EReference getB() { | ||
104 | return this.fB; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("a".equals(parameterName) ) { | ||
111 | this.fA = (EReference) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | if ("b".equals(parameterName) ) { | ||
115 | this.fB = (EReference) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setA(final EReference pA) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fA = pA; | ||
124 | } | ||
125 | |||
126 | public void setB(final EReference pB) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fB = pB; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String patternName() { | ||
133 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.opposite"; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public List<String> parameterNames() { | ||
138 | return Opposite.Match.parameterNames; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public Object[] toArray() { | ||
143 | return new Object[]{fA, fB}; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public Opposite.Match toImmutable() { | ||
148 | return isMutable() ? newMatch(fA, fB) : this; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public String prettyPrint() { | ||
153 | StringBuilder result = new StringBuilder(); | ||
154 | result.append("\"a\"=" + prettyPrintValue(fA) + ", "); | ||
155 | result.append("\"b\"=" + prettyPrintValue(fB)); | ||
156 | return result.toString(); | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public int hashCode() { | ||
161 | return Objects.hash(fA, fB); | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | public boolean equals(final Object obj) { | ||
166 | if (this == obj) | ||
167 | return true; | ||
168 | if (obj == null) { | ||
169 | return false; | ||
170 | } | ||
171 | if ((obj instanceof Opposite.Match)) { | ||
172 | Opposite.Match other = (Opposite.Match) obj; | ||
173 | return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB); | ||
174 | } else { | ||
175 | // this should be infrequent | ||
176 | if (!(obj instanceof IPatternMatch)) { | ||
177 | return false; | ||
178 | } | ||
179 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
180 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | @Override | ||
185 | public Opposite specification() { | ||
186 | return Opposite.instance(); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns an empty, mutable match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @return the empty match. | ||
194 | * | ||
195 | */ | ||
196 | public static Opposite.Match newEmptyMatch() { | ||
197 | return new Mutable(null, null); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns a mutable (partial) match. | ||
202 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
203 | * | ||
204 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
205 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
206 | * @return the new, mutable (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static Opposite.Match newMutableMatch(final EReference pA, final EReference pB) { | ||
210 | return new Mutable(pA, pB); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Returns a new (partial) match. | ||
215 | * This can be used e.g. to call the matcher with a partial match. | ||
216 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
217 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
218 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
219 | * @return the (partial) match object. | ||
220 | * | ||
221 | */ | ||
222 | public static Opposite.Match newMatch(final EReference pA, final EReference pB) { | ||
223 | return new Immutable(pA, pB); | ||
224 | } | ||
225 | |||
226 | private static final class Mutable extends Opposite.Match { | ||
227 | Mutable(final EReference pA, final EReference pB) { | ||
228 | super(pA, pB); | ||
229 | } | ||
230 | |||
231 | @Override | ||
232 | public boolean isMutable() { | ||
233 | return true; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private static final class Immutable extends Opposite.Match { | ||
238 | Immutable(final EReference pA, final EReference pB) { | ||
239 | super(pA, pB); | ||
240 | } | ||
241 | |||
242 | @Override | ||
243 | public boolean isMutable() { | ||
244 | return false; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.opposite pattern, | ||
251 | * providing pattern-specific query methods. | ||
252 | * | ||
253 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
254 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
255 | * | ||
256 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
257 | * | ||
258 | * <p>Original source: | ||
259 | * <code><pre> | ||
260 | * pattern opposite(a:EReference, b: EReference) { | ||
261 | * EReference.eOpposite(a,b); | ||
262 | * } | ||
263 | * </pre></code> | ||
264 | * | ||
265 | * @see Match | ||
266 | * @see Opposite | ||
267 | * | ||
268 | */ | ||
269 | public static class Matcher extends BaseMatcher<Opposite.Match> { | ||
270 | /** | ||
271 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
272 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
273 | * | ||
274 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
276 | * | ||
277 | */ | ||
278 | public static Opposite.Matcher on(final ViatraQueryEngine engine) { | ||
279 | // check if matcher already exists | ||
280 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
281 | if (matcher == null) { | ||
282 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
283 | } | ||
284 | return matcher; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * @return an initialized matcher | ||
290 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
291 | * | ||
292 | */ | ||
293 | public static Opposite.Matcher create() { | ||
294 | return new Matcher(); | ||
295 | } | ||
296 | |||
297 | private static final int POSITION_A = 0; | ||
298 | |||
299 | private static final int POSITION_B = 1; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Opposite.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
318 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
319 | * @return matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Collection<Opposite.Match> getAllMatches(final EReference pA, final EReference pB) { | ||
323 | return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * </p> | ||
329 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
330 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
331 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
332 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
333 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
334 | * @return a stream of matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Stream<Opposite.Match> streamAllMatches(final EReference pA, final EReference pB) { | ||
338 | return rawStreamAllMatches(new Object[]{pA, pB}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
343 | * Neither determinism nor randomness of selection is guaranteed. | ||
344 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
345 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
346 | * @return a match represented as a Match object, or null if no match is found. | ||
347 | * | ||
348 | */ | ||
349 | public Optional<Opposite.Match> getOneArbitraryMatch(final EReference pA, final EReference pB) { | ||
350 | return rawGetOneArbitraryMatch(new Object[]{pA, pB}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
355 | * under any possible substitution of the unspecified parameters (if any). | ||
356 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
357 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
358 | * @return true if the input is a valid (partial) match of the pattern. | ||
359 | * | ||
360 | */ | ||
361 | public boolean hasMatch(final EReference pA, final EReference pB) { | ||
362 | return rawHasMatch(new Object[]{pA, pB}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
368 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
369 | * @return the number of pattern matches found. | ||
370 | * | ||
371 | */ | ||
372 | public int countMatches(final EReference pA, final EReference pB) { | ||
373 | return rawCountMatches(new Object[]{pA, pB}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
378 | * Neither determinism nor randomness of selection is guaranteed. | ||
379 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
380 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
381 | * @param processor the action that will process the selected match. | ||
382 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
383 | * | ||
384 | */ | ||
385 | public boolean forOneArbitraryMatch(final EReference pA, final EReference pB, final Consumer<? super Opposite.Match> processor) { | ||
386 | return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Returns a new (partial) match. | ||
391 | * This can be used e.g. to call the matcher with a partial match. | ||
392 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
393 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
394 | * @param pB the fixed value of pattern parameter b, or null if not bound. | ||
395 | * @return the (partial) match object. | ||
396 | * | ||
397 | */ | ||
398 | public Opposite.Match newMatch(final EReference pA, final EReference pB) { | ||
399 | return Opposite.Match.newMatch(pA, pB); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for a. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | protected Stream<EReference> rawStreamAllValuesOfa(final Object[] parameters) { | ||
408 | return rawStreamAllValues(POSITION_A, parameters).map(EReference.class::cast); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Retrieve the set of values that occur in matches for a. | ||
413 | * @return the Set of all values or empty set if there are no matches | ||
414 | * | ||
415 | */ | ||
416 | public Set<EReference> getAllValuesOfa() { | ||
417 | return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * Retrieve the set of values that occur in matches for a. | ||
422 | * @return the Set of all values or empty set if there are no matches | ||
423 | * | ||
424 | */ | ||
425 | public Stream<EReference> streamAllValuesOfa() { | ||
426 | return rawStreamAllValuesOfa(emptyArray()); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * Retrieve the set of values that occur in matches for a. | ||
431 | * </p> | ||
432 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
433 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
434 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
435 | * | ||
436 | * @return the Stream of all values or empty set if there are no matches | ||
437 | * | ||
438 | */ | ||
439 | public Stream<EReference> streamAllValuesOfa(final Opposite.Match partialMatch) { | ||
440 | return rawStreamAllValuesOfa(partialMatch.toArray()); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * Retrieve the set of values that occur in matches for a. | ||
445 | * </p> | ||
446 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
447 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
448 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
449 | * | ||
450 | * @return the Stream of all values or empty set if there are no matches | ||
451 | * | ||
452 | */ | ||
453 | public Stream<EReference> streamAllValuesOfa(final EReference pB) { | ||
454 | return rawStreamAllValuesOfa(new Object[]{null, pB}); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * Retrieve the set of values that occur in matches for a. | ||
459 | * @return the Set of all values or empty set if there are no matches | ||
460 | * | ||
461 | */ | ||
462 | public Set<EReference> getAllValuesOfa(final Opposite.Match partialMatch) { | ||
463 | return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet()); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * Retrieve the set of values that occur in matches for a. | ||
468 | * @return the Set of all values or empty set if there are no matches | ||
469 | * | ||
470 | */ | ||
471 | public Set<EReference> getAllValuesOfa(final EReference pB) { | ||
472 | return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet()); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * Retrieve the set of values that occur in matches for b. | ||
477 | * @return the Set of all values or empty set if there are no matches | ||
478 | * | ||
479 | */ | ||
480 | protected Stream<EReference> rawStreamAllValuesOfb(final Object[] parameters) { | ||
481 | return rawStreamAllValues(POSITION_B, parameters).map(EReference.class::cast); | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | * Retrieve the set of values that occur in matches for b. | ||
486 | * @return the Set of all values or empty set if there are no matches | ||
487 | * | ||
488 | */ | ||
489 | public Set<EReference> getAllValuesOfb() { | ||
490 | return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet()); | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * Retrieve the set of values that occur in matches for b. | ||
495 | * @return the Set of all values or empty set if there are no matches | ||
496 | * | ||
497 | */ | ||
498 | public Stream<EReference> streamAllValuesOfb() { | ||
499 | return rawStreamAllValuesOfb(emptyArray()); | ||
500 | } | ||
501 | |||
502 | /** | ||
503 | * Retrieve the set of values that occur in matches for b. | ||
504 | * </p> | ||
505 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
506 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
507 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
508 | * | ||
509 | * @return the Stream of all values or empty set if there are no matches | ||
510 | * | ||
511 | */ | ||
512 | public Stream<EReference> streamAllValuesOfb(final Opposite.Match partialMatch) { | ||
513 | return rawStreamAllValuesOfb(partialMatch.toArray()); | ||
514 | } | ||
515 | |||
516 | /** | ||
517 | * Retrieve the set of values that occur in matches for b. | ||
518 | * </p> | ||
519 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
520 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
521 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
522 | * | ||
523 | * @return the Stream of all values or empty set if there are no matches | ||
524 | * | ||
525 | */ | ||
526 | public Stream<EReference> streamAllValuesOfb(final EReference pA) { | ||
527 | return rawStreamAllValuesOfb(new Object[]{pA, null}); | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * Retrieve the set of values that occur in matches for b. | ||
532 | * @return the Set of all values or empty set if there are no matches | ||
533 | * | ||
534 | */ | ||
535 | public Set<EReference> getAllValuesOfb(final Opposite.Match partialMatch) { | ||
536 | return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet()); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * Retrieve the set of values that occur in matches for b. | ||
541 | * @return the Set of all values or empty set if there are no matches | ||
542 | * | ||
543 | */ | ||
544 | public Set<EReference> getAllValuesOfb(final EReference pA) { | ||
545 | return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet()); | ||
546 | } | ||
547 | |||
548 | @Override | ||
549 | protected Opposite.Match tupleToMatch(final Tuple t) { | ||
550 | try { | ||
551 | return Opposite.Match.newMatch((EReference) t.get(POSITION_A), (EReference) t.get(POSITION_B)); | ||
552 | } catch(ClassCastException e) { | ||
553 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
554 | return null; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | @Override | ||
559 | protected Opposite.Match arrayToMatch(final Object[] match) { | ||
560 | try { | ||
561 | return Opposite.Match.newMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]); | ||
562 | } catch(ClassCastException e) { | ||
563 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
564 | return null; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | @Override | ||
569 | protected Opposite.Match arrayToMatchMutable(final Object[] match) { | ||
570 | try { | ||
571 | return Opposite.Match.newMutableMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]); | ||
572 | } catch(ClassCastException e) { | ||
573 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
574 | return null; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * @return the singleton instance of the query specification of this pattern | ||
580 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
581 | * | ||
582 | */ | ||
583 | public static IQuerySpecification<Opposite.Matcher> querySpecification() { | ||
584 | return Opposite.instance(); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | private Opposite() { | ||
589 | super(GeneratedPQuery.INSTANCE); | ||
590 | } | ||
591 | |||
592 | /** | ||
593 | * @return the singleton instance of the query specification | ||
594 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
595 | * | ||
596 | */ | ||
597 | public static Opposite instance() { | ||
598 | try{ | ||
599 | return LazyHolder.INSTANCE; | ||
600 | } catch (ExceptionInInitializerError err) { | ||
601 | throw processInitializerError(err); | ||
602 | } | ||
603 | } | ||
604 | |||
605 | @Override | ||
606 | protected Opposite.Matcher instantiate(final ViatraQueryEngine engine) { | ||
607 | return Opposite.Matcher.on(engine); | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | public Opposite.Matcher instantiate() { | ||
612 | return Opposite.Matcher.create(); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public Opposite.Match newEmptyMatch() { | ||
617 | return Opposite.Match.newEmptyMatch(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public Opposite.Match newMatch(final Object... parameters) { | ||
622 | return Opposite.Match.newMatch((org.eclipse.emf.ecore.EReference) parameters[0], (org.eclipse.emf.ecore.EReference) parameters[1]); | ||
623 | } | ||
624 | |||
625 | /** | ||
626 | * Inner class allowing the singleton instance of {@link Opposite} to be created | ||
627 | * <b>not</b> at the class load time of the outer class, | ||
628 | * but rather at the first call to {@link Opposite#instance()}. | ||
629 | * | ||
630 | * <p> This workaround is required e.g. to support recursion. | ||
631 | * | ||
632 | */ | ||
633 | private static class LazyHolder { | ||
634 | private static final Opposite INSTANCE = new Opposite(); | ||
635 | |||
636 | /** | ||
637 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
638 | * This initialization order is required to support indirect recursion. | ||
639 | * | ||
640 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
641 | * | ||
642 | */ | ||
643 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
644 | |||
645 | public static Object ensureInitialized() { | ||
646 | INSTANCE.ensureInitializedInternal(); | ||
647 | return null; | ||
648 | } | ||
649 | } | ||
650 | |||
651 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
652 | private static final Opposite.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
653 | |||
654 | private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT); | ||
655 | |||
656 | private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT); | ||
657 | |||
658 | private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b); | ||
659 | |||
660 | private GeneratedPQuery() { | ||
661 | super(PVisibility.PUBLIC); | ||
662 | } | ||
663 | |||
664 | @Override | ||
665 | public String getFullyQualifiedName() { | ||
666 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.opposite"; | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public List<String> getParameterNames() { | ||
671 | return Arrays.asList("a","b"); | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<PParameter> getParameters() { | ||
676 | return parameters; | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public Set<PBody> doGetContainedBodies() { | ||
681 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
682 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
683 | { | ||
684 | PBody body = new PBody(this); | ||
685 | PVariable var_a = body.getOrCreateVariableByName("a"); | ||
686 | PVariable var_b = body.getOrCreateVariableByName("b"); | ||
687 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
688 | new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
689 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
690 | new ExportedParameter(body, var_a, parameter_a), | ||
691 | new ExportedParameter(body, var_b, parameter_b) | ||
692 | )); | ||
693 | // EReference.eOpposite(a,b) | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
695 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference", "eOpposite"))); | ||
697 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
698 | new Equality(body, var__virtual_0_, var_b); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | return bodies; | ||
702 | } | ||
703 | } | ||
704 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/OppositeDifferentClass.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/OppositeDifferentClass.java new file mode 100644 index 00000000..aca12eca --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/OppositeDifferentClass.java | |||
@@ -0,0 +1,587 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import org.apache.log4j.Logger; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.EReference; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(key={a}, severity="error", message="error") | ||
50 | * pattern oppositeDifferentClass(a:EReference) { | ||
51 | * EReference.eOpposite(a,b); | ||
52 | * EReference.eContainingClass(a,aContaining); | ||
53 | * EReference.eType(b,bTarget); | ||
54 | * aContaining != bTarget; | ||
55 | * } | ||
56 | * </pre></code> | ||
57 | * | ||
58 | * @see Matcher | ||
59 | * @see Match | ||
60 | * | ||
61 | */ | ||
62 | @SuppressWarnings("all") | ||
63 | public final class OppositeDifferentClass extends BaseGeneratedEMFQuerySpecification<OppositeDifferentClass.Matcher> { | ||
64 | /** | ||
65 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.oppositeDifferentClass pattern, | ||
66 | * to be used in conjunction with {@link Matcher}. | ||
67 | * | ||
68 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
69 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
70 | * usable to represent a match of the pattern in the result of a query, | ||
71 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
72 | * | ||
73 | * @see Matcher | ||
74 | * | ||
75 | */ | ||
76 | public static abstract class Match extends BasePatternMatch { | ||
77 | private EReference fA; | ||
78 | |||
79 | private static List<String> parameterNames = makeImmutableList("a"); | ||
80 | |||
81 | private Match(final EReference pA) { | ||
82 | this.fA = pA; | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public Object get(final String parameterName) { | ||
87 | switch(parameterName) { | ||
88 | case "a": return this.fA; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fA; | ||
97 | default: return null; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | public EReference getA() { | ||
102 | return this.fA; | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public boolean set(final String parameterName, final Object newValue) { | ||
107 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
108 | if ("a".equals(parameterName) ) { | ||
109 | this.fA = (EReference) newValue; | ||
110 | return true; | ||
111 | } | ||
112 | return false; | ||
113 | } | ||
114 | |||
115 | public void setA(final EReference pA) { | ||
116 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
117 | this.fA = pA; | ||
118 | } | ||
119 | |||
120 | @Override | ||
121 | public String patternName() { | ||
122 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.oppositeDifferentClass"; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public List<String> parameterNames() { | ||
127 | return OppositeDifferentClass.Match.parameterNames; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public Object[] toArray() { | ||
132 | return new Object[]{fA}; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public OppositeDifferentClass.Match toImmutable() { | ||
137 | return isMutable() ? newMatch(fA) : this; | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public String prettyPrint() { | ||
142 | StringBuilder result = new StringBuilder(); | ||
143 | result.append("\"a\"=" + prettyPrintValue(fA)); | ||
144 | return result.toString(); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public int hashCode() { | ||
149 | return Objects.hash(fA); | ||
150 | } | ||
151 | |||
152 | @Override | ||
153 | public boolean equals(final Object obj) { | ||
154 | if (this == obj) | ||
155 | return true; | ||
156 | if (obj == null) { | ||
157 | return false; | ||
158 | } | ||
159 | if ((obj instanceof OppositeDifferentClass.Match)) { | ||
160 | OppositeDifferentClass.Match other = (OppositeDifferentClass.Match) obj; | ||
161 | return Objects.equals(fA, other.fA); | ||
162 | } else { | ||
163 | // this should be infrequent | ||
164 | if (!(obj instanceof IPatternMatch)) { | ||
165 | return false; | ||
166 | } | ||
167 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
168 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | @Override | ||
173 | public OppositeDifferentClass specification() { | ||
174 | return OppositeDifferentClass.instance(); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * Returns an empty, mutable match. | ||
179 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
180 | * | ||
181 | * @return the empty match. | ||
182 | * | ||
183 | */ | ||
184 | public static OppositeDifferentClass.Match newEmptyMatch() { | ||
185 | return new Mutable(null); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Returns a mutable (partial) match. | ||
190 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
191 | * | ||
192 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
193 | * @return the new, mutable (partial) match object. | ||
194 | * | ||
195 | */ | ||
196 | public static OppositeDifferentClass.Match newMutableMatch(final EReference pA) { | ||
197 | return new Mutable(pA); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns a new (partial) match. | ||
202 | * This can be used e.g. to call the matcher with a partial match. | ||
203 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
204 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
205 | * @return the (partial) match object. | ||
206 | * | ||
207 | */ | ||
208 | public static OppositeDifferentClass.Match newMatch(final EReference pA) { | ||
209 | return new Immutable(pA); | ||
210 | } | ||
211 | |||
212 | private static final class Mutable extends OppositeDifferentClass.Match { | ||
213 | Mutable(final EReference pA) { | ||
214 | super(pA); | ||
215 | } | ||
216 | |||
217 | @Override | ||
218 | public boolean isMutable() { | ||
219 | return true; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | private static final class Immutable extends OppositeDifferentClass.Match { | ||
224 | Immutable(final EReference pA) { | ||
225 | super(pA); | ||
226 | } | ||
227 | |||
228 | @Override | ||
229 | public boolean isMutable() { | ||
230 | return false; | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.oppositeDifferentClass pattern, | ||
237 | * providing pattern-specific query methods. | ||
238 | * | ||
239 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
240 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
241 | * | ||
242 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
243 | * | ||
244 | * <p>Original source: | ||
245 | * <code><pre> | ||
246 | * {@literal @}Constraint(key={a}, severity="error", message="error") | ||
247 | * pattern oppositeDifferentClass(a:EReference) { | ||
248 | * EReference.eOpposite(a,b); | ||
249 | * EReference.eContainingClass(a,aContaining); | ||
250 | * EReference.eType(b,bTarget); | ||
251 | * aContaining != bTarget; | ||
252 | * } | ||
253 | * </pre></code> | ||
254 | * | ||
255 | * @see Match | ||
256 | * @see OppositeDifferentClass | ||
257 | * | ||
258 | */ | ||
259 | public static class Matcher extends BaseMatcher<OppositeDifferentClass.Match> { | ||
260 | /** | ||
261 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
262 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
263 | * | ||
264 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
265 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
266 | * | ||
267 | */ | ||
268 | public static OppositeDifferentClass.Matcher on(final ViatraQueryEngine engine) { | ||
269 | // check if matcher already exists | ||
270 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
271 | if (matcher == null) { | ||
272 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
273 | } | ||
274 | return matcher; | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
279 | * @return an initialized matcher | ||
280 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
281 | * | ||
282 | */ | ||
283 | public static OppositeDifferentClass.Matcher create() { | ||
284 | return new Matcher(); | ||
285 | } | ||
286 | |||
287 | private static final int POSITION_A = 0; | ||
288 | |||
289 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(OppositeDifferentClass.Matcher.class); | ||
290 | |||
291 | /** | ||
292 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
293 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
294 | * | ||
295 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * | ||
298 | */ | ||
299 | private Matcher() { | ||
300 | super(querySpecification()); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
305 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
306 | * @return matches represented as a Match object. | ||
307 | * | ||
308 | */ | ||
309 | public Collection<OppositeDifferentClass.Match> getAllMatches(final EReference pA) { | ||
310 | return rawStreamAllMatches(new Object[]{pA}).collect(Collectors.toSet()); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
315 | * </p> | ||
316 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
317 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
318 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
319 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
320 | * @return a stream of matches represented as a Match object. | ||
321 | * | ||
322 | */ | ||
323 | public Stream<OppositeDifferentClass.Match> streamAllMatches(final EReference pA) { | ||
324 | return rawStreamAllMatches(new Object[]{pA}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
329 | * Neither determinism nor randomness of selection is guaranteed. | ||
330 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
331 | * @return a match represented as a Match object, or null if no match is found. | ||
332 | * | ||
333 | */ | ||
334 | public Optional<OppositeDifferentClass.Match> getOneArbitraryMatch(final EReference pA) { | ||
335 | return rawGetOneArbitraryMatch(new Object[]{pA}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
340 | * under any possible substitution of the unspecified parameters (if any). | ||
341 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
342 | * @return true if the input is a valid (partial) match of the pattern. | ||
343 | * | ||
344 | */ | ||
345 | public boolean hasMatch(final EReference pA) { | ||
346 | return rawHasMatch(new Object[]{pA}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
351 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
352 | * @return the number of pattern matches found. | ||
353 | * | ||
354 | */ | ||
355 | public int countMatches(final EReference pA) { | ||
356 | return rawCountMatches(new Object[]{pA}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
361 | * Neither determinism nor randomness of selection is guaranteed. | ||
362 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
363 | * @param processor the action that will process the selected match. | ||
364 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
365 | * | ||
366 | */ | ||
367 | public boolean forOneArbitraryMatch(final EReference pA, final Consumer<? super OppositeDifferentClass.Match> processor) { | ||
368 | return rawForOneArbitraryMatch(new Object[]{pA}, processor); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns a new (partial) match. | ||
373 | * This can be used e.g. to call the matcher with a partial match. | ||
374 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
375 | * @param pA the fixed value of pattern parameter a, or null if not bound. | ||
376 | * @return the (partial) match object. | ||
377 | * | ||
378 | */ | ||
379 | public OppositeDifferentClass.Match newMatch(final EReference pA) { | ||
380 | return OppositeDifferentClass.Match.newMatch(pA); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for a. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | protected Stream<EReference> rawStreamAllValuesOfa(final Object[] parameters) { | ||
389 | return rawStreamAllValues(POSITION_A, parameters).map(EReference.class::cast); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for a. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Set<EReference> getAllValuesOfa() { | ||
398 | return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for a. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | public Stream<EReference> streamAllValuesOfa() { | ||
407 | return rawStreamAllValuesOfa(emptyArray()); | ||
408 | } | ||
409 | |||
410 | @Override | ||
411 | protected OppositeDifferentClass.Match tupleToMatch(final Tuple t) { | ||
412 | try { | ||
413 | return OppositeDifferentClass.Match.newMatch((EReference) t.get(POSITION_A)); | ||
414 | } catch(ClassCastException e) { | ||
415 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
416 | return null; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | @Override | ||
421 | protected OppositeDifferentClass.Match arrayToMatch(final Object[] match) { | ||
422 | try { | ||
423 | return OppositeDifferentClass.Match.newMatch((EReference) match[POSITION_A]); | ||
424 | } catch(ClassCastException e) { | ||
425 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
426 | return null; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | @Override | ||
431 | protected OppositeDifferentClass.Match arrayToMatchMutable(final Object[] match) { | ||
432 | try { | ||
433 | return OppositeDifferentClass.Match.newMutableMatch((EReference) match[POSITION_A]); | ||
434 | } catch(ClassCastException e) { | ||
435 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
436 | return null; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * @return the singleton instance of the query specification of this pattern | ||
442 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
443 | * | ||
444 | */ | ||
445 | public static IQuerySpecification<OppositeDifferentClass.Matcher> querySpecification() { | ||
446 | return OppositeDifferentClass.instance(); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | private OppositeDifferentClass() { | ||
451 | super(GeneratedPQuery.INSTANCE); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * @return the singleton instance of the query specification | ||
456 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
457 | * | ||
458 | */ | ||
459 | public static OppositeDifferentClass instance() { | ||
460 | try{ | ||
461 | return LazyHolder.INSTANCE; | ||
462 | } catch (ExceptionInInitializerError err) { | ||
463 | throw processInitializerError(err); | ||
464 | } | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | protected OppositeDifferentClass.Matcher instantiate(final ViatraQueryEngine engine) { | ||
469 | return OppositeDifferentClass.Matcher.on(engine); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public OppositeDifferentClass.Matcher instantiate() { | ||
474 | return OppositeDifferentClass.Matcher.create(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public OppositeDifferentClass.Match newEmptyMatch() { | ||
479 | return OppositeDifferentClass.Match.newEmptyMatch(); | ||
480 | } | ||
481 | |||
482 | @Override | ||
483 | public OppositeDifferentClass.Match newMatch(final Object... parameters) { | ||
484 | return OppositeDifferentClass.Match.newMatch((org.eclipse.emf.ecore.EReference) parameters[0]); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * Inner class allowing the singleton instance of {@link OppositeDifferentClass} to be created | ||
489 | * <b>not</b> at the class load time of the outer class, | ||
490 | * but rather at the first call to {@link OppositeDifferentClass#instance()}. | ||
491 | * | ||
492 | * <p> This workaround is required e.g. to support recursion. | ||
493 | * | ||
494 | */ | ||
495 | private static class LazyHolder { | ||
496 | private static final OppositeDifferentClass INSTANCE = new OppositeDifferentClass(); | ||
497 | |||
498 | /** | ||
499 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
500 | * This initialization order is required to support indirect recursion. | ||
501 | * | ||
502 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
503 | * | ||
504 | */ | ||
505 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
506 | |||
507 | public static Object ensureInitialized() { | ||
508 | INSTANCE.ensureInitializedInternal(); | ||
509 | return null; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
514 | private static final OppositeDifferentClass.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
515 | |||
516 | private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT); | ||
517 | |||
518 | private final List<PParameter> parameters = Arrays.asList(parameter_a); | ||
519 | |||
520 | private GeneratedPQuery() { | ||
521 | super(PVisibility.PUBLIC); | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public String getFullyQualifiedName() { | ||
526 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.oppositeDifferentClass"; | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<String> getParameterNames() { | ||
531 | return Arrays.asList("a"); | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public List<PParameter> getParameters() { | ||
536 | return parameters; | ||
537 | } | ||
538 | |||
539 | @Override | ||
540 | public Set<PBody> doGetContainedBodies() { | ||
541 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
542 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
543 | { | ||
544 | PBody body = new PBody(this); | ||
545 | PVariable var_a = body.getOrCreateVariableByName("a"); | ||
546 | PVariable var_b = body.getOrCreateVariableByName("b"); | ||
547 | PVariable var_aContaining = body.getOrCreateVariableByName("aContaining"); | ||
548 | PVariable var_bTarget = body.getOrCreateVariableByName("bTarget"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
550 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
551 | new ExportedParameter(body, var_a, parameter_a) | ||
552 | )); | ||
553 | // EReference.eOpposite(a,b) | ||
554 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
555 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference", "eOpposite"))); | ||
557 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
558 | new Equality(body, var__virtual_0_, var_b); | ||
559 | // EReference.eContainingClass(a,aContaining) | ||
560 | new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
561 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
562 | new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EStructuralFeature", "eContainingClass"))); | ||
563 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); | ||
564 | new Equality(body, var__virtual_1_, var_aContaining); | ||
565 | // EReference.eType(b,bTarget) | ||
566 | new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference"))); | ||
567 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
568 | new TypeConstraint(body, Tuples.flatTupleOf(var_b, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "ETypedElement", "eType"))); | ||
569 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClassifier"))); | ||
570 | new Equality(body, var__virtual_2_, var_bTarget); | ||
571 | // aContaining != bTarget | ||
572 | new Inequality(body, var_aContaining, var_bTarget); | ||
573 | bodies.add(body); | ||
574 | } | ||
575 | { | ||
576 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
577 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
578 | new ParameterReference("a") | ||
579 | })); | ||
580 | annotation.addAttribute("severity", "error"); | ||
581 | annotation.addAttribute("message", "error"); | ||
582 | addAnnotation(annotation); | ||
583 | } | ||
584 | return bodies; | ||
585 | } | ||
586 | } | ||
587 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/PatternContent.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/PatternContent.java new file mode 100644 index 00000000..7c48b978 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/PatternContent.java | |||
@@ -0,0 +1,704 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/FileSystem.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * pattern patternContent(o1: FSObject, o2: FSObject) { | ||
47 | * Dir.contents(o1,o2); | ||
48 | * } | ||
49 | * </pre></code> | ||
50 | * | ||
51 | * @see Matcher | ||
52 | * @see Match | ||
53 | * | ||
54 | */ | ||
55 | @SuppressWarnings("all") | ||
56 | public final class PatternContent extends BaseGeneratedEMFQuerySpecification<PatternContent.Matcher> { | ||
57 | /** | ||
58 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.patternContent pattern, | ||
59 | * to be used in conjunction with {@link Matcher}. | ||
60 | * | ||
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
63 | * usable to represent a match of the pattern in the result of a query, | ||
64 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * | ||
68 | */ | ||
69 | public static abstract class Match extends BasePatternMatch { | ||
70 | private FSObject fO1; | ||
71 | |||
72 | private FSObject fO2; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("o1", "o2"); | ||
75 | |||
76 | private Match(final FSObject pO1, final FSObject pO2) { | ||
77 | this.fO1 = pO1; | ||
78 | this.fO2 = pO2; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "o1": return this.fO1; | ||
85 | case "o2": return this.fO2; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fO1; | ||
94 | case 1: return this.fO2; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public FSObject getO1() { | ||
100 | return this.fO1; | ||
101 | } | ||
102 | |||
103 | public FSObject getO2() { | ||
104 | return this.fO2; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("o1".equals(parameterName) ) { | ||
111 | this.fO1 = (FSObject) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | if ("o2".equals(parameterName) ) { | ||
115 | this.fO2 = (FSObject) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setO1(final FSObject pO1) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fO1 = pO1; | ||
124 | } | ||
125 | |||
126 | public void setO2(final FSObject pO2) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fO2 = pO2; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String patternName() { | ||
133 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.patternContent"; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public List<String> parameterNames() { | ||
138 | return PatternContent.Match.parameterNames; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public Object[] toArray() { | ||
143 | return new Object[]{fO1, fO2}; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public PatternContent.Match toImmutable() { | ||
148 | return isMutable() ? newMatch(fO1, fO2) : this; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public String prettyPrint() { | ||
153 | StringBuilder result = new StringBuilder(); | ||
154 | result.append("\"o1\"=" + prettyPrintValue(fO1) + ", "); | ||
155 | result.append("\"o2\"=" + prettyPrintValue(fO2)); | ||
156 | return result.toString(); | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public int hashCode() { | ||
161 | return Objects.hash(fO1, fO2); | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | public boolean equals(final Object obj) { | ||
166 | if (this == obj) | ||
167 | return true; | ||
168 | if (obj == null) { | ||
169 | return false; | ||
170 | } | ||
171 | if ((obj instanceof PatternContent.Match)) { | ||
172 | PatternContent.Match other = (PatternContent.Match) obj; | ||
173 | return Objects.equals(fO1, other.fO1) && Objects.equals(fO2, other.fO2); | ||
174 | } else { | ||
175 | // this should be infrequent | ||
176 | if (!(obj instanceof IPatternMatch)) { | ||
177 | return false; | ||
178 | } | ||
179 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
180 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | @Override | ||
185 | public PatternContent specification() { | ||
186 | return PatternContent.instance(); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns an empty, mutable match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @return the empty match. | ||
194 | * | ||
195 | */ | ||
196 | public static PatternContent.Match newEmptyMatch() { | ||
197 | return new Mutable(null, null); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns a mutable (partial) match. | ||
202 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
203 | * | ||
204 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
205 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
206 | * @return the new, mutable (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static PatternContent.Match newMutableMatch(final FSObject pO1, final FSObject pO2) { | ||
210 | return new Mutable(pO1, pO2); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Returns a new (partial) match. | ||
215 | * This can be used e.g. to call the matcher with a partial match. | ||
216 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
217 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
218 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
219 | * @return the (partial) match object. | ||
220 | * | ||
221 | */ | ||
222 | public static PatternContent.Match newMatch(final FSObject pO1, final FSObject pO2) { | ||
223 | return new Immutable(pO1, pO2); | ||
224 | } | ||
225 | |||
226 | private static final class Mutable extends PatternContent.Match { | ||
227 | Mutable(final FSObject pO1, final FSObject pO2) { | ||
228 | super(pO1, pO2); | ||
229 | } | ||
230 | |||
231 | @Override | ||
232 | public boolean isMutable() { | ||
233 | return true; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private static final class Immutable extends PatternContent.Match { | ||
238 | Immutable(final FSObject pO1, final FSObject pO2) { | ||
239 | super(pO1, pO2); | ||
240 | } | ||
241 | |||
242 | @Override | ||
243 | public boolean isMutable() { | ||
244 | return false; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.patternContent pattern, | ||
251 | * providing pattern-specific query methods. | ||
252 | * | ||
253 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
254 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
255 | * | ||
256 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
257 | * | ||
258 | * <p>Original source: | ||
259 | * <code><pre> | ||
260 | * pattern patternContent(o1: FSObject, o2: FSObject) { | ||
261 | * Dir.contents(o1,o2); | ||
262 | * } | ||
263 | * </pre></code> | ||
264 | * | ||
265 | * @see Match | ||
266 | * @see PatternContent | ||
267 | * | ||
268 | */ | ||
269 | public static class Matcher extends BaseMatcher<PatternContent.Match> { | ||
270 | /** | ||
271 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
272 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
273 | * | ||
274 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
276 | * | ||
277 | */ | ||
278 | public static PatternContent.Matcher on(final ViatraQueryEngine engine) { | ||
279 | // check if matcher already exists | ||
280 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
281 | if (matcher == null) { | ||
282 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
283 | } | ||
284 | return matcher; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * @return an initialized matcher | ||
290 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
291 | * | ||
292 | */ | ||
293 | public static PatternContent.Matcher create() { | ||
294 | return new Matcher(); | ||
295 | } | ||
296 | |||
297 | private static final int POSITION_O1 = 0; | ||
298 | |||
299 | private static final int POSITION_O2 = 1; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(PatternContent.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
318 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
319 | * @return matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Collection<PatternContent.Match> getAllMatches(final FSObject pO1, final FSObject pO2) { | ||
323 | return rawStreamAllMatches(new Object[]{pO1, pO2}).collect(Collectors.toSet()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * </p> | ||
329 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
330 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
331 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
332 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
333 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
334 | * @return a stream of matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Stream<PatternContent.Match> streamAllMatches(final FSObject pO1, final FSObject pO2) { | ||
338 | return rawStreamAllMatches(new Object[]{pO1, pO2}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
343 | * Neither determinism nor randomness of selection is guaranteed. | ||
344 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
345 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
346 | * @return a match represented as a Match object, or null if no match is found. | ||
347 | * | ||
348 | */ | ||
349 | public Optional<PatternContent.Match> getOneArbitraryMatch(final FSObject pO1, final FSObject pO2) { | ||
350 | return rawGetOneArbitraryMatch(new Object[]{pO1, pO2}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
355 | * under any possible substitution of the unspecified parameters (if any). | ||
356 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
357 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
358 | * @return true if the input is a valid (partial) match of the pattern. | ||
359 | * | ||
360 | */ | ||
361 | public boolean hasMatch(final FSObject pO1, final FSObject pO2) { | ||
362 | return rawHasMatch(new Object[]{pO1, pO2}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
368 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
369 | * @return the number of pattern matches found. | ||
370 | * | ||
371 | */ | ||
372 | public int countMatches(final FSObject pO1, final FSObject pO2) { | ||
373 | return rawCountMatches(new Object[]{pO1, pO2}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
378 | * Neither determinism nor randomness of selection is guaranteed. | ||
379 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
380 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
381 | * @param processor the action that will process the selected match. | ||
382 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
383 | * | ||
384 | */ | ||
385 | public boolean forOneArbitraryMatch(final FSObject pO1, final FSObject pO2, final Consumer<? super PatternContent.Match> processor) { | ||
386 | return rawForOneArbitraryMatch(new Object[]{pO1, pO2}, processor); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Returns a new (partial) match. | ||
391 | * This can be used e.g. to call the matcher with a partial match. | ||
392 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
393 | * @param pO1 the fixed value of pattern parameter o1, or null if not bound. | ||
394 | * @param pO2 the fixed value of pattern parameter o2, or null if not bound. | ||
395 | * @return the (partial) match object. | ||
396 | * | ||
397 | */ | ||
398 | public PatternContent.Match newMatch(final FSObject pO1, final FSObject pO2) { | ||
399 | return PatternContent.Match.newMatch(pO1, pO2); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for o1. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | protected Stream<FSObject> rawStreamAllValuesOfo1(final Object[] parameters) { | ||
408 | return rawStreamAllValues(POSITION_O1, parameters).map(FSObject.class::cast); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Retrieve the set of values that occur in matches for o1. | ||
413 | * @return the Set of all values or empty set if there are no matches | ||
414 | * | ||
415 | */ | ||
416 | public Set<FSObject> getAllValuesOfo1() { | ||
417 | return rawStreamAllValuesOfo1(emptyArray()).collect(Collectors.toSet()); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * Retrieve the set of values that occur in matches for o1. | ||
422 | * @return the Set of all values or empty set if there are no matches | ||
423 | * | ||
424 | */ | ||
425 | public Stream<FSObject> streamAllValuesOfo1() { | ||
426 | return rawStreamAllValuesOfo1(emptyArray()); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * Retrieve the set of values that occur in matches for o1. | ||
431 | * </p> | ||
432 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
433 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
434 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
435 | * | ||
436 | * @return the Stream of all values or empty set if there are no matches | ||
437 | * | ||
438 | */ | ||
439 | public Stream<FSObject> streamAllValuesOfo1(final PatternContent.Match partialMatch) { | ||
440 | return rawStreamAllValuesOfo1(partialMatch.toArray()); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * Retrieve the set of values that occur in matches for o1. | ||
445 | * </p> | ||
446 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
447 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
448 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
449 | * | ||
450 | * @return the Stream of all values or empty set if there are no matches | ||
451 | * | ||
452 | */ | ||
453 | public Stream<FSObject> streamAllValuesOfo1(final FSObject pO2) { | ||
454 | return rawStreamAllValuesOfo1(new Object[]{null, pO2}); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * Retrieve the set of values that occur in matches for o1. | ||
459 | * @return the Set of all values or empty set if there are no matches | ||
460 | * | ||
461 | */ | ||
462 | public Set<FSObject> getAllValuesOfo1(final PatternContent.Match partialMatch) { | ||
463 | return rawStreamAllValuesOfo1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * Retrieve the set of values that occur in matches for o1. | ||
468 | * @return the Set of all values or empty set if there are no matches | ||
469 | * | ||
470 | */ | ||
471 | public Set<FSObject> getAllValuesOfo1(final FSObject pO2) { | ||
472 | return rawStreamAllValuesOfo1(new Object[]{null, pO2}).collect(Collectors.toSet()); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * Retrieve the set of values that occur in matches for o2. | ||
477 | * @return the Set of all values or empty set if there are no matches | ||
478 | * | ||
479 | */ | ||
480 | protected Stream<FSObject> rawStreamAllValuesOfo2(final Object[] parameters) { | ||
481 | return rawStreamAllValues(POSITION_O2, parameters).map(FSObject.class::cast); | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | * Retrieve the set of values that occur in matches for o2. | ||
486 | * @return the Set of all values or empty set if there are no matches | ||
487 | * | ||
488 | */ | ||
489 | public Set<FSObject> getAllValuesOfo2() { | ||
490 | return rawStreamAllValuesOfo2(emptyArray()).collect(Collectors.toSet()); | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * Retrieve the set of values that occur in matches for o2. | ||
495 | * @return the Set of all values or empty set if there are no matches | ||
496 | * | ||
497 | */ | ||
498 | public Stream<FSObject> streamAllValuesOfo2() { | ||
499 | return rawStreamAllValuesOfo2(emptyArray()); | ||
500 | } | ||
501 | |||
502 | /** | ||
503 | * Retrieve the set of values that occur in matches for o2. | ||
504 | * </p> | ||
505 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
506 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
507 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
508 | * | ||
509 | * @return the Stream of all values or empty set if there are no matches | ||
510 | * | ||
511 | */ | ||
512 | public Stream<FSObject> streamAllValuesOfo2(final PatternContent.Match partialMatch) { | ||
513 | return rawStreamAllValuesOfo2(partialMatch.toArray()); | ||
514 | } | ||
515 | |||
516 | /** | ||
517 | * Retrieve the set of values that occur in matches for o2. | ||
518 | * </p> | ||
519 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
520 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
521 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
522 | * | ||
523 | * @return the Stream of all values or empty set if there are no matches | ||
524 | * | ||
525 | */ | ||
526 | public Stream<FSObject> streamAllValuesOfo2(final FSObject pO1) { | ||
527 | return rawStreamAllValuesOfo2(new Object[]{pO1, null}); | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * Retrieve the set of values that occur in matches for o2. | ||
532 | * @return the Set of all values or empty set if there are no matches | ||
533 | * | ||
534 | */ | ||
535 | public Set<FSObject> getAllValuesOfo2(final PatternContent.Match partialMatch) { | ||
536 | return rawStreamAllValuesOfo2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * Retrieve the set of values that occur in matches for o2. | ||
541 | * @return the Set of all values or empty set if there are no matches | ||
542 | * | ||
543 | */ | ||
544 | public Set<FSObject> getAllValuesOfo2(final FSObject pO1) { | ||
545 | return rawStreamAllValuesOfo2(new Object[]{pO1, null}).collect(Collectors.toSet()); | ||
546 | } | ||
547 | |||
548 | @Override | ||
549 | protected PatternContent.Match tupleToMatch(final Tuple t) { | ||
550 | try { | ||
551 | return PatternContent.Match.newMatch((FSObject) t.get(POSITION_O1), (FSObject) t.get(POSITION_O2)); | ||
552 | } catch(ClassCastException e) { | ||
553 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
554 | return null; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | @Override | ||
559 | protected PatternContent.Match arrayToMatch(final Object[] match) { | ||
560 | try { | ||
561 | return PatternContent.Match.newMatch((FSObject) match[POSITION_O1], (FSObject) match[POSITION_O2]); | ||
562 | } catch(ClassCastException e) { | ||
563 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
564 | return null; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | @Override | ||
569 | protected PatternContent.Match arrayToMatchMutable(final Object[] match) { | ||
570 | try { | ||
571 | return PatternContent.Match.newMutableMatch((FSObject) match[POSITION_O1], (FSObject) match[POSITION_O2]); | ||
572 | } catch(ClassCastException e) { | ||
573 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
574 | return null; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * @return the singleton instance of the query specification of this pattern | ||
580 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
581 | * | ||
582 | */ | ||
583 | public static IQuerySpecification<PatternContent.Matcher> querySpecification() { | ||
584 | return PatternContent.instance(); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | private PatternContent() { | ||
589 | super(GeneratedPQuery.INSTANCE); | ||
590 | } | ||
591 | |||
592 | /** | ||
593 | * @return the singleton instance of the query specification | ||
594 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
595 | * | ||
596 | */ | ||
597 | public static PatternContent instance() { | ||
598 | try{ | ||
599 | return LazyHolder.INSTANCE; | ||
600 | } catch (ExceptionInInitializerError err) { | ||
601 | throw processInitializerError(err); | ||
602 | } | ||
603 | } | ||
604 | |||
605 | @Override | ||
606 | protected PatternContent.Matcher instantiate(final ViatraQueryEngine engine) { | ||
607 | return PatternContent.Matcher.on(engine); | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | public PatternContent.Matcher instantiate() { | ||
612 | return PatternContent.Matcher.create(); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public PatternContent.Match newEmptyMatch() { | ||
617 | return PatternContent.Match.newEmptyMatch(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public PatternContent.Match newMatch(final Object... parameters) { | ||
622 | return PatternContent.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject) parameters[1]); | ||
623 | } | ||
624 | |||
625 | /** | ||
626 | * Inner class allowing the singleton instance of {@link PatternContent} to be created | ||
627 | * <b>not</b> at the class load time of the outer class, | ||
628 | * but rather at the first call to {@link PatternContent#instance()}. | ||
629 | * | ||
630 | * <p> This workaround is required e.g. to support recursion. | ||
631 | * | ||
632 | */ | ||
633 | private static class LazyHolder { | ||
634 | private static final PatternContent INSTANCE = new PatternContent(); | ||
635 | |||
636 | /** | ||
637 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
638 | * This initialization order is required to support indirect recursion. | ||
639 | * | ||
640 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
641 | * | ||
642 | */ | ||
643 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
644 | |||
645 | public static Object ensureInitialized() { | ||
646 | INSTANCE.ensureInitializedInternal(); | ||
647 | return null; | ||
648 | } | ||
649 | } | ||
650 | |||
651 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
652 | private static final PatternContent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
653 | |||
654 | private final PParameter parameter_o1 = new PParameter("o1", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FSObject")), PParameterDirection.INOUT); | ||
655 | |||
656 | private final PParameter parameter_o2 = new PParameter("o2", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FSObject")), PParameterDirection.INOUT); | ||
657 | |||
658 | private final List<PParameter> parameters = Arrays.asList(parameter_o1, parameter_o2); | ||
659 | |||
660 | private GeneratedPQuery() { | ||
661 | super(PVisibility.PUBLIC); | ||
662 | } | ||
663 | |||
664 | @Override | ||
665 | public String getFullyQualifiedName() { | ||
666 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.patternContent"; | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public List<String> getParameterNames() { | ||
671 | return Arrays.asList("o1","o2"); | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<PParameter> getParameters() { | ||
676 | return parameters; | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public Set<PBody> doGetContainedBodies() { | ||
681 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
682 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
683 | { | ||
684 | PBody body = new PBody(this); | ||
685 | PVariable var_o1 = body.getOrCreateVariableByName("o1"); | ||
686 | PVariable var_o2 = body.getOrCreateVariableByName("o2"); | ||
687 | new TypeConstraint(body, Tuples.flatTupleOf(var_o1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
688 | new TypeConstraint(body, Tuples.flatTupleOf(var_o2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
689 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
690 | new ExportedParameter(body, var_o1, parameter_o1), | ||
691 | new ExportedParameter(body, var_o2, parameter_o2) | ||
692 | )); | ||
693 | // Dir.contents(o1,o2) | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_o1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
695 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_o1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "Dir", "contents"))); | ||
697 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
698 | new Equality(body, var__virtual_0_, var_o2); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | return bodies; | ||
702 | } | ||
703 | } | ||
704 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF index f15381b2..73ebb2c7 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF | |||
@@ -6,16 +6,16 @@ Bundle-Version: 1.0.0.qualifier | |||
6 | Bundle-ClassPath: . | 6 | Bundle-ClassPath: . |
7 | Bundle-Vendor: %providerName | 7 | Bundle-Vendor: %providerName |
8 | Bundle-Localization: plugin | 8 | Bundle-Localization: plugin |
9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm, | 9 | Export-Package: hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm, |
10 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl, | 10 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl, |
11 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.util, | 11 | hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.util, |
12 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu, | 12 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu, |
13 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated, | 13 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated, |
14 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.util, | 14 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.util, |
15 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.util | 15 | hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.util |
16 | Require-Bundle: org.eclipse.viatra.query.runtime, | 16 | Require-Bundle: org.eclipse.viatra.query.runtime, |
17 | org.eclipse.core.runtime, | 17 | org.eclipse.core.runtime, |
18 | org.eclipse.emf.ecore;visibility:=reexport, | 18 | org.eclipse.emf.ecore;visibility:=reexport, |
19 | com.google.guava;bundle-version="15.0.0" | 19 | com.google.guava;bundle-version="15.0.0" |
20 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | 20 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
21 | Bundle-ActivationPolicy: lazy | 21 | Bundle-ActivationPolicy: lazy |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml index 8069f168..993ec75d 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml | |||
@@ -1,103 +1,103 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><plugin> | 1 | <?xml version="1.0" encoding="UTF-8"?><plugin> |
2 | <extension point="org.eclipse.emf.ecore.generated_package"> | 2 | <extension point="org.eclipse.emf.ecore.generated_package"> |
3 | <!-- @generated yakindu_simplified --> | 3 | <!-- @generated yakindu_simplified --> |
4 | <package class="hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage" genModel="model/yakindu_simplified.genmodel" uri="hu.bme.mit.inf.yakindumm"/> | 4 | <package class="hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage" genModel="model/yakindu_simplified.genmodel" uri="hu.bme.mit.inf.yakindumm"/> |
5 | </extension> | 5 | </extension> |
6 | <extension id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns" point="org.eclipse.viatra.query.runtime.queryspecification"> | 6 | <extension id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns" point="org.eclipse.viatra.query.runtime.queryspecification"> |
7 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns" id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns"> | 7 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns" id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns"> |
8 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.entryInRegion"/> | 8 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.entryInRegion"/> |
9 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.noEntryInRegion"/> | 9 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.noEntryInRegion"/> |
10 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.multipleEntryInRegion"/> | 10 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.multipleEntryInRegion"/> |
11 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.transition"/> | 11 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.transition"/> |
12 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.incomingToEntry"/> | 12 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.incomingToEntry"/> |
13 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.noOutgoingTransitionFromEntry"/> | 13 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.noOutgoingTransitionFromEntry"/> |
14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.multipleTransitionFromEntry"/> | 14 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.multipleTransitionFromEntry"/> |
15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.outgoingFromExit"/> | 15 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.outgoingFromExit"/> |
16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.outgoingFromFinal"/> | 16 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.outgoingFromFinal"/> |
17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.noStateInRegion"/> | 17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.noStateInRegion"/> |
18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.StateInRegion"/> | 18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.StateInRegion"/> |
19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.choiceHasNoOutgoing"/> | 19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.choiceHasNoOutgoing"/> |
20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.choiceHasNoIncoming"/> | 20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.choiceHasNoIncoming"/> |
21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.synchHasNoOutgoing"/> | 21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.synchHasNoOutgoing"/> |
22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.synchHasNoIncoming"/> | 22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.synchHasNoIncoming"/> |
23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.SynchronizedIncomingInSameRegion"/> | 23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.SynchronizedIncomingInSameRegion"/> |
24 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.notSynchronizingStates"/> | 24 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.notSynchronizingStates"/> |
25 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleOutgoingTrainsition"/> | 25 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleOutgoingTrainsition"/> |
26 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleIncomingTrainsition"/> | 26 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleIncomingTrainsition"/> |
27 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.SynchronizedRegionsAreNotSiblings"/> | 27 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.SynchronizedRegionsAreNotSiblings"/> |
28 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.child"/> | 28 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.child"/> |
29 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.SynchronizedRegionDoesNotHaveMultipleRegions"/> | 29 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.SynchronizedRegionDoesNotHaveMultipleRegions"/> |
30 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleRegions"/> | 30 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.hasMultipleRegions"/> |
31 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.synchThree"/> | 31 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.synchThree"/> |
32 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.twoSynch"/> | 32 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.twoSynch"/> |
33 | </group> | 33 | </group> |
34 | </extension> | 34 | </extension> |
35 | <extension id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" point="org.eclipse.viatra.query.runtime.queryspecification"> | 35 | <extension id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" point="org.eclipse.viatra.query.runtime.queryspecification"> |
36 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated"> | 36 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated"> |
37 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M0"/> | 37 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M0"/> |
38 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M1"/> | 38 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M1"/> |
39 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M2"/> | 39 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M2"/> |
40 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M0"/> | 40 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M0"/> |
41 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M1"/> | 41 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M1"/> |
42 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M2"/> | 42 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M2"/> |
43 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M3"/> | 43 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M3"/> |
44 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M4"/> | 44 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M4"/> |
45 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M5"/> | 45 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M5"/> |
46 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M0"/> | 46 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M0"/> |
47 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M1"/> | 47 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M1"/> |
48 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M2"/> | 48 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M2"/> |
49 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M3"/> | 49 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M3"/> |
50 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M4"/> | 50 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M4"/> |
51 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M5"/> | 51 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M5"/> |
52 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M0"/> | 52 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M0"/> |
53 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M1"/> | 53 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M1"/> |
54 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M2"/> | 54 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M2"/> |
55 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M3"/> | 55 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M3"/> |
56 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M4"/> | 56 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M4"/> |
57 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_M0"/> | 57 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_M0"/> |
58 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_1"/> | 58 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_1"/> |
59 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_2"/> | 59 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_2"/> |
60 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_3"/> | 60 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_3"/> |
61 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_4"/> | 61 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_4"/> |
62 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_5"/> | 62 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_5"/> |
63 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M0"/> | 63 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M0"/> |
64 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M1"/> | 64 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M1"/> |
65 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M2"/> | 65 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M2"/> |
66 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M3"/> | 66 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M3"/> |
67 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M4"/> | 67 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M4"/> |
68 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M5"/> | 68 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M5"/> |
69 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M0"/> | 69 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M0"/> |
70 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M1"/> | 70 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M1"/> |
71 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M2"/> | 71 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M2"/> |
72 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M3"/> | 72 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M3"/> |
73 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M4"/> | 73 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M4"/> |
74 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M0"/> | 74 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M0"/> |
75 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M1"/> | 75 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M1"/> |
76 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M2"/> | 76 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M2"/> |
77 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M0"/> | 77 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M0"/> |
78 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M1"/> | 78 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M1"/> |
79 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M2"/> | 79 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M2"/> |
80 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M0"/> | 80 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M0"/> |
81 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M1"/> | 81 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M1"/> |
82 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M2"/> | 82 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M2"/> |
83 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M3"/> | 83 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M3"/> |
84 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M0"/> | 84 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M0"/> |
85 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M1"/> | 85 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M1"/> |
86 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M2"/> | 86 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M2"/> |
87 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M0"/> | 87 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M0"/> |
88 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M1"/> | 88 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M1"/> |
89 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M2"/> | 89 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M2"/> |
90 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M3"/> | 90 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M3"/> |
91 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M4"/> | 91 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M4"/> |
92 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M5"/> | 92 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M5"/> |
93 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M6"/> | 93 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M6"/> |
94 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M0"/> | 94 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M0"/> |
95 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M1"/> | 95 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M1"/> |
96 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M2"/> | 96 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M2"/> |
97 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M3"/> | 97 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M3"/> |
98 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M4"/> | 98 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M4"/> |
99 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M5"/> | 99 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M5"/> |
100 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M6"/> | 100 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M6"/> |
101 | </group> | 101 | </group> |
102 | </extension> | 102 | </extension> |
103 | </plugin> | 103 | </plugin> |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/plugin.xml b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/plugin.xml index 413002e2..bad09614 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/plugin.xml +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/plugin.xml | |||
@@ -1,27 +1,27 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- | 1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- |
2 | --><plugin> | 2 | --><plugin> |
3 | <extension point="org.eclipse.emf.ecore.generated_package"> | 3 | <extension point="org.eclipse.emf.ecore.generated_package"> |
4 | <!-- @generated logiclanguage --> | 4 | <!-- @generated logiclanguage --> |
5 | <package class="hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage" genModel="model/logiclanguage.genmodel" uri="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language"/> | 5 | <package class="hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage" genModel="model/logiclanguage.genmodel" uri="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language"/> |
6 | </extension> | 6 | </extension> |
7 | <extension point="org.eclipse.emf.ecore.generated_package"> | 7 | <extension point="org.eclipse.emf.ecore.generated_package"> |
8 | <!-- @generated logiclanguage --> | 8 | <!-- @generated logiclanguage --> |
9 | <package class="hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage" genModel="model/logiclanguage.genmodel" uri="http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem"/> | 9 | <package class="hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage" genModel="model/logiclanguage.genmodel" uri="http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem"/> |
10 | </extension> | 10 | </extension> |
11 | <extension point="org.eclipse.emf.ecore.generated_package"> | 11 | <extension point="org.eclipse.emf.ecore.generated_package"> |
12 | <!-- @generated logiclanguage --> | 12 | <!-- @generated logiclanguage --> |
13 | <package class="hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultPackage" genModel="model/logiclanguage.genmodel" uri="http://www.bme.hu/mit/inf/dslreasoner/logic/model/result"/> | 13 | <package class="hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultPackage" genModel="model/logiclanguage.genmodel" uri="http://www.bme.hu/mit/inf/dslreasoner/logic/model/result"/> |
14 | </extension> | 14 | </extension> |
15 | <extension id="hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeUtil" point="org.eclipse.viatra.query.runtime.queryspecification"> | 15 | <extension id="hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeUtil" point="org.eclipse.viatra.query.runtime.queryspecification"> |
16 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeUtil" id="hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeUtil"> | 16 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeUtil" id="hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeUtil"> |
17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.supertypeStar"/> | 17 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.supertypeStar"/> |
18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.typeDirectElements"/> | 18 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.typeDirectElements"/> |
19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.possibleDynamicType"/> | 19 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.possibleDynamicType"/> |
20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.mustTypeElement"/> | 20 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.mustTypeElement"/> |
21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.typeSystemIsInconsistent"/> | 21 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.typeSystemIsInconsistent"/> |
22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.elementNotDefinedInSupertype"/> | 22 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.elementNotDefinedInSupertype"/> |
23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.elementWithNoPossibleDynamicType"/> | 23 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.elementWithNoPossibleDynamicType"/> |
24 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.cyclicTypeHierarchy"/> | 24 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.logic.model.patterns.cyclicTypeHierarchy"/> |
25 | </group> | 25 | </group> |
26 | </extension> | 26 | </extension> |
27 | </plugin> | 27 | </plugin> |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath index a2655410..849e2a7b 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath | |||
@@ -1,10 +1,14 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <classpath> | 2 | <classpath> |
3 | <classpathentry kind="src" path="ecore-gen"/> | 3 | <classpathentry kind="src" path="ecore-gen"/> |
4 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | 4 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> |
5 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | 5 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
6 | <classpathentry kind="src" path="src"/> | 6 | <classpathentry kind="src" path="src"/> |
7 | <classpathentry kind="src" path="xtend-gen"/> | 7 | <classpathentry kind="src" path="xtend-gen"/> |
8 | <classpathentry kind="lib" path="lib/com.microsoft.z3.jar"/> | 8 | <classpathentry kind="lib" path="lib/com.microsoft.z3.jar"> |
9 | <classpathentry kind="output" path="bin"/> | 9 | <attributes> |
10 | </classpath> | 10 | <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="hu.bme.mit.inf.dslreasoner.viatra2logic/lib"/> |
11 | </attributes> | ||
12 | </classpathentry> | ||
13 | <classpathentry kind="output" path="bin"/> | ||
14 | </classpath> | ||
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.gitignore b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.gitignore index 8ae4e44d..40206e28 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.gitignore +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.gitignore | |||
@@ -2,3 +2,4 @@ | |||
2 | /src-gen/ | 2 | /src-gen/ |
3 | /vql-gen/ | 3 | /vql-gen/ |
4 | /xtend-gen/ | 4 | /xtend-gen/ |
5 | /lib/* | ||
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/lib/.gitignore b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/lib/.gitignore new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/lib/.gitignore | |||
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml index 5457d70c..e57b595a 100644 --- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml +++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml | |||
@@ -1,17 +1,17 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- | 1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- |
2 | --><plugin> | 2 | --><plugin> |
3 | <extension id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries" point="org.eclipse.viatra.query.runtime.queryspecification"> | 3 | <extension id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries" point="org.eclipse.viatra.query.runtime.queryspecification"> |
4 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries" id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries"> | 4 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries" id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries"> |
5 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.directSubset"/> | 5 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.directSubset"/> |
6 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.subset"/> | 6 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.subset"/> |
7 | </group> | 7 | </group> |
8 | </extension> | 8 | </extension> |
9 | <extension id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries" point="org.eclipse.viatra.query.runtime.queryspecification"> | 9 | <extension id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries" point="org.eclipse.viatra.query.runtime.queryspecification"> |
10 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries" id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries"> | 10 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries" id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries"> |
11 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.supertype"/> | 11 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.supertype"/> |
12 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.topmostCommonSubtypes"/> | 12 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.topmostCommonSubtypes"/> |
13 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.lowermostCommonSupertype"/> | 13 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.lowermostCommonSupertype"/> |
14 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.lowestCommonSupertypeOfAllOccuranceOfElement"/> | 14 | <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.lowestCommonSupertypeOfAllOccuranceOfElement"/> |
15 | </group> | 15 | </group> |
16 | </extension> | 16 | </extension> |
17 | </plugin> | 17 | </plugin> |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/plugin.xml b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/plugin.xml index 05e00983..6e4d96ca 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/plugin.xml +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/plugin.xml | |||
@@ -1,14 +1,14 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><plugin> | 1 | <?xml version="1.0" encoding="UTF-8"?><plugin> |
2 | <extension id="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.TypeAnalysis" point="org.eclipse.viatra.query.runtime.queryspecification"> | 2 | <extension id="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.TypeAnalysis" point="org.eclipse.viatra.query.runtime.queryspecification"> |
3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.TypeAnalysis" id="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.TypeAnalysis"> | 3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.TypeAnalysis" id="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.TypeAnalysis"> |
4 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.hasDefinedSupertype"/> | 4 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.hasDefinedSupertype"/> |
5 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.dontHaveDefinedSupertype"/> | 5 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.dontHaveDefinedSupertype"/> |
6 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementTypeConstructor"/> | 6 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementTypeConstructor"/> |
7 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementTypeRefinementTarget"/> | 7 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementTypeRefinementTarget"/> |
8 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.incompatibleSuperType"/> | 8 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.incompatibleSuperType"/> |
9 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.incompatibleTopType"/> | 9 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.incompatibleTopType"/> |
10 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementTypeRefinementNegativeConstraint"/> | 10 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementTypeRefinementNegativeConstraint"/> |
11 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementMayTypeNegativeConstraint"/> | 11 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries.newElementMayTypeNegativeConstraint"/> |
12 | </group> | 12 | </group> |
13 | </extension> | 13 | </extension> |
14 | </plugin> | 14 | </plugin> |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/.gitignore b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/.gitignore deleted file mode 100644 index 3d70f0da..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/.gitignore +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | /queries/ | ||
2 | /run/ | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace index 12849bfe..ab0f3a9a 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace index 1b0dca98..aaf4d0c2 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.gitignore b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.gitignore new file mode 100644 index 00000000..3be531f5 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.gitignore | |||
@@ -0,0 +1,8 @@ | |||
1 | /.FamilyTreeConstraints.java._trace | ||
2 | /.MemberIsItsOwnParent.java._trace | ||
3 | /FamilyTreeConstraints.java | ||
4 | /MemberIsItsOwnParent.java | ||
5 | /.ParentTooYoung.java._trace | ||
6 | /.MemberHasNoParent.java._trace | ||
7 | /.MemberHasParent.java._trace | ||
8 | /.TwoMembersHaveNoParent.java._trace | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/errors.txt b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/errors.txt index b7eed629..637be9c5 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/errors.txt +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/errors.txt | |||
@@ -1,16 +1,16 @@ | |||
1 | Error occured (NullPointerException): | 1 | Error occured (NullPointerException): |
2 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PConstraintTransformer.hasValueExpression(PConstraintTransformer.java:487) | 2 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PConstraintTransformer.hasValueExpression(PConstraintTransformer.java:487) |
3 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PConstraintTransformer._transformConstraint(PConstraintTransformer.java:614) | 3 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PConstraintTransformer._transformConstraint(PConstraintTransformer.java:614) |
4 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PConstraintTransformer.transformConstraint(PConstraintTransformer.java:689) | 4 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PConstraintTransformer.transformConstraint(PConstraintTransformer.java:689) |
5 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.RelationDefinitionIndexer.transformPattern(RelationDefinitionIndexer.java:169) | 5 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.RelationDefinitionIndexer.transformPattern(RelationDefinitionIndexer.java:169) |
6 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.RelationDefinitionIndexer.generateRelationDefinitions(RelationDefinitionIndexer.java:51) | 6 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.RelationDefinitionIndexer.generateRelationDefinitions(RelationDefinitionIndexer.java:51) |
7 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator.transformBaseProperties(PatternGenerator.java:747) | 7 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator.transformBaseProperties(PatternGenerator.java:747) |
8 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider.generateQueries(PatternProvider.java:59) | 8 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider.generateQueries(PatternProvider.java:59) |
9 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethodProvider.createModelGenerationMethod(ModelGenerationMethodProvider.java:57) | 9 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethodProvider.createModelGenerationMethod(ModelGenerationMethodProvider.java:57) |
10 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner.solve(ViatraReasoner.java:96) | 10 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner.solve(ViatraReasoner.java:96) |
11 | hu.bme.mit.inf.dslreasoner.application.execution.GenerationTaskExecutor.executeGenerationTask(GenerationTaskExecutor.java:316) | 11 | hu.bme.mit.inf.dslreasoner.application.execution.GenerationTaskExecutor.executeGenerationTask(GenerationTaskExecutor.java:316) |
12 | hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor._execute(ScriptExecutor.java:129) | 12 | hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor._execute(ScriptExecutor.java:129) |
13 | hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor.execute(ScriptExecutor.java:338) | 13 | hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor.execute(ScriptExecutor.java:338) |
14 | hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor.executeScript(ScriptExecutor.java:110) | 14 | hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor.executeScript(ScriptExecutor.java:110) |
15 | hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor.executeScript(StandaloneScriptExecutor.java:149) | 15 | hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor.executeScript(StandaloneScriptExecutor.java:149) |
16 | run.FamilyTreeGen.main(FamilyTreeGen.java:7) | 16 | run.FamilyTreeGen.main(FamilyTreeGen.java:7) |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem index 327ce8b0..d15360ce 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem | |||
@@ -1,340 +1,340 @@ | |||
1 | <?xml version="1.0" encoding="ASCII"?> | 1 | <?xml version="1.0" encoding="ASCII"?> |
2 | <language:LogicProblem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore2logicannotations="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language/ecore2logicannotation" xmlns:language="http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem" xmlns:language_1="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" xmlns:viatra2logicannotations="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language/viatra2logicannotation"> | 2 | <language:LogicProblem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore2logicannotations="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language/ecore2logicannotation" xmlns:language="http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem" xmlns:language_1="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" xmlns:viatra2logicannotations="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language/viatra2logicannotation"> |
3 | <types xsi:type="language_1:TypeDeclaration" name="FamilyTree class"/> | 3 | <types xsi:type="language_1:TypeDeclaration" name="FamilyTree class"/> |
4 | <types xsi:type="language_1:TypeDeclaration" name="Member class"/> | 4 | <types xsi:type="language_1:TypeDeclaration" name="Member class"/> |
5 | <assertions name="upperMultiplicity parents Member" annotations="//@annotations.0"> | 5 | <assertions name="upperMultiplicity parents Member" annotations="//@annotations.0"> |
6 | <value xsi:type="language_1:Forall"> | 6 | <value xsi:type="language_1:Forall"> |
7 | <quantifiedVariables name="src"> | 7 | <quantifiedVariables name="src"> |
8 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 8 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
9 | </quantifiedVariables> | 9 | </quantifiedVariables> |
10 | <quantifiedVariables name="trg 1"> | 10 | <quantifiedVariables name="trg 1"> |
11 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 11 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
12 | </quantifiedVariables> | 12 | </quantifiedVariables> |
13 | <quantifiedVariables name="trg 2"> | 13 | <quantifiedVariables name="trg 2"> |
14 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 14 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
15 | </quantifiedVariables> | 15 | </quantifiedVariables> |
16 | <quantifiedVariables name="trg 3"> | 16 | <quantifiedVariables name="trg 3"> |
17 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 17 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
18 | </quantifiedVariables> | 18 | </quantifiedVariables> |
19 | <expression xsi:type="language_1:Impl"> | 19 | <expression xsi:type="language_1:Impl"> |
20 | <leftOperand xsi:type="language_1:And"> | 20 | <leftOperand xsi:type="language_1:And"> |
21 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 21 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
22 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/> | 22 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/> |
23 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.1"/> | 23 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.1"/> |
24 | </operands> | 24 | </operands> |
25 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 25 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
26 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/> | 26 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/> |
27 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.2"/> | 27 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.2"/> |
28 | </operands> | 28 | </operands> |
29 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 29 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
30 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/> | 30 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/> |
31 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.3"/> | 31 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.3"/> |
32 | </operands> | 32 | </operands> |
33 | </leftOperand> | 33 | </leftOperand> |
34 | <rightOperand xsi:type="language_1:Not"> | 34 | <rightOperand xsi:type="language_1:Not"> |
35 | <operand xsi:type="language_1:Distinct"> | 35 | <operand xsi:type="language_1:Distinct"> |
36 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.1"/> | 36 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.1"/> |
37 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.2"/> | 37 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.2"/> |
38 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.3"/> | 38 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.3"/> |
39 | </operand> | 39 | </operand> |
40 | </rightOperand> | 40 | </rightOperand> |
41 | </expression> | 41 | </expression> |
42 | </value> | 42 | </value> |
43 | </assertions> | 43 | </assertions> |
44 | <assertions name="oppositeReference children Member" annotations="//@annotations.1"> | 44 | <assertions name="oppositeReference children Member" annotations="//@annotations.1"> |
45 | <value xsi:type="language_1:Forall"> | 45 | <value xsi:type="language_1:Forall"> |
46 | <quantifiedVariables name="src"> | 46 | <quantifiedVariables name="src"> |
47 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 47 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
48 | </quantifiedVariables> | 48 | </quantifiedVariables> |
49 | <quantifiedVariables name="trg"> | 49 | <quantifiedVariables name="trg"> |
50 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 50 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
51 | </quantifiedVariables> | 51 | </quantifiedVariables> |
52 | <expression xsi:type="language_1:Iff"> | 52 | <expression xsi:type="language_1:Iff"> |
53 | <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.1"> | 53 | <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.1"> |
54 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.0"/> | 54 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.0"/> |
55 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.1"/> | 55 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.1"/> |
56 | </leftOperand> | 56 | </leftOperand> |
57 | <rightOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 57 | <rightOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
58 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.1"/> | 58 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.1"/> |
59 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.0"/> | 59 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.0"/> |
60 | </rightOperand> | 60 | </rightOperand> |
61 | </expression> | 61 | </expression> |
62 | </value> | 62 | </value> |
63 | </assertions> | 63 | </assertions> |
64 | <assertions name="upperMultiplicity name Member" annotations="//@annotations.2"> | 64 | <assertions name="upperMultiplicity name Member" annotations="//@annotations.2"> |
65 | <value xsi:type="language_1:Forall"> | 65 | <value xsi:type="language_1:Forall"> |
66 | <quantifiedVariables name="src"> | 66 | <quantifiedVariables name="src"> |
67 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 67 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
68 | </quantifiedVariables> | 68 | </quantifiedVariables> |
69 | <quantifiedVariables name="trg 1"> | 69 | <quantifiedVariables name="trg 1"> |
70 | <range xsi:type="language_1:StringTypeReference"/> | 70 | <range xsi:type="language_1:StringTypeReference"/> |
71 | </quantifiedVariables> | 71 | </quantifiedVariables> |
72 | <quantifiedVariables name="trg 2"> | 72 | <quantifiedVariables name="trg 2"> |
73 | <range xsi:type="language_1:StringTypeReference"/> | 73 | <range xsi:type="language_1:StringTypeReference"/> |
74 | </quantifiedVariables> | 74 | </quantifiedVariables> |
75 | <expression xsi:type="language_1:Impl"> | 75 | <expression xsi:type="language_1:Impl"> |
76 | <leftOperand xsi:type="language_1:And"> | 76 | <leftOperand xsi:type="language_1:And"> |
77 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.3"> | 77 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.3"> |
78 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.0"/> | 78 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.0"/> |
79 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.1"/> | 79 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.1"/> |
80 | </operands> | 80 | </operands> |
81 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.3"> | 81 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.3"> |
82 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.0"/> | 82 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.0"/> |
83 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.2"/> | 83 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.2"/> |
84 | </operands> | 84 | </operands> |
85 | </leftOperand> | 85 | </leftOperand> |
86 | <rightOperand xsi:type="language_1:Not"> | 86 | <rightOperand xsi:type="language_1:Not"> |
87 | <operand xsi:type="language_1:Distinct"> | 87 | <operand xsi:type="language_1:Distinct"> |
88 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.1"/> | 88 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.1"/> |
89 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.2"/> | 89 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.2"/> |
90 | </operand> | 90 | </operand> |
91 | </rightOperand> | 91 | </rightOperand> |
92 | </expression> | 92 | </expression> |
93 | </value> | 93 | </value> |
94 | </assertions> | 94 | </assertions> |
95 | <assertions name="upperMultiplicity age Member" annotations="//@annotations.3"> | 95 | <assertions name="upperMultiplicity age Member" annotations="//@annotations.3"> |
96 | <value xsi:type="language_1:Forall"> | 96 | <value xsi:type="language_1:Forall"> |
97 | <quantifiedVariables name="src"> | 97 | <quantifiedVariables name="src"> |
98 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 98 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
99 | </quantifiedVariables> | 99 | </quantifiedVariables> |
100 | <quantifiedVariables name="trg 1"> | 100 | <quantifiedVariables name="trg 1"> |
101 | <range xsi:type="language_1:IntTypeReference"/> | 101 | <range xsi:type="language_1:IntTypeReference"/> |
102 | </quantifiedVariables> | 102 | </quantifiedVariables> |
103 | <quantifiedVariables name="trg 2"> | 103 | <quantifiedVariables name="trg 2"> |
104 | <range xsi:type="language_1:IntTypeReference"/> | 104 | <range xsi:type="language_1:IntTypeReference"/> |
105 | </quantifiedVariables> | 105 | </quantifiedVariables> |
106 | <expression xsi:type="language_1:Impl"> | 106 | <expression xsi:type="language_1:Impl"> |
107 | <leftOperand xsi:type="language_1:And"> | 107 | <leftOperand xsi:type="language_1:And"> |
108 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> | 108 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> |
109 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.0"/> | 109 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.0"/> |
110 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.1"/> | 110 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.1"/> |
111 | </operands> | 111 | </operands> |
112 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> | 112 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> |
113 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.0"/> | 113 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.0"/> |
114 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.2"/> | 114 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.2"/> |
115 | </operands> | 115 | </operands> |
116 | </leftOperand> | 116 | </leftOperand> |
117 | <rightOperand xsi:type="language_1:Not"> | 117 | <rightOperand xsi:type="language_1:Not"> |
118 | <operand xsi:type="language_1:Distinct"> | 118 | <operand xsi:type="language_1:Distinct"> |
119 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.1"/> | 119 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.1"/> |
120 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.2"/> | 120 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.2"/> |
121 | </operand> | 121 | </operand> |
122 | </rightOperand> | 122 | </rightOperand> |
123 | </expression> | 123 | </expression> |
124 | </value> | 124 | </value> |
125 | </assertions> | 125 | </assertions> |
126 | <assertions name="errorpattern queries memberIsItsOwnParent" annotations="//@annotations.8"> | 126 | <assertions name="errorpattern queries memberIsItsOwnParent" annotations="//@annotations.8"> |
127 | <value xsi:type="language_1:Forall"> | 127 | <value xsi:type="language_1:Forall"> |
128 | <quantifiedVariables name="p0"> | 128 | <quantifiedVariables name="p0"> |
129 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 129 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
130 | </quantifiedVariables> | 130 | </quantifiedVariables> |
131 | <expression xsi:type="language_1:Not"> | 131 | <expression xsi:type="language_1:Not"> |
132 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5"> | 132 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5"> |
133 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.4/@value/@quantifiedVariables.0"/> | 133 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.4/@value/@quantifiedVariables.0"/> |
134 | </operand> | 134 | </operand> |
135 | </expression> | 135 | </expression> |
136 | </value> | 136 | </value> |
137 | </assertions> | 137 | </assertions> |
138 | <assertions name="errorpattern queries twoMembersHaveNoParent" annotations="//@annotations.9"> | 138 | <assertions name="errorpattern queries twoMembersHaveNoParent" annotations="//@annotations.9"> |
139 | <value xsi:type="language_1:Forall"> | 139 | <value xsi:type="language_1:Forall"> |
140 | <quantifiedVariables name="p0"> | 140 | <quantifiedVariables name="p0"> |
141 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 141 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
142 | </quantifiedVariables> | 142 | </quantifiedVariables> |
143 | <quantifiedVariables name="p1"> | 143 | <quantifiedVariables name="p1"> |
144 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 144 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
145 | </quantifiedVariables> | 145 | </quantifiedVariables> |
146 | <expression xsi:type="language_1:Not"> | 146 | <expression xsi:type="language_1:Not"> |
147 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6"> | 147 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6"> |
148 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.5/@value/@quantifiedVariables.0"/> | 148 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.5/@value/@quantifiedVariables.0"/> |
149 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.5/@value/@quantifiedVariables.1"/> | 149 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.5/@value/@quantifiedVariables.1"/> |
150 | </operand> | 150 | </operand> |
151 | </expression> | 151 | </expression> |
152 | </value> | 152 | </value> |
153 | </assertions> | 153 | </assertions> |
154 | <assertions name="errorpattern queries parentTooYoung" annotations="//@annotations.10"> | 154 | <assertions name="errorpattern queries parentTooYoung" annotations="//@annotations.10"> |
155 | <value xsi:type="language_1:Forall"> | 155 | <value xsi:type="language_1:Forall"> |
156 | <quantifiedVariables name="p0"> | 156 | <quantifiedVariables name="p0"> |
157 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 157 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
158 | </quantifiedVariables> | 158 | </quantifiedVariables> |
159 | <quantifiedVariables name="p1"> | 159 | <quantifiedVariables name="p1"> |
160 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 160 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
161 | </quantifiedVariables> | 161 | </quantifiedVariables> |
162 | <expression xsi:type="language_1:Not"> | 162 | <expression xsi:type="language_1:Not"> |
163 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8"> | 163 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8"> |
164 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.6/@value/@quantifiedVariables.0"/> | 164 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.6/@value/@quantifiedVariables.0"/> |
165 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.6/@value/@quantifiedVariables.1"/> | 165 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.6/@value/@quantifiedVariables.1"/> |
166 | </operand> | 166 | </operand> |
167 | </expression> | 167 | </expression> |
168 | </value> | 168 | </value> |
169 | </assertions> | 169 | </assertions> |
170 | <relations xsi:type="language_1:RelationDeclaration" name="members reference FamilyTree"> | 170 | <relations xsi:type="language_1:RelationDeclaration" name="members reference FamilyTree"> |
171 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/> | 171 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/> |
172 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 172 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
173 | </relations> | 173 | </relations> |
174 | <relations xsi:type="language_1:RelationDeclaration" name="children reference Member"> | 174 | <relations xsi:type="language_1:RelationDeclaration" name="children reference Member"> |
175 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 175 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
176 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 176 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
177 | </relations> | 177 | </relations> |
178 | <relations xsi:type="language_1:RelationDeclaration" name="parents reference Member"> | 178 | <relations xsi:type="language_1:RelationDeclaration" name="parents reference Member"> |
179 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 179 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
180 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 180 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
181 | </relations> | 181 | </relations> |
182 | <relations xsi:type="language_1:RelationDeclaration" name="name attribute Member"> | 182 | <relations xsi:type="language_1:RelationDeclaration" name="name attribute Member"> |
183 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 183 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
184 | <parameters xsi:type="language_1:StringTypeReference"/> | 184 | <parameters xsi:type="language_1:StringTypeReference"/> |
185 | </relations> | 185 | </relations> |
186 | <relations xsi:type="language_1:RelationDeclaration" name="age attribute Member"> | 186 | <relations xsi:type="language_1:RelationDeclaration" name="age attribute Member"> |
187 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 187 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
188 | <parameters xsi:type="language_1:IntTypeReference"/> | 188 | <parameters xsi:type="language_1:IntTypeReference"/> |
189 | </relations> | 189 | </relations> |
190 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries memberIsItsOwnParent" annotations="//@annotations.4"> | 190 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries memberIsItsOwnParent" annotations="//@annotations.4"> |
191 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 191 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
192 | <variables name="parameter m"> | 192 | <variables name="parameter m"> |
193 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 193 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
194 | </variables> | 194 | </variables> |
195 | <value xsi:type="language_1:Or"> | 195 | <value xsi:type="language_1:Or"> |
196 | <operands xsi:type="language_1:Exists"> | 196 | <operands xsi:type="language_1:Exists"> |
197 | <quantifiedVariables name="variable 0"> | 197 | <quantifiedVariables name="variable 0"> |
198 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/> | 198 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/> |
199 | </quantifiedVariables> | 199 | </quantifiedVariables> |
200 | <expression xsi:type="language_1:And"> | 200 | <expression xsi:type="language_1:And"> |
201 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.0"> | 201 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.0"> |
202 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@value/@operands.0/@quantifiedVariables.0"/> | 202 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@value/@operands.0/@quantifiedVariables.0"/> |
203 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/> | 203 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/> |
204 | </operands> | 204 | </operands> |
205 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 205 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
206 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/> | 206 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/> |
207 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/> | 207 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/> |
208 | </operands> | 208 | </operands> |
209 | </expression> | 209 | </expression> |
210 | </operands> | 210 | </operands> |
211 | </value> | 211 | </value> |
212 | </relations> | 212 | </relations> |
213 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries twoMembersHaveNoParent" annotations="//@annotations.5"> | 213 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries twoMembersHaveNoParent" annotations="//@annotations.5"> |
214 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 214 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
215 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 215 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
216 | <variables name="parameter m1"> | 216 | <variables name="parameter m1"> |
217 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 217 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
218 | </variables> | 218 | </variables> |
219 | <variables name="parameter m2"> | 219 | <variables name="parameter m2"> |
220 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 220 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
221 | </variables> | 221 | </variables> |
222 | <value xsi:type="language_1:Or"> | 222 | <value xsi:type="language_1:Or"> |
223 | <operands xsi:type="language_1:And"> | 223 | <operands xsi:type="language_1:And"> |
224 | <operands xsi:type="language_1:InstanceOf"> | 224 | <operands xsi:type="language_1:InstanceOf"> |
225 | <value xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.0"/> | 225 | <value xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.0"/> |
226 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 226 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
227 | </operands> | 227 | </operands> |
228 | <operands xsi:type="language_1:InstanceOf"> | 228 | <operands xsi:type="language_1:InstanceOf"> |
229 | <value xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.1"/> | 229 | <value xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.1"/> |
230 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 230 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
231 | </operands> | 231 | </operands> |
232 | <operands xsi:type="language_1:Not"> | 232 | <operands xsi:type="language_1:Not"> |
233 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7"> | 233 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7"> |
234 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.0"/> | 234 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.0"/> |
235 | </operand> | 235 | </operand> |
236 | </operands> | 236 | </operands> |
237 | <operands xsi:type="language_1:Not"> | 237 | <operands xsi:type="language_1:Not"> |
238 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7"> | 238 | <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7"> |
239 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.1"/> | 239 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.1"/> |
240 | </operand> | 240 | </operand> |
241 | </operands> | 241 | </operands> |
242 | <operands xsi:type="language_1:Distinct"> | 242 | <operands xsi:type="language_1:Distinct"> |
243 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.0"/> | 243 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.0"/> |
244 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.1"/> | 244 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.6/@variables.1"/> |
245 | </operands> | 245 | </operands> |
246 | </operands> | 246 | </operands> |
247 | </value> | 247 | </value> |
248 | </relations> | 248 | </relations> |
249 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries memberHasParent" annotations="//@annotations.6"> | 249 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries memberHasParent" annotations="//@annotations.6"> |
250 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 250 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
251 | <variables name="parameter m"> | 251 | <variables name="parameter m"> |
252 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 252 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
253 | </variables> | 253 | </variables> |
254 | <value xsi:type="language_1:Or"> | 254 | <value xsi:type="language_1:Or"> |
255 | <operands xsi:type="language_1:Exists"> | 255 | <operands xsi:type="language_1:Exists"> |
256 | <quantifiedVariables name="variable 0"> | 256 | <quantifiedVariables name="variable 0"> |
257 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 257 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
258 | </quantifiedVariables> | 258 | </quantifiedVariables> |
259 | <expression xsi:type="language_1:And"> | 259 | <expression xsi:type="language_1:And"> |
260 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 260 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
261 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7/@variables.0"/> | 261 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7/@variables.0"/> |
262 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7/@value/@operands.0/@quantifiedVariables.0"/> | 262 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7/@value/@operands.0/@quantifiedVariables.0"/> |
263 | </operands> | 263 | </operands> |
264 | <operands xsi:type="language_1:InstanceOf"> | 264 | <operands xsi:type="language_1:InstanceOf"> |
265 | <value xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7/@value/@operands.0/@quantifiedVariables.0"/> | 265 | <value xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.7/@value/@operands.0/@quantifiedVariables.0"/> |
266 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 266 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
267 | </operands> | 267 | </operands> |
268 | </expression> | 268 | </expression> |
269 | </operands> | 269 | </operands> |
270 | </value> | 270 | </value> |
271 | </relations> | 271 | </relations> |
272 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries parentTooYoung" annotations="//@annotations.7"> | 272 | <relations xsi:type="language_1:RelationDefinition" name="pattern queries parentTooYoung" annotations="//@annotations.7"> |
273 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 273 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
274 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 274 | <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
275 | <variables name="parameter m"> | 275 | <variables name="parameter m"> |
276 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 276 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
277 | </variables> | 277 | </variables> |
278 | <variables name="parameter p"> | 278 | <variables name="parameter p"> |
279 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> | 279 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/> |
280 | </variables> | 280 | </variables> |
281 | <value xsi:type="language_1:Or"> | 281 | <value xsi:type="language_1:Or"> |
282 | <operands xsi:type="language_1:Exists"> | 282 | <operands xsi:type="language_1:Exists"> |
283 | <quantifiedVariables name="variable 0"> | 283 | <quantifiedVariables name="variable 0"> |
284 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/> | 284 | <range xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/> |
285 | </quantifiedVariables> | 285 | </quantifiedVariables> |
286 | <quantifiedVariables name="variable mAge"> | 286 | <quantifiedVariables name="variable mAge"> |
287 | <range xsi:type="language_1:IntTypeReference"/> | 287 | <range xsi:type="language_1:IntTypeReference"/> |
288 | </quantifiedVariables> | 288 | </quantifiedVariables> |
289 | <quantifiedVariables name="variable pAge"> | 289 | <quantifiedVariables name="variable pAge"> |
290 | <range xsi:type="language_1:IntTypeReference"/> | 290 | <range xsi:type="language_1:IntTypeReference"/> |
291 | </quantifiedVariables> | 291 | </quantifiedVariables> |
292 | <expression xsi:type="language_1:And"> | 292 | <expression xsi:type="language_1:And"> |
293 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.0"> | 293 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.0"> |
294 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.0"/> | 294 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.0"/> |
295 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.0"/> | 295 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.0"/> |
296 | </operands> | 296 | </operands> |
297 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> | 297 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2"> |
298 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.0"/> | 298 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.0"/> |
299 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.1"/> | 299 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.1"/> |
300 | </operands> | 300 | </operands> |
301 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> | 301 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> |
302 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.0"/> | 302 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.0"/> |
303 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.1"/> | 303 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.1"/> |
304 | </operands> | 304 | </operands> |
305 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> | 305 | <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4"> |
306 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.1"/> | 306 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@variables.1"/> |
307 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.2"/> | 307 | <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.2"/> |
308 | </operands> | 308 | </operands> |
309 | <operands xsi:type="language_1:LessOrEqualThan"> | 309 | <operands xsi:type="language_1:LessOrEqualThan"> |
310 | <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.1"/> | 310 | <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.1"/> |
311 | <rightOperand xsi:type="language_1:Plus"> | 311 | <rightOperand xsi:type="language_1:Plus"> |
312 | <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.2"/> | 312 | <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.8/@value/@operands.0/@quantifiedVariables.2"/> |
313 | <rightOperand xsi:type="language_1:IntLiteral" value="12"/> | 313 | <rightOperand xsi:type="language_1:IntLiteral" value="12"/> |
314 | </rightOperand> | 314 | </rightOperand> |
315 | </operands> | 315 | </operands> |
316 | </expression> | 316 | </expression> |
317 | </operands> | 317 | </operands> |
318 | </value> | 318 | </value> |
319 | </relations> | 319 | </relations> |
320 | <containmentHierarchies typesOrderedInHierarchy="//@types.1 //@types.0" containmentRelations="//@relations.0"/> | 320 | <containmentHierarchies typesOrderedInHierarchy="//@types.0 //@types.1" containmentRelations="//@relations.0"/> |
321 | <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.0" relation="//@relations.2" upper="2"/> | 321 | <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.0" relation="//@relations.2" upper="2"/> |
322 | <annotations xsi:type="ecore2logicannotations:InverseRelationAssertion" target="//@assertions.1" inverseA="//@relations.1" inverseB="//@relations.2"/> | 322 | <annotations xsi:type="ecore2logicannotations:InverseRelationAssertion" target="//@assertions.1" inverseA="//@relations.1" inverseB="//@relations.2"/> |
323 | <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.2" relation="//@relations.3" upper="1"/> | 323 | <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.2" relation="//@relations.3" upper="1"/> |
324 | <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.3" relation="//@relations.4" upper="1"/> | 324 | <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.3" relation="//@relations.4" upper="1"/> |
325 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.5" patternFullyQualifiedName="queries.memberIsItsOwnParent"> | 325 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.5" patternFullyQualifiedName="queries.memberIsItsOwnParent"> |
326 | <variableTrace targetLogicVariable="//@relations.5/@value/@operands.0/@quantifiedVariables.0"/> | 326 | <variableTrace targetLogicVariable="//@relations.5/@value/@operands.0/@quantifiedVariables.0"/> |
327 | </annotations> | 327 | </annotations> |
328 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.6" patternFullyQualifiedName="queries.twoMembersHaveNoParent"/> | 328 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.6" patternFullyQualifiedName="queries.twoMembersHaveNoParent"/> |
329 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.7" patternFullyQualifiedName="queries.memberHasParent"> | 329 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.7" patternFullyQualifiedName="queries.memberHasParent"> |
330 | <variableTrace targetLogicVariable="//@relations.7/@value/@operands.0/@quantifiedVariables.0"/> | 330 | <variableTrace targetLogicVariable="//@relations.7/@value/@operands.0/@quantifiedVariables.0"/> |
331 | </annotations> | 331 | </annotations> |
332 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.8" patternFullyQualifiedName="queries.parentTooYoung"> | 332 | <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.8" patternFullyQualifiedName="queries.parentTooYoung"> |
333 | <variableTrace targetLogicVariable="//@relations.8/@value/@operands.0/@quantifiedVariables.0"/> | 333 | <variableTrace targetLogicVariable="//@relations.8/@value/@operands.0/@quantifiedVariables.0"/> |
334 | <variableTrace targetLogicVariable="//@relations.8/@value/@operands.0/@quantifiedVariables.1"/> | 334 | <variableTrace targetLogicVariable="//@relations.8/@value/@operands.0/@quantifiedVariables.1"/> |
335 | <variableTrace targetLogicVariable="//@relations.8/@value/@operands.0/@quantifiedVariables.2"/> | 335 | <variableTrace targetLogicVariable="//@relations.8/@value/@operands.0/@quantifiedVariables.2"/> |
336 | </annotations> | 336 | </annotations> |
337 | <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.4" query="//@annotations.4"/> | 337 | <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.4" query="//@annotations.4"/> |
338 | <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.5" query="//@annotations.5"/> | 338 | <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.5" query="//@annotations.5"/> |
339 | <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.6" query="//@annotations.7"/> | 339 | <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.6" query="//@annotations.7"/> |
340 | </language:LogicProblem> | 340 | </language:LogicProblem> |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel index 949d6b64..df908518 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel | |||
@@ -1,51 +1,51 @@ | |||
1 | <?xml version="1.0" encoding="ASCII"?> | 1 | <?xml version="1.0" encoding="ASCII"?> |
2 | <partialinterpretation:PartialInterpretation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:language="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" xmlns:partialinterpretation="http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage" minNewElements="6" maxNewElements="6"> | 2 | <partialinterpretation:PartialInterpretation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:language="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" xmlns:partialinterpretation="http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage" minNewElements="6" maxNewElements="6"> |
3 | <problem href="outputs/debug/generation.logicproblem#/"/> | 3 | <problem href="outputs/debug/generation.logicproblem#/"/> |
4 | <partialrelationinterpretation> | 4 | <partialrelationinterpretation> |
5 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.0"/> | 5 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.0"/> |
6 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.0/@parameters.0"/> | 6 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.0/@parameters.0"/> |
7 | <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.0/@parameters.1"/> | 7 | <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.0/@parameters.1"/> |
8 | </partialrelationinterpretation> | 8 | </partialrelationinterpretation> |
9 | <partialrelationinterpretation> | 9 | <partialrelationinterpretation> |
10 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.1"/> | 10 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.1"/> |
11 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.1/@parameters.0"/> | 11 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.1/@parameters.0"/> |
12 | <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.1/@parameters.1"/> | 12 | <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.1/@parameters.1"/> |
13 | </partialrelationinterpretation> | 13 | </partialrelationinterpretation> |
14 | <partialrelationinterpretation> | 14 | <partialrelationinterpretation> |
15 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.2"/> | 15 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.2"/> |
16 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.2/@parameters.0"/> | 16 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.2/@parameters.0"/> |
17 | <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.2/@parameters.1"/> | 17 | <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.2/@parameters.1"/> |
18 | </partialrelationinterpretation> | 18 | </partialrelationinterpretation> |
19 | <partialrelationinterpretation> | 19 | <partialrelationinterpretation> |
20 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.3"/> | 20 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.3"/> |
21 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.3/@parameters.0"/> | 21 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.3/@parameters.0"/> |
22 | <param2 xsi:type="language:StringTypeReference" href="outputs/debug/generation.logicproblem#//@relations.3/@parameters.1"/> | 22 | <param2 xsi:type="language:StringTypeReference" href="outputs/debug/generation.logicproblem#//@relations.3/@parameters.1"/> |
23 | </partialrelationinterpretation> | 23 | </partialrelationinterpretation> |
24 | <partialrelationinterpretation> | 24 | <partialrelationinterpretation> |
25 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.4"/> | 25 | <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.4"/> |
26 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.4/@parameters.0"/> | 26 | <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.4/@parameters.0"/> |
27 | <param2 xsi:type="language:IntTypeReference" href="outputs/debug/generation.logicproblem#//@relations.4/@parameters.1"/> | 27 | <param2 xsi:type="language:IntTypeReference" href="outputs/debug/generation.logicproblem#//@relations.4/@parameters.1"/> |
28 | </partialrelationinterpretation> | 28 | </partialrelationinterpretation> |
29 | <newElements xsi:type="partialinterpretation:BooleanElement" name="true" valueSet="true" value="true"/> | 29 | <newElements xsi:type="partialinterpretation:BooleanElement" name="true" valueSet="true" value="true"/> |
30 | <newElements xsi:type="partialinterpretation:BooleanElement" name="false" valueSet="true"/> | 30 | <newElements xsi:type="partialinterpretation:BooleanElement" name="false" valueSet="true"/> |
31 | <newElements xsi:type="partialinterpretation:IntegerElement" name="1" valueSet="true" value="1"/> | 31 | <newElements xsi:type="partialinterpretation:IntegerElement" name="1" valueSet="true" value="1"/> |
32 | <newElements xsi:type="partialinterpretation:IntegerElement" name="2" valueSet="true" value="2"/> | 32 | <newElements xsi:type="partialinterpretation:IntegerElement" name="2" valueSet="true" value="2"/> |
33 | <newElements xsi:type="partialinterpretation:IntegerElement" name="3" valueSet="true" value="3"/> | 33 | <newElements xsi:type="partialinterpretation:IntegerElement" name="3" valueSet="true" value="3"/> |
34 | <newElements xsi:type="partialinterpretation:IntegerElement" name="4" valueSet="true" value="4"/> | 34 | <newElements xsi:type="partialinterpretation:IntegerElement" name="4" valueSet="true" value="4"/> |
35 | <newElements xsi:type="partialinterpretation:IntegerElement" name="5" valueSet="true" value="5"/> | 35 | <newElements xsi:type="partialinterpretation:IntegerElement" name="5" valueSet="true" value="5"/> |
36 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialBooleanInterpretation" elements="//@newElements.0 //@newElements.1"/> | 36 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialBooleanInterpretation" elements="//@newElements.0 //@newElements.1"/> |
37 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialIntegerInterpretation" elements="//@newElements.2 //@newElements.3 //@newElements.4 //@newElements.5 //@newElements.6"/> | 37 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialIntegerInterpretation" elements="//@newElements.2 //@newElements.3 //@newElements.4 //@newElements.5 //@newElements.6"/> |
38 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialRealInterpretation" elements="//@openWorldElements.0"/> | 38 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialRealInterpretation" elements="//@openWorldElements.0"/> |
39 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialStringInterpretation" elements="//@openWorldElements.1"/> | 39 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialStringInterpretation" elements="//@openWorldElements.1"/> |
40 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialComplexTypeInterpretation" scopes="//@scopes.0"> | 40 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialComplexTypeInterpretation" scopes="//@scopes.0"> |
41 | <interpretationOf href="outputs/debug/generation.logicproblem#//@types.0"/> | 41 | <interpretationOf href="outputs/debug/generation.logicproblem#//@types.0"/> |
42 | </partialtypeinterpratation> | 42 | </partialtypeinterpratation> |
43 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialComplexTypeInterpretation" scopes="//@scopes.1"> | 43 | <partialtypeinterpratation xsi:type="partialinterpretation:PartialComplexTypeInterpretation" scopes="//@scopes.1"> |
44 | <interpretationOf href="outputs/debug/generation.logicproblem#//@types.1"/> | 44 | <interpretationOf href="outputs/debug/generation.logicproblem#//@types.1"/> |
45 | </partialtypeinterpratation> | 45 | </partialtypeinterpratation> |
46 | <openWorldElements xsi:type="partialinterpretation:RealElement" name="New Reals"/> | 46 | <openWorldElements xsi:type="partialinterpretation:RealElement" name="New Reals"/> |
47 | <openWorldElements xsi:type="partialinterpretation:StringElement" name="New Strings"/> | 47 | <openWorldElements xsi:type="partialinterpretation:StringElement" name="New Strings"/> |
48 | <openWorldElements name="New Objects"/> | 48 | <openWorldElements name="New Objects"/> |
49 | <scopes targetTypeInterpretation="//@partialtypeinterpratation.4"/> | 49 | <scopes targetTypeInterpretation="//@partialtypeinterpratation.4"/> |
50 | <scopes targetTypeInterpretation="//@partialtypeinterpratation.5"/> | 50 | <scopes targetTypeInterpretation="//@partialtypeinterpratation.5"/> |
51 | </partialinterpretation:PartialInterpretation> | 51 | </partialinterpretation:PartialInterpretation> |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt index 43befb00..1d3c9f62 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt | |||
@@ -1 +1 @@ | |||
Model generation started | Model generation started | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml index 9364ebb2..941ef4d7 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml | |||
@@ -1,10 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><plugin> | 1 | <?xml version="1.0" encoding="UTF-8"?><plugin> |
2 | <extension id="queries.FamilyTreeConstraints" point="org.eclipse.viatra.query.runtime.queryspecification"> | 2 | <extension id="queries.FamilyTreeConstraints" point="org.eclipse.viatra.query.runtime.queryspecification"> |
3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.FamilyTreeConstraints" id="queries.FamilyTreeConstraints"> | 3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.FamilyTreeConstraints" id="queries.FamilyTreeConstraints"> |
4 | <query-specification fqn="queries.memberIsItsOwnParent"/> | 4 | <query-specification fqn="queries.memberIsItsOwnParent"/> |
5 | <query-specification fqn="queries.twoMembersHaveNoParent"/> | 5 | <query-specification fqn="queries.twoMembersHaveNoParent"/> |
6 | <query-specification fqn="queries.memberHasParent"/> | 6 | <query-specification fqn="queries.memberHasParent"/> |
7 | <query-specification fqn="queries.parentTooYoung"/> | 7 | <query-specification fqn="queries.parentTooYoung"/> |
8 | </group> | 8 | </group> |
9 | </extension> | 9 | </extension> |
10 | </plugin> | 10 | </plugin> |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace index 12849bfe..ab0f3a9a 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace index 1b0dca98..aaf4d0c2 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java index 738b41c0..97148b5e 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java | |||
@@ -1,86 +1,86 @@ | |||
1 | /** | 1 | /** |
2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql | 2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql |
3 | */ | 3 | */ |
4 | package queries; | 4 | package queries; |
5 | 5 | ||
6 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 6 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; |
7 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | 7 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; |
8 | import queries.MemberHasParent; | 8 | import queries.MemberHasParent; |
9 | import queries.MemberIsItsOwnParent; | 9 | import queries.MemberIsItsOwnParent; |
10 | import queries.ParentTooYoung; | 10 | import queries.ParentTooYoung; |
11 | import queries.TwoMembersHaveNoParent; | 11 | import queries.TwoMembersHaveNoParent; |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * A pattern group formed of all public patterns defined in familyTreeConstraints.vql. | 14 | * A pattern group formed of all public patterns defined in familyTreeConstraints.vql. |
15 | * | 15 | * |
16 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare | 16 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare |
17 | * a VIATRA Query engine for matching all patterns originally defined in file familyTreeConstraints.vql, | 17 | * a VIATRA Query engine for matching all patterns originally defined in file familyTreeConstraints.vql, |
18 | * in order to achieve better performance than one-by-one on-demand matcher initialization. | 18 | * in order to achieve better performance than one-by-one on-demand matcher initialization. |
19 | * | 19 | * |
20 | * <p> From package queries, the group contains the definition of the following patterns: <ul> | 20 | * <p> From package queries, the group contains the definition of the following patterns: <ul> |
21 | * <li>memberIsItsOwnParent</li> | 21 | * <li>memberIsItsOwnParent</li> |
22 | * <li>twoMembersHaveNoParent</li> | 22 | * <li>twoMembersHaveNoParent</li> |
23 | * <li>memberHasParent</li> | 23 | * <li>memberHasParent</li> |
24 | * <li>parentTooYoung</li> | 24 | * <li>parentTooYoung</li> |
25 | * </ul> | 25 | * </ul> |
26 | * | 26 | * |
27 | * @see IQueryGroup | 27 | * @see IQueryGroup |
28 | * | 28 | * |
29 | */ | 29 | */ |
30 | @SuppressWarnings("all") | 30 | @SuppressWarnings("all") |
31 | public final class FamilyTreeConstraints extends BaseGeneratedPatternGroup { | 31 | public final class FamilyTreeConstraints extends BaseGeneratedPatternGroup { |
32 | /** | 32 | /** |
33 | * Access the pattern group. | 33 | * Access the pattern group. |
34 | * | 34 | * |
35 | * @return the singleton instance of the group | 35 | * @return the singleton instance of the group |
36 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | 36 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications |
37 | * | 37 | * |
38 | */ | 38 | */ |
39 | public static FamilyTreeConstraints instance() { | 39 | public static FamilyTreeConstraints instance() { |
40 | if (INSTANCE == null) { | 40 | if (INSTANCE == null) { |
41 | INSTANCE = new FamilyTreeConstraints(); | 41 | INSTANCE = new FamilyTreeConstraints(); |
42 | } | 42 | } |
43 | return INSTANCE; | 43 | return INSTANCE; |
44 | } | 44 | } |
45 | 45 | ||
46 | private static FamilyTreeConstraints INSTANCE; | 46 | private static FamilyTreeConstraints INSTANCE; |
47 | 47 | ||
48 | private FamilyTreeConstraints() { | 48 | private FamilyTreeConstraints() { |
49 | querySpecifications.add(MemberIsItsOwnParent.instance()); | 49 | querySpecifications.add(MemberIsItsOwnParent.instance()); |
50 | querySpecifications.add(TwoMembersHaveNoParent.instance()); | 50 | querySpecifications.add(TwoMembersHaveNoParent.instance()); |
51 | querySpecifications.add(MemberHasParent.instance()); | 51 | querySpecifications.add(MemberHasParent.instance()); |
52 | querySpecifications.add(ParentTooYoung.instance()); | 52 | querySpecifications.add(ParentTooYoung.instance()); |
53 | } | 53 | } |
54 | 54 | ||
55 | public MemberIsItsOwnParent getMemberIsItsOwnParent() { | 55 | public MemberIsItsOwnParent getMemberIsItsOwnParent() { |
56 | return MemberIsItsOwnParent.instance(); | 56 | return MemberIsItsOwnParent.instance(); |
57 | } | 57 | } |
58 | 58 | ||
59 | public MemberIsItsOwnParent.Matcher getMemberIsItsOwnParent(final ViatraQueryEngine engine) { | 59 | public MemberIsItsOwnParent.Matcher getMemberIsItsOwnParent(final ViatraQueryEngine engine) { |
60 | return MemberIsItsOwnParent.Matcher.on(engine); | 60 | return MemberIsItsOwnParent.Matcher.on(engine); |
61 | } | 61 | } |
62 | 62 | ||
63 | public TwoMembersHaveNoParent getTwoMembersHaveNoParent() { | 63 | public TwoMembersHaveNoParent getTwoMembersHaveNoParent() { |
64 | return TwoMembersHaveNoParent.instance(); | 64 | return TwoMembersHaveNoParent.instance(); |
65 | } | 65 | } |
66 | 66 | ||
67 | public TwoMembersHaveNoParent.Matcher getTwoMembersHaveNoParent(final ViatraQueryEngine engine) { | 67 | public TwoMembersHaveNoParent.Matcher getTwoMembersHaveNoParent(final ViatraQueryEngine engine) { |
68 | return TwoMembersHaveNoParent.Matcher.on(engine); | 68 | return TwoMembersHaveNoParent.Matcher.on(engine); |
69 | } | 69 | } |
70 | 70 | ||
71 | public MemberHasParent getMemberHasParent() { | 71 | public MemberHasParent getMemberHasParent() { |
72 | return MemberHasParent.instance(); | 72 | return MemberHasParent.instance(); |
73 | } | 73 | } |
74 | 74 | ||
75 | public MemberHasParent.Matcher getMemberHasParent(final ViatraQueryEngine engine) { | 75 | public MemberHasParent.Matcher getMemberHasParent(final ViatraQueryEngine engine) { |
76 | return MemberHasParent.Matcher.on(engine); | 76 | return MemberHasParent.Matcher.on(engine); |
77 | } | 77 | } |
78 | 78 | ||
79 | public ParentTooYoung getParentTooYoung() { | 79 | public ParentTooYoung getParentTooYoung() { |
80 | return ParentTooYoung.instance(); | 80 | return ParentTooYoung.instance(); |
81 | } | 81 | } |
82 | 82 | ||
83 | public ParentTooYoung.Matcher getParentTooYoung(final ViatraQueryEngine engine) { | 83 | public ParentTooYoung.Matcher getParentTooYoung(final ViatraQueryEngine engine) { |
84 | return ParentTooYoung.Matcher.on(engine); | 84 | return ParentTooYoung.Matcher.on(engine); |
85 | } | 85 | } |
86 | } | 86 | } |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberHasParent.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberHasParent.java index 82b83d0c..83bb4aac 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberHasParent.java +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberHasParent.java | |||
@@ -1,551 +1,551 @@ | |||
1 | /** | 1 | /** |
2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql | 2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql |
3 | */ | 3 | */ |
4 | package queries; | 4 | package queries; |
5 | 5 | ||
6 | import familytree.Member; | 6 | import familytree.Member; |
7 | import java.util.Arrays; | 7 | import java.util.Arrays; |
8 | import java.util.Collection; | 8 | import java.util.Collection; |
9 | import java.util.LinkedHashSet; | 9 | import java.util.LinkedHashSet; |
10 | import java.util.List; | 10 | import java.util.List; |
11 | import java.util.Objects; | 11 | import java.util.Objects; |
12 | import java.util.Optional; | 12 | import java.util.Optional; |
13 | import java.util.Set; | 13 | import java.util.Set; |
14 | import java.util.function.Consumer; | 14 | import java.util.function.Consumer; |
15 | import java.util.stream.Collectors; | 15 | import java.util.stream.Collectors; |
16 | import java.util.stream.Stream; | 16 | import java.util.stream.Stream; |
17 | import org.apache.log4j.Logger; | 17 | import org.apache.log4j.Logger; |
18 | import org.eclipse.emf.ecore.EClass; | 18 | import org.eclipse.emf.ecore.EClass; |
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | 19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; |
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; |
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | 22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; |
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | 23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; |
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | 24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; |
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | 25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; |
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | 26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; |
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | 27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; |
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | 28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | 29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; |
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | 30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; |
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | 32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; |
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | 33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; |
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | 34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; |
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | 35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; |
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; |
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | 37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; |
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | 39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | 42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. |
43 | * | 43 | * |
44 | * <p>Original source: | 44 | * <p>Original source: |
45 | * <code><pre> | 45 | * <code><pre> |
46 | * pattern memberHasParent(m: Member) = { | 46 | * pattern memberHasParent(m: Member) = { |
47 | * Member.parents(m, _); | 47 | * Member.parents(m, _); |
48 | * } | 48 | * } |
49 | * </pre></code> | 49 | * </pre></code> |
50 | * | 50 | * |
51 | * @see Matcher | 51 | * @see Matcher |
52 | * @see Match | 52 | * @see Match |
53 | * | 53 | * |
54 | */ | 54 | */ |
55 | @SuppressWarnings("all") | 55 | @SuppressWarnings("all") |
56 | public final class MemberHasParent extends BaseGeneratedEMFQuerySpecification<MemberHasParent.Matcher> { | 56 | public final class MemberHasParent extends BaseGeneratedEMFQuerySpecification<MemberHasParent.Matcher> { |
57 | /** | 57 | /** |
58 | * Pattern-specific match representation of the queries.memberHasParent pattern, | 58 | * Pattern-specific match representation of the queries.memberHasParent pattern, |
59 | * to be used in conjunction with {@link Matcher}. | 59 | * to be used in conjunction with {@link Matcher}. |
60 | * | 60 | * |
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | 61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. |
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | 62 | * Each instance is a (possibly partial) substitution of pattern parameters, |
63 | * usable to represent a match of the pattern in the result of a query, | 63 | * usable to represent a match of the pattern in the result of a query, |
64 | * or to specify the bound (fixed) input parameters when issuing a query. | 64 | * or to specify the bound (fixed) input parameters when issuing a query. |
65 | * | 65 | * |
66 | * @see Matcher | 66 | * @see Matcher |
67 | * | 67 | * |
68 | */ | 68 | */ |
69 | public static abstract class Match extends BasePatternMatch { | 69 | public static abstract class Match extends BasePatternMatch { |
70 | private Member fM; | 70 | private Member fM; |
71 | 71 | ||
72 | private static List<String> parameterNames = makeImmutableList("m"); | 72 | private static List<String> parameterNames = makeImmutableList("m"); |
73 | 73 | ||
74 | private Match(final Member pM) { | 74 | private Match(final Member pM) { |
75 | this.fM = pM; | 75 | this.fM = pM; |
76 | } | 76 | } |
77 | 77 | ||
78 | @Override | 78 | @Override |
79 | public Object get(final String parameterName) { | 79 | public Object get(final String parameterName) { |
80 | switch(parameterName) { | 80 | switch(parameterName) { |
81 | case "m": return this.fM; | 81 | case "m": return this.fM; |
82 | default: return null; | 82 | default: return null; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | @Override | 86 | @Override |
87 | public Object get(final int index) { | 87 | public Object get(final int index) { |
88 | switch(index) { | 88 | switch(index) { |
89 | case 0: return this.fM; | 89 | case 0: return this.fM; |
90 | default: return null; | 90 | default: return null; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | public Member getM() { | 94 | public Member getM() { |
95 | return this.fM; | 95 | return this.fM; |
96 | } | 96 | } |
97 | 97 | ||
98 | @Override | 98 | @Override |
99 | public boolean set(final String parameterName, final Object newValue) { | 99 | public boolean set(final String parameterName, final Object newValue) { |
100 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 100 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
101 | if ("m".equals(parameterName) ) { | 101 | if ("m".equals(parameterName) ) { |
102 | this.fM = (Member) newValue; | 102 | this.fM = (Member) newValue; |
103 | return true; | 103 | return true; |
104 | } | 104 | } |
105 | return false; | 105 | return false; |
106 | } | 106 | } |
107 | 107 | ||
108 | public void setM(final Member pM) { | 108 | public void setM(final Member pM) { |
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
110 | this.fM = pM; | 110 | this.fM = pM; |
111 | } | 111 | } |
112 | 112 | ||
113 | @Override | 113 | @Override |
114 | public String patternName() { | 114 | public String patternName() { |
115 | return "queries.memberHasParent"; | 115 | return "queries.memberHasParent"; |
116 | } | 116 | } |
117 | 117 | ||
118 | @Override | 118 | @Override |
119 | public List<String> parameterNames() { | 119 | public List<String> parameterNames() { |
120 | return MemberHasParent.Match.parameterNames; | 120 | return MemberHasParent.Match.parameterNames; |
121 | } | 121 | } |
122 | 122 | ||
123 | @Override | 123 | @Override |
124 | public Object[] toArray() { | 124 | public Object[] toArray() { |
125 | return new Object[]{fM}; | 125 | return new Object[]{fM}; |
126 | } | 126 | } |
127 | 127 | ||
128 | @Override | 128 | @Override |
129 | public MemberHasParent.Match toImmutable() { | 129 | public MemberHasParent.Match toImmutable() { |
130 | return isMutable() ? newMatch(fM) : this; | 130 | return isMutable() ? newMatch(fM) : this; |
131 | } | 131 | } |
132 | 132 | ||
133 | @Override | 133 | @Override |
134 | public String prettyPrint() { | 134 | public String prettyPrint() { |
135 | StringBuilder result = new StringBuilder(); | 135 | StringBuilder result = new StringBuilder(); |
136 | result.append("\"m\"=" + prettyPrintValue(fM)); | 136 | result.append("\"m\"=" + prettyPrintValue(fM)); |
137 | return result.toString(); | 137 | return result.toString(); |
138 | } | 138 | } |
139 | 139 | ||
140 | @Override | 140 | @Override |
141 | public int hashCode() { | 141 | public int hashCode() { |
142 | return Objects.hash(fM); | 142 | return Objects.hash(fM); |
143 | } | 143 | } |
144 | 144 | ||
145 | @Override | 145 | @Override |
146 | public boolean equals(final Object obj) { | 146 | public boolean equals(final Object obj) { |
147 | if (this == obj) | 147 | if (this == obj) |
148 | return true; | 148 | return true; |
149 | if (obj == null) { | 149 | if (obj == null) { |
150 | return false; | 150 | return false; |
151 | } | 151 | } |
152 | if ((obj instanceof MemberHasParent.Match)) { | 152 | if ((obj instanceof MemberHasParent.Match)) { |
153 | MemberHasParent.Match other = (MemberHasParent.Match) obj; | 153 | MemberHasParent.Match other = (MemberHasParent.Match) obj; |
154 | return Objects.equals(fM, other.fM); | 154 | return Objects.equals(fM, other.fM); |
155 | } else { | 155 | } else { |
156 | // this should be infrequent | 156 | // this should be infrequent |
157 | if (!(obj instanceof IPatternMatch)) { | 157 | if (!(obj instanceof IPatternMatch)) { |
158 | return false; | 158 | return false; |
159 | } | 159 | } |
160 | IPatternMatch otherSig = (IPatternMatch) obj; | 160 | IPatternMatch otherSig = (IPatternMatch) obj; |
161 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | 161 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | @Override | 165 | @Override |
166 | public MemberHasParent specification() { | 166 | public MemberHasParent specification() { |
167 | return MemberHasParent.instance(); | 167 | return MemberHasParent.instance(); |
168 | } | 168 | } |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Returns an empty, mutable match. | 171 | * Returns an empty, mutable match. |
172 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 172 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
173 | * | 173 | * |
174 | * @return the empty match. | 174 | * @return the empty match. |
175 | * | 175 | * |
176 | */ | 176 | */ |
177 | public static MemberHasParent.Match newEmptyMatch() { | 177 | public static MemberHasParent.Match newEmptyMatch() { |
178 | return new Mutable(null); | 178 | return new Mutable(null); |
179 | } | 179 | } |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * Returns a mutable (partial) match. | 182 | * Returns a mutable (partial) match. |
183 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 183 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
184 | * | 184 | * |
185 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 185 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
186 | * @return the new, mutable (partial) match object. | 186 | * @return the new, mutable (partial) match object. |
187 | * | 187 | * |
188 | */ | 188 | */ |
189 | public static MemberHasParent.Match newMutableMatch(final Member pM) { | 189 | public static MemberHasParent.Match newMutableMatch(final Member pM) { |
190 | return new Mutable(pM); | 190 | return new Mutable(pM); |
191 | } | 191 | } |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Returns a new (partial) match. | 194 | * Returns a new (partial) match. |
195 | * This can be used e.g. to call the matcher with a partial match. | 195 | * This can be used e.g. to call the matcher with a partial match. |
196 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 196 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
197 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 197 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
198 | * @return the (partial) match object. | 198 | * @return the (partial) match object. |
199 | * | 199 | * |
200 | */ | 200 | */ |
201 | public static MemberHasParent.Match newMatch(final Member pM) { | 201 | public static MemberHasParent.Match newMatch(final Member pM) { |
202 | return new Immutable(pM); | 202 | return new Immutable(pM); |
203 | } | 203 | } |
204 | 204 | ||
205 | private static final class Mutable extends MemberHasParent.Match { | 205 | private static final class Mutable extends MemberHasParent.Match { |
206 | Mutable(final Member pM) { | 206 | Mutable(final Member pM) { |
207 | super(pM); | 207 | super(pM); |
208 | } | 208 | } |
209 | 209 | ||
210 | @Override | 210 | @Override |
211 | public boolean isMutable() { | 211 | public boolean isMutable() { |
212 | return true; | 212 | return true; |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | private static final class Immutable extends MemberHasParent.Match { | 216 | private static final class Immutable extends MemberHasParent.Match { |
217 | Immutable(final Member pM) { | 217 | Immutable(final Member pM) { |
218 | super(pM); | 218 | super(pM); |
219 | } | 219 | } |
220 | 220 | ||
221 | @Override | 221 | @Override |
222 | public boolean isMutable() { | 222 | public boolean isMutable() { |
223 | return false; | 223 | return false; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * Generated pattern matcher API of the queries.memberHasParent pattern, | 229 | * Generated pattern matcher API of the queries.memberHasParent pattern, |
230 | * providing pattern-specific query methods. | 230 | * providing pattern-specific query methods. |
231 | * | 231 | * |
232 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | 232 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, |
233 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | 233 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. |
234 | * | 234 | * |
235 | * <p>Matches of the pattern will be represented as {@link Match}. | 235 | * <p>Matches of the pattern will be represented as {@link Match}. |
236 | * | 236 | * |
237 | * <p>Original source: | 237 | * <p>Original source: |
238 | * <code><pre> | 238 | * <code><pre> |
239 | * pattern memberHasParent(m: Member) = { | 239 | * pattern memberHasParent(m: Member) = { |
240 | * Member.parents(m, _); | 240 | * Member.parents(m, _); |
241 | * } | 241 | * } |
242 | * </pre></code> | 242 | * </pre></code> |
243 | * | 243 | * |
244 | * @see Match | 244 | * @see Match |
245 | * @see MemberHasParent | 245 | * @see MemberHasParent |
246 | * | 246 | * |
247 | */ | 247 | */ |
248 | public static class Matcher extends BaseMatcher<MemberHasParent.Match> { | 248 | public static class Matcher extends BaseMatcher<MemberHasParent.Match> { |
249 | /** | 249 | /** |
250 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 250 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
251 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 251 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
252 | * | 252 | * |
253 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 253 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
254 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 254 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
255 | * | 255 | * |
256 | */ | 256 | */ |
257 | public static MemberHasParent.Matcher on(final ViatraQueryEngine engine) { | 257 | public static MemberHasParent.Matcher on(final ViatraQueryEngine engine) { |
258 | // check if matcher already exists | 258 | // check if matcher already exists |
259 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | 259 | Matcher matcher = engine.getExistingMatcher(querySpecification()); |
260 | if (matcher == null) { | 260 | if (matcher == null) { |
261 | matcher = (Matcher)engine.getMatcher(querySpecification()); | 261 | matcher = (Matcher)engine.getMatcher(querySpecification()); |
262 | } | 262 | } |
263 | return matcher; | 263 | return matcher; |
264 | } | 264 | } |
265 | 265 | ||
266 | /** | 266 | /** |
267 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 267 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
268 | * @return an initialized matcher | 268 | * @return an initialized matcher |
269 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | 269 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. |
270 | * | 270 | * |
271 | */ | 271 | */ |
272 | public static MemberHasParent.Matcher create() { | 272 | public static MemberHasParent.Matcher create() { |
273 | return new Matcher(); | 273 | return new Matcher(); |
274 | } | 274 | } |
275 | 275 | ||
276 | private static final int POSITION_M = 0; | 276 | private static final int POSITION_M = 0; |
277 | 277 | ||
278 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MemberHasParent.Matcher.class); | 278 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MemberHasParent.Matcher.class); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 281 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
282 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 282 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
283 | * | 283 | * |
284 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 284 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
286 | * | 286 | * |
287 | */ | 287 | */ |
288 | private Matcher() { | 288 | private Matcher() { |
289 | super(querySpecification()); | 289 | super(querySpecification()); |
290 | } | 290 | } |
291 | 291 | ||
292 | /** | 292 | /** |
293 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | 293 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. |
294 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 294 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
295 | * @return matches represented as a Match object. | 295 | * @return matches represented as a Match object. |
296 | * | 296 | * |
297 | */ | 297 | */ |
298 | public Collection<MemberHasParent.Match> getAllMatches(final Member pM) { | 298 | public Collection<MemberHasParent.Match> getAllMatches(final Member pM) { |
299 | return rawStreamAllMatches(new Object[]{pM}).collect(Collectors.toSet()); | 299 | return rawStreamAllMatches(new Object[]{pM}).collect(Collectors.toSet()); |
300 | } | 300 | } |
301 | 301 | ||
302 | /** | 302 | /** |
303 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | 303 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. |
304 | * </p> | 304 | * </p> |
305 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 305 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
306 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 306 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
307 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 307 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
308 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 308 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
309 | * @return a stream of matches represented as a Match object. | 309 | * @return a stream of matches represented as a Match object. |
310 | * | 310 | * |
311 | */ | 311 | */ |
312 | public Stream<MemberHasParent.Match> streamAllMatches(final Member pM) { | 312 | public Stream<MemberHasParent.Match> streamAllMatches(final Member pM) { |
313 | return rawStreamAllMatches(new Object[]{pM}); | 313 | return rawStreamAllMatches(new Object[]{pM}); |
314 | } | 314 | } |
315 | 315 | ||
316 | /** | 316 | /** |
317 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 317 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
318 | * Neither determinism nor randomness of selection is guaranteed. | 318 | * Neither determinism nor randomness of selection is guaranteed. |
319 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 319 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
320 | * @return a match represented as a Match object, or null if no match is found. | 320 | * @return a match represented as a Match object, or null if no match is found. |
321 | * | 321 | * |
322 | */ | 322 | */ |
323 | public Optional<MemberHasParent.Match> getOneArbitraryMatch(final Member pM) { | 323 | public Optional<MemberHasParent.Match> getOneArbitraryMatch(final Member pM) { |
324 | return rawGetOneArbitraryMatch(new Object[]{pM}); | 324 | return rawGetOneArbitraryMatch(new Object[]{pM}); |
325 | } | 325 | } |
326 | 326 | ||
327 | /** | 327 | /** |
328 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | 328 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, |
329 | * under any possible substitution of the unspecified parameters (if any). | 329 | * under any possible substitution of the unspecified parameters (if any). |
330 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 330 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
331 | * @return true if the input is a valid (partial) match of the pattern. | 331 | * @return true if the input is a valid (partial) match of the pattern. |
332 | * | 332 | * |
333 | */ | 333 | */ |
334 | public boolean hasMatch(final Member pM) { | 334 | public boolean hasMatch(final Member pM) { |
335 | return rawHasMatch(new Object[]{pM}); | 335 | return rawHasMatch(new Object[]{pM}); |
336 | } | 336 | } |
337 | 337 | ||
338 | /** | 338 | /** |
339 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | 339 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. |
340 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 340 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
341 | * @return the number of pattern matches found. | 341 | * @return the number of pattern matches found. |
342 | * | 342 | * |
343 | */ | 343 | */ |
344 | public int countMatches(final Member pM) { | 344 | public int countMatches(final Member pM) { |
345 | return rawCountMatches(new Object[]{pM}); | 345 | return rawCountMatches(new Object[]{pM}); |
346 | } | 346 | } |
347 | 347 | ||
348 | /** | 348 | /** |
349 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 349 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
350 | * Neither determinism nor randomness of selection is guaranteed. | 350 | * Neither determinism nor randomness of selection is guaranteed. |
351 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 351 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
352 | * @param processor the action that will process the selected match. | 352 | * @param processor the action that will process the selected match. |
353 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | 353 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked |
354 | * | 354 | * |
355 | */ | 355 | */ |
356 | public boolean forOneArbitraryMatch(final Member pM, final Consumer<? super MemberHasParent.Match> processor) { | 356 | public boolean forOneArbitraryMatch(final Member pM, final Consumer<? super MemberHasParent.Match> processor) { |
357 | return rawForOneArbitraryMatch(new Object[]{pM}, processor); | 357 | return rawForOneArbitraryMatch(new Object[]{pM}, processor); |
358 | } | 358 | } |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Returns a new (partial) match. | 361 | * Returns a new (partial) match. |
362 | * This can be used e.g. to call the matcher with a partial match. | 362 | * This can be used e.g. to call the matcher with a partial match. |
363 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 363 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
364 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 364 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
365 | * @return the (partial) match object. | 365 | * @return the (partial) match object. |
366 | * | 366 | * |
367 | */ | 367 | */ |
368 | public MemberHasParent.Match newMatch(final Member pM) { | 368 | public MemberHasParent.Match newMatch(final Member pM) { |
369 | return MemberHasParent.Match.newMatch(pM); | 369 | return MemberHasParent.Match.newMatch(pM); |
370 | } | 370 | } |
371 | 371 | ||
372 | /** | 372 | /** |
373 | * Retrieve the set of values that occur in matches for m. | 373 | * Retrieve the set of values that occur in matches for m. |
374 | * @return the Set of all values or empty set if there are no matches | 374 | * @return the Set of all values or empty set if there are no matches |
375 | * | 375 | * |
376 | */ | 376 | */ |
377 | protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) { | 377 | protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) { |
378 | return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast); | 378 | return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast); |
379 | } | 379 | } |
380 | 380 | ||
381 | /** | 381 | /** |
382 | * Retrieve the set of values that occur in matches for m. | 382 | * Retrieve the set of values that occur in matches for m. |
383 | * @return the Set of all values or empty set if there are no matches | 383 | * @return the Set of all values or empty set if there are no matches |
384 | * | 384 | * |
385 | */ | 385 | */ |
386 | public Set<Member> getAllValuesOfm() { | 386 | public Set<Member> getAllValuesOfm() { |
387 | return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet()); | 387 | return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet()); |
388 | } | 388 | } |
389 | 389 | ||
390 | /** | 390 | /** |
391 | * Retrieve the set of values that occur in matches for m. | 391 | * Retrieve the set of values that occur in matches for m. |
392 | * @return the Set of all values or empty set if there are no matches | 392 | * @return the Set of all values or empty set if there are no matches |
393 | * | 393 | * |
394 | */ | 394 | */ |
395 | public Stream<Member> streamAllValuesOfm() { | 395 | public Stream<Member> streamAllValuesOfm() { |
396 | return rawStreamAllValuesOfm(emptyArray()); | 396 | return rawStreamAllValuesOfm(emptyArray()); |
397 | } | 397 | } |
398 | 398 | ||
399 | @Override | 399 | @Override |
400 | protected MemberHasParent.Match tupleToMatch(final Tuple t) { | 400 | protected MemberHasParent.Match tupleToMatch(final Tuple t) { |
401 | try { | 401 | try { |
402 | return MemberHasParent.Match.newMatch((Member) t.get(POSITION_M)); | 402 | return MemberHasParent.Match.newMatch((Member) t.get(POSITION_M)); |
403 | } catch(ClassCastException e) { | 403 | } catch(ClassCastException e) { |
404 | LOGGER.error("Element(s) in tuple not properly typed!",e); | 404 | LOGGER.error("Element(s) in tuple not properly typed!",e); |
405 | return null; | 405 | return null; |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | @Override | 409 | @Override |
410 | protected MemberHasParent.Match arrayToMatch(final Object[] match) { | 410 | protected MemberHasParent.Match arrayToMatch(final Object[] match) { |
411 | try { | 411 | try { |
412 | return MemberHasParent.Match.newMatch((Member) match[POSITION_M]); | 412 | return MemberHasParent.Match.newMatch((Member) match[POSITION_M]); |
413 | } catch(ClassCastException e) { | 413 | } catch(ClassCastException e) { |
414 | LOGGER.error("Element(s) in array not properly typed!",e); | 414 | LOGGER.error("Element(s) in array not properly typed!",e); |
415 | return null; | 415 | return null; |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | @Override | 419 | @Override |
420 | protected MemberHasParent.Match arrayToMatchMutable(final Object[] match) { | 420 | protected MemberHasParent.Match arrayToMatchMutable(final Object[] match) { |
421 | try { | 421 | try { |
422 | return MemberHasParent.Match.newMutableMatch((Member) match[POSITION_M]); | 422 | return MemberHasParent.Match.newMutableMatch((Member) match[POSITION_M]); |
423 | } catch(ClassCastException e) { | 423 | } catch(ClassCastException e) { |
424 | LOGGER.error("Element(s) in array not properly typed!",e); | 424 | LOGGER.error("Element(s) in array not properly typed!",e); |
425 | return null; | 425 | return null; |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | /** | 429 | /** |
430 | * @return the singleton instance of the query specification of this pattern | 430 | * @return the singleton instance of the query specification of this pattern |
431 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 431 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
432 | * | 432 | * |
433 | */ | 433 | */ |
434 | public static IQuerySpecification<MemberHasParent.Matcher> querySpecification() { | 434 | public static IQuerySpecification<MemberHasParent.Matcher> querySpecification() { |
435 | return MemberHasParent.instance(); | 435 | return MemberHasParent.instance(); |
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||
439 | private MemberHasParent() { | 439 | private MemberHasParent() { |
440 | super(GeneratedPQuery.INSTANCE); | 440 | super(GeneratedPQuery.INSTANCE); |
441 | } | 441 | } |
442 | 442 | ||
443 | /** | 443 | /** |
444 | * @return the singleton instance of the query specification | 444 | * @return the singleton instance of the query specification |
445 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 445 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
446 | * | 446 | * |
447 | */ | 447 | */ |
448 | public static MemberHasParent instance() { | 448 | public static MemberHasParent instance() { |
449 | try{ | 449 | try{ |
450 | return LazyHolder.INSTANCE; | 450 | return LazyHolder.INSTANCE; |
451 | } catch (ExceptionInInitializerError err) { | 451 | } catch (ExceptionInInitializerError err) { |
452 | throw processInitializerError(err); | 452 | throw processInitializerError(err); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | @Override | 456 | @Override |
457 | protected MemberHasParent.Matcher instantiate(final ViatraQueryEngine engine) { | 457 | protected MemberHasParent.Matcher instantiate(final ViatraQueryEngine engine) { |
458 | return MemberHasParent.Matcher.on(engine); | 458 | return MemberHasParent.Matcher.on(engine); |
459 | } | 459 | } |
460 | 460 | ||
461 | @Override | 461 | @Override |
462 | public MemberHasParent.Matcher instantiate() { | 462 | public MemberHasParent.Matcher instantiate() { |
463 | return MemberHasParent.Matcher.create(); | 463 | return MemberHasParent.Matcher.create(); |
464 | } | 464 | } |
465 | 465 | ||
466 | @Override | 466 | @Override |
467 | public MemberHasParent.Match newEmptyMatch() { | 467 | public MemberHasParent.Match newEmptyMatch() { |
468 | return MemberHasParent.Match.newEmptyMatch(); | 468 | return MemberHasParent.Match.newEmptyMatch(); |
469 | } | 469 | } |
470 | 470 | ||
471 | @Override | 471 | @Override |
472 | public MemberHasParent.Match newMatch(final Object... parameters) { | 472 | public MemberHasParent.Match newMatch(final Object... parameters) { |
473 | return MemberHasParent.Match.newMatch((familytree.Member) parameters[0]); | 473 | return MemberHasParent.Match.newMatch((familytree.Member) parameters[0]); |
474 | } | 474 | } |
475 | 475 | ||
476 | /** | 476 | /** |
477 | * Inner class allowing the singleton instance of {@link MemberHasParent} to be created | 477 | * Inner class allowing the singleton instance of {@link MemberHasParent} to be created |
478 | * <b>not</b> at the class load time of the outer class, | 478 | * <b>not</b> at the class load time of the outer class, |
479 | * but rather at the first call to {@link MemberHasParent#instance()}. | 479 | * but rather at the first call to {@link MemberHasParent#instance()}. |
480 | * | 480 | * |
481 | * <p> This workaround is required e.g. to support recursion. | 481 | * <p> This workaround is required e.g. to support recursion. |
482 | * | 482 | * |
483 | */ | 483 | */ |
484 | private static class LazyHolder { | 484 | private static class LazyHolder { |
485 | private static final MemberHasParent INSTANCE = new MemberHasParent(); | 485 | private static final MemberHasParent INSTANCE = new MemberHasParent(); |
486 | 486 | ||
487 | /** | 487 | /** |
488 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | 488 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. |
489 | * This initialization order is required to support indirect recursion. | 489 | * This initialization order is required to support indirect recursion. |
490 | * | 490 | * |
491 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | 491 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. |
492 | * | 492 | * |
493 | */ | 493 | */ |
494 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | 494 | private static final Object STATIC_INITIALIZER = ensureInitialized(); |
495 | 495 | ||
496 | public static Object ensureInitialized() { | 496 | public static Object ensureInitialized() { |
497 | INSTANCE.ensureInitializedInternal(); | 497 | INSTANCE.ensureInitializedInternal(); |
498 | return null; | 498 | return null; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | 502 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { |
503 | private static final MemberHasParent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | 503 | private static final MemberHasParent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); |
504 | 504 | ||
505 | private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); | 505 | private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); |
506 | 506 | ||
507 | private final List<PParameter> parameters = Arrays.asList(parameter_m); | 507 | private final List<PParameter> parameters = Arrays.asList(parameter_m); |
508 | 508 | ||
509 | private GeneratedPQuery() { | 509 | private GeneratedPQuery() { |
510 | super(PVisibility.PUBLIC); | 510 | super(PVisibility.PUBLIC); |
511 | } | 511 | } |
512 | 512 | ||
513 | @Override | 513 | @Override |
514 | public String getFullyQualifiedName() { | 514 | public String getFullyQualifiedName() { |
515 | return "queries.memberHasParent"; | 515 | return "queries.memberHasParent"; |
516 | } | 516 | } |
517 | 517 | ||
518 | @Override | 518 | @Override |
519 | public List<String> getParameterNames() { | 519 | public List<String> getParameterNames() { |
520 | return Arrays.asList("m"); | 520 | return Arrays.asList("m"); |
521 | } | 521 | } |
522 | 522 | ||
523 | @Override | 523 | @Override |
524 | public List<PParameter> getParameters() { | 524 | public List<PParameter> getParameters() { |
525 | return parameters; | 525 | return parameters; |
526 | } | 526 | } |
527 | 527 | ||
528 | @Override | 528 | @Override |
529 | public Set<PBody> doGetContainedBodies() { | 529 | public Set<PBody> doGetContainedBodies() { |
530 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | 530 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); |
531 | Set<PBody> bodies = new LinkedHashSet<>(); | 531 | Set<PBody> bodies = new LinkedHashSet<>(); |
532 | { | 532 | { |
533 | PBody body = new PBody(this); | 533 | PBody body = new PBody(this); |
534 | PVariable var_m = body.getOrCreateVariableByName("m"); | 534 | PVariable var_m = body.getOrCreateVariableByName("m"); |
535 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | 535 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); |
536 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 536 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
537 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | 537 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( |
538 | new ExportedParameter(body, var_m, parameter_m) | 538 | new ExportedParameter(body, var_m, parameter_m) |
539 | )); | 539 | )); |
540 | // Member.parents(m, _) | 540 | // Member.parents(m, _) |
541 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 541 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
542 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | 542 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); |
543 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents"))); | 543 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents"))); |
544 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 544 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
545 | new Equality(body, var__virtual_0_, var___0_); | 545 | new Equality(body, var__virtual_0_, var___0_); |
546 | bodies.add(body); | 546 | bodies.add(body); |
547 | } | 547 | } |
548 | return bodies; | 548 | return bodies; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | } | 551 | } |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java index 67cdafb5..63cb882d 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java | |||
@@ -1,577 +1,577 @@ | |||
1 | /** | 1 | /** |
2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql | 2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql |
3 | */ | 3 | */ |
4 | package queries; | 4 | package queries; |
5 | 5 | ||
6 | import familytree.Member; | 6 | import familytree.Member; |
7 | import java.util.Arrays; | 7 | import java.util.Arrays; |
8 | import java.util.Collection; | 8 | import java.util.Collection; |
9 | import java.util.LinkedHashSet; | 9 | import java.util.LinkedHashSet; |
10 | import java.util.List; | 10 | import java.util.List; |
11 | import java.util.Objects; | 11 | import java.util.Objects; |
12 | import java.util.Optional; | 12 | import java.util.Optional; |
13 | import java.util.Set; | 13 | import java.util.Set; |
14 | import java.util.function.Consumer; | 14 | import java.util.function.Consumer; |
15 | import java.util.stream.Collectors; | 15 | import java.util.stream.Collectors; |
16 | import java.util.stream.Stream; | 16 | import java.util.stream.Stream; |
17 | import org.apache.log4j.Logger; | 17 | import org.apache.log4j.Logger; |
18 | import org.eclipse.emf.ecore.EClass; | 18 | import org.eclipse.emf.ecore.EClass; |
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | 19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; |
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; |
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | 22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; |
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | 23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; |
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | 24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; |
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | 25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; |
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | 26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; |
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | 27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; |
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | 28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | 29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; |
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | 30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; |
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | 32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; |
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | 33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; |
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | 34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; |
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | 35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; |
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | 36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; |
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | 37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; |
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; |
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | 39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; |
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | 41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | 44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. |
45 | * | 45 | * |
46 | * <p>Original source: | 46 | * <p>Original source: |
47 | * <code><pre> | 47 | * <code><pre> |
48 | * {@literal @}Constraint(message="memberIsItsOwnParent", severity="error", key={m}) | 48 | * {@literal @}Constraint(message="memberIsItsOwnParent", severity="error", key={m}) |
49 | * pattern memberIsItsOwnParent(m: Member) = { | 49 | * pattern memberIsItsOwnParent(m: Member) = { |
50 | * FamilyTree.members(_, m); | 50 | * FamilyTree.members(_, m); |
51 | * Member.parents(m, p); | 51 | * Member.parents(m, p); |
52 | * m == p; | 52 | * m == p; |
53 | * } | 53 | * } |
54 | * </pre></code> | 54 | * </pre></code> |
55 | * | 55 | * |
56 | * @see Matcher | 56 | * @see Matcher |
57 | * @see Match | 57 | * @see Match |
58 | * | 58 | * |
59 | */ | 59 | */ |
60 | @SuppressWarnings("all") | 60 | @SuppressWarnings("all") |
61 | public final class MemberIsItsOwnParent extends BaseGeneratedEMFQuerySpecification<MemberIsItsOwnParent.Matcher> { | 61 | public final class MemberIsItsOwnParent extends BaseGeneratedEMFQuerySpecification<MemberIsItsOwnParent.Matcher> { |
62 | /** | 62 | /** |
63 | * Pattern-specific match representation of the queries.memberIsItsOwnParent pattern, | 63 | * Pattern-specific match representation of the queries.memberIsItsOwnParent pattern, |
64 | * to be used in conjunction with {@link Matcher}. | 64 | * to be used in conjunction with {@link Matcher}. |
65 | * | 65 | * |
66 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | 66 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. |
67 | * Each instance is a (possibly partial) substitution of pattern parameters, | 67 | * Each instance is a (possibly partial) substitution of pattern parameters, |
68 | * usable to represent a match of the pattern in the result of a query, | 68 | * usable to represent a match of the pattern in the result of a query, |
69 | * or to specify the bound (fixed) input parameters when issuing a query. | 69 | * or to specify the bound (fixed) input parameters when issuing a query. |
70 | * | 70 | * |
71 | * @see Matcher | 71 | * @see Matcher |
72 | * | 72 | * |
73 | */ | 73 | */ |
74 | public static abstract class Match extends BasePatternMatch { | 74 | public static abstract class Match extends BasePatternMatch { |
75 | private Member fM; | 75 | private Member fM; |
76 | 76 | ||
77 | private static List<String> parameterNames = makeImmutableList("m"); | 77 | private static List<String> parameterNames = makeImmutableList("m"); |
78 | 78 | ||
79 | private Match(final Member pM) { | 79 | private Match(final Member pM) { |
80 | this.fM = pM; | 80 | this.fM = pM; |
81 | } | 81 | } |
82 | 82 | ||
83 | @Override | 83 | @Override |
84 | public Object get(final String parameterName) { | 84 | public Object get(final String parameterName) { |
85 | switch(parameterName) { | 85 | switch(parameterName) { |
86 | case "m": return this.fM; | 86 | case "m": return this.fM; |
87 | default: return null; | 87 | default: return null; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | @Override | 91 | @Override |
92 | public Object get(final int index) { | 92 | public Object get(final int index) { |
93 | switch(index) { | 93 | switch(index) { |
94 | case 0: return this.fM; | 94 | case 0: return this.fM; |
95 | default: return null; | 95 | default: return null; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | public Member getM() { | 99 | public Member getM() { |
100 | return this.fM; | 100 | return this.fM; |
101 | } | 101 | } |
102 | 102 | ||
103 | @Override | 103 | @Override |
104 | public boolean set(final String parameterName, final Object newValue) { | 104 | public boolean set(final String parameterName, final Object newValue) { |
105 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 105 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
106 | if ("m".equals(parameterName) ) { | 106 | if ("m".equals(parameterName) ) { |
107 | this.fM = (Member) newValue; | 107 | this.fM = (Member) newValue; |
108 | return true; | 108 | return true; |
109 | } | 109 | } |
110 | return false; | 110 | return false; |
111 | } | 111 | } |
112 | 112 | ||
113 | public void setM(final Member pM) { | 113 | public void setM(final Member pM) { |
114 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 114 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
115 | this.fM = pM; | 115 | this.fM = pM; |
116 | } | 116 | } |
117 | 117 | ||
118 | @Override | 118 | @Override |
119 | public String patternName() { | 119 | public String patternName() { |
120 | return "queries.memberIsItsOwnParent"; | 120 | return "queries.memberIsItsOwnParent"; |
121 | } | 121 | } |
122 | 122 | ||
123 | @Override | 123 | @Override |
124 | public List<String> parameterNames() { | 124 | public List<String> parameterNames() { |
125 | return MemberIsItsOwnParent.Match.parameterNames; | 125 | return MemberIsItsOwnParent.Match.parameterNames; |
126 | } | 126 | } |
127 | 127 | ||
128 | @Override | 128 | @Override |
129 | public Object[] toArray() { | 129 | public Object[] toArray() { |
130 | return new Object[]{fM}; | 130 | return new Object[]{fM}; |
131 | } | 131 | } |
132 | 132 | ||
133 | @Override | 133 | @Override |
134 | public MemberIsItsOwnParent.Match toImmutable() { | 134 | public MemberIsItsOwnParent.Match toImmutable() { |
135 | return isMutable() ? newMatch(fM) : this; | 135 | return isMutable() ? newMatch(fM) : this; |
136 | } | 136 | } |
137 | 137 | ||
138 | @Override | 138 | @Override |
139 | public String prettyPrint() { | 139 | public String prettyPrint() { |
140 | StringBuilder result = new StringBuilder(); | 140 | StringBuilder result = new StringBuilder(); |
141 | result.append("\"m\"=" + prettyPrintValue(fM)); | 141 | result.append("\"m\"=" + prettyPrintValue(fM)); |
142 | return result.toString(); | 142 | return result.toString(); |
143 | } | 143 | } |
144 | 144 | ||
145 | @Override | 145 | @Override |
146 | public int hashCode() { | 146 | public int hashCode() { |
147 | return Objects.hash(fM); | 147 | return Objects.hash(fM); |
148 | } | 148 | } |
149 | 149 | ||
150 | @Override | 150 | @Override |
151 | public boolean equals(final Object obj) { | 151 | public boolean equals(final Object obj) { |
152 | if (this == obj) | 152 | if (this == obj) |
153 | return true; | 153 | return true; |
154 | if (obj == null) { | 154 | if (obj == null) { |
155 | return false; | 155 | return false; |
156 | } | 156 | } |
157 | if ((obj instanceof MemberIsItsOwnParent.Match)) { | 157 | if ((obj instanceof MemberIsItsOwnParent.Match)) { |
158 | MemberIsItsOwnParent.Match other = (MemberIsItsOwnParent.Match) obj; | 158 | MemberIsItsOwnParent.Match other = (MemberIsItsOwnParent.Match) obj; |
159 | return Objects.equals(fM, other.fM); | 159 | return Objects.equals(fM, other.fM); |
160 | } else { | 160 | } else { |
161 | // this should be infrequent | 161 | // this should be infrequent |
162 | if (!(obj instanceof IPatternMatch)) { | 162 | if (!(obj instanceof IPatternMatch)) { |
163 | return false; | 163 | return false; |
164 | } | 164 | } |
165 | IPatternMatch otherSig = (IPatternMatch) obj; | 165 | IPatternMatch otherSig = (IPatternMatch) obj; |
166 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | 166 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | @Override | 170 | @Override |
171 | public MemberIsItsOwnParent specification() { | 171 | public MemberIsItsOwnParent specification() { |
172 | return MemberIsItsOwnParent.instance(); | 172 | return MemberIsItsOwnParent.instance(); |
173 | } | 173 | } |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * Returns an empty, mutable match. | 176 | * Returns an empty, mutable match. |
177 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 177 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
178 | * | 178 | * |
179 | * @return the empty match. | 179 | * @return the empty match. |
180 | * | 180 | * |
181 | */ | 181 | */ |
182 | public static MemberIsItsOwnParent.Match newEmptyMatch() { | 182 | public static MemberIsItsOwnParent.Match newEmptyMatch() { |
183 | return new Mutable(null); | 183 | return new Mutable(null); |
184 | } | 184 | } |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * Returns a mutable (partial) match. | 187 | * Returns a mutable (partial) match. |
188 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 188 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
189 | * | 189 | * |
190 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 190 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
191 | * @return the new, mutable (partial) match object. | 191 | * @return the new, mutable (partial) match object. |
192 | * | 192 | * |
193 | */ | 193 | */ |
194 | public static MemberIsItsOwnParent.Match newMutableMatch(final Member pM) { | 194 | public static MemberIsItsOwnParent.Match newMutableMatch(final Member pM) { |
195 | return new Mutable(pM); | 195 | return new Mutable(pM); |
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Returns a new (partial) match. | 199 | * Returns a new (partial) match. |
200 | * This can be used e.g. to call the matcher with a partial match. | 200 | * This can be used e.g. to call the matcher with a partial match. |
201 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 201 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
202 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 202 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
203 | * @return the (partial) match object. | 203 | * @return the (partial) match object. |
204 | * | 204 | * |
205 | */ | 205 | */ |
206 | public static MemberIsItsOwnParent.Match newMatch(final Member pM) { | 206 | public static MemberIsItsOwnParent.Match newMatch(final Member pM) { |
207 | return new Immutable(pM); | 207 | return new Immutable(pM); |
208 | } | 208 | } |
209 | 209 | ||
210 | private static final class Mutable extends MemberIsItsOwnParent.Match { | 210 | private static final class Mutable extends MemberIsItsOwnParent.Match { |
211 | Mutable(final Member pM) { | 211 | Mutable(final Member pM) { |
212 | super(pM); | 212 | super(pM); |
213 | } | 213 | } |
214 | 214 | ||
215 | @Override | 215 | @Override |
216 | public boolean isMutable() { | 216 | public boolean isMutable() { |
217 | return true; | 217 | return true; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | private static final class Immutable extends MemberIsItsOwnParent.Match { | 221 | private static final class Immutable extends MemberIsItsOwnParent.Match { |
222 | Immutable(final Member pM) { | 222 | Immutable(final Member pM) { |
223 | super(pM); | 223 | super(pM); |
224 | } | 224 | } |
225 | 225 | ||
226 | @Override | 226 | @Override |
227 | public boolean isMutable() { | 227 | public boolean isMutable() { |
228 | return false; | 228 | return false; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * Generated pattern matcher API of the queries.memberIsItsOwnParent pattern, | 234 | * Generated pattern matcher API of the queries.memberIsItsOwnParent pattern, |
235 | * providing pattern-specific query methods. | 235 | * providing pattern-specific query methods. |
236 | * | 236 | * |
237 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | 237 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, |
238 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | 238 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. |
239 | * | 239 | * |
240 | * <p>Matches of the pattern will be represented as {@link Match}. | 240 | * <p>Matches of the pattern will be represented as {@link Match}. |
241 | * | 241 | * |
242 | * <p>Original source: | 242 | * <p>Original source: |
243 | * <code><pre> | 243 | * <code><pre> |
244 | * {@literal @}Constraint(message="memberIsItsOwnParent", severity="error", key={m}) | 244 | * {@literal @}Constraint(message="memberIsItsOwnParent", severity="error", key={m}) |
245 | * pattern memberIsItsOwnParent(m: Member) = { | 245 | * pattern memberIsItsOwnParent(m: Member) = { |
246 | * FamilyTree.members(_, m); | 246 | * FamilyTree.members(_, m); |
247 | * Member.parents(m, p); | 247 | * Member.parents(m, p); |
248 | * m == p; | 248 | * m == p; |
249 | * } | 249 | * } |
250 | * </pre></code> | 250 | * </pre></code> |
251 | * | 251 | * |
252 | * @see Match | 252 | * @see Match |
253 | * @see MemberIsItsOwnParent | 253 | * @see MemberIsItsOwnParent |
254 | * | 254 | * |
255 | */ | 255 | */ |
256 | public static class Matcher extends BaseMatcher<MemberIsItsOwnParent.Match> { | 256 | public static class Matcher extends BaseMatcher<MemberIsItsOwnParent.Match> { |
257 | /** | 257 | /** |
258 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 258 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
259 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 259 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
260 | * | 260 | * |
261 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 261 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
262 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 262 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
263 | * | 263 | * |
264 | */ | 264 | */ |
265 | public static MemberIsItsOwnParent.Matcher on(final ViatraQueryEngine engine) { | 265 | public static MemberIsItsOwnParent.Matcher on(final ViatraQueryEngine engine) { |
266 | // check if matcher already exists | 266 | // check if matcher already exists |
267 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | 267 | Matcher matcher = engine.getExistingMatcher(querySpecification()); |
268 | if (matcher == null) { | 268 | if (matcher == null) { |
269 | matcher = (Matcher)engine.getMatcher(querySpecification()); | 269 | matcher = (Matcher)engine.getMatcher(querySpecification()); |
270 | } | 270 | } |
271 | return matcher; | 271 | return matcher; |
272 | } | 272 | } |
273 | 273 | ||
274 | /** | 274 | /** |
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
276 | * @return an initialized matcher | 276 | * @return an initialized matcher |
277 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | 277 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. |
278 | * | 278 | * |
279 | */ | 279 | */ |
280 | public static MemberIsItsOwnParent.Matcher create() { | 280 | public static MemberIsItsOwnParent.Matcher create() { |
281 | return new Matcher(); | 281 | return new Matcher(); |
282 | } | 282 | } |
283 | 283 | ||
284 | private static final int POSITION_M = 0; | 284 | private static final int POSITION_M = 0; |
285 | 285 | ||
286 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MemberIsItsOwnParent.Matcher.class); | 286 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MemberIsItsOwnParent.Matcher.class); |
287 | 287 | ||
288 | /** | 288 | /** |
289 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 289 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
290 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 290 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
291 | * | 291 | * |
292 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 292 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
294 | * | 294 | * |
295 | */ | 295 | */ |
296 | private Matcher() { | 296 | private Matcher() { |
297 | super(querySpecification()); | 297 | super(querySpecification()); |
298 | } | 298 | } |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | 301 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. |
302 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 302 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
303 | * @return matches represented as a Match object. | 303 | * @return matches represented as a Match object. |
304 | * | 304 | * |
305 | */ | 305 | */ |
306 | public Collection<MemberIsItsOwnParent.Match> getAllMatches(final Member pM) { | 306 | public Collection<MemberIsItsOwnParent.Match> getAllMatches(final Member pM) { |
307 | return rawStreamAllMatches(new Object[]{pM}).collect(Collectors.toSet()); | 307 | return rawStreamAllMatches(new Object[]{pM}).collect(Collectors.toSet()); |
308 | } | 308 | } |
309 | 309 | ||
310 | /** | 310 | /** |
311 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | 311 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. |
312 | * </p> | 312 | * </p> |
313 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 313 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
314 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 314 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
315 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 315 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
316 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 316 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
317 | * @return a stream of matches represented as a Match object. | 317 | * @return a stream of matches represented as a Match object. |
318 | * | 318 | * |
319 | */ | 319 | */ |
320 | public Stream<MemberIsItsOwnParent.Match> streamAllMatches(final Member pM) { | 320 | public Stream<MemberIsItsOwnParent.Match> streamAllMatches(final Member pM) { |
321 | return rawStreamAllMatches(new Object[]{pM}); | 321 | return rawStreamAllMatches(new Object[]{pM}); |
322 | } | 322 | } |
323 | 323 | ||
324 | /** | 324 | /** |
325 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 325 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
326 | * Neither determinism nor randomness of selection is guaranteed. | 326 | * Neither determinism nor randomness of selection is guaranteed. |
327 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 327 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
328 | * @return a match represented as a Match object, or null if no match is found. | 328 | * @return a match represented as a Match object, or null if no match is found. |
329 | * | 329 | * |
330 | */ | 330 | */ |
331 | public Optional<MemberIsItsOwnParent.Match> getOneArbitraryMatch(final Member pM) { | 331 | public Optional<MemberIsItsOwnParent.Match> getOneArbitraryMatch(final Member pM) { |
332 | return rawGetOneArbitraryMatch(new Object[]{pM}); | 332 | return rawGetOneArbitraryMatch(new Object[]{pM}); |
333 | } | 333 | } |
334 | 334 | ||
335 | /** | 335 | /** |
336 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | 336 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, |
337 | * under any possible substitution of the unspecified parameters (if any). | 337 | * under any possible substitution of the unspecified parameters (if any). |
338 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 338 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
339 | * @return true if the input is a valid (partial) match of the pattern. | 339 | * @return true if the input is a valid (partial) match of the pattern. |
340 | * | 340 | * |
341 | */ | 341 | */ |
342 | public boolean hasMatch(final Member pM) { | 342 | public boolean hasMatch(final Member pM) { |
343 | return rawHasMatch(new Object[]{pM}); | 343 | return rawHasMatch(new Object[]{pM}); |
344 | } | 344 | } |
345 | 345 | ||
346 | /** | 346 | /** |
347 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | 347 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. |
348 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 348 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
349 | * @return the number of pattern matches found. | 349 | * @return the number of pattern matches found. |
350 | * | 350 | * |
351 | */ | 351 | */ |
352 | public int countMatches(final Member pM) { | 352 | public int countMatches(final Member pM) { |
353 | return rawCountMatches(new Object[]{pM}); | 353 | return rawCountMatches(new Object[]{pM}); |
354 | } | 354 | } |
355 | 355 | ||
356 | /** | 356 | /** |
357 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 357 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
358 | * Neither determinism nor randomness of selection is guaranteed. | 358 | * Neither determinism nor randomness of selection is guaranteed. |
359 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 359 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
360 | * @param processor the action that will process the selected match. | 360 | * @param processor the action that will process the selected match. |
361 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | 361 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked |
362 | * | 362 | * |
363 | */ | 363 | */ |
364 | public boolean forOneArbitraryMatch(final Member pM, final Consumer<? super MemberIsItsOwnParent.Match> processor) { | 364 | public boolean forOneArbitraryMatch(final Member pM, final Consumer<? super MemberIsItsOwnParent.Match> processor) { |
365 | return rawForOneArbitraryMatch(new Object[]{pM}, processor); | 365 | return rawForOneArbitraryMatch(new Object[]{pM}, processor); |
366 | } | 366 | } |
367 | 367 | ||
368 | /** | 368 | /** |
369 | * Returns a new (partial) match. | 369 | * Returns a new (partial) match. |
370 | * This can be used e.g. to call the matcher with a partial match. | 370 | * This can be used e.g. to call the matcher with a partial match. |
371 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 371 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
372 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 372 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
373 | * @return the (partial) match object. | 373 | * @return the (partial) match object. |
374 | * | 374 | * |
375 | */ | 375 | */ |
376 | public MemberIsItsOwnParent.Match newMatch(final Member pM) { | 376 | public MemberIsItsOwnParent.Match newMatch(final Member pM) { |
377 | return MemberIsItsOwnParent.Match.newMatch(pM); | 377 | return MemberIsItsOwnParent.Match.newMatch(pM); |
378 | } | 378 | } |
379 | 379 | ||
380 | /** | 380 | /** |
381 | * Retrieve the set of values that occur in matches for m. | 381 | * Retrieve the set of values that occur in matches for m. |
382 | * @return the Set of all values or empty set if there are no matches | 382 | * @return the Set of all values or empty set if there are no matches |
383 | * | 383 | * |
384 | */ | 384 | */ |
385 | protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) { | 385 | protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) { |
386 | return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast); | 386 | return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast); |
387 | } | 387 | } |
388 | 388 | ||
389 | /** | 389 | /** |
390 | * Retrieve the set of values that occur in matches for m. | 390 | * Retrieve the set of values that occur in matches for m. |
391 | * @return the Set of all values or empty set if there are no matches | 391 | * @return the Set of all values or empty set if there are no matches |
392 | * | 392 | * |
393 | */ | 393 | */ |
394 | public Set<Member> getAllValuesOfm() { | 394 | public Set<Member> getAllValuesOfm() { |
395 | return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet()); | 395 | return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet()); |
396 | } | 396 | } |
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Retrieve the set of values that occur in matches for m. | 399 | * Retrieve the set of values that occur in matches for m. |
400 | * @return the Set of all values or empty set if there are no matches | 400 | * @return the Set of all values or empty set if there are no matches |
401 | * | 401 | * |
402 | */ | 402 | */ |
403 | public Stream<Member> streamAllValuesOfm() { | 403 | public Stream<Member> streamAllValuesOfm() { |
404 | return rawStreamAllValuesOfm(emptyArray()); | 404 | return rawStreamAllValuesOfm(emptyArray()); |
405 | } | 405 | } |
406 | 406 | ||
407 | @Override | 407 | @Override |
408 | protected MemberIsItsOwnParent.Match tupleToMatch(final Tuple t) { | 408 | protected MemberIsItsOwnParent.Match tupleToMatch(final Tuple t) { |
409 | try { | 409 | try { |
410 | return MemberIsItsOwnParent.Match.newMatch((Member) t.get(POSITION_M)); | 410 | return MemberIsItsOwnParent.Match.newMatch((Member) t.get(POSITION_M)); |
411 | } catch(ClassCastException e) { | 411 | } catch(ClassCastException e) { |
412 | LOGGER.error("Element(s) in tuple not properly typed!",e); | 412 | LOGGER.error("Element(s) in tuple not properly typed!",e); |
413 | return null; | 413 | return null; |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | @Override | 417 | @Override |
418 | protected MemberIsItsOwnParent.Match arrayToMatch(final Object[] match) { | 418 | protected MemberIsItsOwnParent.Match arrayToMatch(final Object[] match) { |
419 | try { | 419 | try { |
420 | return MemberIsItsOwnParent.Match.newMatch((Member) match[POSITION_M]); | 420 | return MemberIsItsOwnParent.Match.newMatch((Member) match[POSITION_M]); |
421 | } catch(ClassCastException e) { | 421 | } catch(ClassCastException e) { |
422 | LOGGER.error("Element(s) in array not properly typed!",e); | 422 | LOGGER.error("Element(s) in array not properly typed!",e); |
423 | return null; | 423 | return null; |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | @Override | 427 | @Override |
428 | protected MemberIsItsOwnParent.Match arrayToMatchMutable(final Object[] match) { | 428 | protected MemberIsItsOwnParent.Match arrayToMatchMutable(final Object[] match) { |
429 | try { | 429 | try { |
430 | return MemberIsItsOwnParent.Match.newMutableMatch((Member) match[POSITION_M]); | 430 | return MemberIsItsOwnParent.Match.newMutableMatch((Member) match[POSITION_M]); |
431 | } catch(ClassCastException e) { | 431 | } catch(ClassCastException e) { |
432 | LOGGER.error("Element(s) in array not properly typed!",e); | 432 | LOGGER.error("Element(s) in array not properly typed!",e); |
433 | return null; | 433 | return null; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | /** | 437 | /** |
438 | * @return the singleton instance of the query specification of this pattern | 438 | * @return the singleton instance of the query specification of this pattern |
439 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 439 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
440 | * | 440 | * |
441 | */ | 441 | */ |
442 | public static IQuerySpecification<MemberIsItsOwnParent.Matcher> querySpecification() { | 442 | public static IQuerySpecification<MemberIsItsOwnParent.Matcher> querySpecification() { |
443 | return MemberIsItsOwnParent.instance(); | 443 | return MemberIsItsOwnParent.instance(); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | private MemberIsItsOwnParent() { | 447 | private MemberIsItsOwnParent() { |
448 | super(GeneratedPQuery.INSTANCE); | 448 | super(GeneratedPQuery.INSTANCE); |
449 | } | 449 | } |
450 | 450 | ||
451 | /** | 451 | /** |
452 | * @return the singleton instance of the query specification | 452 | * @return the singleton instance of the query specification |
453 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 453 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
454 | * | 454 | * |
455 | */ | 455 | */ |
456 | public static MemberIsItsOwnParent instance() { | 456 | public static MemberIsItsOwnParent instance() { |
457 | try{ | 457 | try{ |
458 | return LazyHolder.INSTANCE; | 458 | return LazyHolder.INSTANCE; |
459 | } catch (ExceptionInInitializerError err) { | 459 | } catch (ExceptionInInitializerError err) { |
460 | throw processInitializerError(err); | 460 | throw processInitializerError(err); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | @Override | 464 | @Override |
465 | protected MemberIsItsOwnParent.Matcher instantiate(final ViatraQueryEngine engine) { | 465 | protected MemberIsItsOwnParent.Matcher instantiate(final ViatraQueryEngine engine) { |
466 | return MemberIsItsOwnParent.Matcher.on(engine); | 466 | return MemberIsItsOwnParent.Matcher.on(engine); |
467 | } | 467 | } |
468 | 468 | ||
469 | @Override | 469 | @Override |
470 | public MemberIsItsOwnParent.Matcher instantiate() { | 470 | public MemberIsItsOwnParent.Matcher instantiate() { |
471 | return MemberIsItsOwnParent.Matcher.create(); | 471 | return MemberIsItsOwnParent.Matcher.create(); |
472 | } | 472 | } |
473 | 473 | ||
474 | @Override | 474 | @Override |
475 | public MemberIsItsOwnParent.Match newEmptyMatch() { | 475 | public MemberIsItsOwnParent.Match newEmptyMatch() { |
476 | return MemberIsItsOwnParent.Match.newEmptyMatch(); | 476 | return MemberIsItsOwnParent.Match.newEmptyMatch(); |
477 | } | 477 | } |
478 | 478 | ||
479 | @Override | 479 | @Override |
480 | public MemberIsItsOwnParent.Match newMatch(final Object... parameters) { | 480 | public MemberIsItsOwnParent.Match newMatch(final Object... parameters) { |
481 | return MemberIsItsOwnParent.Match.newMatch((familytree.Member) parameters[0]); | 481 | return MemberIsItsOwnParent.Match.newMatch((familytree.Member) parameters[0]); |
482 | } | 482 | } |
483 | 483 | ||
484 | /** | 484 | /** |
485 | * Inner class allowing the singleton instance of {@link MemberIsItsOwnParent} to be created | 485 | * Inner class allowing the singleton instance of {@link MemberIsItsOwnParent} to be created |
486 | * <b>not</b> at the class load time of the outer class, | 486 | * <b>not</b> at the class load time of the outer class, |
487 | * but rather at the first call to {@link MemberIsItsOwnParent#instance()}. | 487 | * but rather at the first call to {@link MemberIsItsOwnParent#instance()}. |
488 | * | 488 | * |
489 | * <p> This workaround is required e.g. to support recursion. | 489 | * <p> This workaround is required e.g. to support recursion. |
490 | * | 490 | * |
491 | */ | 491 | */ |
492 | private static class LazyHolder { | 492 | private static class LazyHolder { |
493 | private static final MemberIsItsOwnParent INSTANCE = new MemberIsItsOwnParent(); | 493 | private static final MemberIsItsOwnParent INSTANCE = new MemberIsItsOwnParent(); |
494 | 494 | ||
495 | /** | 495 | /** |
496 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | 496 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. |
497 | * This initialization order is required to support indirect recursion. | 497 | * This initialization order is required to support indirect recursion. |
498 | * | 498 | * |
499 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | 499 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. |
500 | * | 500 | * |
501 | */ | 501 | */ |
502 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | 502 | private static final Object STATIC_INITIALIZER = ensureInitialized(); |
503 | 503 | ||
504 | public static Object ensureInitialized() { | 504 | public static Object ensureInitialized() { |
505 | INSTANCE.ensureInitializedInternal(); | 505 | INSTANCE.ensureInitializedInternal(); |
506 | return null; | 506 | return null; |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | 510 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { |
511 | private static final MemberIsItsOwnParent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | 511 | private static final MemberIsItsOwnParent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); |
512 | 512 | ||
513 | private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); | 513 | private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); |
514 | 514 | ||
515 | private final List<PParameter> parameters = Arrays.asList(parameter_m); | 515 | private final List<PParameter> parameters = Arrays.asList(parameter_m); |
516 | 516 | ||
517 | private GeneratedPQuery() { | 517 | private GeneratedPQuery() { |
518 | super(PVisibility.PUBLIC); | 518 | super(PVisibility.PUBLIC); |
519 | } | 519 | } |
520 | 520 | ||
521 | @Override | 521 | @Override |
522 | public String getFullyQualifiedName() { | 522 | public String getFullyQualifiedName() { |
523 | return "queries.memberIsItsOwnParent"; | 523 | return "queries.memberIsItsOwnParent"; |
524 | } | 524 | } |
525 | 525 | ||
526 | @Override | 526 | @Override |
527 | public List<String> getParameterNames() { | 527 | public List<String> getParameterNames() { |
528 | return Arrays.asList("m"); | 528 | return Arrays.asList("m"); |
529 | } | 529 | } |
530 | 530 | ||
531 | @Override | 531 | @Override |
532 | public List<PParameter> getParameters() { | 532 | public List<PParameter> getParameters() { |
533 | return parameters; | 533 | return parameters; |
534 | } | 534 | } |
535 | 535 | ||
536 | @Override | 536 | @Override |
537 | public Set<PBody> doGetContainedBodies() { | 537 | public Set<PBody> doGetContainedBodies() { |
538 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | 538 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); |
539 | Set<PBody> bodies = new LinkedHashSet<>(); | 539 | Set<PBody> bodies = new LinkedHashSet<>(); |
540 | { | 540 | { |
541 | PBody body = new PBody(this); | 541 | PBody body = new PBody(this); |
542 | PVariable var_m = body.getOrCreateVariableByName("m"); | 542 | PVariable var_m = body.getOrCreateVariableByName("m"); |
543 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | 543 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); |
544 | PVariable var_p = body.getOrCreateVariableByName("p"); | 544 | PVariable var_p = body.getOrCreateVariableByName("p"); |
545 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 545 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
546 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | 546 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( |
547 | new ExportedParameter(body, var_m, parameter_m) | 547 | new ExportedParameter(body, var_m, parameter_m) |
548 | )); | 548 | )); |
549 | // FamilyTree.members(_, m) | 549 | // FamilyTree.members(_, m) |
550 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "FamilyTree"))); | 550 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "FamilyTree"))); |
551 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | 551 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); |
552 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "FamilyTree", "members"))); | 552 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "FamilyTree", "members"))); |
553 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 553 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
554 | new Equality(body, var__virtual_0_, var_m); | 554 | new Equality(body, var__virtual_0_, var_m); |
555 | // Member.parents(m, p) | 555 | // Member.parents(m, p) |
556 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 556 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
557 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | 557 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); |
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents"))); | 558 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents"))); |
559 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 559 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
560 | new Equality(body, var__virtual_1_, var_p); | 560 | new Equality(body, var__virtual_1_, var_p); |
561 | // m == p | 561 | // m == p |
562 | new Equality(body, var_m, var_p); | 562 | new Equality(body, var_m, var_p); |
563 | bodies.add(body); | 563 | bodies.add(body); |
564 | } | 564 | } |
565 | { | 565 | { |
566 | PAnnotation annotation = new PAnnotation("Constraint"); | 566 | PAnnotation annotation = new PAnnotation("Constraint"); |
567 | annotation.addAttribute("message", "memberIsItsOwnParent"); | 567 | annotation.addAttribute("message", "memberIsItsOwnParent"); |
568 | annotation.addAttribute("severity", "error"); | 568 | annotation.addAttribute("severity", "error"); |
569 | annotation.addAttribute("key", Arrays.asList(new Object[] { | 569 | annotation.addAttribute("key", Arrays.asList(new Object[] { |
570 | new ParameterReference("m") | 570 | new ParameterReference("m") |
571 | })); | 571 | })); |
572 | addAnnotation(annotation); | 572 | addAnnotation(annotation); |
573 | } | 573 | } |
574 | return bodies; | 574 | return bodies; |
575 | } | 575 | } |
576 | } | 576 | } |
577 | } | 577 | } |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java index e90186e2..726ab7e4 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java | |||
@@ -1,775 +1,775 @@ | |||
1 | /** | 1 | /** |
2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql | 2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql |
3 | */ | 3 | */ |
4 | package queries; | 4 | package queries; |
5 | 5 | ||
6 | import familytree.Member; | 6 | import familytree.Member; |
7 | import java.util.Arrays; | 7 | import java.util.Arrays; |
8 | import java.util.Collection; | 8 | import java.util.Collection; |
9 | import java.util.LinkedHashSet; | 9 | import java.util.LinkedHashSet; |
10 | import java.util.List; | 10 | import java.util.List; |
11 | import java.util.Objects; | 11 | import java.util.Objects; |
12 | import java.util.Optional; | 12 | import java.util.Optional; |
13 | import java.util.Set; | 13 | import java.util.Set; |
14 | import java.util.function.Consumer; | 14 | import java.util.function.Consumer; |
15 | import java.util.stream.Collectors; | 15 | import java.util.stream.Collectors; |
16 | import java.util.stream.Stream; | 16 | import java.util.stream.Stream; |
17 | import org.apache.log4j.Logger; | 17 | import org.apache.log4j.Logger; |
18 | import org.eclipse.emf.ecore.EClass; | 18 | import org.eclipse.emf.ecore.EClass; |
19 | import org.eclipse.emf.ecore.EDataType; | 19 | import org.eclipse.emf.ecore.EDataType; |
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | 20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; |
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; |
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | 23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; |
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | 24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; |
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | 25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; |
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | 26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; |
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | 27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; |
28 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | 28 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; |
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | 29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; |
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | 30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; |
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | 32 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; |
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | 33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; |
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | 34 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; |
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | 36 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; |
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | 37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; |
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | 38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; |
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | 39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; |
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | 40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; |
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | 41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; |
42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | 42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; |
43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 43 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; |
44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | 44 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; |
45 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 45 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
46 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | 46 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | 49 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. |
50 | * | 50 | * |
51 | * <p>Original source: | 51 | * <p>Original source: |
52 | * <code><pre> | 52 | * <code><pre> |
53 | * {@literal @}Constraint(message="parentTooYoung", severity="error", key={m, p}) | 53 | * {@literal @}Constraint(message="parentTooYoung", severity="error", key={m, p}) |
54 | * pattern parentTooYoung(m: Member, p: Member) = { | 54 | * pattern parentTooYoung(m: Member, p: Member) = { |
55 | * FamilyTree.members(_, m); | 55 | * FamilyTree.members(_, m); |
56 | * Member.parents(m, p); | 56 | * Member.parents(m, p); |
57 | * Member.age(m, mAge); | 57 | * Member.age(m, mAge); |
58 | * Member.age(p, pAge); | 58 | * Member.age(p, pAge); |
59 | * check (mAge {@literal <}= (pAge + 12)); | 59 | * check (mAge {@literal <}= (pAge + 12)); |
60 | * } | 60 | * } |
61 | * </pre></code> | 61 | * </pre></code> |
62 | * | 62 | * |
63 | * @see Matcher | 63 | * @see Matcher |
64 | * @see Match | 64 | * @see Match |
65 | * | 65 | * |
66 | */ | 66 | */ |
67 | @SuppressWarnings("all") | 67 | @SuppressWarnings("all") |
68 | public final class ParentTooYoung extends BaseGeneratedEMFQuerySpecification<ParentTooYoung.Matcher> { | 68 | public final class ParentTooYoung extends BaseGeneratedEMFQuerySpecification<ParentTooYoung.Matcher> { |
69 | /** | 69 | /** |
70 | * Pattern-specific match representation of the queries.parentTooYoung pattern, | 70 | * Pattern-specific match representation of the queries.parentTooYoung pattern, |
71 | * to be used in conjunction with {@link Matcher}. | 71 | * to be used in conjunction with {@link Matcher}. |
72 | * | 72 | * |
73 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | 73 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. |
74 | * Each instance is a (possibly partial) substitution of pattern parameters, | 74 | * Each instance is a (possibly partial) substitution of pattern parameters, |
75 | * usable to represent a match of the pattern in the result of a query, | 75 | * usable to represent a match of the pattern in the result of a query, |
76 | * or to specify the bound (fixed) input parameters when issuing a query. | 76 | * or to specify the bound (fixed) input parameters when issuing a query. |
77 | * | 77 | * |
78 | * @see Matcher | 78 | * @see Matcher |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | public static abstract class Match extends BasePatternMatch { | 81 | public static abstract class Match extends BasePatternMatch { |
82 | private Member fM; | 82 | private Member fM; |
83 | 83 | ||
84 | private Member fP; | 84 | private Member fP; |
85 | 85 | ||
86 | private static List<String> parameterNames = makeImmutableList("m", "p"); | 86 | private static List<String> parameterNames = makeImmutableList("m", "p"); |
87 | 87 | ||
88 | private Match(final Member pM, final Member pP) { | 88 | private Match(final Member pM, final Member pP) { |
89 | this.fM = pM; | 89 | this.fM = pM; |
90 | this.fP = pP; | 90 | this.fP = pP; |
91 | } | 91 | } |
92 | 92 | ||
93 | @Override | 93 | @Override |
94 | public Object get(final String parameterName) { | 94 | public Object get(final String parameterName) { |
95 | switch(parameterName) { | 95 | switch(parameterName) { |
96 | case "m": return this.fM; | 96 | case "m": return this.fM; |
97 | case "p": return this.fP; | 97 | case "p": return this.fP; |
98 | default: return null; | 98 | default: return null; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | @Override | 102 | @Override |
103 | public Object get(final int index) { | 103 | public Object get(final int index) { |
104 | switch(index) { | 104 | switch(index) { |
105 | case 0: return this.fM; | 105 | case 0: return this.fM; |
106 | case 1: return this.fP; | 106 | case 1: return this.fP; |
107 | default: return null; | 107 | default: return null; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | public Member getM() { | 111 | public Member getM() { |
112 | return this.fM; | 112 | return this.fM; |
113 | } | 113 | } |
114 | 114 | ||
115 | public Member getP() { | 115 | public Member getP() { |
116 | return this.fP; | 116 | return this.fP; |
117 | } | 117 | } |
118 | 118 | ||
119 | @Override | 119 | @Override |
120 | public boolean set(final String parameterName, final Object newValue) { | 120 | public boolean set(final String parameterName, final Object newValue) { |
121 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 121 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
122 | if ("m".equals(parameterName) ) { | 122 | if ("m".equals(parameterName) ) { |
123 | this.fM = (Member) newValue; | 123 | this.fM = (Member) newValue; |
124 | return true; | 124 | return true; |
125 | } | 125 | } |
126 | if ("p".equals(parameterName) ) { | 126 | if ("p".equals(parameterName) ) { |
127 | this.fP = (Member) newValue; | 127 | this.fP = (Member) newValue; |
128 | return true; | 128 | return true; |
129 | } | 129 | } |
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | 132 | ||
133 | public void setM(final Member pM) { | 133 | public void setM(final Member pM) { |
134 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 134 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
135 | this.fM = pM; | 135 | this.fM = pM; |
136 | } | 136 | } |
137 | 137 | ||
138 | public void setP(final Member pP) { | 138 | public void setP(final Member pP) { |
139 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 139 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
140 | this.fP = pP; | 140 | this.fP = pP; |
141 | } | 141 | } |
142 | 142 | ||
143 | @Override | 143 | @Override |
144 | public String patternName() { | 144 | public String patternName() { |
145 | return "queries.parentTooYoung"; | 145 | return "queries.parentTooYoung"; |
146 | } | 146 | } |
147 | 147 | ||
148 | @Override | 148 | @Override |
149 | public List<String> parameterNames() { | 149 | public List<String> parameterNames() { |
150 | return ParentTooYoung.Match.parameterNames; | 150 | return ParentTooYoung.Match.parameterNames; |
151 | } | 151 | } |
152 | 152 | ||
153 | @Override | 153 | @Override |
154 | public Object[] toArray() { | 154 | public Object[] toArray() { |
155 | return new Object[]{fM, fP}; | 155 | return new Object[]{fM, fP}; |
156 | } | 156 | } |
157 | 157 | ||
158 | @Override | 158 | @Override |
159 | public ParentTooYoung.Match toImmutable() { | 159 | public ParentTooYoung.Match toImmutable() { |
160 | return isMutable() ? newMatch(fM, fP) : this; | 160 | return isMutable() ? newMatch(fM, fP) : this; |
161 | } | 161 | } |
162 | 162 | ||
163 | @Override | 163 | @Override |
164 | public String prettyPrint() { | 164 | public String prettyPrint() { |
165 | StringBuilder result = new StringBuilder(); | 165 | StringBuilder result = new StringBuilder(); |
166 | result.append("\"m\"=" + prettyPrintValue(fM) + ", "); | 166 | result.append("\"m\"=" + prettyPrintValue(fM) + ", "); |
167 | result.append("\"p\"=" + prettyPrintValue(fP)); | 167 | result.append("\"p\"=" + prettyPrintValue(fP)); |
168 | return result.toString(); | 168 | return result.toString(); |
169 | } | 169 | } |
170 | 170 | ||
171 | @Override | 171 | @Override |
172 | public int hashCode() { | 172 | public int hashCode() { |
173 | return Objects.hash(fM, fP); | 173 | return Objects.hash(fM, fP); |
174 | } | 174 | } |
175 | 175 | ||
176 | @Override | 176 | @Override |
177 | public boolean equals(final Object obj) { | 177 | public boolean equals(final Object obj) { |
178 | if (this == obj) | 178 | if (this == obj) |
179 | return true; | 179 | return true; |
180 | if (obj == null) { | 180 | if (obj == null) { |
181 | return false; | 181 | return false; |
182 | } | 182 | } |
183 | if ((obj instanceof ParentTooYoung.Match)) { | 183 | if ((obj instanceof ParentTooYoung.Match)) { |
184 | ParentTooYoung.Match other = (ParentTooYoung.Match) obj; | 184 | ParentTooYoung.Match other = (ParentTooYoung.Match) obj; |
185 | return Objects.equals(fM, other.fM) && Objects.equals(fP, other.fP); | 185 | return Objects.equals(fM, other.fM) && Objects.equals(fP, other.fP); |
186 | } else { | 186 | } else { |
187 | // this should be infrequent | 187 | // this should be infrequent |
188 | if (!(obj instanceof IPatternMatch)) { | 188 | if (!(obj instanceof IPatternMatch)) { |
189 | return false; | 189 | return false; |
190 | } | 190 | } |
191 | IPatternMatch otherSig = (IPatternMatch) obj; | 191 | IPatternMatch otherSig = (IPatternMatch) obj; |
192 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | 192 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | @Override | 196 | @Override |
197 | public ParentTooYoung specification() { | 197 | public ParentTooYoung specification() { |
198 | return ParentTooYoung.instance(); | 198 | return ParentTooYoung.instance(); |
199 | } | 199 | } |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * Returns an empty, mutable match. | 202 | * Returns an empty, mutable match. |
203 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 203 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
204 | * | 204 | * |
205 | * @return the empty match. | 205 | * @return the empty match. |
206 | * | 206 | * |
207 | */ | 207 | */ |
208 | public static ParentTooYoung.Match newEmptyMatch() { | 208 | public static ParentTooYoung.Match newEmptyMatch() { |
209 | return new Mutable(null, null); | 209 | return new Mutable(null, null); |
210 | } | 210 | } |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * Returns a mutable (partial) match. | 213 | * Returns a mutable (partial) match. |
214 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 214 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
215 | * | 215 | * |
216 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 216 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
217 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 217 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
218 | * @return the new, mutable (partial) match object. | 218 | * @return the new, mutable (partial) match object. |
219 | * | 219 | * |
220 | */ | 220 | */ |
221 | public static ParentTooYoung.Match newMutableMatch(final Member pM, final Member pP) { | 221 | public static ParentTooYoung.Match newMutableMatch(final Member pM, final Member pP) { |
222 | return new Mutable(pM, pP); | 222 | return new Mutable(pM, pP); |
223 | } | 223 | } |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * Returns a new (partial) match. | 226 | * Returns a new (partial) match. |
227 | * This can be used e.g. to call the matcher with a partial match. | 227 | * This can be used e.g. to call the matcher with a partial match. |
228 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 228 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
229 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 229 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
230 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 230 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
231 | * @return the (partial) match object. | 231 | * @return the (partial) match object. |
232 | * | 232 | * |
233 | */ | 233 | */ |
234 | public static ParentTooYoung.Match newMatch(final Member pM, final Member pP) { | 234 | public static ParentTooYoung.Match newMatch(final Member pM, final Member pP) { |
235 | return new Immutable(pM, pP); | 235 | return new Immutable(pM, pP); |
236 | } | 236 | } |
237 | 237 | ||
238 | private static final class Mutable extends ParentTooYoung.Match { | 238 | private static final class Mutable extends ParentTooYoung.Match { |
239 | Mutable(final Member pM, final Member pP) { | 239 | Mutable(final Member pM, final Member pP) { |
240 | super(pM, pP); | 240 | super(pM, pP); |
241 | } | 241 | } |
242 | 242 | ||
243 | @Override | 243 | @Override |
244 | public boolean isMutable() { | 244 | public boolean isMutable() { |
245 | return true; | 245 | return true; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | private static final class Immutable extends ParentTooYoung.Match { | 249 | private static final class Immutable extends ParentTooYoung.Match { |
250 | Immutable(final Member pM, final Member pP) { | 250 | Immutable(final Member pM, final Member pP) { |
251 | super(pM, pP); | 251 | super(pM, pP); |
252 | } | 252 | } |
253 | 253 | ||
254 | @Override | 254 | @Override |
255 | public boolean isMutable() { | 255 | public boolean isMutable() { |
256 | return false; | 256 | return false; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | /** | 261 | /** |
262 | * Generated pattern matcher API of the queries.parentTooYoung pattern, | 262 | * Generated pattern matcher API of the queries.parentTooYoung pattern, |
263 | * providing pattern-specific query methods. | 263 | * providing pattern-specific query methods. |
264 | * | 264 | * |
265 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | 265 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, |
266 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | 266 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. |
267 | * | 267 | * |
268 | * <p>Matches of the pattern will be represented as {@link Match}. | 268 | * <p>Matches of the pattern will be represented as {@link Match}. |
269 | * | 269 | * |
270 | * <p>Original source: | 270 | * <p>Original source: |
271 | * <code><pre> | 271 | * <code><pre> |
272 | * {@literal @}Constraint(message="parentTooYoung", severity="error", key={m, p}) | 272 | * {@literal @}Constraint(message="parentTooYoung", severity="error", key={m, p}) |
273 | * pattern parentTooYoung(m: Member, p: Member) = { | 273 | * pattern parentTooYoung(m: Member, p: Member) = { |
274 | * FamilyTree.members(_, m); | 274 | * FamilyTree.members(_, m); |
275 | * Member.parents(m, p); | 275 | * Member.parents(m, p); |
276 | * Member.age(m, mAge); | 276 | * Member.age(m, mAge); |
277 | * Member.age(p, pAge); | 277 | * Member.age(p, pAge); |
278 | * check (mAge {@literal <}= (pAge + 12)); | 278 | * check (mAge {@literal <}= (pAge + 12)); |
279 | * } | 279 | * } |
280 | * </pre></code> | 280 | * </pre></code> |
281 | * | 281 | * |
282 | * @see Match | 282 | * @see Match |
283 | * @see ParentTooYoung | 283 | * @see ParentTooYoung |
284 | * | 284 | * |
285 | */ | 285 | */ |
286 | public static class Matcher extends BaseMatcher<ParentTooYoung.Match> { | 286 | public static class Matcher extends BaseMatcher<ParentTooYoung.Match> { |
287 | /** | 287 | /** |
288 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 288 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
289 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 289 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
290 | * | 290 | * |
291 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 291 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
293 | * | 293 | * |
294 | */ | 294 | */ |
295 | public static ParentTooYoung.Matcher on(final ViatraQueryEngine engine) { | 295 | public static ParentTooYoung.Matcher on(final ViatraQueryEngine engine) { |
296 | // check if matcher already exists | 296 | // check if matcher already exists |
297 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | 297 | Matcher matcher = engine.getExistingMatcher(querySpecification()); |
298 | if (matcher == null) { | 298 | if (matcher == null) { |
299 | matcher = (Matcher)engine.getMatcher(querySpecification()); | 299 | matcher = (Matcher)engine.getMatcher(querySpecification()); |
300 | } | 300 | } |
301 | return matcher; | 301 | return matcher; |
302 | } | 302 | } |
303 | 303 | ||
304 | /** | 304 | /** |
305 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 305 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
306 | * @return an initialized matcher | 306 | * @return an initialized matcher |
307 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | 307 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. |
308 | * | 308 | * |
309 | */ | 309 | */ |
310 | public static ParentTooYoung.Matcher create() { | 310 | public static ParentTooYoung.Matcher create() { |
311 | return new Matcher(); | 311 | return new Matcher(); |
312 | } | 312 | } |
313 | 313 | ||
314 | private static final int POSITION_M = 0; | 314 | private static final int POSITION_M = 0; |
315 | 315 | ||
316 | private static final int POSITION_P = 1; | 316 | private static final int POSITION_P = 1; |
317 | 317 | ||
318 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ParentTooYoung.Matcher.class); | 318 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ParentTooYoung.Matcher.class); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 321 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
322 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 322 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
323 | * | 323 | * |
324 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 324 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
325 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 325 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
326 | * | 326 | * |
327 | */ | 327 | */ |
328 | private Matcher() { | 328 | private Matcher() { |
329 | super(querySpecification()); | 329 | super(querySpecification()); |
330 | } | 330 | } |
331 | 331 | ||
332 | /** | 332 | /** |
333 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | 333 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. |
334 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 334 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
335 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 335 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
336 | * @return matches represented as a Match object. | 336 | * @return matches represented as a Match object. |
337 | * | 337 | * |
338 | */ | 338 | */ |
339 | public Collection<ParentTooYoung.Match> getAllMatches(final Member pM, final Member pP) { | 339 | public Collection<ParentTooYoung.Match> getAllMatches(final Member pM, final Member pP) { |
340 | return rawStreamAllMatches(new Object[]{pM, pP}).collect(Collectors.toSet()); | 340 | return rawStreamAllMatches(new Object[]{pM, pP}).collect(Collectors.toSet()); |
341 | } | 341 | } |
342 | 342 | ||
343 | /** | 343 | /** |
344 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | 344 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. |
345 | * </p> | 345 | * </p> |
346 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 346 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
347 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 347 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
348 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 348 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
349 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 349 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
350 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 350 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
351 | * @return a stream of matches represented as a Match object. | 351 | * @return a stream of matches represented as a Match object. |
352 | * | 352 | * |
353 | */ | 353 | */ |
354 | public Stream<ParentTooYoung.Match> streamAllMatches(final Member pM, final Member pP) { | 354 | public Stream<ParentTooYoung.Match> streamAllMatches(final Member pM, final Member pP) { |
355 | return rawStreamAllMatches(new Object[]{pM, pP}); | 355 | return rawStreamAllMatches(new Object[]{pM, pP}); |
356 | } | 356 | } |
357 | 357 | ||
358 | /** | 358 | /** |
359 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 359 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
360 | * Neither determinism nor randomness of selection is guaranteed. | 360 | * Neither determinism nor randomness of selection is guaranteed. |
361 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 361 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
362 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 362 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
363 | * @return a match represented as a Match object, or null if no match is found. | 363 | * @return a match represented as a Match object, or null if no match is found. |
364 | * | 364 | * |
365 | */ | 365 | */ |
366 | public Optional<ParentTooYoung.Match> getOneArbitraryMatch(final Member pM, final Member pP) { | 366 | public Optional<ParentTooYoung.Match> getOneArbitraryMatch(final Member pM, final Member pP) { |
367 | return rawGetOneArbitraryMatch(new Object[]{pM, pP}); | 367 | return rawGetOneArbitraryMatch(new Object[]{pM, pP}); |
368 | } | 368 | } |
369 | 369 | ||
370 | /** | 370 | /** |
371 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | 371 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, |
372 | * under any possible substitution of the unspecified parameters (if any). | 372 | * under any possible substitution of the unspecified parameters (if any). |
373 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 373 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
374 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 374 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
375 | * @return true if the input is a valid (partial) match of the pattern. | 375 | * @return true if the input is a valid (partial) match of the pattern. |
376 | * | 376 | * |
377 | */ | 377 | */ |
378 | public boolean hasMatch(final Member pM, final Member pP) { | 378 | public boolean hasMatch(final Member pM, final Member pP) { |
379 | return rawHasMatch(new Object[]{pM, pP}); | 379 | return rawHasMatch(new Object[]{pM, pP}); |
380 | } | 380 | } |
381 | 381 | ||
382 | /** | 382 | /** |
383 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | 383 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. |
384 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 384 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
385 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 385 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
386 | * @return the number of pattern matches found. | 386 | * @return the number of pattern matches found. |
387 | * | 387 | * |
388 | */ | 388 | */ |
389 | public int countMatches(final Member pM, final Member pP) { | 389 | public int countMatches(final Member pM, final Member pP) { |
390 | return rawCountMatches(new Object[]{pM, pP}); | 390 | return rawCountMatches(new Object[]{pM, pP}); |
391 | } | 391 | } |
392 | 392 | ||
393 | /** | 393 | /** |
394 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 394 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
395 | * Neither determinism nor randomness of selection is guaranteed. | 395 | * Neither determinism nor randomness of selection is guaranteed. |
396 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 396 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
397 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 397 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
398 | * @param processor the action that will process the selected match. | 398 | * @param processor the action that will process the selected match. |
399 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | 399 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked |
400 | * | 400 | * |
401 | */ | 401 | */ |
402 | public boolean forOneArbitraryMatch(final Member pM, final Member pP, final Consumer<? super ParentTooYoung.Match> processor) { | 402 | public boolean forOneArbitraryMatch(final Member pM, final Member pP, final Consumer<? super ParentTooYoung.Match> processor) { |
403 | return rawForOneArbitraryMatch(new Object[]{pM, pP}, processor); | 403 | return rawForOneArbitraryMatch(new Object[]{pM, pP}, processor); |
404 | } | 404 | } |
405 | 405 | ||
406 | /** | 406 | /** |
407 | * Returns a new (partial) match. | 407 | * Returns a new (partial) match. |
408 | * This can be used e.g. to call the matcher with a partial match. | 408 | * This can be used e.g. to call the matcher with a partial match. |
409 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 409 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
410 | * @param pM the fixed value of pattern parameter m, or null if not bound. | 410 | * @param pM the fixed value of pattern parameter m, or null if not bound. |
411 | * @param pP the fixed value of pattern parameter p, or null if not bound. | 411 | * @param pP the fixed value of pattern parameter p, or null if not bound. |
412 | * @return the (partial) match object. | 412 | * @return the (partial) match object. |
413 | * | 413 | * |
414 | */ | 414 | */ |
415 | public ParentTooYoung.Match newMatch(final Member pM, final Member pP) { | 415 | public ParentTooYoung.Match newMatch(final Member pM, final Member pP) { |
416 | return ParentTooYoung.Match.newMatch(pM, pP); | 416 | return ParentTooYoung.Match.newMatch(pM, pP); |
417 | } | 417 | } |
418 | 418 | ||
419 | /** | 419 | /** |
420 | * Retrieve the set of values that occur in matches for m. | 420 | * Retrieve the set of values that occur in matches for m. |
421 | * @return the Set of all values or empty set if there are no matches | 421 | * @return the Set of all values or empty set if there are no matches |
422 | * | 422 | * |
423 | */ | 423 | */ |
424 | protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) { | 424 | protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) { |
425 | return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast); | 425 | return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast); |
426 | } | 426 | } |
427 | 427 | ||
428 | /** | 428 | /** |
429 | * Retrieve the set of values that occur in matches for m. | 429 | * Retrieve the set of values that occur in matches for m. |
430 | * @return the Set of all values or empty set if there are no matches | 430 | * @return the Set of all values or empty set if there are no matches |
431 | * | 431 | * |
432 | */ | 432 | */ |
433 | public Set<Member> getAllValuesOfm() { | 433 | public Set<Member> getAllValuesOfm() { |
434 | return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet()); | 434 | return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet()); |
435 | } | 435 | } |
436 | 436 | ||
437 | /** | 437 | /** |
438 | * Retrieve the set of values that occur in matches for m. | 438 | * Retrieve the set of values that occur in matches for m. |
439 | * @return the Set of all values or empty set if there are no matches | 439 | * @return the Set of all values or empty set if there are no matches |
440 | * | 440 | * |
441 | */ | 441 | */ |
442 | public Stream<Member> streamAllValuesOfm() { | 442 | public Stream<Member> streamAllValuesOfm() { |
443 | return rawStreamAllValuesOfm(emptyArray()); | 443 | return rawStreamAllValuesOfm(emptyArray()); |
444 | } | 444 | } |
445 | 445 | ||
446 | /** | 446 | /** |
447 | * Retrieve the set of values that occur in matches for m. | 447 | * Retrieve the set of values that occur in matches for m. |
448 | * </p> | 448 | * </p> |
449 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 449 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
450 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 450 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
451 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 451 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
452 | * | 452 | * |
453 | * @return the Stream of all values or empty set if there are no matches | 453 | * @return the Stream of all values or empty set if there are no matches |
454 | * | 454 | * |
455 | */ | 455 | */ |
456 | public Stream<Member> streamAllValuesOfm(final ParentTooYoung.Match partialMatch) { | 456 | public Stream<Member> streamAllValuesOfm(final ParentTooYoung.Match partialMatch) { |
457 | return rawStreamAllValuesOfm(partialMatch.toArray()); | 457 | return rawStreamAllValuesOfm(partialMatch.toArray()); |
458 | } | 458 | } |
459 | 459 | ||
460 | /** | 460 | /** |
461 | * Retrieve the set of values that occur in matches for m. | 461 | * Retrieve the set of values that occur in matches for m. |
462 | * </p> | 462 | * </p> |
463 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 463 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
464 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 464 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
465 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 465 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
466 | * | 466 | * |
467 | * @return the Stream of all values or empty set if there are no matches | 467 | * @return the Stream of all values or empty set if there are no matches |
468 | * | 468 | * |
469 | */ | 469 | */ |
470 | public Stream<Member> streamAllValuesOfm(final Member pP) { | 470 | public Stream<Member> streamAllValuesOfm(final Member pP) { |
471 | return rawStreamAllValuesOfm(new Object[]{null, pP}); | 471 | return rawStreamAllValuesOfm(new Object[]{null, pP}); |
472 | } | 472 | } |
473 | 473 | ||
474 | /** | 474 | /** |
475 | * Retrieve the set of values that occur in matches for m. | 475 | * Retrieve the set of values that occur in matches for m. |
476 | * @return the Set of all values or empty set if there are no matches | 476 | * @return the Set of all values or empty set if there are no matches |
477 | * | 477 | * |
478 | */ | 478 | */ |
479 | public Set<Member> getAllValuesOfm(final ParentTooYoung.Match partialMatch) { | 479 | public Set<Member> getAllValuesOfm(final ParentTooYoung.Match partialMatch) { |
480 | return rawStreamAllValuesOfm(partialMatch.toArray()).collect(Collectors.toSet()); | 480 | return rawStreamAllValuesOfm(partialMatch.toArray()).collect(Collectors.toSet()); |
481 | } | 481 | } |
482 | 482 | ||
483 | /** | 483 | /** |
484 | * Retrieve the set of values that occur in matches for m. | 484 | * Retrieve the set of values that occur in matches for m. |
485 | * @return the Set of all values or empty set if there are no matches | 485 | * @return the Set of all values or empty set if there are no matches |
486 | * | 486 | * |
487 | */ | 487 | */ |
488 | public Set<Member> getAllValuesOfm(final Member pP) { | 488 | public Set<Member> getAllValuesOfm(final Member pP) { |
489 | return rawStreamAllValuesOfm(new Object[]{null, pP}).collect(Collectors.toSet()); | 489 | return rawStreamAllValuesOfm(new Object[]{null, pP}).collect(Collectors.toSet()); |
490 | } | 490 | } |
491 | 491 | ||
492 | /** | 492 | /** |
493 | * Retrieve the set of values that occur in matches for p. | 493 | * Retrieve the set of values that occur in matches for p. |
494 | * @return the Set of all values or empty set if there are no matches | 494 | * @return the Set of all values or empty set if there are no matches |
495 | * | 495 | * |
496 | */ | 496 | */ |
497 | protected Stream<Member> rawStreamAllValuesOfp(final Object[] parameters) { | 497 | protected Stream<Member> rawStreamAllValuesOfp(final Object[] parameters) { |
498 | return rawStreamAllValues(POSITION_P, parameters).map(Member.class::cast); | 498 | return rawStreamAllValues(POSITION_P, parameters).map(Member.class::cast); |
499 | } | 499 | } |
500 | 500 | ||
501 | /** | 501 | /** |
502 | * Retrieve the set of values that occur in matches for p. | 502 | * Retrieve the set of values that occur in matches for p. |
503 | * @return the Set of all values or empty set if there are no matches | 503 | * @return the Set of all values or empty set if there are no matches |
504 | * | 504 | * |
505 | */ | 505 | */ |
506 | public Set<Member> getAllValuesOfp() { | 506 | public Set<Member> getAllValuesOfp() { |
507 | return rawStreamAllValuesOfp(emptyArray()).collect(Collectors.toSet()); | 507 | return rawStreamAllValuesOfp(emptyArray()).collect(Collectors.toSet()); |
508 | } | 508 | } |
509 | 509 | ||
510 | /** | 510 | /** |
511 | * Retrieve the set of values that occur in matches for p. | 511 | * Retrieve the set of values that occur in matches for p. |
512 | * @return the Set of all values or empty set if there are no matches | 512 | * @return the Set of all values or empty set if there are no matches |
513 | * | 513 | * |
514 | */ | 514 | */ |
515 | public Stream<Member> streamAllValuesOfp() { | 515 | public Stream<Member> streamAllValuesOfp() { |
516 | return rawStreamAllValuesOfp(emptyArray()); | 516 | return rawStreamAllValuesOfp(emptyArray()); |
517 | } | 517 | } |
518 | 518 | ||
519 | /** | 519 | /** |
520 | * Retrieve the set of values that occur in matches for p. | 520 | * Retrieve the set of values that occur in matches for p. |
521 | * </p> | 521 | * </p> |
522 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 522 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
523 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 523 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
524 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 524 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
525 | * | 525 | * |
526 | * @return the Stream of all values or empty set if there are no matches | 526 | * @return the Stream of all values or empty set if there are no matches |
527 | * | 527 | * |
528 | */ | 528 | */ |
529 | public Stream<Member> streamAllValuesOfp(final ParentTooYoung.Match partialMatch) { | 529 | public Stream<Member> streamAllValuesOfp(final ParentTooYoung.Match partialMatch) { |
530 | return rawStreamAllValuesOfp(partialMatch.toArray()); | 530 | return rawStreamAllValuesOfp(partialMatch.toArray()); |
531 | } | 531 | } |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * Retrieve the set of values that occur in matches for p. | 534 | * Retrieve the set of values that occur in matches for p. |
535 | * </p> | 535 | * </p> |
536 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 536 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
537 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 537 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
538 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 538 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
539 | * | 539 | * |
540 | * @return the Stream of all values or empty set if there are no matches | 540 | * @return the Stream of all values or empty set if there are no matches |
541 | * | 541 | * |
542 | */ | 542 | */ |
543 | public Stream<Member> streamAllValuesOfp(final Member pM) { | 543 | public Stream<Member> streamAllValuesOfp(final Member pM) { |
544 | return rawStreamAllValuesOfp(new Object[]{pM, null}); | 544 | return rawStreamAllValuesOfp(new Object[]{pM, null}); |
545 | } | 545 | } |
546 | 546 | ||
547 | /** | 547 | /** |
548 | * Retrieve the set of values that occur in matches for p. | 548 | * Retrieve the set of values that occur in matches for p. |
549 | * @return the Set of all values or empty set if there are no matches | 549 | * @return the Set of all values or empty set if there are no matches |
550 | * | 550 | * |
551 | */ | 551 | */ |
552 | public Set<Member> getAllValuesOfp(final ParentTooYoung.Match partialMatch) { | 552 | public Set<Member> getAllValuesOfp(final ParentTooYoung.Match partialMatch) { |
553 | return rawStreamAllValuesOfp(partialMatch.toArray()).collect(Collectors.toSet()); | 553 | return rawStreamAllValuesOfp(partialMatch.toArray()).collect(Collectors.toSet()); |
554 | } | 554 | } |
555 | 555 | ||
556 | /** | 556 | /** |
557 | * Retrieve the set of values that occur in matches for p. | 557 | * Retrieve the set of values that occur in matches for p. |
558 | * @return the Set of all values or empty set if there are no matches | 558 | * @return the Set of all values or empty set if there are no matches |
559 | * | 559 | * |
560 | */ | 560 | */ |
561 | public Set<Member> getAllValuesOfp(final Member pM) { | 561 | public Set<Member> getAllValuesOfp(final Member pM) { |
562 | return rawStreamAllValuesOfp(new Object[]{pM, null}).collect(Collectors.toSet()); | 562 | return rawStreamAllValuesOfp(new Object[]{pM, null}).collect(Collectors.toSet()); |
563 | } | 563 | } |
564 | 564 | ||
565 | @Override | 565 | @Override |
566 | protected ParentTooYoung.Match tupleToMatch(final Tuple t) { | 566 | protected ParentTooYoung.Match tupleToMatch(final Tuple t) { |
567 | try { | 567 | try { |
568 | return ParentTooYoung.Match.newMatch((Member) t.get(POSITION_M), (Member) t.get(POSITION_P)); | 568 | return ParentTooYoung.Match.newMatch((Member) t.get(POSITION_M), (Member) t.get(POSITION_P)); |
569 | } catch(ClassCastException e) { | 569 | } catch(ClassCastException e) { |
570 | LOGGER.error("Element(s) in tuple not properly typed!",e); | 570 | LOGGER.error("Element(s) in tuple not properly typed!",e); |
571 | return null; | 571 | return null; |
572 | } | 572 | } |
573 | } | 573 | } |
574 | 574 | ||
575 | @Override | 575 | @Override |
576 | protected ParentTooYoung.Match arrayToMatch(final Object[] match) { | 576 | protected ParentTooYoung.Match arrayToMatch(final Object[] match) { |
577 | try { | 577 | try { |
578 | return ParentTooYoung.Match.newMatch((Member) match[POSITION_M], (Member) match[POSITION_P]); | 578 | return ParentTooYoung.Match.newMatch((Member) match[POSITION_M], (Member) match[POSITION_P]); |
579 | } catch(ClassCastException e) { | 579 | } catch(ClassCastException e) { |
580 | LOGGER.error("Element(s) in array not properly typed!",e); | 580 | LOGGER.error("Element(s) in array not properly typed!",e); |
581 | return null; | 581 | return null; |
582 | } | 582 | } |
583 | } | 583 | } |
584 | 584 | ||
585 | @Override | 585 | @Override |
586 | protected ParentTooYoung.Match arrayToMatchMutable(final Object[] match) { | 586 | protected ParentTooYoung.Match arrayToMatchMutable(final Object[] match) { |
587 | try { | 587 | try { |
588 | return ParentTooYoung.Match.newMutableMatch((Member) match[POSITION_M], (Member) match[POSITION_P]); | 588 | return ParentTooYoung.Match.newMutableMatch((Member) match[POSITION_M], (Member) match[POSITION_P]); |
589 | } catch(ClassCastException e) { | 589 | } catch(ClassCastException e) { |
590 | LOGGER.error("Element(s) in array not properly typed!",e); | 590 | LOGGER.error("Element(s) in array not properly typed!",e); |
591 | return null; | 591 | return null; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | 594 | ||
595 | /** | 595 | /** |
596 | * @return the singleton instance of the query specification of this pattern | 596 | * @return the singleton instance of the query specification of this pattern |
597 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 597 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
598 | * | 598 | * |
599 | */ | 599 | */ |
600 | public static IQuerySpecification<ParentTooYoung.Matcher> querySpecification() { | 600 | public static IQuerySpecification<ParentTooYoung.Matcher> querySpecification() { |
601 | return ParentTooYoung.instance(); | 601 | return ParentTooYoung.instance(); |
602 | } | 602 | } |
603 | } | 603 | } |
604 | 604 | ||
605 | private ParentTooYoung() { | 605 | private ParentTooYoung() { |
606 | super(GeneratedPQuery.INSTANCE); | 606 | super(GeneratedPQuery.INSTANCE); |
607 | } | 607 | } |
608 | 608 | ||
609 | /** | 609 | /** |
610 | * @return the singleton instance of the query specification | 610 | * @return the singleton instance of the query specification |
611 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 611 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
612 | * | 612 | * |
613 | */ | 613 | */ |
614 | public static ParentTooYoung instance() { | 614 | public static ParentTooYoung instance() { |
615 | try{ | 615 | try{ |
616 | return LazyHolder.INSTANCE; | 616 | return LazyHolder.INSTANCE; |
617 | } catch (ExceptionInInitializerError err) { | 617 | } catch (ExceptionInInitializerError err) { |
618 | throw processInitializerError(err); | 618 | throw processInitializerError(err); |
619 | } | 619 | } |
620 | } | 620 | } |
621 | 621 | ||
622 | @Override | 622 | @Override |
623 | protected ParentTooYoung.Matcher instantiate(final ViatraQueryEngine engine) { | 623 | protected ParentTooYoung.Matcher instantiate(final ViatraQueryEngine engine) { |
624 | return ParentTooYoung.Matcher.on(engine); | 624 | return ParentTooYoung.Matcher.on(engine); |
625 | } | 625 | } |
626 | 626 | ||
627 | @Override | 627 | @Override |
628 | public ParentTooYoung.Matcher instantiate() { | 628 | public ParentTooYoung.Matcher instantiate() { |
629 | return ParentTooYoung.Matcher.create(); | 629 | return ParentTooYoung.Matcher.create(); |
630 | } | 630 | } |
631 | 631 | ||
632 | @Override | 632 | @Override |
633 | public ParentTooYoung.Match newEmptyMatch() { | 633 | public ParentTooYoung.Match newEmptyMatch() { |
634 | return ParentTooYoung.Match.newEmptyMatch(); | 634 | return ParentTooYoung.Match.newEmptyMatch(); |
635 | } | 635 | } |
636 | 636 | ||
637 | @Override | 637 | @Override |
638 | public ParentTooYoung.Match newMatch(final Object... parameters) { | 638 | public ParentTooYoung.Match newMatch(final Object... parameters) { |
639 | return ParentTooYoung.Match.newMatch((familytree.Member) parameters[0], (familytree.Member) parameters[1]); | 639 | return ParentTooYoung.Match.newMatch((familytree.Member) parameters[0], (familytree.Member) parameters[1]); |
640 | } | 640 | } |
641 | 641 | ||
642 | /** | 642 | /** |
643 | * Inner class allowing the singleton instance of {@link ParentTooYoung} to be created | 643 | * Inner class allowing the singleton instance of {@link ParentTooYoung} to be created |
644 | * <b>not</b> at the class load time of the outer class, | 644 | * <b>not</b> at the class load time of the outer class, |
645 | * but rather at the first call to {@link ParentTooYoung#instance()}. | 645 | * but rather at the first call to {@link ParentTooYoung#instance()}. |
646 | * | 646 | * |
647 | * <p> This workaround is required e.g. to support recursion. | 647 | * <p> This workaround is required e.g. to support recursion. |
648 | * | 648 | * |
649 | */ | 649 | */ |
650 | private static class LazyHolder { | 650 | private static class LazyHolder { |
651 | private static final ParentTooYoung INSTANCE = new ParentTooYoung(); | 651 | private static final ParentTooYoung INSTANCE = new ParentTooYoung(); |
652 | 652 | ||
653 | /** | 653 | /** |
654 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | 654 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. |
655 | * This initialization order is required to support indirect recursion. | 655 | * This initialization order is required to support indirect recursion. |
656 | * | 656 | * |
657 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | 657 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. |
658 | * | 658 | * |
659 | */ | 659 | */ |
660 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | 660 | private static final Object STATIC_INITIALIZER = ensureInitialized(); |
661 | 661 | ||
662 | public static Object ensureInitialized() { | 662 | public static Object ensureInitialized() { |
663 | INSTANCE.ensureInitializedInternal(); | 663 | INSTANCE.ensureInitializedInternal(); |
664 | return null; | 664 | return null; |
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | 668 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { |
669 | private static final ParentTooYoung.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | 669 | private static final ParentTooYoung.GeneratedPQuery INSTANCE = new GeneratedPQuery(); |
670 | 670 | ||
671 | private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); | 671 | private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); |
672 | 672 | ||
673 | private final PParameter parameter_p = new PParameter("p", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); | 673 | private final PParameter parameter_p = new PParameter("p", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); |
674 | 674 | ||
675 | private final List<PParameter> parameters = Arrays.asList(parameter_m, parameter_p); | 675 | private final List<PParameter> parameters = Arrays.asList(parameter_m, parameter_p); |
676 | 676 | ||
677 | private GeneratedPQuery() { | 677 | private GeneratedPQuery() { |
678 | super(PVisibility.PUBLIC); | 678 | super(PVisibility.PUBLIC); |
679 | } | 679 | } |
680 | 680 | ||
681 | @Override | 681 | @Override |
682 | public String getFullyQualifiedName() { | 682 | public String getFullyQualifiedName() { |
683 | return "queries.parentTooYoung"; | 683 | return "queries.parentTooYoung"; |
684 | } | 684 | } |
685 | 685 | ||
686 | @Override | 686 | @Override |
687 | public List<String> getParameterNames() { | 687 | public List<String> getParameterNames() { |
688 | return Arrays.asList("m","p"); | 688 | return Arrays.asList("m","p"); |
689 | } | 689 | } |
690 | 690 | ||
691 | @Override | 691 | @Override |
692 | public List<PParameter> getParameters() { | 692 | public List<PParameter> getParameters() { |
693 | return parameters; | 693 | return parameters; |
694 | } | 694 | } |
695 | 695 | ||
696 | @Override | 696 | @Override |
697 | public Set<PBody> doGetContainedBodies() { | 697 | public Set<PBody> doGetContainedBodies() { |
698 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | 698 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); |
699 | Set<PBody> bodies = new LinkedHashSet<>(); | 699 | Set<PBody> bodies = new LinkedHashSet<>(); |
700 | { | 700 | { |
701 | PBody body = new PBody(this); | 701 | PBody body = new PBody(this); |
702 | PVariable var_m = body.getOrCreateVariableByName("m"); | 702 | PVariable var_m = body.getOrCreateVariableByName("m"); |
703 | PVariable var_p = body.getOrCreateVariableByName("p"); | 703 | PVariable var_p = body.getOrCreateVariableByName("p"); |
704 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | 704 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); |
705 | PVariable var_mAge = body.getOrCreateVariableByName("mAge"); | 705 | PVariable var_mAge = body.getOrCreateVariableByName("mAge"); |
706 | PVariable var_pAge = body.getOrCreateVariableByName("pAge"); | 706 | PVariable var_pAge = body.getOrCreateVariableByName("pAge"); |
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 707 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
708 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 708 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
709 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | 709 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( |
710 | new ExportedParameter(body, var_m, parameter_m), | 710 | new ExportedParameter(body, var_m, parameter_m), |
711 | new ExportedParameter(body, var_p, parameter_p) | 711 | new ExportedParameter(body, var_p, parameter_p) |
712 | )); | 712 | )); |
713 | // FamilyTree.members(_, m) | 713 | // FamilyTree.members(_, m) |
714 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "FamilyTree"))); | 714 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "FamilyTree"))); |
715 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | 715 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); |
716 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "FamilyTree", "members"))); | 716 | new TypeConstraint(body, Tuples.flatTupleOf(var___0_, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "FamilyTree", "members"))); |
717 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 717 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
718 | new Equality(body, var__virtual_0_, var_m); | 718 | new Equality(body, var__virtual_0_, var_m); |
719 | // Member.parents(m, p) | 719 | // Member.parents(m, p) |
720 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 720 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
721 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | 721 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); |
722 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents"))); | 722 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents"))); |
723 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 723 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
724 | new Equality(body, var__virtual_1_, var_p); | 724 | new Equality(body, var__virtual_1_, var_p); |
725 | // Member.age(m, mAge) | 725 | // Member.age(m, mAge) |
726 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 726 | new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
727 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | 727 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); |
728 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "age"))); | 728 | new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "age"))); |
729 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | 729 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); |
730 | new Equality(body, var__virtual_2_, var_mAge); | 730 | new Equality(body, var__virtual_2_, var_mAge); |
731 | // Member.age(p, pAge) | 731 | // Member.age(p, pAge) |
732 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 732 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
733 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | 733 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); |
734 | new TypeConstraint(body, Tuples.flatTupleOf(var_p, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "age"))); | 734 | new TypeConstraint(body, Tuples.flatTupleOf(var_p, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "age"))); |
735 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | 735 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); |
736 | new Equality(body, var__virtual_3_, var_pAge); | 736 | new Equality(body, var__virtual_3_, var_pAge); |
737 | // check (mAge <= (pAge + 12)) | 737 | // check (mAge <= (pAge + 12)) |
738 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | 738 | new ExpressionEvaluation(body, new IExpressionEvaluator() { |
739 | 739 | ||
740 | @Override | 740 | @Override |
741 | public String getShortDescription() { | 741 | public String getShortDescription() { |
742 | return "Expression evaluation from pattern parentTooYoung"; | 742 | return "Expression evaluation from pattern parentTooYoung"; |
743 | } | 743 | } |
744 | 744 | ||
745 | @Override | 745 | @Override |
746 | public Iterable<String> getInputParameterNames() { | 746 | public Iterable<String> getInputParameterNames() { |
747 | return Arrays.asList("mAge", "pAge");} | 747 | return Arrays.asList("mAge", "pAge");} |
748 | 748 | ||
749 | @Override | 749 | @Override |
750 | public Object evaluateExpression(IValueProvider provider) throws Exception { | 750 | public Object evaluateExpression(IValueProvider provider) throws Exception { |
751 | Integer mAge = (Integer) provider.getValue("mAge"); | 751 | Integer mAge = (Integer) provider.getValue("mAge"); |
752 | Integer pAge = (Integer) provider.getValue("pAge"); | 752 | Integer pAge = (Integer) provider.getValue("pAge"); |
753 | return evaluateExpression_1_1(mAge, pAge); | 753 | return evaluateExpression_1_1(mAge, pAge); |
754 | } | 754 | } |
755 | }, null); | 755 | }, null); |
756 | bodies.add(body); | 756 | bodies.add(body); |
757 | } | 757 | } |
758 | { | 758 | { |
759 | PAnnotation annotation = new PAnnotation("Constraint"); | 759 | PAnnotation annotation = new PAnnotation("Constraint"); |
760 | annotation.addAttribute("message", "parentTooYoung"); | 760 | annotation.addAttribute("message", "parentTooYoung"); |
761 | annotation.addAttribute("severity", "error"); | 761 | annotation.addAttribute("severity", "error"); |
762 | annotation.addAttribute("key", Arrays.asList(new Object[] { | 762 | annotation.addAttribute("key", Arrays.asList(new Object[] { |
763 | new ParameterReference("m"), | 763 | new ParameterReference("m"), |
764 | new ParameterReference("p") | 764 | new ParameterReference("p") |
765 | })); | 765 | })); |
766 | addAnnotation(annotation); | 766 | addAnnotation(annotation); |
767 | } | 767 | } |
768 | return bodies; | 768 | return bodies; |
769 | } | 769 | } |
770 | } | 770 | } |
771 | 771 | ||
772 | private static boolean evaluateExpression_1_1(final Integer mAge, final Integer pAge) { | 772 | private static boolean evaluateExpression_1_1(final Integer mAge, final Integer pAge) { |
773 | return ((mAge).intValue() <= ((pAge).intValue() + 12)); | 773 | return ((mAge).intValue() <= ((pAge).intValue() + 12)); |
774 | } | 774 | } |
775 | } | 775 | } |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/TwoMembersHaveNoParent.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/TwoMembersHaveNoParent.java index 58ad57a6..365939dd 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/TwoMembersHaveNoParent.java +++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/TwoMembersHaveNoParent.java | |||
@@ -1,723 +1,723 @@ | |||
1 | /** | 1 | /** |
2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql | 2 | * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql |
3 | */ | 3 | */ |
4 | package queries; | 4 | package queries; |
5 | 5 | ||
6 | import familytree.Member; | 6 | import familytree.Member; |
7 | import java.util.Arrays; | 7 | import java.util.Arrays; |
8 | import java.util.Collection; | 8 | import java.util.Collection; |
9 | import java.util.LinkedHashSet; | 9 | import java.util.LinkedHashSet; |
10 | import java.util.List; | 10 | import java.util.List; |
11 | import java.util.Objects; | 11 | import java.util.Objects; |
12 | import java.util.Optional; | 12 | import java.util.Optional; |
13 | import java.util.Set; | 13 | import java.util.Set; |
14 | import java.util.function.Consumer; | 14 | import java.util.function.Consumer; |
15 | import java.util.stream.Collectors; | 15 | import java.util.stream.Collectors; |
16 | import java.util.stream.Stream; | 16 | import java.util.stream.Stream; |
17 | import org.apache.log4j.Logger; | 17 | import org.apache.log4j.Logger; |
18 | import org.eclipse.emf.ecore.EClass; | 18 | import org.eclipse.emf.ecore.EClass; |
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | 19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; |
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; |
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | 22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; |
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | 23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; |
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | 24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; |
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | 25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; |
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | 26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; |
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | 27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; |
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | 28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | 29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; |
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 30 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | 32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; |
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | 33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; |
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | 34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; |
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | 35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; |
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | 36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; |
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | 37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; |
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; |
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | 39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; |
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | 41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; |
42 | import queries.MemberHasParent; | 42 | import queries.MemberHasParent; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | 45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. |
46 | * | 46 | * |
47 | * <p>Original source: | 47 | * <p>Original source: |
48 | * <code><pre> | 48 | * <code><pre> |
49 | * {@literal @}Constraint(message="twoMembersHaveNoParent", severity="error", key={m1, m2}) | 49 | * {@literal @}Constraint(message="twoMembersHaveNoParent", severity="error", key={m1, m2}) |
50 | * pattern twoMembersHaveNoParent(m1:Member, m2:Member) = { | 50 | * pattern twoMembersHaveNoParent(m1:Member, m2:Member) = { |
51 | * neg find memberHasParent(m1); | 51 | * neg find memberHasParent(m1); |
52 | * neg find memberHasParent(m2); | 52 | * neg find memberHasParent(m2); |
53 | * m1 != m2; | 53 | * m1 != m2; |
54 | * } | 54 | * } |
55 | * </pre></code> | 55 | * </pre></code> |
56 | * | 56 | * |
57 | * @see Matcher | 57 | * @see Matcher |
58 | * @see Match | 58 | * @see Match |
59 | * | 59 | * |
60 | */ | 60 | */ |
61 | @SuppressWarnings("all") | 61 | @SuppressWarnings("all") |
62 | public final class TwoMembersHaveNoParent extends BaseGeneratedEMFQuerySpecification<TwoMembersHaveNoParent.Matcher> { | 62 | public final class TwoMembersHaveNoParent extends BaseGeneratedEMFQuerySpecification<TwoMembersHaveNoParent.Matcher> { |
63 | /** | 63 | /** |
64 | * Pattern-specific match representation of the queries.twoMembersHaveNoParent pattern, | 64 | * Pattern-specific match representation of the queries.twoMembersHaveNoParent pattern, |
65 | * to be used in conjunction with {@link Matcher}. | 65 | * to be used in conjunction with {@link Matcher}. |
66 | * | 66 | * |
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | 67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. |
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | 68 | * Each instance is a (possibly partial) substitution of pattern parameters, |
69 | * usable to represent a match of the pattern in the result of a query, | 69 | * usable to represent a match of the pattern in the result of a query, |
70 | * or to specify the bound (fixed) input parameters when issuing a query. | 70 | * or to specify the bound (fixed) input parameters when issuing a query. |
71 | * | 71 | * |
72 | * @see Matcher | 72 | * @see Matcher |
73 | * | 73 | * |
74 | */ | 74 | */ |
75 | public static abstract class Match extends BasePatternMatch { | 75 | public static abstract class Match extends BasePatternMatch { |
76 | private Member fM1; | 76 | private Member fM1; |
77 | 77 | ||
78 | private Member fM2; | 78 | private Member fM2; |
79 | 79 | ||
80 | private static List<String> parameterNames = makeImmutableList("m1", "m2"); | 80 | private static List<String> parameterNames = makeImmutableList("m1", "m2"); |
81 | 81 | ||
82 | private Match(final Member pM1, final Member pM2) { | 82 | private Match(final Member pM1, final Member pM2) { |
83 | this.fM1 = pM1; | 83 | this.fM1 = pM1; |
84 | this.fM2 = pM2; | 84 | this.fM2 = pM2; |
85 | } | 85 | } |
86 | 86 | ||
87 | @Override | 87 | @Override |
88 | public Object get(final String parameterName) { | 88 | public Object get(final String parameterName) { |
89 | switch(parameterName) { | 89 | switch(parameterName) { |
90 | case "m1": return this.fM1; | 90 | case "m1": return this.fM1; |
91 | case "m2": return this.fM2; | 91 | case "m2": return this.fM2; |
92 | default: return null; | 92 | default: return null; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | @Override | 96 | @Override |
97 | public Object get(final int index) { | 97 | public Object get(final int index) { |
98 | switch(index) { | 98 | switch(index) { |
99 | case 0: return this.fM1; | 99 | case 0: return this.fM1; |
100 | case 1: return this.fM2; | 100 | case 1: return this.fM2; |
101 | default: return null; | 101 | default: return null; |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | public Member getM1() { | 105 | public Member getM1() { |
106 | return this.fM1; | 106 | return this.fM1; |
107 | } | 107 | } |
108 | 108 | ||
109 | public Member getM2() { | 109 | public Member getM2() { |
110 | return this.fM2; | 110 | return this.fM2; |
111 | } | 111 | } |
112 | 112 | ||
113 | @Override | 113 | @Override |
114 | public boolean set(final String parameterName, final Object newValue) { | 114 | public boolean set(final String parameterName, final Object newValue) { |
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
116 | if ("m1".equals(parameterName) ) { | 116 | if ("m1".equals(parameterName) ) { |
117 | this.fM1 = (Member) newValue; | 117 | this.fM1 = (Member) newValue; |
118 | return true; | 118 | return true; |
119 | } | 119 | } |
120 | if ("m2".equals(parameterName) ) { | 120 | if ("m2".equals(parameterName) ) { |
121 | this.fM2 = (Member) newValue; | 121 | this.fM2 = (Member) newValue; |
122 | return true; | 122 | return true; |
123 | } | 123 | } |
124 | return false; | 124 | return false; |
125 | } | 125 | } |
126 | 126 | ||
127 | public void setM1(final Member pM1) { | 127 | public void setM1(final Member pM1) { |
128 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 128 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
129 | this.fM1 = pM1; | 129 | this.fM1 = pM1; |
130 | } | 130 | } |
131 | 131 | ||
132 | public void setM2(final Member pM2) { | 132 | public void setM2(final Member pM2) { |
133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | 133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); |
134 | this.fM2 = pM2; | 134 | this.fM2 = pM2; |
135 | } | 135 | } |
136 | 136 | ||
137 | @Override | 137 | @Override |
138 | public String patternName() { | 138 | public String patternName() { |
139 | return "queries.twoMembersHaveNoParent"; | 139 | return "queries.twoMembersHaveNoParent"; |
140 | } | 140 | } |
141 | 141 | ||
142 | @Override | 142 | @Override |
143 | public List<String> parameterNames() { | 143 | public List<String> parameterNames() { |
144 | return TwoMembersHaveNoParent.Match.parameterNames; | 144 | return TwoMembersHaveNoParent.Match.parameterNames; |
145 | } | 145 | } |
146 | 146 | ||
147 | @Override | 147 | @Override |
148 | public Object[] toArray() { | 148 | public Object[] toArray() { |
149 | return new Object[]{fM1, fM2}; | 149 | return new Object[]{fM1, fM2}; |
150 | } | 150 | } |
151 | 151 | ||
152 | @Override | 152 | @Override |
153 | public TwoMembersHaveNoParent.Match toImmutable() { | 153 | public TwoMembersHaveNoParent.Match toImmutable() { |
154 | return isMutable() ? newMatch(fM1, fM2) : this; | 154 | return isMutable() ? newMatch(fM1, fM2) : this; |
155 | } | 155 | } |
156 | 156 | ||
157 | @Override | 157 | @Override |
158 | public String prettyPrint() { | 158 | public String prettyPrint() { |
159 | StringBuilder result = new StringBuilder(); | 159 | StringBuilder result = new StringBuilder(); |
160 | result.append("\"m1\"=" + prettyPrintValue(fM1) + ", "); | 160 | result.append("\"m1\"=" + prettyPrintValue(fM1) + ", "); |
161 | result.append("\"m2\"=" + prettyPrintValue(fM2)); | 161 | result.append("\"m2\"=" + prettyPrintValue(fM2)); |
162 | return result.toString(); | 162 | return result.toString(); |
163 | } | 163 | } |
164 | 164 | ||
165 | @Override | 165 | @Override |
166 | public int hashCode() { | 166 | public int hashCode() { |
167 | return Objects.hash(fM1, fM2); | 167 | return Objects.hash(fM1, fM2); |
168 | } | 168 | } |
169 | 169 | ||
170 | @Override | 170 | @Override |
171 | public boolean equals(final Object obj) { | 171 | public boolean equals(final Object obj) { |
172 | if (this == obj) | 172 | if (this == obj) |
173 | return true; | 173 | return true; |
174 | if (obj == null) { | 174 | if (obj == null) { |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | if ((obj instanceof TwoMembersHaveNoParent.Match)) { | 177 | if ((obj instanceof TwoMembersHaveNoParent.Match)) { |
178 | TwoMembersHaveNoParent.Match other = (TwoMembersHaveNoParent.Match) obj; | 178 | TwoMembersHaveNoParent.Match other = (TwoMembersHaveNoParent.Match) obj; |
179 | return Objects.equals(fM1, other.fM1) && Objects.equals(fM2, other.fM2); | 179 | return Objects.equals(fM1, other.fM1) && Objects.equals(fM2, other.fM2); |
180 | } else { | 180 | } else { |
181 | // this should be infrequent | 181 | // this should be infrequent |
182 | if (!(obj instanceof IPatternMatch)) { | 182 | if (!(obj instanceof IPatternMatch)) { |
183 | return false; | 183 | return false; |
184 | } | 184 | } |
185 | IPatternMatch otherSig = (IPatternMatch) obj; | 185 | IPatternMatch otherSig = (IPatternMatch) obj; |
186 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | 186 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | @Override | 190 | @Override |
191 | public TwoMembersHaveNoParent specification() { | 191 | public TwoMembersHaveNoParent specification() { |
192 | return TwoMembersHaveNoParent.instance(); | 192 | return TwoMembersHaveNoParent.instance(); |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Returns an empty, mutable match. | 196 | * Returns an empty, mutable match. |
197 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 197 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
198 | * | 198 | * |
199 | * @return the empty match. | 199 | * @return the empty match. |
200 | * | 200 | * |
201 | */ | 201 | */ |
202 | public static TwoMembersHaveNoParent.Match newEmptyMatch() { | 202 | public static TwoMembersHaveNoParent.Match newEmptyMatch() { |
203 | return new Mutable(null, null); | 203 | return new Mutable(null, null); |
204 | } | 204 | } |
205 | 205 | ||
206 | /** | 206 | /** |
207 | * Returns a mutable (partial) match. | 207 | * Returns a mutable (partial) match. |
208 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | 208 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. |
209 | * | 209 | * |
210 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 210 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
211 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 211 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
212 | * @return the new, mutable (partial) match object. | 212 | * @return the new, mutable (partial) match object. |
213 | * | 213 | * |
214 | */ | 214 | */ |
215 | public static TwoMembersHaveNoParent.Match newMutableMatch(final Member pM1, final Member pM2) { | 215 | public static TwoMembersHaveNoParent.Match newMutableMatch(final Member pM1, final Member pM2) { |
216 | return new Mutable(pM1, pM2); | 216 | return new Mutable(pM1, pM2); |
217 | } | 217 | } |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * Returns a new (partial) match. | 220 | * Returns a new (partial) match. |
221 | * This can be used e.g. to call the matcher with a partial match. | 221 | * This can be used e.g. to call the matcher with a partial match. |
222 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 222 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
223 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 223 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
224 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 224 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
225 | * @return the (partial) match object. | 225 | * @return the (partial) match object. |
226 | * | 226 | * |
227 | */ | 227 | */ |
228 | public static TwoMembersHaveNoParent.Match newMatch(final Member pM1, final Member pM2) { | 228 | public static TwoMembersHaveNoParent.Match newMatch(final Member pM1, final Member pM2) { |
229 | return new Immutable(pM1, pM2); | 229 | return new Immutable(pM1, pM2); |
230 | } | 230 | } |
231 | 231 | ||
232 | private static final class Mutable extends TwoMembersHaveNoParent.Match { | 232 | private static final class Mutable extends TwoMembersHaveNoParent.Match { |
233 | Mutable(final Member pM1, final Member pM2) { | 233 | Mutable(final Member pM1, final Member pM2) { |
234 | super(pM1, pM2); | 234 | super(pM1, pM2); |
235 | } | 235 | } |
236 | 236 | ||
237 | @Override | 237 | @Override |
238 | public boolean isMutable() { | 238 | public boolean isMutable() { |
239 | return true; | 239 | return true; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | private static final class Immutable extends TwoMembersHaveNoParent.Match { | 243 | private static final class Immutable extends TwoMembersHaveNoParent.Match { |
244 | Immutable(final Member pM1, final Member pM2) { | 244 | Immutable(final Member pM1, final Member pM2) { |
245 | super(pM1, pM2); | 245 | super(pM1, pM2); |
246 | } | 246 | } |
247 | 247 | ||
248 | @Override | 248 | @Override |
249 | public boolean isMutable() { | 249 | public boolean isMutable() { |
250 | return false; | 250 | return false; |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * Generated pattern matcher API of the queries.twoMembersHaveNoParent pattern, | 256 | * Generated pattern matcher API of the queries.twoMembersHaveNoParent pattern, |
257 | * providing pattern-specific query methods. | 257 | * providing pattern-specific query methods. |
258 | * | 258 | * |
259 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | 259 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, |
260 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | 260 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. |
261 | * | 261 | * |
262 | * <p>Matches of the pattern will be represented as {@link Match}. | 262 | * <p>Matches of the pattern will be represented as {@link Match}. |
263 | * | 263 | * |
264 | * <p>Original source: | 264 | * <p>Original source: |
265 | * <code><pre> | 265 | * <code><pre> |
266 | * {@literal @}Constraint(message="twoMembersHaveNoParent", severity="error", key={m1, m2}) | 266 | * {@literal @}Constraint(message="twoMembersHaveNoParent", severity="error", key={m1, m2}) |
267 | * pattern twoMembersHaveNoParent(m1:Member, m2:Member) = { | 267 | * pattern twoMembersHaveNoParent(m1:Member, m2:Member) = { |
268 | * neg find memberHasParent(m1); | 268 | * neg find memberHasParent(m1); |
269 | * neg find memberHasParent(m2); | 269 | * neg find memberHasParent(m2); |
270 | * m1 != m2; | 270 | * m1 != m2; |
271 | * } | 271 | * } |
272 | * </pre></code> | 272 | * </pre></code> |
273 | * | 273 | * |
274 | * @see Match | 274 | * @see Match |
275 | * @see TwoMembersHaveNoParent | 275 | * @see TwoMembersHaveNoParent |
276 | * | 276 | * |
277 | */ | 277 | */ |
278 | public static class Matcher extends BaseMatcher<TwoMembersHaveNoParent.Match> { | 278 | public static class Matcher extends BaseMatcher<TwoMembersHaveNoParent.Match> { |
279 | /** | 279 | /** |
280 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 280 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
281 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 281 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
282 | * | 282 | * |
283 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 283 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
284 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 284 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
285 | * | 285 | * |
286 | */ | 286 | */ |
287 | public static TwoMembersHaveNoParent.Matcher on(final ViatraQueryEngine engine) { | 287 | public static TwoMembersHaveNoParent.Matcher on(final ViatraQueryEngine engine) { |
288 | // check if matcher already exists | 288 | // check if matcher already exists |
289 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | 289 | Matcher matcher = engine.getExistingMatcher(querySpecification()); |
290 | if (matcher == null) { | 290 | if (matcher == null) { |
291 | matcher = (Matcher)engine.getMatcher(querySpecification()); | 291 | matcher = (Matcher)engine.getMatcher(querySpecification()); |
292 | } | 292 | } |
293 | return matcher; | 293 | return matcher; |
294 | } | 294 | } |
295 | 295 | ||
296 | /** | 296 | /** |
297 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 297 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
298 | * @return an initialized matcher | 298 | * @return an initialized matcher |
299 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | 299 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. |
300 | * | 300 | * |
301 | */ | 301 | */ |
302 | public static TwoMembersHaveNoParent.Matcher create() { | 302 | public static TwoMembersHaveNoParent.Matcher create() { |
303 | return new Matcher(); | 303 | return new Matcher(); |
304 | } | 304 | } |
305 | 305 | ||
306 | private static final int POSITION_M1 = 0; | 306 | private static final int POSITION_M1 = 0; |
307 | 307 | ||
308 | private static final int POSITION_M2 = 1; | 308 | private static final int POSITION_M2 = 1; |
309 | 309 | ||
310 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TwoMembersHaveNoParent.Matcher.class); | 310 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TwoMembersHaveNoParent.Matcher.class); |
311 | 311 | ||
312 | /** | 312 | /** |
313 | * Initializes the pattern matcher within an existing VIATRA Query engine. | 313 | * Initializes the pattern matcher within an existing VIATRA Query engine. |
314 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | 314 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. |
315 | * | 315 | * |
316 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | 316 | * @param engine the existing VIATRA Query engine in which this matcher will be created. |
317 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | 317 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation |
318 | * | 318 | * |
319 | */ | 319 | */ |
320 | private Matcher() { | 320 | private Matcher() { |
321 | super(querySpecification()); | 321 | super(querySpecification()); |
322 | } | 322 | } |
323 | 323 | ||
324 | /** | 324 | /** |
325 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | 325 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. |
326 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 326 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
327 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 327 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
328 | * @return matches represented as a Match object. | 328 | * @return matches represented as a Match object. |
329 | * | 329 | * |
330 | */ | 330 | */ |
331 | public Collection<TwoMembersHaveNoParent.Match> getAllMatches(final Member pM1, final Member pM2) { | 331 | public Collection<TwoMembersHaveNoParent.Match> getAllMatches(final Member pM1, final Member pM2) { |
332 | return rawStreamAllMatches(new Object[]{pM1, pM2}).collect(Collectors.toSet()); | 332 | return rawStreamAllMatches(new Object[]{pM1, pM2}).collect(Collectors.toSet()); |
333 | } | 333 | } |
334 | 334 | ||
335 | /** | 335 | /** |
336 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | 336 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. |
337 | * </p> | 337 | * </p> |
338 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 338 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
339 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 339 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
340 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 340 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
341 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 341 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
342 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 342 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
343 | * @return a stream of matches represented as a Match object. | 343 | * @return a stream of matches represented as a Match object. |
344 | * | 344 | * |
345 | */ | 345 | */ |
346 | public Stream<TwoMembersHaveNoParent.Match> streamAllMatches(final Member pM1, final Member pM2) { | 346 | public Stream<TwoMembersHaveNoParent.Match> streamAllMatches(final Member pM1, final Member pM2) { |
347 | return rawStreamAllMatches(new Object[]{pM1, pM2}); | 347 | return rawStreamAllMatches(new Object[]{pM1, pM2}); |
348 | } | 348 | } |
349 | 349 | ||
350 | /** | 350 | /** |
351 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 351 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
352 | * Neither determinism nor randomness of selection is guaranteed. | 352 | * Neither determinism nor randomness of selection is guaranteed. |
353 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 353 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
354 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 354 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
355 | * @return a match represented as a Match object, or null if no match is found. | 355 | * @return a match represented as a Match object, or null if no match is found. |
356 | * | 356 | * |
357 | */ | 357 | */ |
358 | public Optional<TwoMembersHaveNoParent.Match> getOneArbitraryMatch(final Member pM1, final Member pM2) { | 358 | public Optional<TwoMembersHaveNoParent.Match> getOneArbitraryMatch(final Member pM1, final Member pM2) { |
359 | return rawGetOneArbitraryMatch(new Object[]{pM1, pM2}); | 359 | return rawGetOneArbitraryMatch(new Object[]{pM1, pM2}); |
360 | } | 360 | } |
361 | 361 | ||
362 | /** | 362 | /** |
363 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | 363 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, |
364 | * under any possible substitution of the unspecified parameters (if any). | 364 | * under any possible substitution of the unspecified parameters (if any). |
365 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 365 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
366 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 366 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
367 | * @return true if the input is a valid (partial) match of the pattern. | 367 | * @return true if the input is a valid (partial) match of the pattern. |
368 | * | 368 | * |
369 | */ | 369 | */ |
370 | public boolean hasMatch(final Member pM1, final Member pM2) { | 370 | public boolean hasMatch(final Member pM1, final Member pM2) { |
371 | return rawHasMatch(new Object[]{pM1, pM2}); | 371 | return rawHasMatch(new Object[]{pM1, pM2}); |
372 | } | 372 | } |
373 | 373 | ||
374 | /** | 374 | /** |
375 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | 375 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. |
376 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 376 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
377 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 377 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
378 | * @return the number of pattern matches found. | 378 | * @return the number of pattern matches found. |
379 | * | 379 | * |
380 | */ | 380 | */ |
381 | public int countMatches(final Member pM1, final Member pM2) { | 381 | public int countMatches(final Member pM1, final Member pM2) { |
382 | return rawCountMatches(new Object[]{pM1, pM2}); | 382 | return rawCountMatches(new Object[]{pM1, pM2}); |
383 | } | 383 | } |
384 | 384 | ||
385 | /** | 385 | /** |
386 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | 386 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. |
387 | * Neither determinism nor randomness of selection is guaranteed. | 387 | * Neither determinism nor randomness of selection is guaranteed. |
388 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 388 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
389 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 389 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
390 | * @param processor the action that will process the selected match. | 390 | * @param processor the action that will process the selected match. |
391 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | 391 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked |
392 | * | 392 | * |
393 | */ | 393 | */ |
394 | public boolean forOneArbitraryMatch(final Member pM1, final Member pM2, final Consumer<? super TwoMembersHaveNoParent.Match> processor) { | 394 | public boolean forOneArbitraryMatch(final Member pM1, final Member pM2, final Consumer<? super TwoMembersHaveNoParent.Match> processor) { |
395 | return rawForOneArbitraryMatch(new Object[]{pM1, pM2}, processor); | 395 | return rawForOneArbitraryMatch(new Object[]{pM1, pM2}, processor); |
396 | } | 396 | } |
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Returns a new (partial) match. | 399 | * Returns a new (partial) match. |
400 | * This can be used e.g. to call the matcher with a partial match. | 400 | * This can be used e.g. to call the matcher with a partial match. |
401 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | 401 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. |
402 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. | 402 | * @param pM1 the fixed value of pattern parameter m1, or null if not bound. |
403 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. | 403 | * @param pM2 the fixed value of pattern parameter m2, or null if not bound. |
404 | * @return the (partial) match object. | 404 | * @return the (partial) match object. |
405 | * | 405 | * |
406 | */ | 406 | */ |
407 | public TwoMembersHaveNoParent.Match newMatch(final Member pM1, final Member pM2) { | 407 | public TwoMembersHaveNoParent.Match newMatch(final Member pM1, final Member pM2) { |
408 | return TwoMembersHaveNoParent.Match.newMatch(pM1, pM2); | 408 | return TwoMembersHaveNoParent.Match.newMatch(pM1, pM2); |
409 | } | 409 | } |
410 | 410 | ||
411 | /** | 411 | /** |
412 | * Retrieve the set of values that occur in matches for m1. | 412 | * Retrieve the set of values that occur in matches for m1. |
413 | * @return the Set of all values or empty set if there are no matches | 413 | * @return the Set of all values or empty set if there are no matches |
414 | * | 414 | * |
415 | */ | 415 | */ |
416 | protected Stream<Member> rawStreamAllValuesOfm1(final Object[] parameters) { | 416 | protected Stream<Member> rawStreamAllValuesOfm1(final Object[] parameters) { |
417 | return rawStreamAllValues(POSITION_M1, parameters).map(Member.class::cast); | 417 | return rawStreamAllValues(POSITION_M1, parameters).map(Member.class::cast); |
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * Retrieve the set of values that occur in matches for m1. | 421 | * Retrieve the set of values that occur in matches for m1. |
422 | * @return the Set of all values or empty set if there are no matches | 422 | * @return the Set of all values or empty set if there are no matches |
423 | * | 423 | * |
424 | */ | 424 | */ |
425 | public Set<Member> getAllValuesOfm1() { | 425 | public Set<Member> getAllValuesOfm1() { |
426 | return rawStreamAllValuesOfm1(emptyArray()).collect(Collectors.toSet()); | 426 | return rawStreamAllValuesOfm1(emptyArray()).collect(Collectors.toSet()); |
427 | } | 427 | } |
428 | 428 | ||
429 | /** | 429 | /** |
430 | * Retrieve the set of values that occur in matches for m1. | 430 | * Retrieve the set of values that occur in matches for m1. |
431 | * @return the Set of all values or empty set if there are no matches | 431 | * @return the Set of all values or empty set if there are no matches |
432 | * | 432 | * |
433 | */ | 433 | */ |
434 | public Stream<Member> streamAllValuesOfm1() { | 434 | public Stream<Member> streamAllValuesOfm1() { |
435 | return rawStreamAllValuesOfm1(emptyArray()); | 435 | return rawStreamAllValuesOfm1(emptyArray()); |
436 | } | 436 | } |
437 | 437 | ||
438 | /** | 438 | /** |
439 | * Retrieve the set of values that occur in matches for m1. | 439 | * Retrieve the set of values that occur in matches for m1. |
440 | * </p> | 440 | * </p> |
441 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 441 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
442 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 442 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
443 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 443 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
444 | * | 444 | * |
445 | * @return the Stream of all values or empty set if there are no matches | 445 | * @return the Stream of all values or empty set if there are no matches |
446 | * | 446 | * |
447 | */ | 447 | */ |
448 | public Stream<Member> streamAllValuesOfm1(final TwoMembersHaveNoParent.Match partialMatch) { | 448 | public Stream<Member> streamAllValuesOfm1(final TwoMembersHaveNoParent.Match partialMatch) { |
449 | return rawStreamAllValuesOfm1(partialMatch.toArray()); | 449 | return rawStreamAllValuesOfm1(partialMatch.toArray()); |
450 | } | 450 | } |
451 | 451 | ||
452 | /** | 452 | /** |
453 | * Retrieve the set of values that occur in matches for m1. | 453 | * Retrieve the set of values that occur in matches for m1. |
454 | * </p> | 454 | * </p> |
455 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 455 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
456 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 456 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
457 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 457 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
458 | * | 458 | * |
459 | * @return the Stream of all values or empty set if there are no matches | 459 | * @return the Stream of all values or empty set if there are no matches |
460 | * | 460 | * |
461 | */ | 461 | */ |
462 | public Stream<Member> streamAllValuesOfm1(final Member pM2) { | 462 | public Stream<Member> streamAllValuesOfm1(final Member pM2) { |
463 | return rawStreamAllValuesOfm1(new Object[]{null, pM2}); | 463 | return rawStreamAllValuesOfm1(new Object[]{null, pM2}); |
464 | } | 464 | } |
465 | 465 | ||
466 | /** | 466 | /** |
467 | * Retrieve the set of values that occur in matches for m1. | 467 | * Retrieve the set of values that occur in matches for m1. |
468 | * @return the Set of all values or empty set if there are no matches | 468 | * @return the Set of all values or empty set if there are no matches |
469 | * | 469 | * |
470 | */ | 470 | */ |
471 | public Set<Member> getAllValuesOfm1(final TwoMembersHaveNoParent.Match partialMatch) { | 471 | public Set<Member> getAllValuesOfm1(final TwoMembersHaveNoParent.Match partialMatch) { |
472 | return rawStreamAllValuesOfm1(partialMatch.toArray()).collect(Collectors.toSet()); | 472 | return rawStreamAllValuesOfm1(partialMatch.toArray()).collect(Collectors.toSet()); |
473 | } | 473 | } |
474 | 474 | ||
475 | /** | 475 | /** |
476 | * Retrieve the set of values that occur in matches for m1. | 476 | * Retrieve the set of values that occur in matches for m1. |
477 | * @return the Set of all values or empty set if there are no matches | 477 | * @return the Set of all values or empty set if there are no matches |
478 | * | 478 | * |
479 | */ | 479 | */ |
480 | public Set<Member> getAllValuesOfm1(final Member pM2) { | 480 | public Set<Member> getAllValuesOfm1(final Member pM2) { |
481 | return rawStreamAllValuesOfm1(new Object[]{null, pM2}).collect(Collectors.toSet()); | 481 | return rawStreamAllValuesOfm1(new Object[]{null, pM2}).collect(Collectors.toSet()); |
482 | } | 482 | } |
483 | 483 | ||
484 | /** | 484 | /** |
485 | * Retrieve the set of values that occur in matches for m2. | 485 | * Retrieve the set of values that occur in matches for m2. |
486 | * @return the Set of all values or empty set if there are no matches | 486 | * @return the Set of all values or empty set if there are no matches |
487 | * | 487 | * |
488 | */ | 488 | */ |
489 | protected Stream<Member> rawStreamAllValuesOfm2(final Object[] parameters) { | 489 | protected Stream<Member> rawStreamAllValuesOfm2(final Object[] parameters) { |
490 | return rawStreamAllValues(POSITION_M2, parameters).map(Member.class::cast); | 490 | return rawStreamAllValues(POSITION_M2, parameters).map(Member.class::cast); |
491 | } | 491 | } |
492 | 492 | ||
493 | /** | 493 | /** |
494 | * Retrieve the set of values that occur in matches for m2. | 494 | * Retrieve the set of values that occur in matches for m2. |
495 | * @return the Set of all values or empty set if there are no matches | 495 | * @return the Set of all values or empty set if there are no matches |
496 | * | 496 | * |
497 | */ | 497 | */ |
498 | public Set<Member> getAllValuesOfm2() { | 498 | public Set<Member> getAllValuesOfm2() { |
499 | return rawStreamAllValuesOfm2(emptyArray()).collect(Collectors.toSet()); | 499 | return rawStreamAllValuesOfm2(emptyArray()).collect(Collectors.toSet()); |
500 | } | 500 | } |
501 | 501 | ||
502 | /** | 502 | /** |
503 | * Retrieve the set of values that occur in matches for m2. | 503 | * Retrieve the set of values that occur in matches for m2. |
504 | * @return the Set of all values or empty set if there are no matches | 504 | * @return the Set of all values or empty set if there are no matches |
505 | * | 505 | * |
506 | */ | 506 | */ |
507 | public Stream<Member> streamAllValuesOfm2() { | 507 | public Stream<Member> streamAllValuesOfm2() { |
508 | return rawStreamAllValuesOfm2(emptyArray()); | 508 | return rawStreamAllValuesOfm2(emptyArray()); |
509 | } | 509 | } |
510 | 510 | ||
511 | /** | 511 | /** |
512 | * Retrieve the set of values that occur in matches for m2. | 512 | * Retrieve the set of values that occur in matches for m2. |
513 | * </p> | 513 | * </p> |
514 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 514 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
515 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 515 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
516 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 516 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
517 | * | 517 | * |
518 | * @return the Stream of all values or empty set if there are no matches | 518 | * @return the Stream of all values or empty set if there are no matches |
519 | * | 519 | * |
520 | */ | 520 | */ |
521 | public Stream<Member> streamAllValuesOfm2(final TwoMembersHaveNoParent.Match partialMatch) { | 521 | public Stream<Member> streamAllValuesOfm2(final TwoMembersHaveNoParent.Match partialMatch) { |
522 | return rawStreamAllValuesOfm2(partialMatch.toArray()); | 522 | return rawStreamAllValuesOfm2(partialMatch.toArray()); |
523 | } | 523 | } |
524 | 524 | ||
525 | /** | 525 | /** |
526 | * Retrieve the set of values that occur in matches for m2. | 526 | * Retrieve the set of values that occur in matches for m2. |
527 | * </p> | 527 | * </p> |
528 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | 528 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. |
529 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | 529 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. |
530 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | 530 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. |
531 | * | 531 | * |
532 | * @return the Stream of all values or empty set if there are no matches | 532 | * @return the Stream of all values or empty set if there are no matches |
533 | * | 533 | * |
534 | */ | 534 | */ |
535 | public Stream<Member> streamAllValuesOfm2(final Member pM1) { | 535 | public Stream<Member> streamAllValuesOfm2(final Member pM1) { |
536 | return rawStreamAllValuesOfm2(new Object[]{pM1, null}); | 536 | return rawStreamAllValuesOfm2(new Object[]{pM1, null}); |
537 | } | 537 | } |
538 | 538 | ||
539 | /** | 539 | /** |
540 | * Retrieve the set of values that occur in matches for m2. | 540 | * Retrieve the set of values that occur in matches for m2. |
541 | * @return the Set of all values or empty set if there are no matches | 541 | * @return the Set of all values or empty set if there are no matches |
542 | * | 542 | * |
543 | */ | 543 | */ |
544 | public Set<Member> getAllValuesOfm2(final TwoMembersHaveNoParent.Match partialMatch) { | 544 | public Set<Member> getAllValuesOfm2(final TwoMembersHaveNoParent.Match partialMatch) { |
545 | return rawStreamAllValuesOfm2(partialMatch.toArray()).collect(Collectors.toSet()); | 545 | return rawStreamAllValuesOfm2(partialMatch.toArray()).collect(Collectors.toSet()); |
546 | } | 546 | } |
547 | 547 | ||
548 | /** | 548 | /** |
549 | * Retrieve the set of values that occur in matches for m2. | 549 | * Retrieve the set of values that occur in matches for m2. |
550 | * @return the Set of all values or empty set if there are no matches | 550 | * @return the Set of all values or empty set if there are no matches |
551 | * | 551 | * |
552 | */ | 552 | */ |
553 | public Set<Member> getAllValuesOfm2(final Member pM1) { | 553 | public Set<Member> getAllValuesOfm2(final Member pM1) { |
554 | return rawStreamAllValuesOfm2(new Object[]{pM1, null}).collect(Collectors.toSet()); | 554 | return rawStreamAllValuesOfm2(new Object[]{pM1, null}).collect(Collectors.toSet()); |
555 | } | 555 | } |
556 | 556 | ||
557 | @Override | 557 | @Override |
558 | protected TwoMembersHaveNoParent.Match tupleToMatch(final Tuple t) { | 558 | protected TwoMembersHaveNoParent.Match tupleToMatch(final Tuple t) { |
559 | try { | 559 | try { |
560 | return TwoMembersHaveNoParent.Match.newMatch((Member) t.get(POSITION_M1), (Member) t.get(POSITION_M2)); | 560 | return TwoMembersHaveNoParent.Match.newMatch((Member) t.get(POSITION_M1), (Member) t.get(POSITION_M2)); |
561 | } catch(ClassCastException e) { | 561 | } catch(ClassCastException e) { |
562 | LOGGER.error("Element(s) in tuple not properly typed!",e); | 562 | LOGGER.error("Element(s) in tuple not properly typed!",e); |
563 | return null; | 563 | return null; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | @Override | 567 | @Override |
568 | protected TwoMembersHaveNoParent.Match arrayToMatch(final Object[] match) { | 568 | protected TwoMembersHaveNoParent.Match arrayToMatch(final Object[] match) { |
569 | try { | 569 | try { |
570 | return TwoMembersHaveNoParent.Match.newMatch((Member) match[POSITION_M1], (Member) match[POSITION_M2]); | 570 | return TwoMembersHaveNoParent.Match.newMatch((Member) match[POSITION_M1], (Member) match[POSITION_M2]); |
571 | } catch(ClassCastException e) { | 571 | } catch(ClassCastException e) { |
572 | LOGGER.error("Element(s) in array not properly typed!",e); | 572 | LOGGER.error("Element(s) in array not properly typed!",e); |
573 | return null; | 573 | return null; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | 576 | ||
577 | @Override | 577 | @Override |
578 | protected TwoMembersHaveNoParent.Match arrayToMatchMutable(final Object[] match) { | 578 | protected TwoMembersHaveNoParent.Match arrayToMatchMutable(final Object[] match) { |
579 | try { | 579 | try { |
580 | return TwoMembersHaveNoParent.Match.newMutableMatch((Member) match[POSITION_M1], (Member) match[POSITION_M2]); | 580 | return TwoMembersHaveNoParent.Match.newMutableMatch((Member) match[POSITION_M1], (Member) match[POSITION_M2]); |
581 | } catch(ClassCastException e) { | 581 | } catch(ClassCastException e) { |
582 | LOGGER.error("Element(s) in array not properly typed!",e); | 582 | LOGGER.error("Element(s) in array not properly typed!",e); |
583 | return null; | 583 | return null; |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | /** | 587 | /** |
588 | * @return the singleton instance of the query specification of this pattern | 588 | * @return the singleton instance of the query specification of this pattern |
589 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 589 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
590 | * | 590 | * |
591 | */ | 591 | */ |
592 | public static IQuerySpecification<TwoMembersHaveNoParent.Matcher> querySpecification() { | 592 | public static IQuerySpecification<TwoMembersHaveNoParent.Matcher> querySpecification() { |
593 | return TwoMembersHaveNoParent.instance(); | 593 | return TwoMembersHaveNoParent.instance(); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
597 | private TwoMembersHaveNoParent() { | 597 | private TwoMembersHaveNoParent() { |
598 | super(GeneratedPQuery.INSTANCE); | 598 | super(GeneratedPQuery.INSTANCE); |
599 | } | 599 | } |
600 | 600 | ||
601 | /** | 601 | /** |
602 | * @return the singleton instance of the query specification | 602 | * @return the singleton instance of the query specification |
603 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | 603 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded |
604 | * | 604 | * |
605 | */ | 605 | */ |
606 | public static TwoMembersHaveNoParent instance() { | 606 | public static TwoMembersHaveNoParent instance() { |
607 | try{ | 607 | try{ |
608 | return LazyHolder.INSTANCE; | 608 | return LazyHolder.INSTANCE; |
609 | } catch (ExceptionInInitializerError err) { | 609 | } catch (ExceptionInInitializerError err) { |
610 | throw processInitializerError(err); | 610 | throw processInitializerError(err); |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | @Override | 614 | @Override |
615 | protected TwoMembersHaveNoParent.Matcher instantiate(final ViatraQueryEngine engine) { | 615 | protected TwoMembersHaveNoParent.Matcher instantiate(final ViatraQueryEngine engine) { |
616 | return TwoMembersHaveNoParent.Matcher.on(engine); | 616 | return TwoMembersHaveNoParent.Matcher.on(engine); |
617 | } | 617 | } |
618 | 618 | ||
619 | @Override | 619 | @Override |
620 | public TwoMembersHaveNoParent.Matcher instantiate() { | 620 | public TwoMembersHaveNoParent.Matcher instantiate() { |
621 | return TwoMembersHaveNoParent.Matcher.create(); | 621 | return TwoMembersHaveNoParent.Matcher.create(); |
622 | } | 622 | } |
623 | 623 | ||
624 | @Override | 624 | @Override |
625 | public TwoMembersHaveNoParent.Match newEmptyMatch() { | 625 | public TwoMembersHaveNoParent.Match newEmptyMatch() { |
626 | return TwoMembersHaveNoParent.Match.newEmptyMatch(); | 626 | return TwoMembersHaveNoParent.Match.newEmptyMatch(); |
627 | } | 627 | } |
628 | 628 | ||
629 | @Override | 629 | @Override |
630 | public TwoMembersHaveNoParent.Match newMatch(final Object... parameters) { | 630 | public TwoMembersHaveNoParent.Match newMatch(final Object... parameters) { |
631 | return TwoMembersHaveNoParent.Match.newMatch((familytree.Member) parameters[0], (familytree.Member) parameters[1]); | 631 | return TwoMembersHaveNoParent.Match.newMatch((familytree.Member) parameters[0], (familytree.Member) parameters[1]); |
632 | } | 632 | } |
633 | 633 | ||
634 | /** | 634 | /** |
635 | * Inner class allowing the singleton instance of {@link TwoMembersHaveNoParent} to be created | 635 | * Inner class allowing the singleton instance of {@link TwoMembersHaveNoParent} to be created |
636 | * <b>not</b> at the class load time of the outer class, | 636 | * <b>not</b> at the class load time of the outer class, |
637 | * but rather at the first call to {@link TwoMembersHaveNoParent#instance()}. | 637 | * but rather at the first call to {@link TwoMembersHaveNoParent#instance()}. |
638 | * | 638 | * |
639 | * <p> This workaround is required e.g. to support recursion. | 639 | * <p> This workaround is required e.g. to support recursion. |
640 | * | 640 | * |
641 | */ | 641 | */ |
642 | private static class LazyHolder { | 642 | private static class LazyHolder { |
643 | private static final TwoMembersHaveNoParent INSTANCE = new TwoMembersHaveNoParent(); | 643 | private static final TwoMembersHaveNoParent INSTANCE = new TwoMembersHaveNoParent(); |
644 | 644 | ||
645 | /** | 645 | /** |
646 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | 646 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. |
647 | * This initialization order is required to support indirect recursion. | 647 | * This initialization order is required to support indirect recursion. |
648 | * | 648 | * |
649 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | 649 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. |
650 | * | 650 | * |
651 | */ | 651 | */ |
652 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | 652 | private static final Object STATIC_INITIALIZER = ensureInitialized(); |
653 | 653 | ||
654 | public static Object ensureInitialized() { | 654 | public static Object ensureInitialized() { |
655 | INSTANCE.ensureInitializedInternal(); | 655 | INSTANCE.ensureInitializedInternal(); |
656 | return null; | 656 | return null; |
657 | } | 657 | } |
658 | } | 658 | } |
659 | 659 | ||
660 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | 660 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { |
661 | private static final TwoMembersHaveNoParent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | 661 | private static final TwoMembersHaveNoParent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); |
662 | 662 | ||
663 | private final PParameter parameter_m1 = new PParameter("m1", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); | 663 | private final PParameter parameter_m1 = new PParameter("m1", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); |
664 | 664 | ||
665 | private final PParameter parameter_m2 = new PParameter("m2", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); | 665 | private final PParameter parameter_m2 = new PParameter("m2", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT); |
666 | 666 | ||
667 | private final List<PParameter> parameters = Arrays.asList(parameter_m1, parameter_m2); | 667 | private final List<PParameter> parameters = Arrays.asList(parameter_m1, parameter_m2); |
668 | 668 | ||
669 | private GeneratedPQuery() { | 669 | private GeneratedPQuery() { |
670 | super(PVisibility.PUBLIC); | 670 | super(PVisibility.PUBLIC); |
671 | } | 671 | } |
672 | 672 | ||
673 | @Override | 673 | @Override |
674 | public String getFullyQualifiedName() { | 674 | public String getFullyQualifiedName() { |
675 | return "queries.twoMembersHaveNoParent"; | 675 | return "queries.twoMembersHaveNoParent"; |
676 | } | 676 | } |
677 | 677 | ||
678 | @Override | 678 | @Override |
679 | public List<String> getParameterNames() { | 679 | public List<String> getParameterNames() { |
680 | return Arrays.asList("m1","m2"); | 680 | return Arrays.asList("m1","m2"); |
681 | } | 681 | } |
682 | 682 | ||
683 | @Override | 683 | @Override |
684 | public List<PParameter> getParameters() { | 684 | public List<PParameter> getParameters() { |
685 | return parameters; | 685 | return parameters; |
686 | } | 686 | } |
687 | 687 | ||
688 | @Override | 688 | @Override |
689 | public Set<PBody> doGetContainedBodies() { | 689 | public Set<PBody> doGetContainedBodies() { |
690 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | 690 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); |
691 | Set<PBody> bodies = new LinkedHashSet<>(); | 691 | Set<PBody> bodies = new LinkedHashSet<>(); |
692 | { | 692 | { |
693 | PBody body = new PBody(this); | 693 | PBody body = new PBody(this); |
694 | PVariable var_m1 = body.getOrCreateVariableByName("m1"); | 694 | PVariable var_m1 = body.getOrCreateVariableByName("m1"); |
695 | PVariable var_m2 = body.getOrCreateVariableByName("m2"); | 695 | PVariable var_m2 = body.getOrCreateVariableByName("m2"); |
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_m1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 696 | new TypeConstraint(body, Tuples.flatTupleOf(var_m1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
697 | new TypeConstraint(body, Tuples.flatTupleOf(var_m2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); | 697 | new TypeConstraint(body, Tuples.flatTupleOf(var_m2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member"))); |
698 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | 698 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( |
699 | new ExportedParameter(body, var_m1, parameter_m1), | 699 | new ExportedParameter(body, var_m1, parameter_m1), |
700 | new ExportedParameter(body, var_m2, parameter_m2) | 700 | new ExportedParameter(body, var_m2, parameter_m2) |
701 | )); | 701 | )); |
702 | // neg find memberHasParent(m1) | 702 | // neg find memberHasParent(m1) |
703 | new NegativePatternCall(body, Tuples.flatTupleOf(var_m1), MemberHasParent.instance().getInternalQueryRepresentation()); | 703 | new NegativePatternCall(body, Tuples.flatTupleOf(var_m1), MemberHasParent.instance().getInternalQueryRepresentation()); |
704 | // neg find memberHasParent(m2) | 704 | // neg find memberHasParent(m2) |
705 | new NegativePatternCall(body, Tuples.flatTupleOf(var_m2), MemberHasParent.instance().getInternalQueryRepresentation()); | 705 | new NegativePatternCall(body, Tuples.flatTupleOf(var_m2), MemberHasParent.instance().getInternalQueryRepresentation()); |
706 | // m1 != m2 | 706 | // m1 != m2 |
707 | new Inequality(body, var_m1, var_m2); | 707 | new Inequality(body, var_m1, var_m2); |
708 | bodies.add(body); | 708 | bodies.add(body); |
709 | } | 709 | } |
710 | { | 710 | { |
711 | PAnnotation annotation = new PAnnotation("Constraint"); | 711 | PAnnotation annotation = new PAnnotation("Constraint"); |
712 | annotation.addAttribute("message", "twoMembersHaveNoParent"); | 712 | annotation.addAttribute("message", "twoMembersHaveNoParent"); |
713 | annotation.addAttribute("severity", "error"); | 713 | annotation.addAttribute("severity", "error"); |
714 | annotation.addAttribute("key", Arrays.asList(new Object[] { | 714 | annotation.addAttribute("key", Arrays.asList(new Object[] { |
715 | new ParameterReference("m1"), | 715 | new ParameterReference("m1"), |
716 | new ParameterReference("m2") | 716 | new ParameterReference("m2") |
717 | })); | 717 | })); |
718 | addAnnotation(annotation); | 718 | addAnnotation(annotation); |
719 | } | 719 | } |
720 | return bodies; | 720 | return bodies; |
721 | } | 721 | } |
722 | } | 722 | } |
723 | } | 723 | } |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml index 63aa0b02..8b036ff2 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/plugin.xml | |||
@@ -1,42 +1,42 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><plugin> | 1 | <?xml version="1.0" encoding="UTF-8"?><plugin> |
2 | <extension id="queries.Case_study_A" point="org.eclipse.viatra.query.runtime.queryspecification"> | 2 | <extension id="queries.Case_study_A" point="org.eclipse.viatra.query.runtime.queryspecification"> |
3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.Case_study_A" id="queries.Case_study_A"> | 3 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.Case_study_A" id="queries.Case_study_A"> |
4 | <query-specification fqn="queries.inv03"/> | 4 | <query-specification fqn="queries.inv03"/> |
5 | <query-specification fqn="queries.x_inv03_eligAll"/> | 5 | <query-specification fqn="queries.x_inv03_eligAll"/> |
6 | <query-specification fqn="queries.x_inv03_hasAll"/> | 6 | <query-specification fqn="queries.x_inv03_hasAll"/> |
7 | <query-specification fqn="queries.inv05"/> | 7 | <query-specification fqn="queries.inv05"/> |
8 | <query-specification fqn="queries.x_inv05_inRange"/> | 8 | <query-specification fqn="queries.x_inv05_inRange"/> |
9 | <query-specification fqn="queries.inv06"/> | 9 | <query-specification fqn="queries.inv06"/> |
10 | <query-specification fqn="queries.inv07"/> | 10 | <query-specification fqn="queries.inv07"/> |
11 | <query-specification fqn="queries.inv08"/> | 11 | <query-specification fqn="queries.inv08"/> |
12 | <query-specification fqn="queries.x_inv08_notEI"/> | 12 | <query-specification fqn="queries.x_inv08_notEI"/> |
13 | <query-specification fqn="queries.x_inv08_noType"/> | 13 | <query-specification fqn="queries.x_inv08_noType"/> |
14 | <query-specification fqn="queries.x_inv08_inRange"/> | 14 | <query-specification fqn="queries.x_inv08_inRange"/> |
15 | <query-specification fqn="queries.inv10"/> | 15 | <query-specification fqn="queries.inv10"/> |
16 | <query-specification fqn="queries.inv11"/> | 16 | <query-specification fqn="queries.inv11"/> |
17 | <query-specification fqn="queries.x_inv11_incOver100"/> | 17 | <query-specification fqn="queries.x_inv11_incOver100"/> |
18 | <query-specification fqn="queries.x_inv11_incNotOver100"/> | 18 | <query-specification fqn="queries.x_inv11_incNotOver100"/> |
19 | <query-specification fqn="queries.inv12"/> | 19 | <query-specification fqn="queries.inv12"/> |
20 | <query-specification fqn="queries.x_inv12_notNonRes"/> | 20 | <query-specification fqn="queries.x_inv12_notNonRes"/> |
21 | <query-specification fqn="queries.x_inv12_notZZ"/> | 21 | <query-specification fqn="queries.x_inv12_notZZ"/> |
22 | <query-specification fqn="queries.inv13"/> | 22 | <query-specification fqn="queries.inv13"/> |
23 | <query-specification fqn="queries.x_inv13"/> | 23 | <query-specification fqn="queries.x_inv13"/> |
24 | <query-specification fqn="queries.inv15"/> | 24 | <query-specification fqn="queries.inv15"/> |
25 | <query-specification fqn="queries.x_inv15"/> | 25 | <query-specification fqn="queries.x_inv15"/> |
26 | <query-specification fqn="queries.inv17"/> | 26 | <query-specification fqn="queries.inv17"/> |
27 | <query-specification fqn="queries.inv20"/> | 27 | <query-specification fqn="queries.inv20"/> |
28 | <query-specification fqn="queries.inv33"/> | 28 | <query-specification fqn="queries.inv33"/> |
29 | <query-specification fqn="queries.inv34"/> | 29 | <query-specification fqn="queries.inv34"/> |
30 | <query-specification fqn="queries.inv35"/> | 30 | <query-specification fqn="queries.inv35"/> |
31 | <query-specification fqn="queries.inv47"/> | 31 | <query-specification fqn="queries.inv47"/> |
32 | <query-specification fqn="queries.x_inv47"/> | 32 | <query-specification fqn="queries.x_inv47"/> |
33 | <query-specification fqn="queries.inv48"/> | 33 | <query-specification fqn="queries.inv48"/> |
34 | <query-specification fqn="queries.x_inv48_notDis"/> | 34 | <query-specification fqn="queries.x_inv48_notDis"/> |
35 | <query-specification fqn="queries.x_inv48_Dis"/> | 35 | <query-specification fqn="queries.x_inv48_Dis"/> |
36 | <query-specification fqn="queries.x_inv48_3"/> | 36 | <query-specification fqn="queries.x_inv48_3"/> |
37 | <query-specification fqn="queries.inv49"/> | 37 | <query-specification fqn="queries.inv49"/> |
38 | <query-specification fqn="queries.x_inv49_1"/> | 38 | <query-specification fqn="queries.x_inv49_1"/> |
39 | <query-specification fqn="queries.x_inv49_2"/> | 39 | <query-specification fqn="queries.x_inv49_2"/> |
40 | </group> | 40 | </group> |
41 | </extension> | 41 | </extension> |
42 | </plugin> | 42 | </plugin> |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin index 3430ce88..163f84a1 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java index 35ddb32f..2809679d 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java | |||
@@ -1,314 +1,314 @@ | |||
1 | package run; | 1 | package run; |
2 | 2 | ||
3 | import Taxation.TaxationPackage; | 3 | import Taxation.TaxationPackage; |
4 | import com.google.common.base.Objects; | 4 | import com.google.common.base.Objects; |
5 | import com.google.common.collect.Iterables; | 5 | import com.google.common.collect.Iterables; |
6 | import com.google.inject.Injector; | 6 | import com.google.inject.Injector; |
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | 7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; |
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; | 8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; |
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | 9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; |
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | 10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; |
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | 15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; |
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | 16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; |
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | 17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; |
18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; | 18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; |
19 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; | 19 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; |
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | 20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; |
21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | 21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | 22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; |
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | 24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; |
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | 27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; |
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
29 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | 29 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; |
30 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | 30 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; |
31 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | 31 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; |
32 | import java.math.BigDecimal; | 32 | import java.math.BigDecimal; |
33 | import java.text.SimpleDateFormat; | 33 | import java.text.SimpleDateFormat; |
34 | import java.util.Collections; | 34 | import java.util.Collections; |
35 | import java.util.Date; | 35 | import java.util.Date; |
36 | import java.util.HashMap; | 36 | import java.util.HashMap; |
37 | import java.util.List; | 37 | import java.util.List; |
38 | import java.util.Map; | 38 | import java.util.Map; |
39 | import java.util.Set; | 39 | import java.util.Set; |
40 | import java.util.TreeSet; | 40 | import java.util.TreeSet; |
41 | import org.eclipse.emf.common.util.EList; | 41 | import org.eclipse.emf.common.util.EList; |
42 | import org.eclipse.emf.ecore.EAttribute; | 42 | import org.eclipse.emf.ecore.EAttribute; |
43 | import org.eclipse.emf.ecore.EClass; | 43 | import org.eclipse.emf.ecore.EClass; |
44 | import org.eclipse.emf.ecore.EEnum; | 44 | import org.eclipse.emf.ecore.EEnum; |
45 | import org.eclipse.emf.ecore.EEnumLiteral; | 45 | import org.eclipse.emf.ecore.EEnumLiteral; |
46 | import org.eclipse.emf.ecore.EObject; | 46 | import org.eclipse.emf.ecore.EObject; |
47 | import org.eclipse.emf.ecore.EPackage; | 47 | import org.eclipse.emf.ecore.EPackage; |
48 | import org.eclipse.emf.ecore.EReference; | 48 | import org.eclipse.emf.ecore.EReference; |
49 | import org.eclipse.emf.ecore.EStructuralFeature; | 49 | import org.eclipse.emf.ecore.EStructuralFeature; |
50 | import org.eclipse.emf.ecore.resource.Resource; | 50 | import org.eclipse.emf.ecore.resource.Resource; |
51 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | 51 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
52 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | 52 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; |
53 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; | 53 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; |
54 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 54 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
55 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 55 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
56 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; | 56 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; |
57 | import org.eclipse.xtend2.lib.StringConcatenation; | 57 | import org.eclipse.xtend2.lib.StringConcatenation; |
58 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; | 58 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; |
59 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | 59 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
60 | import org.eclipse.xtext.xbase.lib.Exceptions; | 60 | import org.eclipse.xtext.xbase.lib.Exceptions; |
61 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | 61 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; |
62 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | 62 | import org.eclipse.xtext.xbase.lib.Functions.Function1; |
63 | import org.eclipse.xtext.xbase.lib.InputOutput; | 63 | import org.eclipse.xtext.xbase.lib.InputOutput; |
64 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | 64 | import org.eclipse.xtext.xbase.lib.IterableExtensions; |
65 | import org.eclipse.xtext.xbase.lib.ListExtensions; | 65 | import org.eclipse.xtext.xbase.lib.ListExtensions; |
66 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | 66 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; |
67 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | 67 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
68 | 68 | ||
69 | @SuppressWarnings("all") | 69 | @SuppressWarnings("all") |
70 | public class GeneratePledgeModels { | 70 | public class GeneratePledgeModels { |
71 | public static void main(final String[] args) { | 71 | public static void main(final String[] args) { |
72 | try { | 72 | try { |
73 | final Injector x = new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); | 73 | final Injector x = new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); |
74 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 74 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
75 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 75 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
76 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); | 76 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); |
77 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 77 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
78 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); | 78 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); |
79 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); | 79 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); |
80 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 80 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
81 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); | 81 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); |
82 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); | 82 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); |
83 | ReteEngine.class.getClass(); | 83 | ReteEngine.class.getClass(); |
84 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); | 84 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); |
85 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); | 85 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); |
86 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); | 86 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); |
87 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | 87 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); |
88 | long _currentTimeMillis = System.currentTimeMillis(); | 88 | long _currentTimeMillis = System.currentTimeMillis(); |
89 | final Date date = new Date(_currentTimeMillis); | 89 | final Date date = new Date(_currentTimeMillis); |
90 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); | 90 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); |
91 | final String formattedDate = format.format(date); | 91 | final String formattedDate = format.format(date); |
92 | StringConcatenation _builder = new StringConcatenation(); | 92 | StringConcatenation _builder = new StringConcatenation(); |
93 | _builder.append("inputs/"); | 93 | _builder.append("inputs/"); |
94 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); | 94 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); |
95 | StringConcatenation _builder_1 = new StringConcatenation(); | 95 | StringConcatenation _builder_1 = new StringConcatenation(); |
96 | _builder_1.append("output/"); | 96 | _builder_1.append("output/"); |
97 | String _plus = (_builder_1.toString() + formattedDate); | 97 | String _plus = (_builder_1.toString() + formattedDate); |
98 | StringConcatenation _builder_2 = new StringConcatenation(); | 98 | StringConcatenation _builder_2 = new StringConcatenation(); |
99 | _builder_2.append("/"); | 99 | _builder_2.append("/"); |
100 | String _plus_1 = (_plus + _builder_2); | 100 | String _plus_1 = (_plus + _builder_2); |
101 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_1, ""); | 101 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_1, ""); |
102 | StringConcatenation _builder_3 = new StringConcatenation(); | 102 | StringConcatenation _builder_3 = new StringConcatenation(); |
103 | _builder_3.append("output/"); | 103 | _builder_3.append("output/"); |
104 | String _plus_2 = (_builder_3.toString() + formattedDate); | 104 | String _plus_2 = (_builder_3.toString() + formattedDate); |
105 | StringConcatenation _builder_4 = new StringConcatenation(); | 105 | StringConcatenation _builder_4 = new StringConcatenation(); |
106 | _builder_4.append("/debug/"); | 106 | _builder_4.append("/debug/"); |
107 | String _plus_3 = (_plus_2 + _builder_4); | 107 | String _plus_3 = (_plus_2 + _builder_4); |
108 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_3, ""); | 108 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_3, ""); |
109 | workspace.initAndClear(); | 109 | workspace.initAndClear(); |
110 | InputOutput.<String>println("Input and output workspaces are created"); | 110 | InputOutput.<String>println("Input and output workspaces are created"); |
111 | final EcoreMetamodelDescriptor metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); | 111 | final EcoreMetamodelDescriptor metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); |
112 | final EList<EObject> partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); | 112 | final EList<EObject> partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); |
113 | InputOutput.<String>println("DSL loaded"); | 113 | InputOutput.<String>println("DSL loaded"); |
114 | final int SIZE = 2; | 114 | final int SIZE = 2; |
115 | int REPS = 1; | 115 | int REPS = 1; |
116 | final int RUNTIME = 600; | 116 | final int RUNTIME = 600; |
117 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | 117 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); |
118 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | 118 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); |
119 | LogicProblem problem = modelGenerationProblem.getOutput(); | 119 | LogicProblem problem = modelGenerationProblem.getOutput(); |
120 | debug.writeModel(problem, "problem.logicproblem"); | 120 | debug.writeModel(problem, "problem.logicproblem"); |
121 | InputOutput.<String>println("Problem created"); | 121 | InputOutput.<String>println("Problem created"); |
122 | for (int i = 0; (i < REPS); i++) { | 122 | for (int i = 0; (i < REPS); i++) { |
123 | { | 123 | { |
124 | ViatraReasoner reasoner = new ViatraReasoner(); | 124 | ViatraReasoner reasoner = new ViatraReasoner(); |
125 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); | 125 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); |
126 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0)); | 126 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0)); |
127 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); | 127 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); |
128 | BigDecimal _bigDecimal = new BigDecimal("0.0"); | 128 | BigDecimal _bigDecimal = new BigDecimal("0.0"); |
129 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); | 129 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); |
130 | final TreeSet<String> knownStrings = new TreeSet<String>(); | 130 | final TreeSet<String> knownStrings = new TreeSet<String>(); |
131 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2"); | 131 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2"); |
132 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | 132 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); |
133 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { | 133 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { |
134 | it.documentationLevel = DocumentationLevel.FULL; | 134 | it.documentationLevel = DocumentationLevel.FULL; |
135 | DebugConfiguration _debugConfiguration = new DebugConfiguration(); | 135 | DebugConfiguration _debugConfiguration = new DebugConfiguration(); |
136 | final Procedure1<DebugConfiguration> _function_1 = (DebugConfiguration it_1) -> { | 136 | final Procedure1<DebugConfiguration> _function_1 = (DebugConfiguration it_1) -> { |
137 | it_1.logging = true; | 137 | it_1.logging = true; |
138 | }; | 138 | }; |
139 | DebugConfiguration _doubleArrow = ObjectExtensions.<DebugConfiguration>operator_doubleArrow(_debugConfiguration, _function_1); | 139 | DebugConfiguration _doubleArrow = ObjectExtensions.<DebugConfiguration>operator_doubleArrow(_debugConfiguration, _function_1); |
140 | it.debugCongiguration = _doubleArrow; | 140 | it.debugCongiguration = _doubleArrow; |
141 | it.runtimeLimit = RUNTIME; | 141 | it.runtimeLimit = RUNTIME; |
142 | boolean _isEmpty = knownIntegers.isEmpty(); | 142 | boolean _isEmpty = knownIntegers.isEmpty(); |
143 | boolean _not = (!_isEmpty); | 143 | boolean _not = (!_isEmpty); |
144 | if (_not) { | 144 | if (_not) { |
145 | it.typeScopes.knownIntegers = knownIntegers; | 145 | it.typeScopes.knownIntegers = knownIntegers; |
146 | } | 146 | } |
147 | boolean _isEmpty_1 = knownReals.isEmpty(); | 147 | boolean _isEmpty_1 = knownReals.isEmpty(); |
148 | boolean _not_1 = (!_isEmpty_1); | 148 | boolean _not_1 = (!_isEmpty_1); |
149 | if (_not_1) { | 149 | if (_not_1) { |
150 | it.typeScopes.knownReals = knownReals; | 150 | it.typeScopes.knownReals = knownReals; |
151 | } | 151 | } |
152 | }; | 152 | }; |
153 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); | 153 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); |
154 | InputOutput.<String>println((("Run #" + Integer.valueOf(i)) + ":")); | 154 | InputOutput.<String>println((("Run #" + Integer.valueOf(i)) + ":")); |
155 | final long startTime = System.currentTimeMillis(); | 155 | final long startTime = System.currentTimeMillis(); |
156 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); | 156 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); |
157 | long _currentTimeMillis_1 = System.currentTimeMillis(); | 157 | long _currentTimeMillis_1 = System.currentTimeMillis(); |
158 | final long totalTime = (_currentTimeMillis_1 - startTime); | 158 | final long totalTime = (_currentTimeMillis_1 - startTime); |
159 | InputOutput.<String>println(" Problem Solved"); | 159 | InputOutput.<String>println(" Problem Solved"); |
160 | GeneratePledgeModels.writeStats(solution, totalTime, solverConfig); | 160 | GeneratePledgeModels.writeStats(solution, totalTime, solverConfig); |
161 | if ((solution instanceof ModelResult)) { | 161 | if ((solution instanceof ModelResult)) { |
162 | GeneratePledgeModels.writeRepresentation(solution, workspace, i); | 162 | GeneratePledgeModels.writeRepresentation(solution, workspace, i); |
163 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, workspace, i, reasoner, modelGenerationProblem); | 163 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, workspace, i, reasoner, modelGenerationProblem); |
164 | InputOutput.<String>println(" Solution saved and visualised"); | 164 | InputOutput.<String>println(" Solution saved and visualised"); |
165 | } else { | 165 | } else { |
166 | String _string = solution.getClass().getSimpleName().toString(); | 166 | String _string = solution.getClass().getSimpleName().toString(); |
167 | String _plus_4 = (" Returned: " + _string); | 167 | String _plus_4 = (" Returned: " + _string); |
168 | InputOutput.<String>println(_plus_4); | 168 | InputOutput.<String>println(_plus_4); |
169 | } | 169 | } |
170 | final Runtime r = Runtime.getRuntime(); | 170 | final Runtime r = Runtime.getRuntime(); |
171 | r.gc(); | 171 | r.gc(); |
172 | r.gc(); | 172 | r.gc(); |
173 | r.gc(); | 173 | r.gc(); |
174 | Thread.sleep(3000); | 174 | Thread.sleep(3000); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | InputOutput.<String>println("---End---"); | 177 | InputOutput.<String>println("---End---"); |
178 | } catch (Throwable _e) { | 178 | } catch (Throwable _e) { |
179 | throw Exceptions.sneakyThrow(_e); | 179 | throw Exceptions.sneakyThrow(_e); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | 183 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { |
184 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | 184 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); |
185 | final Function1<EClass, String> _function = (EClass s) -> { | 185 | final Function1<EClass, String> _function = (EClass s) -> { |
186 | return s.getName(); | 186 | return s.getName(); |
187 | }; | 187 | }; |
188 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | 188 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); |
189 | Set<Class> _keySet = classMap.keySet(); | 189 | Set<Class> _keySet = classMap.keySet(); |
190 | for (final Class elem : _keySet) { | 190 | for (final Class elem : _keySet) { |
191 | typeMap.put( | 191 | typeMap.put( |
192 | e2l.TypeofEClass(trace, | 192 | e2l.TypeofEClass(trace, |
193 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | 193 | listMap.get(elem.getSimpleName())), classMap.get(elem)); |
194 | } | 194 | } |
195 | return typeMap; | 195 | return typeMap; |
196 | } | 196 | } |
197 | 197 | ||
198 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | 198 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { |
199 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | 199 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); |
200 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | 200 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); |
201 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | 201 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { |
202 | return it.getELiterals(); | 202 | return it.getELiterals(); |
203 | }; | 203 | }; |
204 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | 204 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); |
205 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | 205 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { |
206 | return it.getEReferences(); | 206 | return it.getEReferences(); |
207 | }; | 207 | }; |
208 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | 208 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); |
209 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | 209 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { |
210 | return it.getEAttributes(); | 210 | return it.getEAttributes(); |
211 | }; | 211 | }; |
212 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | 212 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); |
213 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | 213 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); |
214 | } | 214 | } |
215 | 215 | ||
216 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | 216 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { |
217 | EList<EObject> _xblockexpression = null; | 217 | EList<EObject> _xblockexpression = null; |
218 | { | 218 | { |
219 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 219 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
220 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 220 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
221 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | 221 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); |
222 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | 222 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); |
223 | } | 223 | } |
224 | return _xblockexpression; | 224 | return _xblockexpression; |
225 | } | 225 | } |
226 | 226 | ||
227 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | 227 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { |
228 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | 228 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); |
229 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | 229 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { |
230 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | 230 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { |
231 | String _name = it_1.getName(); | 231 | String _name = it_1.getName(); |
232 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | 232 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); |
233 | }; | 233 | }; |
234 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | 234 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); |
235 | }; | 235 | }; |
236 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | 236 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); |
237 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | 237 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); |
238 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | 238 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); |
239 | return res; | 239 | return res; |
240 | } | 240 | } |
241 | 241 | ||
242 | public static void writeInterpretation(final LogicResult solution, final Logic2Ecore logic2Ecore, final ReasonerWorkspace workspace, final int i, final ViatraReasoner reasoner, final TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | 242 | public static void writeInterpretation(final LogicResult solution, final Logic2Ecore logic2Ecore, final ReasonerWorkspace workspace, final int i, final ViatraReasoner reasoner, final TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { |
243 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | 243 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); |
244 | int _size = interpretations.size(); | 244 | int _size = interpretations.size(); |
245 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 245 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); |
246 | for (final Integer interpIndex : _doubleDotLessThan) { | 246 | for (final Integer interpIndex : _doubleDotLessThan) { |
247 | { | 247 | { |
248 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | 248 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); |
249 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | 249 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); |
250 | StringConcatenation _builder = new StringConcatenation(); | 250 | StringConcatenation _builder = new StringConcatenation(); |
251 | _builder.append("solution"); | 251 | _builder.append("solution"); |
252 | _builder.append(i); | 252 | _builder.append(i); |
253 | _builder.append("_"); | 253 | _builder.append("_"); |
254 | _builder.append(interpIndex); | 254 | _builder.append(interpIndex); |
255 | _builder.append(".xmi"); | 255 | _builder.append(".xmi"); |
256 | workspace.writeModel(model, _builder.toString()); | 256 | workspace.writeModel(model, _builder.toString()); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final int i) { | 261 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final int i) { |
262 | final EList<Object> representations = solution.getRepresentation(); | 262 | final EList<Object> representations = solution.getRepresentation(); |
263 | int _size = representations.size(); | 263 | int _size = representations.size(); |
264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); |
265 | for (final Integer representationIndex : _doubleDotLessThan) { | 265 | for (final Integer representationIndex : _doubleDotLessThan) { |
266 | { | 266 | { |
267 | final Object representation = representations.get((representationIndex).intValue()); | 267 | final Object representation = representations.get((representationIndex).intValue()); |
268 | if ((representation instanceof PartialInterpretation)) { | 268 | if ((representation instanceof PartialInterpretation)) { |
269 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | 269 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); |
270 | StringConcatenation _builder = new StringConcatenation(); | 270 | StringConcatenation _builder = new StringConcatenation(); |
271 | _builder.append("solution"); | 271 | _builder.append("solution"); |
272 | _builder.append(i); | 272 | _builder.append(i); |
273 | _builder.append("_"); | 273 | _builder.append("_"); |
274 | _builder.append(representationIndex); | 274 | _builder.append(representationIndex); |
275 | _builder.append(".gml"); | 275 | _builder.append(".gml"); |
276 | workspace.writeText(_builder.toString(), gml); | 276 | workspace.writeText(_builder.toString(), gml); |
277 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | 277 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); |
278 | StringConcatenation _builder_1 = new StringConcatenation(); | 278 | StringConcatenation _builder_1 = new StringConcatenation(); |
279 | _builder_1.append("solution"); | 279 | _builder_1.append("solution"); |
280 | _builder_1.append(i); | 280 | _builder_1.append(i); |
281 | _builder_1.append("_"); | 281 | _builder_1.append("_"); |
282 | _builder_1.append(representationIndex); | 282 | _builder_1.append(representationIndex); |
283 | _builder_1.append(".png"); | 283 | _builder_1.append(".png"); |
284 | png.writeToFile(workspace, _builder_1.toString()); | 284 | png.writeToFile(workspace, _builder_1.toString()); |
285 | } else { | 285 | } else { |
286 | StringConcatenation _builder_2 = new StringConcatenation(); | 286 | StringConcatenation _builder_2 = new StringConcatenation(); |
287 | _builder_2.append("solution"); | 287 | _builder_2.append("solution"); |
288 | _builder_2.append(representationIndex); | 288 | _builder_2.append(representationIndex); |
289 | _builder_2.append(".txt"); | 289 | _builder_2.append(".txt"); |
290 | workspace.writeText(_builder_2.toString(), representation.toString()); | 290 | workspace.writeText(_builder_2.toString(), representation.toString()); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | 296 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { |
297 | String _xblockexpression = null; | 297 | String _xblockexpression = null; |
298 | { | 298 | { |
299 | final Statistics stats = solution.getStatistics(); | 299 | final Statistics stats = solution.getStatistics(); |
300 | InputOutput.<String>println(" Statistics:"); | 300 | InputOutput.<String>println(" Statistics:"); |
301 | Object _xifexpression = null; | 301 | Object _xifexpression = null; |
302 | if ((config.typeScopes.maxNewElements == 2147483647)) { | 302 | if ((config.typeScopes.maxNewElements == 2147483647)) { |
303 | _xifexpression = "*"; | 303 | _xifexpression = "*"; |
304 | } else { | 304 | } else { |
305 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); | 305 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); |
306 | } | 306 | } |
307 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); | 307 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); |
308 | String _plus_1 = (_plus + "]"); | 308 | String _plus_1 = (_plus + "]"); |
309 | InputOutput.<String>println(_plus_1); | 309 | InputOutput.<String>println(_plus_1); |
310 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); | 310 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); |
311 | } | 311 | } |
312 | return _xblockexpression; | 312 | return _xblockexpression; |
313 | } | 313 | } |
314 | } | 314 | } |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.application.FAMTest/plugin.xml b/Tests/hu.bme.mit.inf.dslreasoner.application.FAMTest/plugin.xml index 2f4febdb..c760d4ef 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.application.FAMTest/plugin.xml +++ b/Tests/hu.bme.mit.inf.dslreasoner.application.FAMTest/plugin.xml | |||
@@ -1 +1 @@ | |||
<?xml version="1.0" encoding="UTF-8"?><plugin/> | <?xml version="1.0" encoding="UTF-8"?><plugin/> | ||