diff options
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberHasParent.java')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberHasParent.java | 1102 |
1 files changed, 551 insertions, 551 deletions
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 | } |