aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/ParentTooYoung.java1550
1 files changed, 775 insertions, 775 deletions
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 */
4package queries; 4package queries;
5 5
6import familytree.Member; 6import familytree.Member;
7import java.util.Arrays; 7import java.util.Arrays;
8import java.util.Collection; 8import java.util.Collection;
9import java.util.LinkedHashSet; 9import java.util.LinkedHashSet;
10import java.util.List; 10import java.util.List;
11import java.util.Objects; 11import java.util.Objects;
12import java.util.Optional; 12import java.util.Optional;
13import java.util.Set; 13import java.util.Set;
14import java.util.function.Consumer; 14import java.util.function.Consumer;
15import java.util.stream.Collectors; 15import java.util.stream.Collectors;
16import java.util.stream.Stream; 16import java.util.stream.Stream;
17import org.apache.log4j.Logger; 17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass; 18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.emf.ecore.EDataType; 19import org.eclipse.emf.ecore.EDataType;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch; 20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification; 21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; 22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; 23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; 24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; 25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; 26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; 27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; 28import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; 29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; 30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; 31import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
32import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; 32import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; 33import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; 34import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
35import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; 35import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
36import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; 36import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; 37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; 38import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; 39import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
40import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; 40import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; 41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
42import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; 42import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
43import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; 43import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
44import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; 44import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
45import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; 45import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
46import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; 46import 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")
68public final class ParentTooYoung extends BaseGeneratedEMFQuerySpecification<ParentTooYoung.Matcher> { 68public 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}