aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/github-graph
diff options
context:
space:
mode:
authorLibravatar 20001LastOrder <boqi.chen@mail.mcgill.ca>2020-11-15 21:56:45 -0500
committerLibravatar 20001LastOrder <boqi.chen@mail.mcgill.ca>2020-11-15 21:56:45 -0500
commit1cfc2e98ffbba1dc2a489ad415c81264b76d8c14 (patch)
treeb342c3541a5728b775564d8a0f5c6e6d93784694 /Domains/github-graph
parentfix node type distance measure (diff)
downloadVIATRA-Generator-Realistic-Generation-SURE.tar.gz
VIATRA-Generator-Realistic-Generation-SURE.tar.zst
VIATRA-Generator-Realistic-Generation-SURE.zip
Diffstat (limited to 'Domains/github-graph')
-rw-r--r--Domains/github-graph/bin/queries/.CheckAction.java._tracebin0 -> 7387 bytes
-rw-r--r--Domains/github-graph/bin/queries/.CheckUserAction.java._tracebin0 -> 9454 bytes
-rw-r--r--Domains/github-graph/bin/queries/.Committer.java._tracebin0 -> 8959 bytes
-rw-r--r--Domains/github-graph/bin/queries/.ConsecutiveClosesWithoutReopen.java._tracebin0 -> 6301 bytes
-rw-r--r--Domains/github-graph/bin/queries/.ConsecutiveReopensWithoutClose.java._tracebin0 -> 3964 bytes
-rw-r--r--Domains/github-graph/bin/queries/.ConsecutiveSubWithoutUnSub.java._tracebin0 -> 6225 bytes
-rw-r--r--Domains/github-graph/bin/queries/.ConsecutiveUnSubWithoutSub.java._tracebin0 -> 6225 bytes
-rw-r--r--Domains/github-graph/bin/queries/.EventUser.java._tracebin0 -> 6198 bytes
-rw-r--r--Domains/github-graph/bin/queries/.IsClose.java._tracebin0 -> 5542 bytes
-rw-r--r--Domains/github-graph/bin/queries/.IsReopen.java._tracebin0 -> 5542 bytes
-rw-r--r--Domains/github-graph/bin/queries/.IsSubscribe.java._tracebin0 -> 7402 bytes
-rw-r--r--Domains/github-graph/bin/queries/.IsUnSubscribe.java._tracebin0 -> 7402 bytes
-rw-r--r--Domains/github-graph/bin/queries/.NoCommitter.java._tracebin0 -> 3947 bytes
-rw-r--r--Domains/github-graph/bin/queries/.NoUser.java._tracebin0 -> 3947 bytes
-rw-r--r--Domains/github-graph/bin/queries/github.vql116
-rw-r--r--Domains/github-graph/model/github.ecore3
-rw-r--r--Domains/github-graph/plugin.xml14
-rw-r--r--Domains/github-graph/queries/queries/github.vql116
-rw-r--r--Domains/github-graph/src-gen/queries/.CheckAction.java._tracebin0 -> 7387 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.CheckUserAction.java._tracebin0 -> 9454 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.Committer.java._tracebin0 -> 8959 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.ConsecutiveClosesWithoutReopen.java._tracebin0 -> 6301 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.ConsecutiveReopensWithoutClose.java._tracebin0 -> 3964 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.ConsecutiveSubWithoutUnSub.java._tracebin0 -> 6225 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.ConsecutiveUnSubWithoutSub.java._tracebin0 -> 6225 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.EventUser.java._tracebin0 -> 6198 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.IsClose.java._tracebin0 -> 5542 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.IsReopen.java._tracebin0 -> 5542 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.IsSubscribe.java._tracebin0 -> 7402 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.IsUnSubscribe.java._tracebin0 -> 7402 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.NoCommitter.java._tracebin0 -> 3947 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/.NoUser.java._tracebin0 -> 3947 bytes
-rw-r--r--Domains/github-graph/src-gen/queries/CheckAction.java829
-rw-r--r--Domains/github-graph/src-gen/queries/CheckUserAction.java946
-rw-r--r--Domains/github-graph/src-gen/queries/Committer.java725
-rw-r--r--Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java602
-rw-r--r--Domains/github-graph/src-gen/queries/ConsecutiveReopensWithoutClose.java582
-rw-r--r--Domains/github-graph/src-gen/queries/ConsecutiveSubWithoutUnSub.java738
-rw-r--r--Domains/github-graph/src-gen/queries/ConsecutiveUnSubWithoutSub.java738
-rw-r--r--Domains/github-graph/src-gen/queries/EventUser.java705
-rw-r--r--Domains/github-graph/src-gen/queries/IsClose.java723
-rw-r--r--Domains/github-graph/src-gen/queries/IsReopen.java723
-rw-r--r--Domains/github-graph/src-gen/queries/IsSubscribe.java840
-rw-r--r--Domains/github-graph/src-gen/queries/IsUnSubscribe.java840
-rw-r--r--Domains/github-graph/src-gen/queries/NoCommitter.java560
-rw-r--r--Domains/github-graph/src-gen/queries/NoUser.java560
46 files changed, 10355 insertions, 5 deletions
diff --git a/Domains/github-graph/bin/queries/.CheckAction.java._trace b/Domains/github-graph/bin/queries/.CheckAction.java._trace
new file mode 100644
index 00000000..fe2295bf
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.CheckAction.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.CheckUserAction.java._trace b/Domains/github-graph/bin/queries/.CheckUserAction.java._trace
new file mode 100644
index 00000000..a050dc45
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.CheckUserAction.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.Committer.java._trace b/Domains/github-graph/bin/queries/.Committer.java._trace
new file mode 100644
index 00000000..763f332c
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.Committer.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.ConsecutiveClosesWithoutReopen.java._trace b/Domains/github-graph/bin/queries/.ConsecutiveClosesWithoutReopen.java._trace
new file mode 100644
index 00000000..ab0463a3
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.ConsecutiveClosesWithoutReopen.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.ConsecutiveReopensWithoutClose.java._trace b/Domains/github-graph/bin/queries/.ConsecutiveReopensWithoutClose.java._trace
new file mode 100644
index 00000000..62ed7508
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.ConsecutiveReopensWithoutClose.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.ConsecutiveSubWithoutUnSub.java._trace b/Domains/github-graph/bin/queries/.ConsecutiveSubWithoutUnSub.java._trace
new file mode 100644
index 00000000..e1bbd189
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.ConsecutiveSubWithoutUnSub.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.ConsecutiveUnSubWithoutSub.java._trace b/Domains/github-graph/bin/queries/.ConsecutiveUnSubWithoutSub.java._trace
new file mode 100644
index 00000000..ebd0a1e3
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.ConsecutiveUnSubWithoutSub.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.EventUser.java._trace b/Domains/github-graph/bin/queries/.EventUser.java._trace
new file mode 100644
index 00000000..0fe22159
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.EventUser.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.IsClose.java._trace b/Domains/github-graph/bin/queries/.IsClose.java._trace
new file mode 100644
index 00000000..c3bb3738
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.IsClose.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.IsReopen.java._trace b/Domains/github-graph/bin/queries/.IsReopen.java._trace
new file mode 100644
index 00000000..592d4d12
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.IsReopen.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.IsSubscribe.java._trace b/Domains/github-graph/bin/queries/.IsSubscribe.java._trace
new file mode 100644
index 00000000..1b8a39fb
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.IsSubscribe.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.IsUnSubscribe.java._trace b/Domains/github-graph/bin/queries/.IsUnSubscribe.java._trace
new file mode 100644
index 00000000..21db9f95
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.IsUnSubscribe.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.NoCommitter.java._trace b/Domains/github-graph/bin/queries/.NoCommitter.java._trace
new file mode 100644
index 00000000..bfc00069
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.NoCommitter.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/.NoUser.java._trace b/Domains/github-graph/bin/queries/.NoUser.java._trace
new file mode 100644
index 00000000..0ecef3e3
--- /dev/null
+++ b/Domains/github-graph/bin/queries/.NoUser.java._trace
Binary files differ
diff --git a/Domains/github-graph/bin/queries/github.vql b/Domains/github-graph/bin/queries/github.vql
index 62853b3f..a8c68f0a 100644
--- a/Domains/github-graph/bin/queries/github.vql
+++ b/Domains/github-graph/bin/queries/github.vql
@@ -6,14 +6,126 @@ pattern directParent(a : Commit, b: Commit) {
6} 6}
7 7
8@Constraint(key={a}, severity="error", message="error") 8@Constraint(key={a}, severity="error", message="error")
9pattern loopInParent(a){ 9pattern loopInParent(a: Commit){
10 find directParent+(a,a); 10 find directParent+(a,a);
11} 11}
12 12
13pattern checkAction(i: Issue, e: IssueEvent, t: Action) {
14 Issue.issueevent(i, e);
15 IssueEvent.action(e, t);
16 a == t;
17}
18
19pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
20 Issue.issueevent(i, e);
21 IssueEvent.user(e, u);
22 IssueEvent.action(e, a);
23 a == t;
24}
25
26pattern isReopen(i: Issue, e: IssueEvent) {
27 Issue.issueevent(i, e);
28 IssueEvent.action(e, a);
29 a == Action::REOPENED;
30}
31
32pattern isClose(i: Issue, e: IssueEvent) {
33 Issue.issueevent(i, e);
34 IssueEvent.action(e, a);
35 a == Action::CLOSED;
36}
37
38pattern isUnSubscribe(i: Issue, u: User, e: IssueEvent) {
39 Issue.issueevent(i, e);
40 IssueEvent.user(e, u);
41 IssueEvent.action(e, a);
42 a == Action::UNSUBSCRIBED;
43}
44
45pattern isSubscribe(i: Issue, u: User, e: IssueEvent) {
46 Issue.issueevent(i, e);
47 IssueEvent.user(e, u);
48 IssueEvent.action(e, a);
49 a == Action::SUBSCRIBED;
50}
51
52
53//pattern pullRequestOfIssue(i: Issue, pr: PullRequest) {
54// Issue.pullrequest(i, pr);
55//}
56//
57//@Constraint(key={i}, severity="error", message="error")
58//pattern mergedIssueWithoutPr(i: Issue){
59// find checkAction(i, _, Action::MERGED);
60// neg find pullRequestOfIssue(i, _);
61//}
62
63@Constraint(key={i}, severity="error", message="error")
64pattern consecutiveClosesWithoutReopen(i: Issue) {
65 find checkAction(i, a1, Action::CLOSED);
66 find checkAction(i, a2, Action::CLOSED);
67 a1 != a2;
68 neg find isReopen(i, _);
69}
70
71
72@Constraint(key={i}, severity="error", message="error")
73pattern consecutiveReopensWithoutClose(i: Issue) {
74 find checkAction(i, a1, Action::REOPENED);
75 find checkAction(i, a2, Action::REOPENED);
76 a1 != a2;
77 neg find isClose(i, _);
78}
79
80@Constraint(key={i, u}, severity="error", message="error")
81pattern consecutiveSubWithoutUnSub(i: Issue, u: User) {
82 find checkUserAction(i, u, a1, Action::SUBSCRIBED);
83 find checkUserAction(i, u, a2, Action::SUBSCRIBED);
84 a1 != a2;
85 neg find isUnSubscribe(i, u, _);
86}
87
88@Constraint(key={i, u}, severity="error", message="error")
89pattern consecutiveUnSubWithoutSub(i: Issue, u: User) {
90 find checkUserAction(i, u, a1, Action::UNSUBSCRIBED);
91 find checkUserAction(i, u, a2, Action::UNSUBSCRIBED);
92 a1 != a2;
93 neg find isSubscribe(i, u, _);
94}
95
96//pattern actionWithIssue(i: IssueEvent, a: Action) {
97// IssueEvent.action(i, a);
98//}
99//
100//@Constraint(key={i}, severity="error", message="error")
101//pattern issueEventNoAction(i: IssueEvent) {
102// neg find actionWithIssue(i, _);
103//}
104
105
106pattern committer(c: Commit, u:User) {
107 Commit.committer(c, u);
108}
109
110pattern eventUser(e: IssueEvent, u:User){
111 IssueEvent.user(e, u);
112}
113
114@Constraint(key={c}, severity="error", message="error")
115pattern noCommitter(c: Commit) {
116 neg find committer(c, _);
117}
118
119@Constraint(key={e}, severity="error", message="error")
120pattern noUser(e: IssueEvent) {
121 neg find eventUser(e, _);
122}
123
124
13 125
14//1. issue with MERGED but no PullRequest 126//1. issue with MERGED but no PullRequest
15//2. issue with 2 CLOSED events without a REOPENED event 127//2. issue with 2 CLOSED events without a REOPENED event
16//3. issue with 2 REOPENED events without a CLOSED event 128//3. issue with 2 REOPENED events without a CLOSED event
17//4. user-issue pair with 2 SUBSCRIBED events without an UNSUBSCRIBED event 129//4. user-issue pair with 2 SUBSCRIBED events without an UNSUBSCRIBED event
18//5. user-issue pair with 2 UNSUBSCRIBED events without a SUBSCRIBED event 130//5. user-issue pair with 2 UNSUBSCRIBED events without a SUBSCRIBED event
19//6. User MERGED/CLOSED/REOPENED issue without being a projectMember of the Project \ No newline at end of file 131//6. User MERGED/CLOSED/REOPENED issue without being a projectMember of the Project (Not possible under this condition) \ No newline at end of file
diff --git a/Domains/github-graph/model/github.ecore b/Domains/github-graph/model/github.ecore
index 012003bc..e3c32df0 100644
--- a/Domains/github-graph/model/github.ecore
+++ b/Domains/github-graph/model/github.ecore
@@ -59,7 +59,8 @@
59 </eClassifiers> 59 </eClassifiers>
60 <eClassifiers xsi:type="ecore:EClass" name="IssueEvent"> 60 <eClassifiers xsi:type="ecore:EClass" name="IssueEvent">
61 <eStructuralFeatures xsi:type="ecore:EReference" name="user" lowerBound="1" eType="#//User"/> 61 <eStructuralFeatures xsi:type="ecore:EReference" name="user" lowerBound="1" eType="#//User"/>
62 <eStructuralFeatures xsi:type="ecore:EAttribute" name="action" eType="#//Action"/> 62 <eStructuralFeatures xsi:type="ecore:EAttribute" name="action" lowerBound="1"
63 eType="#//Action"/>
63 <eStructuralFeatures xsi:type="ecore:EAttribute" name="created_at" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/> 64 <eStructuralFeatures xsi:type="ecore:EAttribute" name="created_at" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
64 <eStructuralFeatures xsi:type="ecore:EAttribute" name="actor_url" lowerBound="1" 65 <eStructuralFeatures xsi:type="ecore:EAttribute" name="actor_url" lowerBound="1"
65 eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> 66 eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
diff --git a/Domains/github-graph/plugin.xml b/Domains/github-graph/plugin.xml
index f207d788..98c96571 100644
--- a/Domains/github-graph/plugin.xml
+++ b/Domains/github-graph/plugin.xml
@@ -8,6 +8,20 @@
8 <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.Github" id="queries.Github"> 8 <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.Github" id="queries.Github">
9 <query-specification fqn="queries.directParent"/> 9 <query-specification fqn="queries.directParent"/>
10 <query-specification fqn="queries.loopInParent"/> 10 <query-specification fqn="queries.loopInParent"/>
11 <query-specification fqn="queries.checkAction"/>
12 <query-specification fqn="queries.checkUserAction"/>
13 <query-specification fqn="queries.isReopen"/>
14 <query-specification fqn="queries.isClose"/>
15 <query-specification fqn="queries.isUnSubscribe"/>
16 <query-specification fqn="queries.isSubscribe"/>
17 <query-specification fqn="queries.consecutiveClosesWithoutReopen"/>
18 <query-specification fqn="queries.consecutiveReopensWithoutClose"/>
19 <query-specification fqn="queries.consecutiveSubWithoutUnSub"/>
20 <query-specification fqn="queries.consecutiveUnSubWithoutSub"/>
21 <query-specification fqn="queries.committer"/>
22 <query-specification fqn="queries.eventUser"/>
23 <query-specification fqn="queries.noCommitter"/>
24 <query-specification fqn="queries.noUser"/>
11 </group> 25 </group>
12 </extension> 26 </extension>
13</plugin> 27</plugin>
diff --git a/Domains/github-graph/queries/queries/github.vql b/Domains/github-graph/queries/queries/github.vql
index 62853b3f..a8c68f0a 100644
--- a/Domains/github-graph/queries/queries/github.vql
+++ b/Domains/github-graph/queries/queries/github.vql
@@ -6,14 +6,126 @@ pattern directParent(a : Commit, b: Commit) {
6} 6}
7 7
8@Constraint(key={a}, severity="error", message="error") 8@Constraint(key={a}, severity="error", message="error")
9pattern loopInParent(a){ 9pattern loopInParent(a: Commit){
10 find directParent+(a,a); 10 find directParent+(a,a);
11} 11}
12 12
13pattern checkAction(i: Issue, e: IssueEvent, t: Action) {
14 Issue.issueevent(i, e);
15 IssueEvent.action(e, t);
16 a == t;
17}
18
19pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
20 Issue.issueevent(i, e);
21 IssueEvent.user(e, u);
22 IssueEvent.action(e, a);
23 a == t;
24}
25
26pattern isReopen(i: Issue, e: IssueEvent) {
27 Issue.issueevent(i, e);
28 IssueEvent.action(e, a);
29 a == Action::REOPENED;
30}
31
32pattern isClose(i: Issue, e: IssueEvent) {
33 Issue.issueevent(i, e);
34 IssueEvent.action(e, a);
35 a == Action::CLOSED;
36}
37
38pattern isUnSubscribe(i: Issue, u: User, e: IssueEvent) {
39 Issue.issueevent(i, e);
40 IssueEvent.user(e, u);
41 IssueEvent.action(e, a);
42 a == Action::UNSUBSCRIBED;
43}
44
45pattern isSubscribe(i: Issue, u: User, e: IssueEvent) {
46 Issue.issueevent(i, e);
47 IssueEvent.user(e, u);
48 IssueEvent.action(e, a);
49 a == Action::SUBSCRIBED;
50}
51
52
53//pattern pullRequestOfIssue(i: Issue, pr: PullRequest) {
54// Issue.pullrequest(i, pr);
55//}
56//
57//@Constraint(key={i}, severity="error", message="error")
58//pattern mergedIssueWithoutPr(i: Issue){
59// find checkAction(i, _, Action::MERGED);
60// neg find pullRequestOfIssue(i, _);
61//}
62
63@Constraint(key={i}, severity="error", message="error")
64pattern consecutiveClosesWithoutReopen(i: Issue) {
65 find checkAction(i, a1, Action::CLOSED);
66 find checkAction(i, a2, Action::CLOSED);
67 a1 != a2;
68 neg find isReopen(i, _);
69}
70
71
72@Constraint(key={i}, severity="error", message="error")
73pattern consecutiveReopensWithoutClose(i: Issue) {
74 find checkAction(i, a1, Action::REOPENED);
75 find checkAction(i, a2, Action::REOPENED);
76 a1 != a2;
77 neg find isClose(i, _);
78}
79
80@Constraint(key={i, u}, severity="error", message="error")
81pattern consecutiveSubWithoutUnSub(i: Issue, u: User) {
82 find checkUserAction(i, u, a1, Action::SUBSCRIBED);
83 find checkUserAction(i, u, a2, Action::SUBSCRIBED);
84 a1 != a2;
85 neg find isUnSubscribe(i, u, _);
86}
87
88@Constraint(key={i, u}, severity="error", message="error")
89pattern consecutiveUnSubWithoutSub(i: Issue, u: User) {
90 find checkUserAction(i, u, a1, Action::UNSUBSCRIBED);
91 find checkUserAction(i, u, a2, Action::UNSUBSCRIBED);
92 a1 != a2;
93 neg find isSubscribe(i, u, _);
94}
95
96//pattern actionWithIssue(i: IssueEvent, a: Action) {
97// IssueEvent.action(i, a);
98//}
99//
100//@Constraint(key={i}, severity="error", message="error")
101//pattern issueEventNoAction(i: IssueEvent) {
102// neg find actionWithIssue(i, _);
103//}
104
105
106pattern committer(c: Commit, u:User) {
107 Commit.committer(c, u);
108}
109
110pattern eventUser(e: IssueEvent, u:User){
111 IssueEvent.user(e, u);
112}
113
114@Constraint(key={c}, severity="error", message="error")
115pattern noCommitter(c: Commit) {
116 neg find committer(c, _);
117}
118
119@Constraint(key={e}, severity="error", message="error")
120pattern noUser(e: IssueEvent) {
121 neg find eventUser(e, _);
122}
123
124
13 125
14//1. issue with MERGED but no PullRequest 126//1. issue with MERGED but no PullRequest
15//2. issue with 2 CLOSED events without a REOPENED event 127//2. issue with 2 CLOSED events without a REOPENED event
16//3. issue with 2 REOPENED events without a CLOSED event 128//3. issue with 2 REOPENED events without a CLOSED event
17//4. user-issue pair with 2 SUBSCRIBED events without an UNSUBSCRIBED event 129//4. user-issue pair with 2 SUBSCRIBED events without an UNSUBSCRIBED event
18//5. user-issue pair with 2 UNSUBSCRIBED events without a SUBSCRIBED event 130//5. user-issue pair with 2 UNSUBSCRIBED events without a SUBSCRIBED event
19//6. User MERGED/CLOSED/REOPENED issue without being a projectMember of the Project \ No newline at end of file 131//6. User MERGED/CLOSED/REOPENED issue without being a projectMember of the Project (Not possible under this condition) \ No newline at end of file
diff --git a/Domains/github-graph/src-gen/queries/.CheckAction.java._trace b/Domains/github-graph/src-gen/queries/.CheckAction.java._trace
new file mode 100644
index 00000000..fe2295bf
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.CheckAction.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.CheckUserAction.java._trace b/Domains/github-graph/src-gen/queries/.CheckUserAction.java._trace
new file mode 100644
index 00000000..a050dc45
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.CheckUserAction.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.Committer.java._trace b/Domains/github-graph/src-gen/queries/.Committer.java._trace
new file mode 100644
index 00000000..763f332c
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.Committer.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.ConsecutiveClosesWithoutReopen.java._trace b/Domains/github-graph/src-gen/queries/.ConsecutiveClosesWithoutReopen.java._trace
new file mode 100644
index 00000000..ab0463a3
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.ConsecutiveClosesWithoutReopen.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.ConsecutiveReopensWithoutClose.java._trace b/Domains/github-graph/src-gen/queries/.ConsecutiveReopensWithoutClose.java._trace
new file mode 100644
index 00000000..62ed7508
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.ConsecutiveReopensWithoutClose.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.ConsecutiveSubWithoutUnSub.java._trace b/Domains/github-graph/src-gen/queries/.ConsecutiveSubWithoutUnSub.java._trace
new file mode 100644
index 00000000..e1bbd189
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.ConsecutiveSubWithoutUnSub.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.ConsecutiveUnSubWithoutSub.java._trace b/Domains/github-graph/src-gen/queries/.ConsecutiveUnSubWithoutSub.java._trace
new file mode 100644
index 00000000..ebd0a1e3
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.ConsecutiveUnSubWithoutSub.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.EventUser.java._trace b/Domains/github-graph/src-gen/queries/.EventUser.java._trace
new file mode 100644
index 00000000..0fe22159
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.EventUser.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.IsClose.java._trace b/Domains/github-graph/src-gen/queries/.IsClose.java._trace
new file mode 100644
index 00000000..c3bb3738
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.IsClose.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.IsReopen.java._trace b/Domains/github-graph/src-gen/queries/.IsReopen.java._trace
new file mode 100644
index 00000000..592d4d12
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.IsReopen.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.IsSubscribe.java._trace b/Domains/github-graph/src-gen/queries/.IsSubscribe.java._trace
new file mode 100644
index 00000000..1b8a39fb
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.IsSubscribe.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.IsUnSubscribe.java._trace b/Domains/github-graph/src-gen/queries/.IsUnSubscribe.java._trace
new file mode 100644
index 00000000..21db9f95
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.IsUnSubscribe.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.NoCommitter.java._trace b/Domains/github-graph/src-gen/queries/.NoCommitter.java._trace
new file mode 100644
index 00000000..bfc00069
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.NoCommitter.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/.NoUser.java._trace b/Domains/github-graph/src-gen/queries/.NoUser.java._trace
new file mode 100644
index 00000000..0ecef3e3
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/.NoUser.java._trace
Binary files differ
diff --git a/Domains/github-graph/src-gen/queries/CheckAction.java b/Domains/github-graph/src-gen/queries/CheckAction.java
new file mode 100644
index 00000000..f3b48a51
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/CheckAction.java
@@ -0,0 +1,829 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Action;
7import github.Issue;
8import github.IssueEvent;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.emf.ecore.EClass;
21import org.eclipse.emf.ecore.EDataType;
22import org.eclipse.viatra.query.runtime.api.IPatternMatch;
23import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
26import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
27import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
28import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
29import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
30import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
31import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
32import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
43import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
44
45/**
46 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
47 *
48 * <p>Original source:
49 * <code><pre>
50 * pattern checkAction(i: Issue, e: IssueEvent, t: Action) {
51 * Issue.issueevent(i, e);
52 * IssueEvent.action(e, t);
53 * a == t;
54 * }
55 * </pre></code>
56 *
57 * @see Matcher
58 * @see Match
59 *
60 */
61@SuppressWarnings("all")
62public final class CheckAction extends BaseGeneratedEMFQuerySpecification<CheckAction.Matcher> {
63 /**
64 * Pattern-specific match representation of the queries.checkAction pattern,
65 * to be used in conjunction with {@link Matcher}.
66 *
67 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
68 * Each instance is a (possibly partial) substitution of pattern parameters,
69 * usable to represent a match of the pattern in the result of a query,
70 * or to specify the bound (fixed) input parameters when issuing a query.
71 *
72 * @see Matcher
73 *
74 */
75 public static abstract class Match extends BasePatternMatch {
76 private Issue fI;
77
78 private IssueEvent fE;
79
80 private Action fT;
81
82 private static List<String> parameterNames = makeImmutableList("i", "e", "t");
83
84 private Match(final Issue pI, final IssueEvent pE, final Action pT) {
85 this.fI = pI;
86 this.fE = pE;
87 this.fT = pT;
88 }
89
90 @Override
91 public Object get(final String parameterName) {
92 switch(parameterName) {
93 case "i": return this.fI;
94 case "e": return this.fE;
95 case "t": return this.fT;
96 default: return null;
97 }
98 }
99
100 @Override
101 public Object get(final int index) {
102 switch(index) {
103 case 0: return this.fI;
104 case 1: return this.fE;
105 case 2: return this.fT;
106 default: return null;
107 }
108 }
109
110 public Issue getI() {
111 return this.fI;
112 }
113
114 public IssueEvent getE() {
115 return this.fE;
116 }
117
118 public Action getT() {
119 return this.fT;
120 }
121
122 @Override
123 public boolean set(final String parameterName, final Object newValue) {
124 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
125 if ("i".equals(parameterName) ) {
126 this.fI = (Issue) newValue;
127 return true;
128 }
129 if ("e".equals(parameterName) ) {
130 this.fE = (IssueEvent) newValue;
131 return true;
132 }
133 if ("t".equals(parameterName) ) {
134 this.fT = (Action) newValue;
135 return true;
136 }
137 return false;
138 }
139
140 public void setI(final Issue pI) {
141 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
142 this.fI = pI;
143 }
144
145 public void setE(final IssueEvent pE) {
146 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
147 this.fE = pE;
148 }
149
150 public void setT(final Action pT) {
151 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
152 this.fT = pT;
153 }
154
155 @Override
156 public String patternName() {
157 return "queries.checkAction";
158 }
159
160 @Override
161 public List<String> parameterNames() {
162 return CheckAction.Match.parameterNames;
163 }
164
165 @Override
166 public Object[] toArray() {
167 return new Object[]{fI, fE, fT};
168 }
169
170 @Override
171 public CheckAction.Match toImmutable() {
172 return isMutable() ? newMatch(fI, fE, fT) : this;
173 }
174
175 @Override
176 public String prettyPrint() {
177 StringBuilder result = new StringBuilder();
178 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
179 result.append("\"e\"=" + prettyPrintValue(fE) + ", ");
180 result.append("\"t\"=" + prettyPrintValue(fT));
181 return result.toString();
182 }
183
184 @Override
185 public int hashCode() {
186 return Objects.hash(fI, fE, fT);
187 }
188
189 @Override
190 public boolean equals(final Object obj) {
191 if (this == obj)
192 return true;
193 if (obj == null) {
194 return false;
195 }
196 if ((obj instanceof CheckAction.Match)) {
197 CheckAction.Match other = (CheckAction.Match) obj;
198 return Objects.equals(fI, other.fI) && Objects.equals(fE, other.fE) && Objects.equals(fT, other.fT);
199 } else {
200 // this should be infrequent
201 if (!(obj instanceof IPatternMatch)) {
202 return false;
203 }
204 IPatternMatch otherSig = (IPatternMatch) obj;
205 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
206 }
207 }
208
209 @Override
210 public CheckAction specification() {
211 return CheckAction.instance();
212 }
213
214 /**
215 * Returns an empty, mutable match.
216 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
217 *
218 * @return the empty match.
219 *
220 */
221 public static CheckAction.Match newEmptyMatch() {
222 return new Mutable(null, null, null);
223 }
224
225 /**
226 * Returns a mutable (partial) match.
227 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
228 *
229 * @param pI the fixed value of pattern parameter i, or null if not bound.
230 * @param pE the fixed value of pattern parameter e, or null if not bound.
231 * @param pT the fixed value of pattern parameter t, or null if not bound.
232 * @return the new, mutable (partial) match object.
233 *
234 */
235 public static CheckAction.Match newMutableMatch(final Issue pI, final IssueEvent pE, final Action pT) {
236 return new Mutable(pI, pE, pT);
237 }
238
239 /**
240 * Returns a new (partial) match.
241 * This can be used e.g. to call the matcher with a partial match.
242 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
243 * @param pI the fixed value of pattern parameter i, or null if not bound.
244 * @param pE the fixed value of pattern parameter e, or null if not bound.
245 * @param pT the fixed value of pattern parameter t, or null if not bound.
246 * @return the (partial) match object.
247 *
248 */
249 public static CheckAction.Match newMatch(final Issue pI, final IssueEvent pE, final Action pT) {
250 return new Immutable(pI, pE, pT);
251 }
252
253 private static final class Mutable extends CheckAction.Match {
254 Mutable(final Issue pI, final IssueEvent pE, final Action pT) {
255 super(pI, pE, pT);
256 }
257
258 @Override
259 public boolean isMutable() {
260 return true;
261 }
262 }
263
264 private static final class Immutable extends CheckAction.Match {
265 Immutable(final Issue pI, final IssueEvent pE, final Action pT) {
266 super(pI, pE, pT);
267 }
268
269 @Override
270 public boolean isMutable() {
271 return false;
272 }
273 }
274 }
275
276 /**
277 * Generated pattern matcher API of the queries.checkAction pattern,
278 * providing pattern-specific query methods.
279 *
280 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
281 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
282 *
283 * <p>Matches of the pattern will be represented as {@link Match}.
284 *
285 * <p>Original source:
286 * <code><pre>
287 * pattern checkAction(i: Issue, e: IssueEvent, t: Action) {
288 * Issue.issueevent(i, e);
289 * IssueEvent.action(e, t);
290 * a == t;
291 * }
292 * </pre></code>
293 *
294 * @see Match
295 * @see CheckAction
296 *
297 */
298 public static class Matcher extends BaseMatcher<CheckAction.Match> {
299 /**
300 * Initializes the pattern matcher within an existing VIATRA Query engine.
301 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
302 *
303 * @param engine the existing VIATRA Query engine in which this matcher will be created.
304 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
305 *
306 */
307 public static CheckAction.Matcher on(final ViatraQueryEngine engine) {
308 // check if matcher already exists
309 Matcher matcher = engine.getExistingMatcher(querySpecification());
310 if (matcher == null) {
311 matcher = (Matcher)engine.getMatcher(querySpecification());
312 }
313 return matcher;
314 }
315
316 /**
317 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
318 * @return an initialized matcher
319 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
320 *
321 */
322 public static CheckAction.Matcher create() {
323 return new Matcher();
324 }
325
326 private static final int POSITION_I = 0;
327
328 private static final int POSITION_E = 1;
329
330 private static final int POSITION_T = 2;
331
332 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CheckAction.Matcher.class);
333
334 /**
335 * Initializes the pattern matcher within an existing VIATRA Query engine.
336 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
337 *
338 * @param engine the existing VIATRA Query engine in which this matcher will be created.
339 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
340 *
341 */
342 private Matcher() {
343 super(querySpecification());
344 }
345
346 /**
347 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
348 * @param pI the fixed value of pattern parameter i, or null if not bound.
349 * @param pE the fixed value of pattern parameter e, or null if not bound.
350 * @param pT the fixed value of pattern parameter t, or null if not bound.
351 * @return matches represented as a Match object.
352 *
353 */
354 public Collection<CheckAction.Match> getAllMatches(final Issue pI, final IssueEvent pE, final Action pT) {
355 return rawStreamAllMatches(new Object[]{pI, pE, pT}).collect(Collectors.toSet());
356 }
357
358 /**
359 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
360 * </p>
361 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
362 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
363 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
364 * @param pI the fixed value of pattern parameter i, or null if not bound.
365 * @param pE the fixed value of pattern parameter e, or null if not bound.
366 * @param pT the fixed value of pattern parameter t, or null if not bound.
367 * @return a stream of matches represented as a Match object.
368 *
369 */
370 public Stream<CheckAction.Match> streamAllMatches(final Issue pI, final IssueEvent pE, final Action pT) {
371 return rawStreamAllMatches(new Object[]{pI, pE, pT});
372 }
373
374 /**
375 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
376 * Neither determinism nor randomness of selection is guaranteed.
377 * @param pI the fixed value of pattern parameter i, or null if not bound.
378 * @param pE the fixed value of pattern parameter e, or null if not bound.
379 * @param pT the fixed value of pattern parameter t, or null if not bound.
380 * @return a match represented as a Match object, or null if no match is found.
381 *
382 */
383 public Optional<CheckAction.Match> getOneArbitraryMatch(final Issue pI, final IssueEvent pE, final Action pT) {
384 return rawGetOneArbitraryMatch(new Object[]{pI, pE, pT});
385 }
386
387 /**
388 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
389 * under any possible substitution of the unspecified parameters (if any).
390 * @param pI the fixed value of pattern parameter i, or null if not bound.
391 * @param pE the fixed value of pattern parameter e, or null if not bound.
392 * @param pT the fixed value of pattern parameter t, or null if not bound.
393 * @return true if the input is a valid (partial) match of the pattern.
394 *
395 */
396 public boolean hasMatch(final Issue pI, final IssueEvent pE, final Action pT) {
397 return rawHasMatch(new Object[]{pI, pE, pT});
398 }
399
400 /**
401 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
402 * @param pI the fixed value of pattern parameter i, or null if not bound.
403 * @param pE the fixed value of pattern parameter e, or null if not bound.
404 * @param pT the fixed value of pattern parameter t, or null if not bound.
405 * @return the number of pattern matches found.
406 *
407 */
408 public int countMatches(final Issue pI, final IssueEvent pE, final Action pT) {
409 return rawCountMatches(new Object[]{pI, pE, pT});
410 }
411
412 /**
413 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
414 * Neither determinism nor randomness of selection is guaranteed.
415 * @param pI the fixed value of pattern parameter i, or null if not bound.
416 * @param pE the fixed value of pattern parameter e, or null if not bound.
417 * @param pT the fixed value of pattern parameter t, or null if not bound.
418 * @param processor the action that will process the selected match.
419 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
420 *
421 */
422 public boolean forOneArbitraryMatch(final Issue pI, final IssueEvent pE, final Action pT, final Consumer<? super CheckAction.Match> processor) {
423 return rawForOneArbitraryMatch(new Object[]{pI, pE, pT}, processor);
424 }
425
426 /**
427 * Returns a new (partial) match.
428 * This can be used e.g. to call the matcher with a partial match.
429 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
430 * @param pI the fixed value of pattern parameter i, or null if not bound.
431 * @param pE the fixed value of pattern parameter e, or null if not bound.
432 * @param pT the fixed value of pattern parameter t, or null if not bound.
433 * @return the (partial) match object.
434 *
435 */
436 public CheckAction.Match newMatch(final Issue pI, final IssueEvent pE, final Action pT) {
437 return CheckAction.Match.newMatch(pI, pE, pT);
438 }
439
440 /**
441 * Retrieve the set of values that occur in matches for i.
442 * @return the Set of all values or empty set if there are no matches
443 *
444 */
445 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
446 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
447 }
448
449 /**
450 * Retrieve the set of values that occur in matches for i.
451 * @return the Set of all values or empty set if there are no matches
452 *
453 */
454 public Set<Issue> getAllValuesOfi() {
455 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
456 }
457
458 /**
459 * Retrieve the set of values that occur in matches for i.
460 * @return the Set of all values or empty set if there are no matches
461 *
462 */
463 public Stream<Issue> streamAllValuesOfi() {
464 return rawStreamAllValuesOfi(emptyArray());
465 }
466
467 /**
468 * Retrieve the set of values that occur in matches for i.
469 * </p>
470 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
471 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
472 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
473 *
474 * @return the Stream of all values or empty set if there are no matches
475 *
476 */
477 public Stream<Issue> streamAllValuesOfi(final CheckAction.Match partialMatch) {
478 return rawStreamAllValuesOfi(partialMatch.toArray());
479 }
480
481 /**
482 * Retrieve the set of values that occur in matches for i.
483 * </p>
484 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
485 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
486 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
487 *
488 * @return the Stream of all values or empty set if there are no matches
489 *
490 */
491 public Stream<Issue> streamAllValuesOfi(final IssueEvent pE, final Action pT) {
492 return rawStreamAllValuesOfi(new Object[]{null, pE, pT});
493 }
494
495 /**
496 * Retrieve the set of values that occur in matches for i.
497 * @return the Set of all values or empty set if there are no matches
498 *
499 */
500 public Set<Issue> getAllValuesOfi(final CheckAction.Match partialMatch) {
501 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
502 }
503
504 /**
505 * Retrieve the set of values that occur in matches for i.
506 * @return the Set of all values or empty set if there are no matches
507 *
508 */
509 public Set<Issue> getAllValuesOfi(final IssueEvent pE, final Action pT) {
510 return rawStreamAllValuesOfi(new Object[]{null, pE, pT}).collect(Collectors.toSet());
511 }
512
513 /**
514 * Retrieve the set of values that occur in matches for e.
515 * @return the Set of all values or empty set if there are no matches
516 *
517 */
518 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
519 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
520 }
521
522 /**
523 * Retrieve the set of values that occur in matches for e.
524 * @return the Set of all values or empty set if there are no matches
525 *
526 */
527 public Set<IssueEvent> getAllValuesOfe() {
528 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
529 }
530
531 /**
532 * Retrieve the set of values that occur in matches for e.
533 * @return the Set of all values or empty set if there are no matches
534 *
535 */
536 public Stream<IssueEvent> streamAllValuesOfe() {
537 return rawStreamAllValuesOfe(emptyArray());
538 }
539
540 /**
541 * Retrieve the set of values that occur in matches for e.
542 * </p>
543 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
544 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
545 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
546 *
547 * @return the Stream of all values or empty set if there are no matches
548 *
549 */
550 public Stream<IssueEvent> streamAllValuesOfe(final CheckAction.Match partialMatch) {
551 return rawStreamAllValuesOfe(partialMatch.toArray());
552 }
553
554 /**
555 * Retrieve the set of values that occur in matches for e.
556 * </p>
557 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
558 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
559 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
560 *
561 * @return the Stream of all values or empty set if there are no matches
562 *
563 */
564 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI, final Action pT) {
565 return rawStreamAllValuesOfe(new Object[]{pI, null, pT});
566 }
567
568 /**
569 * Retrieve the set of values that occur in matches for e.
570 * @return the Set of all values or empty set if there are no matches
571 *
572 */
573 public Set<IssueEvent> getAllValuesOfe(final CheckAction.Match partialMatch) {
574 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
575 }
576
577 /**
578 * Retrieve the set of values that occur in matches for e.
579 * @return the Set of all values or empty set if there are no matches
580 *
581 */
582 public Set<IssueEvent> getAllValuesOfe(final Issue pI, final Action pT) {
583 return rawStreamAllValuesOfe(new Object[]{pI, null, pT}).collect(Collectors.toSet());
584 }
585
586 /**
587 * Retrieve the set of values that occur in matches for t.
588 * @return the Set of all values or empty set if there are no matches
589 *
590 */
591 protected Stream<Action> rawStreamAllValuesOft(final Object[] parameters) {
592 return rawStreamAllValues(POSITION_T, parameters).map(Action.class::cast);
593 }
594
595 /**
596 * Retrieve the set of values that occur in matches for t.
597 * @return the Set of all values or empty set if there are no matches
598 *
599 */
600 public Set<Action> getAllValuesOft() {
601 return rawStreamAllValuesOft(emptyArray()).collect(Collectors.toSet());
602 }
603
604 /**
605 * Retrieve the set of values that occur in matches for t.
606 * @return the Set of all values or empty set if there are no matches
607 *
608 */
609 public Stream<Action> streamAllValuesOft() {
610 return rawStreamAllValuesOft(emptyArray());
611 }
612
613 /**
614 * Retrieve the set of values that occur in matches for t.
615 * </p>
616 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
617 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
618 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
619 *
620 * @return the Stream of all values or empty set if there are no matches
621 *
622 */
623 public Stream<Action> streamAllValuesOft(final CheckAction.Match partialMatch) {
624 return rawStreamAllValuesOft(partialMatch.toArray());
625 }
626
627 /**
628 * Retrieve the set of values that occur in matches for t.
629 * </p>
630 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
631 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
632 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
633 *
634 * @return the Stream of all values or empty set if there are no matches
635 *
636 */
637 public Stream<Action> streamAllValuesOft(final Issue pI, final IssueEvent pE) {
638 return rawStreamAllValuesOft(new Object[]{pI, pE, null});
639 }
640
641 /**
642 * Retrieve the set of values that occur in matches for t.
643 * @return the Set of all values or empty set if there are no matches
644 *
645 */
646 public Set<Action> getAllValuesOft(final CheckAction.Match partialMatch) {
647 return rawStreamAllValuesOft(partialMatch.toArray()).collect(Collectors.toSet());
648 }
649
650 /**
651 * Retrieve the set of values that occur in matches for t.
652 * @return the Set of all values or empty set if there are no matches
653 *
654 */
655 public Set<Action> getAllValuesOft(final Issue pI, final IssueEvent pE) {
656 return rawStreamAllValuesOft(new Object[]{pI, pE, null}).collect(Collectors.toSet());
657 }
658
659 @Override
660 protected CheckAction.Match tupleToMatch(final Tuple t) {
661 try {
662 return CheckAction.Match.newMatch((Issue) t.get(POSITION_I), (IssueEvent) t.get(POSITION_E), (Action) t.get(POSITION_T));
663 } catch(ClassCastException e) {
664 LOGGER.error("Element(s) in tuple not properly typed!",e);
665 return null;
666 }
667 }
668
669 @Override
670 protected CheckAction.Match arrayToMatch(final Object[] match) {
671 try {
672 return CheckAction.Match.newMatch((Issue) match[POSITION_I], (IssueEvent) match[POSITION_E], (Action) match[POSITION_T]);
673 } catch(ClassCastException e) {
674 LOGGER.error("Element(s) in array not properly typed!",e);
675 return null;
676 }
677 }
678
679 @Override
680 protected CheckAction.Match arrayToMatchMutable(final Object[] match) {
681 try {
682 return CheckAction.Match.newMutableMatch((Issue) match[POSITION_I], (IssueEvent) match[POSITION_E], (Action) match[POSITION_T]);
683 } catch(ClassCastException e) {
684 LOGGER.error("Element(s) in array not properly typed!",e);
685 return null;
686 }
687 }
688
689 /**
690 * @return the singleton instance of the query specification of this pattern
691 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
692 *
693 */
694 public static IQuerySpecification<CheckAction.Matcher> querySpecification() {
695 return CheckAction.instance();
696 }
697 }
698
699 private CheckAction() {
700 super(GeneratedPQuery.INSTANCE);
701 }
702
703 /**
704 * @return the singleton instance of the query specification
705 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
706 *
707 */
708 public static CheckAction instance() {
709 try{
710 return LazyHolder.INSTANCE;
711 } catch (ExceptionInInitializerError err) {
712 throw processInitializerError(err);
713 }
714 }
715
716 @Override
717 protected CheckAction.Matcher instantiate(final ViatraQueryEngine engine) {
718 return CheckAction.Matcher.on(engine);
719 }
720
721 @Override
722 public CheckAction.Matcher instantiate() {
723 return CheckAction.Matcher.create();
724 }
725
726 @Override
727 public CheckAction.Match newEmptyMatch() {
728 return CheckAction.Match.newEmptyMatch();
729 }
730
731 @Override
732 public CheckAction.Match newMatch(final Object... parameters) {
733 return CheckAction.Match.newMatch((github.Issue) parameters[0], (github.IssueEvent) parameters[1], (github.Action) parameters[2]);
734 }
735
736 /**
737 * Inner class allowing the singleton instance of {@link CheckAction} to be created
738 * <b>not</b> at the class load time of the outer class,
739 * but rather at the first call to {@link CheckAction#instance()}.
740 *
741 * <p> This workaround is required e.g. to support recursion.
742 *
743 */
744 private static class LazyHolder {
745 private static final CheckAction INSTANCE = new CheckAction();
746
747 /**
748 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
749 * This initialization order is required to support indirect recursion.
750 *
751 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
752 *
753 */
754 private static final Object STATIC_INITIALIZER = ensureInitialized();
755
756 public static Object ensureInitialized() {
757 INSTANCE.ensureInitializedInternal();
758 return null;
759 }
760 }
761
762 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
763 private static final CheckAction.GeneratedPQuery INSTANCE = new GeneratedPQuery();
764
765 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
766
767 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
768
769 private final PParameter parameter_t = new PParameter("t", "github.Action", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("sure.ghtorrent.github", "Action")), PParameterDirection.INOUT);
770
771 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_e, parameter_t);
772
773 private GeneratedPQuery() {
774 super(PVisibility.PUBLIC);
775 }
776
777 @Override
778 public String getFullyQualifiedName() {
779 return "queries.checkAction";
780 }
781
782 @Override
783 public List<String> getParameterNames() {
784 return Arrays.asList("i","e","t");
785 }
786
787 @Override
788 public List<PParameter> getParameters() {
789 return parameters;
790 }
791
792 @Override
793 public Set<PBody> doGetContainedBodies() {
794 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
795 Set<PBody> bodies = new LinkedHashSet<>();
796 {
797 PBody body = new PBody(this);
798 PVariable var_i = body.getOrCreateVariableByName("i");
799 PVariable var_e = body.getOrCreateVariableByName("e");
800 PVariable var_t = body.getOrCreateVariableByName("t");
801 PVariable var_a = body.getOrCreateVariableByName("a");
802 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
803 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
804 new TypeConstraint(body, Tuples.flatTupleOf(var_t), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
805 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
806 new ExportedParameter(body, var_i, parameter_i),
807 new ExportedParameter(body, var_e, parameter_e),
808 new ExportedParameter(body, var_t, parameter_t)
809 ));
810 // Issue.issueevent(i, e)
811 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
812 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
813 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
814 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
815 new Equality(body, var__virtual_0_, var_e);
816 // IssueEvent.action(e, t)
817 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
818 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
819 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
820 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
821 new Equality(body, var__virtual_1_, var_t);
822 // a == t
823 new Equality(body, var_a, var_t);
824 bodies.add(body);
825 }
826 return bodies;
827 }
828 }
829}
diff --git a/Domains/github-graph/src-gen/queries/CheckUserAction.java b/Domains/github-graph/src-gen/queries/CheckUserAction.java
new file mode 100644
index 00000000..d26c0031
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/CheckUserAction.java
@@ -0,0 +1,946 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Action;
7import github.Issue;
8import github.IssueEvent;
9import github.User;
10import java.util.Arrays;
11import java.util.Collection;
12import java.util.LinkedHashSet;
13import java.util.List;
14import java.util.Objects;
15import java.util.Optional;
16import java.util.Set;
17import java.util.function.Consumer;
18import java.util.stream.Collectors;
19import java.util.stream.Stream;
20import org.apache.log4j.Logger;
21import org.eclipse.emf.ecore.EClass;
22import org.eclipse.emf.ecore.EDataType;
23import org.eclipse.viatra.query.runtime.api.IPatternMatch;
24import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
26import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
27import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
28import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
29import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
30import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
31import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
32import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
33import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
35import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45
46/**
47 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
48 *
49 * <p>Original source:
50 * <code><pre>
51 * pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
52 * Issue.issueevent(i, e);
53 * IssueEvent.user(e, u);
54 * IssueEvent.action(e, a);
55 * a == t;
56 * }
57 * </pre></code>
58 *
59 * @see Matcher
60 * @see Match
61 *
62 */
63@SuppressWarnings("all")
64public final class CheckUserAction extends BaseGeneratedEMFQuerySpecification<CheckUserAction.Matcher> {
65 /**
66 * Pattern-specific match representation of the queries.checkUserAction pattern,
67 * to be used in conjunction with {@link Matcher}.
68 *
69 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
70 * Each instance is a (possibly partial) substitution of pattern parameters,
71 * usable to represent a match of the pattern in the result of a query,
72 * or to specify the bound (fixed) input parameters when issuing a query.
73 *
74 * @see Matcher
75 *
76 */
77 public static abstract class Match extends BasePatternMatch {
78 private Issue fI;
79
80 private User fU;
81
82 private IssueEvent fE;
83
84 private Action fT;
85
86 private static List<String> parameterNames = makeImmutableList("i", "u", "e", "t");
87
88 private Match(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
89 this.fI = pI;
90 this.fU = pU;
91 this.fE = pE;
92 this.fT = pT;
93 }
94
95 @Override
96 public Object get(final String parameterName) {
97 switch(parameterName) {
98 case "i": return this.fI;
99 case "u": return this.fU;
100 case "e": return this.fE;
101 case "t": return this.fT;
102 default: return null;
103 }
104 }
105
106 @Override
107 public Object get(final int index) {
108 switch(index) {
109 case 0: return this.fI;
110 case 1: return this.fU;
111 case 2: return this.fE;
112 case 3: return this.fT;
113 default: return null;
114 }
115 }
116
117 public Issue getI() {
118 return this.fI;
119 }
120
121 public User getU() {
122 return this.fU;
123 }
124
125 public IssueEvent getE() {
126 return this.fE;
127 }
128
129 public Action getT() {
130 return this.fT;
131 }
132
133 @Override
134 public boolean set(final String parameterName, final Object newValue) {
135 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
136 if ("i".equals(parameterName) ) {
137 this.fI = (Issue) newValue;
138 return true;
139 }
140 if ("u".equals(parameterName) ) {
141 this.fU = (User) newValue;
142 return true;
143 }
144 if ("e".equals(parameterName) ) {
145 this.fE = (IssueEvent) newValue;
146 return true;
147 }
148 if ("t".equals(parameterName) ) {
149 this.fT = (Action) newValue;
150 return true;
151 }
152 return false;
153 }
154
155 public void setI(final Issue pI) {
156 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
157 this.fI = pI;
158 }
159
160 public void setU(final User pU) {
161 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
162 this.fU = pU;
163 }
164
165 public void setE(final IssueEvent pE) {
166 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
167 this.fE = pE;
168 }
169
170 public void setT(final Action pT) {
171 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
172 this.fT = pT;
173 }
174
175 @Override
176 public String patternName() {
177 return "queries.checkUserAction";
178 }
179
180 @Override
181 public List<String> parameterNames() {
182 return CheckUserAction.Match.parameterNames;
183 }
184
185 @Override
186 public Object[] toArray() {
187 return new Object[]{fI, fU, fE, fT};
188 }
189
190 @Override
191 public CheckUserAction.Match toImmutable() {
192 return isMutable() ? newMatch(fI, fU, fE, fT) : this;
193 }
194
195 @Override
196 public String prettyPrint() {
197 StringBuilder result = new StringBuilder();
198 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
199 result.append("\"u\"=" + prettyPrintValue(fU) + ", ");
200 result.append("\"e\"=" + prettyPrintValue(fE) + ", ");
201 result.append("\"t\"=" + prettyPrintValue(fT));
202 return result.toString();
203 }
204
205 @Override
206 public int hashCode() {
207 return Objects.hash(fI, fU, fE, fT);
208 }
209
210 @Override
211 public boolean equals(final Object obj) {
212 if (this == obj)
213 return true;
214 if (obj == null) {
215 return false;
216 }
217 if ((obj instanceof CheckUserAction.Match)) {
218 CheckUserAction.Match other = (CheckUserAction.Match) obj;
219 return Objects.equals(fI, other.fI) && Objects.equals(fU, other.fU) && Objects.equals(fE, other.fE) && Objects.equals(fT, other.fT);
220 } else {
221 // this should be infrequent
222 if (!(obj instanceof IPatternMatch)) {
223 return false;
224 }
225 IPatternMatch otherSig = (IPatternMatch) obj;
226 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
227 }
228 }
229
230 @Override
231 public CheckUserAction specification() {
232 return CheckUserAction.instance();
233 }
234
235 /**
236 * Returns an empty, mutable match.
237 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
238 *
239 * @return the empty match.
240 *
241 */
242 public static CheckUserAction.Match newEmptyMatch() {
243 return new Mutable(null, null, null, null);
244 }
245
246 /**
247 * Returns a mutable (partial) match.
248 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
249 *
250 * @param pI the fixed value of pattern parameter i, or null if not bound.
251 * @param pU the fixed value of pattern parameter u, or null if not bound.
252 * @param pE the fixed value of pattern parameter e, or null if not bound.
253 * @param pT the fixed value of pattern parameter t, or null if not bound.
254 * @return the new, mutable (partial) match object.
255 *
256 */
257 public static CheckUserAction.Match newMutableMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
258 return new Mutable(pI, pU, pE, pT);
259 }
260
261 /**
262 * Returns a new (partial) match.
263 * This can be used e.g. to call the matcher with a partial match.
264 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
265 * @param pI the fixed value of pattern parameter i, or null if not bound.
266 * @param pU the fixed value of pattern parameter u, or null if not bound.
267 * @param pE the fixed value of pattern parameter e, or null if not bound.
268 * @param pT the fixed value of pattern parameter t, or null if not bound.
269 * @return the (partial) match object.
270 *
271 */
272 public static CheckUserAction.Match newMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
273 return new Immutable(pI, pU, pE, pT);
274 }
275
276 private static final class Mutable extends CheckUserAction.Match {
277 Mutable(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
278 super(pI, pU, pE, pT);
279 }
280
281 @Override
282 public boolean isMutable() {
283 return true;
284 }
285 }
286
287 private static final class Immutable extends CheckUserAction.Match {
288 Immutable(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
289 super(pI, pU, pE, pT);
290 }
291
292 @Override
293 public boolean isMutable() {
294 return false;
295 }
296 }
297 }
298
299 /**
300 * Generated pattern matcher API of the queries.checkUserAction pattern,
301 * providing pattern-specific query methods.
302 *
303 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
304 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
305 *
306 * <p>Matches of the pattern will be represented as {@link Match}.
307 *
308 * <p>Original source:
309 * <code><pre>
310 * pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
311 * Issue.issueevent(i, e);
312 * IssueEvent.user(e, u);
313 * IssueEvent.action(e, a);
314 * a == t;
315 * }
316 * </pre></code>
317 *
318 * @see Match
319 * @see CheckUserAction
320 *
321 */
322 public static class Matcher extends BaseMatcher<CheckUserAction.Match> {
323 /**
324 * Initializes the pattern matcher within an existing VIATRA Query engine.
325 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
326 *
327 * @param engine the existing VIATRA Query engine in which this matcher will be created.
328 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
329 *
330 */
331 public static CheckUserAction.Matcher on(final ViatraQueryEngine engine) {
332 // check if matcher already exists
333 Matcher matcher = engine.getExistingMatcher(querySpecification());
334 if (matcher == null) {
335 matcher = (Matcher)engine.getMatcher(querySpecification());
336 }
337 return matcher;
338 }
339
340 /**
341 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
342 * @return an initialized matcher
343 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
344 *
345 */
346 public static CheckUserAction.Matcher create() {
347 return new Matcher();
348 }
349
350 private static final int POSITION_I = 0;
351
352 private static final int POSITION_U = 1;
353
354 private static final int POSITION_E = 2;
355
356 private static final int POSITION_T = 3;
357
358 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CheckUserAction.Matcher.class);
359
360 /**
361 * Initializes the pattern matcher within an existing VIATRA Query engine.
362 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
363 *
364 * @param engine the existing VIATRA Query engine in which this matcher will be created.
365 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
366 *
367 */
368 private Matcher() {
369 super(querySpecification());
370 }
371
372 /**
373 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
374 * @param pI the fixed value of pattern parameter i, or null if not bound.
375 * @param pU the fixed value of pattern parameter u, or null if not bound.
376 * @param pE the fixed value of pattern parameter e, or null if not bound.
377 * @param pT the fixed value of pattern parameter t, or null if not bound.
378 * @return matches represented as a Match object.
379 *
380 */
381 public Collection<CheckUserAction.Match> getAllMatches(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
382 return rawStreamAllMatches(new Object[]{pI, pU, pE, pT}).collect(Collectors.toSet());
383 }
384
385 /**
386 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
387 * </p>
388 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
389 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
390 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
391 * @param pI the fixed value of pattern parameter i, or null if not bound.
392 * @param pU the fixed value of pattern parameter u, or null if not bound.
393 * @param pE the fixed value of pattern parameter e, or null if not bound.
394 * @param pT the fixed value of pattern parameter t, or null if not bound.
395 * @return a stream of matches represented as a Match object.
396 *
397 */
398 public Stream<CheckUserAction.Match> streamAllMatches(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
399 return rawStreamAllMatches(new Object[]{pI, pU, pE, pT});
400 }
401
402 /**
403 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
404 * Neither determinism nor randomness of selection is guaranteed.
405 * @param pI the fixed value of pattern parameter i, or null if not bound.
406 * @param pU the fixed value of pattern parameter u, or null if not bound.
407 * @param pE the fixed value of pattern parameter e, or null if not bound.
408 * @param pT the fixed value of pattern parameter t, or null if not bound.
409 * @return a match represented as a Match object, or null if no match is found.
410 *
411 */
412 public Optional<CheckUserAction.Match> getOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
413 return rawGetOneArbitraryMatch(new Object[]{pI, pU, pE, pT});
414 }
415
416 /**
417 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
418 * under any possible substitution of the unspecified parameters (if any).
419 * @param pI the fixed value of pattern parameter i, or null if not bound.
420 * @param pU the fixed value of pattern parameter u, or null if not bound.
421 * @param pE the fixed value of pattern parameter e, or null if not bound.
422 * @param pT the fixed value of pattern parameter t, or null if not bound.
423 * @return true if the input is a valid (partial) match of the pattern.
424 *
425 */
426 public boolean hasMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
427 return rawHasMatch(new Object[]{pI, pU, pE, pT});
428 }
429
430 /**
431 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
432 * @param pI the fixed value of pattern parameter i, or null if not bound.
433 * @param pU the fixed value of pattern parameter u, or null if not bound.
434 * @param pE the fixed value of pattern parameter e, or null if not bound.
435 * @param pT the fixed value of pattern parameter t, or null if not bound.
436 * @return the number of pattern matches found.
437 *
438 */
439 public int countMatches(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
440 return rawCountMatches(new Object[]{pI, pU, pE, pT});
441 }
442
443 /**
444 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
445 * Neither determinism nor randomness of selection is guaranteed.
446 * @param pI the fixed value of pattern parameter i, or null if not bound.
447 * @param pU the fixed value of pattern parameter u, or null if not bound.
448 * @param pE the fixed value of pattern parameter e, or null if not bound.
449 * @param pT the fixed value of pattern parameter t, or null if not bound.
450 * @param processor the action that will process the selected match.
451 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
452 *
453 */
454 public boolean forOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT, final Consumer<? super CheckUserAction.Match> processor) {
455 return rawForOneArbitraryMatch(new Object[]{pI, pU, pE, pT}, processor);
456 }
457
458 /**
459 * Returns a new (partial) match.
460 * This can be used e.g. to call the matcher with a partial match.
461 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
462 * @param pI the fixed value of pattern parameter i, or null if not bound.
463 * @param pU the fixed value of pattern parameter u, or null if not bound.
464 * @param pE the fixed value of pattern parameter e, or null if not bound.
465 * @param pT the fixed value of pattern parameter t, or null if not bound.
466 * @return the (partial) match object.
467 *
468 */
469 public CheckUserAction.Match newMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
470 return CheckUserAction.Match.newMatch(pI, pU, pE, pT);
471 }
472
473 /**
474 * Retrieve the set of values that occur in matches for i.
475 * @return the Set of all values or empty set if there are no matches
476 *
477 */
478 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
479 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
480 }
481
482 /**
483 * Retrieve the set of values that occur in matches for i.
484 * @return the Set of all values or empty set if there are no matches
485 *
486 */
487 public Set<Issue> getAllValuesOfi() {
488 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
489 }
490
491 /**
492 * Retrieve the set of values that occur in matches for i.
493 * @return the Set of all values or empty set if there are no matches
494 *
495 */
496 public Stream<Issue> streamAllValuesOfi() {
497 return rawStreamAllValuesOfi(emptyArray());
498 }
499
500 /**
501 * Retrieve the set of values that occur in matches for i.
502 * </p>
503 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
504 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
505 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
506 *
507 * @return the Stream of all values or empty set if there are no matches
508 *
509 */
510 public Stream<Issue> streamAllValuesOfi(final CheckUserAction.Match partialMatch) {
511 return rawStreamAllValuesOfi(partialMatch.toArray());
512 }
513
514 /**
515 * Retrieve the set of values that occur in matches for i.
516 * </p>
517 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
518 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
519 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
520 *
521 * @return the Stream of all values or empty set if there are no matches
522 *
523 */
524 public Stream<Issue> streamAllValuesOfi(final User pU, final IssueEvent pE, final Action pT) {
525 return rawStreamAllValuesOfi(new Object[]{null, pU, pE, pT});
526 }
527
528 /**
529 * Retrieve the set of values that occur in matches for i.
530 * @return the Set of all values or empty set if there are no matches
531 *
532 */
533 public Set<Issue> getAllValuesOfi(final CheckUserAction.Match partialMatch) {
534 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
535 }
536
537 /**
538 * Retrieve the set of values that occur in matches for i.
539 * @return the Set of all values or empty set if there are no matches
540 *
541 */
542 public Set<Issue> getAllValuesOfi(final User pU, final IssueEvent pE, final Action pT) {
543 return rawStreamAllValuesOfi(new Object[]{null, pU, pE, pT}).collect(Collectors.toSet());
544 }
545
546 /**
547 * Retrieve the set of values that occur in matches for u.
548 * @return the Set of all values or empty set if there are no matches
549 *
550 */
551 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
552 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
553 }
554
555 /**
556 * Retrieve the set of values that occur in matches for u.
557 * @return the Set of all values or empty set if there are no matches
558 *
559 */
560 public Set<User> getAllValuesOfu() {
561 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
562 }
563
564 /**
565 * Retrieve the set of values that occur in matches for u.
566 * @return the Set of all values or empty set if there are no matches
567 *
568 */
569 public Stream<User> streamAllValuesOfu() {
570 return rawStreamAllValuesOfu(emptyArray());
571 }
572
573 /**
574 * Retrieve the set of values that occur in matches for u.
575 * </p>
576 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
577 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
578 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
579 *
580 * @return the Stream of all values or empty set if there are no matches
581 *
582 */
583 public Stream<User> streamAllValuesOfu(final CheckUserAction.Match partialMatch) {
584 return rawStreamAllValuesOfu(partialMatch.toArray());
585 }
586
587 /**
588 * Retrieve the set of values that occur in matches for u.
589 * </p>
590 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
591 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
592 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
593 *
594 * @return the Stream of all values or empty set if there are no matches
595 *
596 */
597 public Stream<User> streamAllValuesOfu(final Issue pI, final IssueEvent pE, final Action pT) {
598 return rawStreamAllValuesOfu(new Object[]{pI, null, pE, pT});
599 }
600
601 /**
602 * Retrieve the set of values that occur in matches for u.
603 * @return the Set of all values or empty set if there are no matches
604 *
605 */
606 public Set<User> getAllValuesOfu(final CheckUserAction.Match partialMatch) {
607 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
608 }
609
610 /**
611 * Retrieve the set of values that occur in matches for u.
612 * @return the Set of all values or empty set if there are no matches
613 *
614 */
615 public Set<User> getAllValuesOfu(final Issue pI, final IssueEvent pE, final Action pT) {
616 return rawStreamAllValuesOfu(new Object[]{pI, null, pE, pT}).collect(Collectors.toSet());
617 }
618
619 /**
620 * Retrieve the set of values that occur in matches for e.
621 * @return the Set of all values or empty set if there are no matches
622 *
623 */
624 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
625 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
626 }
627
628 /**
629 * Retrieve the set of values that occur in matches for e.
630 * @return the Set of all values or empty set if there are no matches
631 *
632 */
633 public Set<IssueEvent> getAllValuesOfe() {
634 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
635 }
636
637 /**
638 * Retrieve the set of values that occur in matches for e.
639 * @return the Set of all values or empty set if there are no matches
640 *
641 */
642 public Stream<IssueEvent> streamAllValuesOfe() {
643 return rawStreamAllValuesOfe(emptyArray());
644 }
645
646 /**
647 * Retrieve the set of values that occur in matches for e.
648 * </p>
649 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
650 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
651 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
652 *
653 * @return the Stream of all values or empty set if there are no matches
654 *
655 */
656 public Stream<IssueEvent> streamAllValuesOfe(final CheckUserAction.Match partialMatch) {
657 return rawStreamAllValuesOfe(partialMatch.toArray());
658 }
659
660 /**
661 * Retrieve the set of values that occur in matches for e.
662 * </p>
663 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
664 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
665 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
666 *
667 * @return the Stream of all values or empty set if there are no matches
668 *
669 */
670 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI, final User pU, final Action pT) {
671 return rawStreamAllValuesOfe(new Object[]{pI, pU, null, pT});
672 }
673
674 /**
675 * Retrieve the set of values that occur in matches for e.
676 * @return the Set of all values or empty set if there are no matches
677 *
678 */
679 public Set<IssueEvent> getAllValuesOfe(final CheckUserAction.Match partialMatch) {
680 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
681 }
682
683 /**
684 * Retrieve the set of values that occur in matches for e.
685 * @return the Set of all values or empty set if there are no matches
686 *
687 */
688 public Set<IssueEvent> getAllValuesOfe(final Issue pI, final User pU, final Action pT) {
689 return rawStreamAllValuesOfe(new Object[]{pI, pU, null, pT}).collect(Collectors.toSet());
690 }
691
692 /**
693 * Retrieve the set of values that occur in matches for t.
694 * @return the Set of all values or empty set if there are no matches
695 *
696 */
697 protected Stream<Action> rawStreamAllValuesOft(final Object[] parameters) {
698 return rawStreamAllValues(POSITION_T, parameters).map(Action.class::cast);
699 }
700
701 /**
702 * Retrieve the set of values that occur in matches for t.
703 * @return the Set of all values or empty set if there are no matches
704 *
705 */
706 public Set<Action> getAllValuesOft() {
707 return rawStreamAllValuesOft(emptyArray()).collect(Collectors.toSet());
708 }
709
710 /**
711 * Retrieve the set of values that occur in matches for t.
712 * @return the Set of all values or empty set if there are no matches
713 *
714 */
715 public Stream<Action> streamAllValuesOft() {
716 return rawStreamAllValuesOft(emptyArray());
717 }
718
719 /**
720 * Retrieve the set of values that occur in matches for t.
721 * </p>
722 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
723 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
724 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
725 *
726 * @return the Stream of all values or empty set if there are no matches
727 *
728 */
729 public Stream<Action> streamAllValuesOft(final CheckUserAction.Match partialMatch) {
730 return rawStreamAllValuesOft(partialMatch.toArray());
731 }
732
733 /**
734 * Retrieve the set of values that occur in matches for t.
735 * </p>
736 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
737 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
738 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
739 *
740 * @return the Stream of all values or empty set if there are no matches
741 *
742 */
743 public Stream<Action> streamAllValuesOft(final Issue pI, final User pU, final IssueEvent pE) {
744 return rawStreamAllValuesOft(new Object[]{pI, pU, pE, null});
745 }
746
747 /**
748 * Retrieve the set of values that occur in matches for t.
749 * @return the Set of all values or empty set if there are no matches
750 *
751 */
752 public Set<Action> getAllValuesOft(final CheckUserAction.Match partialMatch) {
753 return rawStreamAllValuesOft(partialMatch.toArray()).collect(Collectors.toSet());
754 }
755
756 /**
757 * Retrieve the set of values that occur in matches for t.
758 * @return the Set of all values or empty set if there are no matches
759 *
760 */
761 public Set<Action> getAllValuesOft(final Issue pI, final User pU, final IssueEvent pE) {
762 return rawStreamAllValuesOft(new Object[]{pI, pU, pE, null}).collect(Collectors.toSet());
763 }
764
765 @Override
766 protected CheckUserAction.Match tupleToMatch(final Tuple t) {
767 try {
768 return CheckUserAction.Match.newMatch((Issue) t.get(POSITION_I), (User) t.get(POSITION_U), (IssueEvent) t.get(POSITION_E), (Action) t.get(POSITION_T));
769 } catch(ClassCastException e) {
770 LOGGER.error("Element(s) in tuple not properly typed!",e);
771 return null;
772 }
773 }
774
775 @Override
776 protected CheckUserAction.Match arrayToMatch(final Object[] match) {
777 try {
778 return CheckUserAction.Match.newMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E], (Action) match[POSITION_T]);
779 } catch(ClassCastException e) {
780 LOGGER.error("Element(s) in array not properly typed!",e);
781 return null;
782 }
783 }
784
785 @Override
786 protected CheckUserAction.Match arrayToMatchMutable(final Object[] match) {
787 try {
788 return CheckUserAction.Match.newMutableMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E], (Action) match[POSITION_T]);
789 } catch(ClassCastException e) {
790 LOGGER.error("Element(s) in array not properly typed!",e);
791 return null;
792 }
793 }
794
795 /**
796 * @return the singleton instance of the query specification of this pattern
797 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
798 *
799 */
800 public static IQuerySpecification<CheckUserAction.Matcher> querySpecification() {
801 return CheckUserAction.instance();
802 }
803 }
804
805 private CheckUserAction() {
806 super(GeneratedPQuery.INSTANCE);
807 }
808
809 /**
810 * @return the singleton instance of the query specification
811 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
812 *
813 */
814 public static CheckUserAction instance() {
815 try{
816 return LazyHolder.INSTANCE;
817 } catch (ExceptionInInitializerError err) {
818 throw processInitializerError(err);
819 }
820 }
821
822 @Override
823 protected CheckUserAction.Matcher instantiate(final ViatraQueryEngine engine) {
824 return CheckUserAction.Matcher.on(engine);
825 }
826
827 @Override
828 public CheckUserAction.Matcher instantiate() {
829 return CheckUserAction.Matcher.create();
830 }
831
832 @Override
833 public CheckUserAction.Match newEmptyMatch() {
834 return CheckUserAction.Match.newEmptyMatch();
835 }
836
837 @Override
838 public CheckUserAction.Match newMatch(final Object... parameters) {
839 return CheckUserAction.Match.newMatch((github.Issue) parameters[0], (github.User) parameters[1], (github.IssueEvent) parameters[2], (github.Action) parameters[3]);
840 }
841
842 /**
843 * Inner class allowing the singleton instance of {@link CheckUserAction} to be created
844 * <b>not</b> at the class load time of the outer class,
845 * but rather at the first call to {@link CheckUserAction#instance()}.
846 *
847 * <p> This workaround is required e.g. to support recursion.
848 *
849 */
850 private static class LazyHolder {
851 private static final CheckUserAction INSTANCE = new CheckUserAction();
852
853 /**
854 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
855 * This initialization order is required to support indirect recursion.
856 *
857 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
858 *
859 */
860 private static final Object STATIC_INITIALIZER = ensureInitialized();
861
862 public static Object ensureInitialized() {
863 INSTANCE.ensureInitializedInternal();
864 return null;
865 }
866 }
867
868 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
869 private static final CheckUserAction.GeneratedPQuery INSTANCE = new GeneratedPQuery();
870
871 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
872
873 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
874
875 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
876
877 private final PParameter parameter_t = new PParameter("t", "github.Action", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("sure.ghtorrent.github", "Action")), PParameterDirection.INOUT);
878
879 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_u, parameter_e, parameter_t);
880
881 private GeneratedPQuery() {
882 super(PVisibility.PUBLIC);
883 }
884
885 @Override
886 public String getFullyQualifiedName() {
887 return "queries.checkUserAction";
888 }
889
890 @Override
891 public List<String> getParameterNames() {
892 return Arrays.asList("i","u","e","t");
893 }
894
895 @Override
896 public List<PParameter> getParameters() {
897 return parameters;
898 }
899
900 @Override
901 public Set<PBody> doGetContainedBodies() {
902 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
903 Set<PBody> bodies = new LinkedHashSet<>();
904 {
905 PBody body = new PBody(this);
906 PVariable var_i = body.getOrCreateVariableByName("i");
907 PVariable var_u = body.getOrCreateVariableByName("u");
908 PVariable var_e = body.getOrCreateVariableByName("e");
909 PVariable var_t = body.getOrCreateVariableByName("t");
910 PVariable var_a = body.getOrCreateVariableByName("a");
911 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
912 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
913 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
914 new TypeConstraint(body, Tuples.flatTupleOf(var_t), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
915 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
916 new ExportedParameter(body, var_i, parameter_i),
917 new ExportedParameter(body, var_u, parameter_u),
918 new ExportedParameter(body, var_e, parameter_e),
919 new ExportedParameter(body, var_t, parameter_t)
920 ));
921 // Issue.issueevent(i, e)
922 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
923 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
924 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
925 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
926 new Equality(body, var__virtual_0_, var_e);
927 // IssueEvent.user(e, u)
928 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
929 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
930 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "user")));
931 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
932 new Equality(body, var__virtual_1_, var_u);
933 // IssueEvent.action(e, a)
934 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
935 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
936 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
937 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
938 new Equality(body, var__virtual_2_, var_a);
939 // a == t
940 new Equality(body, var_a, var_t);
941 bodies.add(body);
942 }
943 return bodies;
944 }
945 }
946}
diff --git a/Domains/github-graph/src-gen/queries/Committer.java b/Domains/github-graph/src-gen/queries/Committer.java
new file mode 100644
index 00000000..1c6b588c
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/Committer.java
@@ -0,0 +1,725 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Commit;
7import github.User;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
40import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
41
42/**
43 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
44 *
45 * <p>Original source:
46 * <code><pre>
47 * //pattern actionWithIssue(i: IssueEvent, a: Action) {
48 * // IssueEvent.action(i, a);
49 * //}
50 * //
51 * //{@literal @}Constraint(key={i}, severity="error", message="error")
52 * //pattern issueEventNoAction(i: IssueEvent) {
53 * // neg find actionWithIssue(i, _);
54 * //}
55 *
56 *
57 * pattern committer(c: Commit, u:User) {
58 * Commit.committer(c, u);
59 * }
60 * </pre></code>
61 *
62 * @see Matcher
63 * @see Match
64 *
65 */
66@SuppressWarnings("all")
67public final class Committer extends BaseGeneratedEMFQuerySpecification<Committer.Matcher> {
68 /**
69 * Pattern-specific match representation of the queries.committer pattern,
70 * to be used in conjunction with {@link Matcher}.
71 *
72 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
73 * Each instance is a (possibly partial) substitution of pattern parameters,
74 * usable to represent a match of the pattern in the result of a query,
75 * or to specify the bound (fixed) input parameters when issuing a query.
76 *
77 * @see Matcher
78 *
79 */
80 public static abstract class Match extends BasePatternMatch {
81 private Commit fC;
82
83 private User fU;
84
85 private static List<String> parameterNames = makeImmutableList("c", "u");
86
87 private Match(final Commit pC, final User pU) {
88 this.fC = pC;
89 this.fU = pU;
90 }
91
92 @Override
93 public Object get(final String parameterName) {
94 switch(parameterName) {
95 case "c": return this.fC;
96 case "u": return this.fU;
97 default: return null;
98 }
99 }
100
101 @Override
102 public Object get(final int index) {
103 switch(index) {
104 case 0: return this.fC;
105 case 1: return this.fU;
106 default: return null;
107 }
108 }
109
110 public Commit getC() {
111 return this.fC;
112 }
113
114 public User getU() {
115 return this.fU;
116 }
117
118 @Override
119 public boolean set(final String parameterName, final Object newValue) {
120 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
121 if ("c".equals(parameterName) ) {
122 this.fC = (Commit) newValue;
123 return true;
124 }
125 if ("u".equals(parameterName) ) {
126 this.fU = (User) newValue;
127 return true;
128 }
129 return false;
130 }
131
132 public void setC(final Commit pC) {
133 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
134 this.fC = pC;
135 }
136
137 public void setU(final User pU) {
138 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
139 this.fU = pU;
140 }
141
142 @Override
143 public String patternName() {
144 return "queries.committer";
145 }
146
147 @Override
148 public List<String> parameterNames() {
149 return Committer.Match.parameterNames;
150 }
151
152 @Override
153 public Object[] toArray() {
154 return new Object[]{fC, fU};
155 }
156
157 @Override
158 public Committer.Match toImmutable() {
159 return isMutable() ? newMatch(fC, fU) : this;
160 }
161
162 @Override
163 public String prettyPrint() {
164 StringBuilder result = new StringBuilder();
165 result.append("\"c\"=" + prettyPrintValue(fC) + ", ");
166 result.append("\"u\"=" + prettyPrintValue(fU));
167 return result.toString();
168 }
169
170 @Override
171 public int hashCode() {
172 return Objects.hash(fC, fU);
173 }
174
175 @Override
176 public boolean equals(final Object obj) {
177 if (this == obj)
178 return true;
179 if (obj == null) {
180 return false;
181 }
182 if ((obj instanceof Committer.Match)) {
183 Committer.Match other = (Committer.Match) obj;
184 return Objects.equals(fC, other.fC) && Objects.equals(fU, other.fU);
185 } else {
186 // this should be infrequent
187 if (!(obj instanceof IPatternMatch)) {
188 return false;
189 }
190 IPatternMatch otherSig = (IPatternMatch) obj;
191 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
192 }
193 }
194
195 @Override
196 public Committer specification() {
197 return Committer.instance();
198 }
199
200 /**
201 * Returns an empty, mutable match.
202 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
203 *
204 * @return the empty match.
205 *
206 */
207 public static Committer.Match newEmptyMatch() {
208 return new Mutable(null, null);
209 }
210
211 /**
212 * Returns a mutable (partial) match.
213 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
214 *
215 * @param pC the fixed value of pattern parameter c, or null if not bound.
216 * @param pU the fixed value of pattern parameter u, or null if not bound.
217 * @return the new, mutable (partial) match object.
218 *
219 */
220 public static Committer.Match newMutableMatch(final Commit pC, final User pU) {
221 return new Mutable(pC, pU);
222 }
223
224 /**
225 * Returns a new (partial) match.
226 * This can be used e.g. to call the matcher with a partial match.
227 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
228 * @param pC the fixed value of pattern parameter c, or null if not bound.
229 * @param pU the fixed value of pattern parameter u, or null if not bound.
230 * @return the (partial) match object.
231 *
232 */
233 public static Committer.Match newMatch(final Commit pC, final User pU) {
234 return new Immutable(pC, pU);
235 }
236
237 private static final class Mutable extends Committer.Match {
238 Mutable(final Commit pC, final User pU) {
239 super(pC, pU);
240 }
241
242 @Override
243 public boolean isMutable() {
244 return true;
245 }
246 }
247
248 private static final class Immutable extends Committer.Match {
249 Immutable(final Commit pC, final User pU) {
250 super(pC, pU);
251 }
252
253 @Override
254 public boolean isMutable() {
255 return false;
256 }
257 }
258 }
259
260 /**
261 * Generated pattern matcher API of the queries.committer pattern,
262 * providing pattern-specific query methods.
263 *
264 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
265 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
266 *
267 * <p>Matches of the pattern will be represented as {@link Match}.
268 *
269 * <p>Original source:
270 * <code><pre>
271 * //pattern actionWithIssue(i: IssueEvent, a: Action) {
272 * // IssueEvent.action(i, a);
273 * //}
274 * //
275 * //{@literal @}Constraint(key={i}, severity="error", message="error")
276 * //pattern issueEventNoAction(i: IssueEvent) {
277 * // neg find actionWithIssue(i, _);
278 * //}
279 *
280 *
281 * pattern committer(c: Commit, u:User) {
282 * Commit.committer(c, u);
283 * }
284 * </pre></code>
285 *
286 * @see Match
287 * @see Committer
288 *
289 */
290 public static class Matcher extends BaseMatcher<Committer.Match> {
291 /**
292 * Initializes the pattern matcher within an existing VIATRA Query engine.
293 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
294 *
295 * @param engine the existing VIATRA Query engine in which this matcher will be created.
296 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
297 *
298 */
299 public static Committer.Matcher on(final ViatraQueryEngine engine) {
300 // check if matcher already exists
301 Matcher matcher = engine.getExistingMatcher(querySpecification());
302 if (matcher == null) {
303 matcher = (Matcher)engine.getMatcher(querySpecification());
304 }
305 return matcher;
306 }
307
308 /**
309 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
310 * @return an initialized matcher
311 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
312 *
313 */
314 public static Committer.Matcher create() {
315 return new Matcher();
316 }
317
318 private static final int POSITION_C = 0;
319
320 private static final int POSITION_U = 1;
321
322 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Committer.Matcher.class);
323
324 /**
325 * Initializes the pattern matcher within an existing VIATRA Query engine.
326 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
327 *
328 * @param engine the existing VIATRA Query engine in which this matcher will be created.
329 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
330 *
331 */
332 private Matcher() {
333 super(querySpecification());
334 }
335
336 /**
337 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
338 * @param pC the fixed value of pattern parameter c, or null if not bound.
339 * @param pU the fixed value of pattern parameter u, or null if not bound.
340 * @return matches represented as a Match object.
341 *
342 */
343 public Collection<Committer.Match> getAllMatches(final Commit pC, final User pU) {
344 return rawStreamAllMatches(new Object[]{pC, pU}).collect(Collectors.toSet());
345 }
346
347 /**
348 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
349 * </p>
350 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
351 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
352 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
353 * @param pC the fixed value of pattern parameter c, or null if not bound.
354 * @param pU the fixed value of pattern parameter u, or null if not bound.
355 * @return a stream of matches represented as a Match object.
356 *
357 */
358 public Stream<Committer.Match> streamAllMatches(final Commit pC, final User pU) {
359 return rawStreamAllMatches(new Object[]{pC, pU});
360 }
361
362 /**
363 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
364 * Neither determinism nor randomness of selection is guaranteed.
365 * @param pC the fixed value of pattern parameter c, or null if not bound.
366 * @param pU the fixed value of pattern parameter u, or null if not bound.
367 * @return a match represented as a Match object, or null if no match is found.
368 *
369 */
370 public Optional<Committer.Match> getOneArbitraryMatch(final Commit pC, final User pU) {
371 return rawGetOneArbitraryMatch(new Object[]{pC, pU});
372 }
373
374 /**
375 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
376 * under any possible substitution of the unspecified parameters (if any).
377 * @param pC the fixed value of pattern parameter c, or null if not bound.
378 * @param pU the fixed value of pattern parameter u, or null if not bound.
379 * @return true if the input is a valid (partial) match of the pattern.
380 *
381 */
382 public boolean hasMatch(final Commit pC, final User pU) {
383 return rawHasMatch(new Object[]{pC, pU});
384 }
385
386 /**
387 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
388 * @param pC the fixed value of pattern parameter c, or null if not bound.
389 * @param pU the fixed value of pattern parameter u, or null if not bound.
390 * @return the number of pattern matches found.
391 *
392 */
393 public int countMatches(final Commit pC, final User pU) {
394 return rawCountMatches(new Object[]{pC, pU});
395 }
396
397 /**
398 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
399 * Neither determinism nor randomness of selection is guaranteed.
400 * @param pC the fixed value of pattern parameter c, or null if not bound.
401 * @param pU the fixed value of pattern parameter u, or null if not bound.
402 * @param processor the action that will process the selected match.
403 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
404 *
405 */
406 public boolean forOneArbitraryMatch(final Commit pC, final User pU, final Consumer<? super Committer.Match> processor) {
407 return rawForOneArbitraryMatch(new Object[]{pC, pU}, processor);
408 }
409
410 /**
411 * Returns a new (partial) match.
412 * This can be used e.g. to call the matcher with a partial match.
413 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
414 * @param pC the fixed value of pattern parameter c, or null if not bound.
415 * @param pU the fixed value of pattern parameter u, or null if not bound.
416 * @return the (partial) match object.
417 *
418 */
419 public Committer.Match newMatch(final Commit pC, final User pU) {
420 return Committer.Match.newMatch(pC, pU);
421 }
422
423 /**
424 * Retrieve the set of values that occur in matches for c.
425 * @return the Set of all values or empty set if there are no matches
426 *
427 */
428 protected Stream<Commit> rawStreamAllValuesOfc(final Object[] parameters) {
429 return rawStreamAllValues(POSITION_C, parameters).map(Commit.class::cast);
430 }
431
432 /**
433 * Retrieve the set of values that occur in matches for c.
434 * @return the Set of all values or empty set if there are no matches
435 *
436 */
437 public Set<Commit> getAllValuesOfc() {
438 return rawStreamAllValuesOfc(emptyArray()).collect(Collectors.toSet());
439 }
440
441 /**
442 * Retrieve the set of values that occur in matches for c.
443 * @return the Set of all values or empty set if there are no matches
444 *
445 */
446 public Stream<Commit> streamAllValuesOfc() {
447 return rawStreamAllValuesOfc(emptyArray());
448 }
449
450 /**
451 * Retrieve the set of values that occur in matches for c.
452 * </p>
453 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
454 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
455 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
456 *
457 * @return the Stream of all values or empty set if there are no matches
458 *
459 */
460 public Stream<Commit> streamAllValuesOfc(final Committer.Match partialMatch) {
461 return rawStreamAllValuesOfc(partialMatch.toArray());
462 }
463
464 /**
465 * Retrieve the set of values that occur in matches for c.
466 * </p>
467 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
468 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
469 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
470 *
471 * @return the Stream of all values or empty set if there are no matches
472 *
473 */
474 public Stream<Commit> streamAllValuesOfc(final User pU) {
475 return rawStreamAllValuesOfc(new Object[]{null, pU});
476 }
477
478 /**
479 * Retrieve the set of values that occur in matches for c.
480 * @return the Set of all values or empty set if there are no matches
481 *
482 */
483 public Set<Commit> getAllValuesOfc(final Committer.Match partialMatch) {
484 return rawStreamAllValuesOfc(partialMatch.toArray()).collect(Collectors.toSet());
485 }
486
487 /**
488 * Retrieve the set of values that occur in matches for c.
489 * @return the Set of all values or empty set if there are no matches
490 *
491 */
492 public Set<Commit> getAllValuesOfc(final User pU) {
493 return rawStreamAllValuesOfc(new Object[]{null, pU}).collect(Collectors.toSet());
494 }
495
496 /**
497 * Retrieve the set of values that occur in matches for u.
498 * @return the Set of all values or empty set if there are no matches
499 *
500 */
501 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
502 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
503 }
504
505 /**
506 * Retrieve the set of values that occur in matches for u.
507 * @return the Set of all values or empty set if there are no matches
508 *
509 */
510 public Set<User> getAllValuesOfu() {
511 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
512 }
513
514 /**
515 * Retrieve the set of values that occur in matches for u.
516 * @return the Set of all values or empty set if there are no matches
517 *
518 */
519 public Stream<User> streamAllValuesOfu() {
520 return rawStreamAllValuesOfu(emptyArray());
521 }
522
523 /**
524 * Retrieve the set of values that occur in matches for u.
525 * </p>
526 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
527 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
528 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
529 *
530 * @return the Stream of all values or empty set if there are no matches
531 *
532 */
533 public Stream<User> streamAllValuesOfu(final Committer.Match partialMatch) {
534 return rawStreamAllValuesOfu(partialMatch.toArray());
535 }
536
537 /**
538 * Retrieve the set of values that occur in matches for u.
539 * </p>
540 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
541 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
542 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
543 *
544 * @return the Stream of all values or empty set if there are no matches
545 *
546 */
547 public Stream<User> streamAllValuesOfu(final Commit pC) {
548 return rawStreamAllValuesOfu(new Object[]{pC, null});
549 }
550
551 /**
552 * Retrieve the set of values that occur in matches for u.
553 * @return the Set of all values or empty set if there are no matches
554 *
555 */
556 public Set<User> getAllValuesOfu(final Committer.Match partialMatch) {
557 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
558 }
559
560 /**
561 * Retrieve the set of values that occur in matches for u.
562 * @return the Set of all values or empty set if there are no matches
563 *
564 */
565 public Set<User> getAllValuesOfu(final Commit pC) {
566 return rawStreamAllValuesOfu(new Object[]{pC, null}).collect(Collectors.toSet());
567 }
568
569 @Override
570 protected Committer.Match tupleToMatch(final Tuple t) {
571 try {
572 return Committer.Match.newMatch((Commit) t.get(POSITION_C), (User) t.get(POSITION_U));
573 } catch(ClassCastException e) {
574 LOGGER.error("Element(s) in tuple not properly typed!",e);
575 return null;
576 }
577 }
578
579 @Override
580 protected Committer.Match arrayToMatch(final Object[] match) {
581 try {
582 return Committer.Match.newMatch((Commit) match[POSITION_C], (User) match[POSITION_U]);
583 } catch(ClassCastException e) {
584 LOGGER.error("Element(s) in array not properly typed!",e);
585 return null;
586 }
587 }
588
589 @Override
590 protected Committer.Match arrayToMatchMutable(final Object[] match) {
591 try {
592 return Committer.Match.newMutableMatch((Commit) match[POSITION_C], (User) match[POSITION_U]);
593 } catch(ClassCastException e) {
594 LOGGER.error("Element(s) in array not properly typed!",e);
595 return null;
596 }
597 }
598
599 /**
600 * @return the singleton instance of the query specification of this pattern
601 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
602 *
603 */
604 public static IQuerySpecification<Committer.Matcher> querySpecification() {
605 return Committer.instance();
606 }
607 }
608
609 private Committer() {
610 super(GeneratedPQuery.INSTANCE);
611 }
612
613 /**
614 * @return the singleton instance of the query specification
615 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
616 *
617 */
618 public static Committer instance() {
619 try{
620 return LazyHolder.INSTANCE;
621 } catch (ExceptionInInitializerError err) {
622 throw processInitializerError(err);
623 }
624 }
625
626 @Override
627 protected Committer.Matcher instantiate(final ViatraQueryEngine engine) {
628 return Committer.Matcher.on(engine);
629 }
630
631 @Override
632 public Committer.Matcher instantiate() {
633 return Committer.Matcher.create();
634 }
635
636 @Override
637 public Committer.Match newEmptyMatch() {
638 return Committer.Match.newEmptyMatch();
639 }
640
641 @Override
642 public Committer.Match newMatch(final Object... parameters) {
643 return Committer.Match.newMatch((github.Commit) parameters[0], (github.User) parameters[1]);
644 }
645
646 /**
647 * Inner class allowing the singleton instance of {@link Committer} to be created
648 * <b>not</b> at the class load time of the outer class,
649 * but rather at the first call to {@link Committer#instance()}.
650 *
651 * <p> This workaround is required e.g. to support recursion.
652 *
653 */
654 private static class LazyHolder {
655 private static final Committer INSTANCE = new Committer();
656
657 /**
658 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
659 * This initialization order is required to support indirect recursion.
660 *
661 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
662 *
663 */
664 private static final Object STATIC_INITIALIZER = ensureInitialized();
665
666 public static Object ensureInitialized() {
667 INSTANCE.ensureInitializedInternal();
668 return null;
669 }
670 }
671
672 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
673 private static final Committer.GeneratedPQuery INSTANCE = new GeneratedPQuery();
674
675 private final PParameter parameter_c = new PParameter("c", "github.Commit", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Commit")), PParameterDirection.INOUT);
676
677 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
678
679 private final List<PParameter> parameters = Arrays.asList(parameter_c, parameter_u);
680
681 private GeneratedPQuery() {
682 super(PVisibility.PUBLIC);
683 }
684
685 @Override
686 public String getFullyQualifiedName() {
687 return "queries.committer";
688 }
689
690 @Override
691 public List<String> getParameterNames() {
692 return Arrays.asList("c","u");
693 }
694
695 @Override
696 public List<PParameter> getParameters() {
697 return parameters;
698 }
699
700 @Override
701 public Set<PBody> doGetContainedBodies() {
702 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
703 Set<PBody> bodies = new LinkedHashSet<>();
704 {
705 PBody body = new PBody(this);
706 PVariable var_c = body.getOrCreateVariableByName("c");
707 PVariable var_u = body.getOrCreateVariableByName("u");
708 new TypeConstraint(body, Tuples.flatTupleOf(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Commit")));
709 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
710 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
711 new ExportedParameter(body, var_c, parameter_c),
712 new ExportedParameter(body, var_u, parameter_u)
713 ));
714 // Commit.committer(c, u)
715 new TypeConstraint(body, Tuples.flatTupleOf(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Commit")));
716 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
717 new TypeConstraint(body, Tuples.flatTupleOf(var_c, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Commit", "committer")));
718 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
719 new Equality(body, var__virtual_0_, var_u);
720 bodies.add(body);
721 }
722 return bodies;
723 }
724 }
725}
diff --git a/Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java b/Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java
new file mode 100644
index 00000000..9072feaf
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java
@@ -0,0 +1,602 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
43import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
44import queries.CheckAction;
45import queries.IsReopen;
46
47/**
48 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
49 *
50 * <p>Original source:
51 * <code><pre>
52 * //pattern pullRequestOfIssue(i: Issue, pr: PullRequest) {
53 * // Issue.pullrequest(i, pr);
54 * //}
55 * //
56 * //{@literal @}Constraint(key={i}, severity="error", message="error")
57 * //pattern mergedIssueWithoutPr(i: Issue){
58 * // find checkAction(i, _, Action::MERGED);
59 * // neg find pullRequestOfIssue(i, _);
60 * //}
61 *
62 * {@literal @}Constraint(key={i}, severity="error", message="error")
63 * pattern consecutiveClosesWithoutReopen(i: Issue) {
64 * find checkAction(i, a1, Action::CLOSED);
65 * find checkAction(i, a2, Action::CLOSED);
66 * a1 != a2;
67 * neg find isReopen(i, _);
68 * }
69 * </pre></code>
70 *
71 * @see Matcher
72 * @see Match
73 *
74 */
75@SuppressWarnings("all")
76public final class ConsecutiveClosesWithoutReopen extends BaseGeneratedEMFQuerySpecification<ConsecutiveClosesWithoutReopen.Matcher> {
77 /**
78 * Pattern-specific match representation of the queries.consecutiveClosesWithoutReopen pattern,
79 * to be used in conjunction with {@link Matcher}.
80 *
81 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
82 * Each instance is a (possibly partial) substitution of pattern parameters,
83 * usable to represent a match of the pattern in the result of a query,
84 * or to specify the bound (fixed) input parameters when issuing a query.
85 *
86 * @see Matcher
87 *
88 */
89 public static abstract class Match extends BasePatternMatch {
90 private Issue fI;
91
92 private static List<String> parameterNames = makeImmutableList("i");
93
94 private Match(final Issue pI) {
95 this.fI = pI;
96 }
97
98 @Override
99 public Object get(final String parameterName) {
100 switch(parameterName) {
101 case "i": return this.fI;
102 default: return null;
103 }
104 }
105
106 @Override
107 public Object get(final int index) {
108 switch(index) {
109 case 0: return this.fI;
110 default: return null;
111 }
112 }
113
114 public Issue getI() {
115 return this.fI;
116 }
117
118 @Override
119 public boolean set(final String parameterName, final Object newValue) {
120 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
121 if ("i".equals(parameterName) ) {
122 this.fI = (Issue) newValue;
123 return true;
124 }
125 return false;
126 }
127
128 public void setI(final Issue pI) {
129 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
130 this.fI = pI;
131 }
132
133 @Override
134 public String patternName() {
135 return "queries.consecutiveClosesWithoutReopen";
136 }
137
138 @Override
139 public List<String> parameterNames() {
140 return ConsecutiveClosesWithoutReopen.Match.parameterNames;
141 }
142
143 @Override
144 public Object[] toArray() {
145 return new Object[]{fI};
146 }
147
148 @Override
149 public ConsecutiveClosesWithoutReopen.Match toImmutable() {
150 return isMutable() ? newMatch(fI) : this;
151 }
152
153 @Override
154 public String prettyPrint() {
155 StringBuilder result = new StringBuilder();
156 result.append("\"i\"=" + prettyPrintValue(fI));
157 return result.toString();
158 }
159
160 @Override
161 public int hashCode() {
162 return Objects.hash(fI);
163 }
164
165 @Override
166 public boolean equals(final Object obj) {
167 if (this == obj)
168 return true;
169 if (obj == null) {
170 return false;
171 }
172 if ((obj instanceof ConsecutiveClosesWithoutReopen.Match)) {
173 ConsecutiveClosesWithoutReopen.Match other = (ConsecutiveClosesWithoutReopen.Match) obj;
174 return Objects.equals(fI, other.fI);
175 } else {
176 // this should be infrequent
177 if (!(obj instanceof IPatternMatch)) {
178 return false;
179 }
180 IPatternMatch otherSig = (IPatternMatch) obj;
181 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
182 }
183 }
184
185 @Override
186 public ConsecutiveClosesWithoutReopen specification() {
187 return ConsecutiveClosesWithoutReopen.instance();
188 }
189
190 /**
191 * Returns an empty, mutable match.
192 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
193 *
194 * @return the empty match.
195 *
196 */
197 public static ConsecutiveClosesWithoutReopen.Match newEmptyMatch() {
198 return new Mutable(null);
199 }
200
201 /**
202 * Returns a mutable (partial) match.
203 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
204 *
205 * @param pI the fixed value of pattern parameter i, or null if not bound.
206 * @return the new, mutable (partial) match object.
207 *
208 */
209 public static ConsecutiveClosesWithoutReopen.Match newMutableMatch(final Issue pI) {
210 return new Mutable(pI);
211 }
212
213 /**
214 * Returns a new (partial) match.
215 * This can be used e.g. to call the matcher with a partial match.
216 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
217 * @param pI the fixed value of pattern parameter i, or null if not bound.
218 * @return the (partial) match object.
219 *
220 */
221 public static ConsecutiveClosesWithoutReopen.Match newMatch(final Issue pI) {
222 return new Immutable(pI);
223 }
224
225 private static final class Mutable extends ConsecutiveClosesWithoutReopen.Match {
226 Mutable(final Issue pI) {
227 super(pI);
228 }
229
230 @Override
231 public boolean isMutable() {
232 return true;
233 }
234 }
235
236 private static final class Immutable extends ConsecutiveClosesWithoutReopen.Match {
237 Immutable(final Issue pI) {
238 super(pI);
239 }
240
241 @Override
242 public boolean isMutable() {
243 return false;
244 }
245 }
246 }
247
248 /**
249 * Generated pattern matcher API of the queries.consecutiveClosesWithoutReopen pattern,
250 * providing pattern-specific query methods.
251 *
252 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
253 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
254 *
255 * <p>Matches of the pattern will be represented as {@link Match}.
256 *
257 * <p>Original source:
258 * <code><pre>
259 * //pattern pullRequestOfIssue(i: Issue, pr: PullRequest) {
260 * // Issue.pullrequest(i, pr);
261 * //}
262 * //
263 * //{@literal @}Constraint(key={i}, severity="error", message="error")
264 * //pattern mergedIssueWithoutPr(i: Issue){
265 * // find checkAction(i, _, Action::MERGED);
266 * // neg find pullRequestOfIssue(i, _);
267 * //}
268 *
269 * {@literal @}Constraint(key={i}, severity="error", message="error")
270 * pattern consecutiveClosesWithoutReopen(i: Issue) {
271 * find checkAction(i, a1, Action::CLOSED);
272 * find checkAction(i, a2, Action::CLOSED);
273 * a1 != a2;
274 * neg find isReopen(i, _);
275 * }
276 * </pre></code>
277 *
278 * @see Match
279 * @see ConsecutiveClosesWithoutReopen
280 *
281 */
282 public static class Matcher extends BaseMatcher<ConsecutiveClosesWithoutReopen.Match> {
283 /**
284 * Initializes the pattern matcher within an existing VIATRA Query engine.
285 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
286 *
287 * @param engine the existing VIATRA Query engine in which this matcher will be created.
288 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
289 *
290 */
291 public static ConsecutiveClosesWithoutReopen.Matcher on(final ViatraQueryEngine engine) {
292 // check if matcher already exists
293 Matcher matcher = engine.getExistingMatcher(querySpecification());
294 if (matcher == null) {
295 matcher = (Matcher)engine.getMatcher(querySpecification());
296 }
297 return matcher;
298 }
299
300 /**
301 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
302 * @return an initialized matcher
303 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
304 *
305 */
306 public static ConsecutiveClosesWithoutReopen.Matcher create() {
307 return new Matcher();
308 }
309
310 private static final int POSITION_I = 0;
311
312 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConsecutiveClosesWithoutReopen.Matcher.class);
313
314 /**
315 * Initializes the pattern matcher within an existing VIATRA Query engine.
316 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
317 *
318 * @param engine the existing VIATRA Query engine in which this matcher will be created.
319 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
320 *
321 */
322 private Matcher() {
323 super(querySpecification());
324 }
325
326 /**
327 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
328 * @param pI the fixed value of pattern parameter i, or null if not bound.
329 * @return matches represented as a Match object.
330 *
331 */
332 public Collection<ConsecutiveClosesWithoutReopen.Match> getAllMatches(final Issue pI) {
333 return rawStreamAllMatches(new Object[]{pI}).collect(Collectors.toSet());
334 }
335
336 /**
337 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
338 * </p>
339 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
340 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
341 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
342 * @param pI the fixed value of pattern parameter i, or null if not bound.
343 * @return a stream of matches represented as a Match object.
344 *
345 */
346 public Stream<ConsecutiveClosesWithoutReopen.Match> streamAllMatches(final Issue pI) {
347 return rawStreamAllMatches(new Object[]{pI});
348 }
349
350 /**
351 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
352 * Neither determinism nor randomness of selection is guaranteed.
353 * @param pI the fixed value of pattern parameter i, or null if not bound.
354 * @return a match represented as a Match object, or null if no match is found.
355 *
356 */
357 public Optional<ConsecutiveClosesWithoutReopen.Match> getOneArbitraryMatch(final Issue pI) {
358 return rawGetOneArbitraryMatch(new Object[]{pI});
359 }
360
361 /**
362 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
363 * under any possible substitution of the unspecified parameters (if any).
364 * @param pI the fixed value of pattern parameter i, or null if not bound.
365 * @return true if the input is a valid (partial) match of the pattern.
366 *
367 */
368 public boolean hasMatch(final Issue pI) {
369 return rawHasMatch(new Object[]{pI});
370 }
371
372 /**
373 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
374 * @param pI the fixed value of pattern parameter i, or null if not bound.
375 * @return the number of pattern matches found.
376 *
377 */
378 public int countMatches(final Issue pI) {
379 return rawCountMatches(new Object[]{pI});
380 }
381
382 /**
383 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
384 * Neither determinism nor randomness of selection is guaranteed.
385 * @param pI the fixed value of pattern parameter i, or null if not bound.
386 * @param processor the action that will process the selected match.
387 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
388 *
389 */
390 public boolean forOneArbitraryMatch(final Issue pI, final Consumer<? super ConsecutiveClosesWithoutReopen.Match> processor) {
391 return rawForOneArbitraryMatch(new Object[]{pI}, processor);
392 }
393
394 /**
395 * Returns a new (partial) match.
396 * This can be used e.g. to call the matcher with a partial match.
397 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
398 * @param pI the fixed value of pattern parameter i, or null if not bound.
399 * @return the (partial) match object.
400 *
401 */
402 public ConsecutiveClosesWithoutReopen.Match newMatch(final Issue pI) {
403 return ConsecutiveClosesWithoutReopen.Match.newMatch(pI);
404 }
405
406 /**
407 * Retrieve the set of values that occur in matches for i.
408 * @return the Set of all values or empty set if there are no matches
409 *
410 */
411 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
412 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
413 }
414
415 /**
416 * Retrieve the set of values that occur in matches for i.
417 * @return the Set of all values or empty set if there are no matches
418 *
419 */
420 public Set<Issue> getAllValuesOfi() {
421 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
422 }
423
424 /**
425 * Retrieve the set of values that occur in matches for i.
426 * @return the Set of all values or empty set if there are no matches
427 *
428 */
429 public Stream<Issue> streamAllValuesOfi() {
430 return rawStreamAllValuesOfi(emptyArray());
431 }
432
433 @Override
434 protected ConsecutiveClosesWithoutReopen.Match tupleToMatch(final Tuple t) {
435 try {
436 return ConsecutiveClosesWithoutReopen.Match.newMatch((Issue) t.get(POSITION_I));
437 } catch(ClassCastException e) {
438 LOGGER.error("Element(s) in tuple not properly typed!",e);
439 return null;
440 }
441 }
442
443 @Override
444 protected ConsecutiveClosesWithoutReopen.Match arrayToMatch(final Object[] match) {
445 try {
446 return ConsecutiveClosesWithoutReopen.Match.newMatch((Issue) match[POSITION_I]);
447 } catch(ClassCastException e) {
448 LOGGER.error("Element(s) in array not properly typed!",e);
449 return null;
450 }
451 }
452
453 @Override
454 protected ConsecutiveClosesWithoutReopen.Match arrayToMatchMutable(final Object[] match) {
455 try {
456 return ConsecutiveClosesWithoutReopen.Match.newMutableMatch((Issue) match[POSITION_I]);
457 } catch(ClassCastException e) {
458 LOGGER.error("Element(s) in array not properly typed!",e);
459 return null;
460 }
461 }
462
463 /**
464 * @return the singleton instance of the query specification of this pattern
465 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
466 *
467 */
468 public static IQuerySpecification<ConsecutiveClosesWithoutReopen.Matcher> querySpecification() {
469 return ConsecutiveClosesWithoutReopen.instance();
470 }
471 }
472
473 private ConsecutiveClosesWithoutReopen() {
474 super(GeneratedPQuery.INSTANCE);
475 }
476
477 /**
478 * @return the singleton instance of the query specification
479 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
480 *
481 */
482 public static ConsecutiveClosesWithoutReopen instance() {
483 try{
484 return LazyHolder.INSTANCE;
485 } catch (ExceptionInInitializerError err) {
486 throw processInitializerError(err);
487 }
488 }
489
490 @Override
491 protected ConsecutiveClosesWithoutReopen.Matcher instantiate(final ViatraQueryEngine engine) {
492 return ConsecutiveClosesWithoutReopen.Matcher.on(engine);
493 }
494
495 @Override
496 public ConsecutiveClosesWithoutReopen.Matcher instantiate() {
497 return ConsecutiveClosesWithoutReopen.Matcher.create();
498 }
499
500 @Override
501 public ConsecutiveClosesWithoutReopen.Match newEmptyMatch() {
502 return ConsecutiveClosesWithoutReopen.Match.newEmptyMatch();
503 }
504
505 @Override
506 public ConsecutiveClosesWithoutReopen.Match newMatch(final Object... parameters) {
507 return ConsecutiveClosesWithoutReopen.Match.newMatch((github.Issue) parameters[0]);
508 }
509
510 /**
511 * Inner class allowing the singleton instance of {@link ConsecutiveClosesWithoutReopen} to be created
512 * <b>not</b> at the class load time of the outer class,
513 * but rather at the first call to {@link ConsecutiveClosesWithoutReopen#instance()}.
514 *
515 * <p> This workaround is required e.g. to support recursion.
516 *
517 */
518 private static class LazyHolder {
519 private static final ConsecutiveClosesWithoutReopen INSTANCE = new ConsecutiveClosesWithoutReopen();
520
521 /**
522 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
523 * This initialization order is required to support indirect recursion.
524 *
525 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
526 *
527 */
528 private static final Object STATIC_INITIALIZER = ensureInitialized();
529
530 public static Object ensureInitialized() {
531 INSTANCE.ensureInitializedInternal();
532 return null;
533 }
534 }
535
536 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
537 private static final ConsecutiveClosesWithoutReopen.GeneratedPQuery INSTANCE = new GeneratedPQuery();
538
539 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
540
541 private final List<PParameter> parameters = Arrays.asList(parameter_i);
542
543 private GeneratedPQuery() {
544 super(PVisibility.PUBLIC);
545 }
546
547 @Override
548 public String getFullyQualifiedName() {
549 return "queries.consecutiveClosesWithoutReopen";
550 }
551
552 @Override
553 public List<String> getParameterNames() {
554 return Arrays.asList("i");
555 }
556
557 @Override
558 public List<PParameter> getParameters() {
559 return parameters;
560 }
561
562 @Override
563 public Set<PBody> doGetContainedBodies() {
564 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
565 Set<PBody> bodies = new LinkedHashSet<>();
566 {
567 PBody body = new PBody(this);
568 PVariable var_i = body.getOrCreateVariableByName("i");
569 PVariable var_a1 = body.getOrCreateVariableByName("a1");
570 PVariable var_a2 = body.getOrCreateVariableByName("a2");
571 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
572 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
573 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
574 new ExportedParameter(body, var_i, parameter_i)
575 ));
576 // find checkAction(i, a1, Action::CLOSED)
577 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
578 new ConstantValue(body, var__virtual_0_, getEnumLiteral("sure.ghtorrent.github", "Action", "CLOSED").getInstance());
579 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_a1, var__virtual_0_), CheckAction.instance().getInternalQueryRepresentation());
580 // find checkAction(i, a2, Action::CLOSED)
581 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
582 new ConstantValue(body, var__virtual_1_, getEnumLiteral("sure.ghtorrent.github", "Action", "CLOSED").getInstance());
583 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_a2, var__virtual_1_), CheckAction.instance().getInternalQueryRepresentation());
584 // a1 != a2
585 new Inequality(body, var_a1, var_a2);
586 // neg find isReopen(i, _)
587 new NegativePatternCall(body, Tuples.flatTupleOf(var_i, var___0_), IsReopen.instance().getInternalQueryRepresentation());
588 bodies.add(body);
589 }
590 {
591 PAnnotation annotation = new PAnnotation("Constraint");
592 annotation.addAttribute("key", Arrays.asList(new Object[] {
593 new ParameterReference("i")
594 }));
595 annotation.addAttribute("severity", "error");
596 annotation.addAttribute("message", "error");
597 addAnnotation(annotation);
598 }
599 return bodies;
600 }
601 }
602}
diff --git a/Domains/github-graph/src-gen/queries/ConsecutiveReopensWithoutClose.java b/Domains/github-graph/src-gen/queries/ConsecutiveReopensWithoutClose.java
new file mode 100644
index 00000000..992c1a72
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/ConsecutiveReopensWithoutClose.java
@@ -0,0 +1,582 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
43import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
44import queries.CheckAction;
45import queries.IsClose;
46
47/**
48 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
49 *
50 * <p>Original source:
51 * <code><pre>
52 * {@literal @}Constraint(key={i}, severity="error", message="error")
53 * pattern consecutiveReopensWithoutClose(i: Issue) {
54 * find checkAction(i, a1, Action::REOPENED);
55 * find checkAction(i, a2, Action::REOPENED);
56 * a1 != a2;
57 * neg find isClose(i, _);
58 * }
59 * </pre></code>
60 *
61 * @see Matcher
62 * @see Match
63 *
64 */
65@SuppressWarnings("all")
66public final class ConsecutiveReopensWithoutClose extends BaseGeneratedEMFQuerySpecification<ConsecutiveReopensWithoutClose.Matcher> {
67 /**
68 * Pattern-specific match representation of the queries.consecutiveReopensWithoutClose pattern,
69 * to be used in conjunction with {@link Matcher}.
70 *
71 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
72 * Each instance is a (possibly partial) substitution of pattern parameters,
73 * usable to represent a match of the pattern in the result of a query,
74 * or to specify the bound (fixed) input parameters when issuing a query.
75 *
76 * @see Matcher
77 *
78 */
79 public static abstract class Match extends BasePatternMatch {
80 private Issue fI;
81
82 private static List<String> parameterNames = makeImmutableList("i");
83
84 private Match(final Issue pI) {
85 this.fI = pI;
86 }
87
88 @Override
89 public Object get(final String parameterName) {
90 switch(parameterName) {
91 case "i": return this.fI;
92 default: return null;
93 }
94 }
95
96 @Override
97 public Object get(final int index) {
98 switch(index) {
99 case 0: return this.fI;
100 default: return null;
101 }
102 }
103
104 public Issue getI() {
105 return this.fI;
106 }
107
108 @Override
109 public boolean set(final String parameterName, final Object newValue) {
110 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
111 if ("i".equals(parameterName) ) {
112 this.fI = (Issue) newValue;
113 return true;
114 }
115 return false;
116 }
117
118 public void setI(final Issue pI) {
119 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
120 this.fI = pI;
121 }
122
123 @Override
124 public String patternName() {
125 return "queries.consecutiveReopensWithoutClose";
126 }
127
128 @Override
129 public List<String> parameterNames() {
130 return ConsecutiveReopensWithoutClose.Match.parameterNames;
131 }
132
133 @Override
134 public Object[] toArray() {
135 return new Object[]{fI};
136 }
137
138 @Override
139 public ConsecutiveReopensWithoutClose.Match toImmutable() {
140 return isMutable() ? newMatch(fI) : this;
141 }
142
143 @Override
144 public String prettyPrint() {
145 StringBuilder result = new StringBuilder();
146 result.append("\"i\"=" + prettyPrintValue(fI));
147 return result.toString();
148 }
149
150 @Override
151 public int hashCode() {
152 return Objects.hash(fI);
153 }
154
155 @Override
156 public boolean equals(final Object obj) {
157 if (this == obj)
158 return true;
159 if (obj == null) {
160 return false;
161 }
162 if ((obj instanceof ConsecutiveReopensWithoutClose.Match)) {
163 ConsecutiveReopensWithoutClose.Match other = (ConsecutiveReopensWithoutClose.Match) obj;
164 return Objects.equals(fI, other.fI);
165 } else {
166 // this should be infrequent
167 if (!(obj instanceof IPatternMatch)) {
168 return false;
169 }
170 IPatternMatch otherSig = (IPatternMatch) obj;
171 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
172 }
173 }
174
175 @Override
176 public ConsecutiveReopensWithoutClose specification() {
177 return ConsecutiveReopensWithoutClose.instance();
178 }
179
180 /**
181 * Returns an empty, mutable match.
182 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
183 *
184 * @return the empty match.
185 *
186 */
187 public static ConsecutiveReopensWithoutClose.Match newEmptyMatch() {
188 return new Mutable(null);
189 }
190
191 /**
192 * Returns a mutable (partial) match.
193 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
194 *
195 * @param pI the fixed value of pattern parameter i, or null if not bound.
196 * @return the new, mutable (partial) match object.
197 *
198 */
199 public static ConsecutiveReopensWithoutClose.Match newMutableMatch(final Issue pI) {
200 return new Mutable(pI);
201 }
202
203 /**
204 * Returns a new (partial) match.
205 * This can be used e.g. to call the matcher with a partial match.
206 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
207 * @param pI the fixed value of pattern parameter i, or null if not bound.
208 * @return the (partial) match object.
209 *
210 */
211 public static ConsecutiveReopensWithoutClose.Match newMatch(final Issue pI) {
212 return new Immutable(pI);
213 }
214
215 private static final class Mutable extends ConsecutiveReopensWithoutClose.Match {
216 Mutable(final Issue pI) {
217 super(pI);
218 }
219
220 @Override
221 public boolean isMutable() {
222 return true;
223 }
224 }
225
226 private static final class Immutable extends ConsecutiveReopensWithoutClose.Match {
227 Immutable(final Issue pI) {
228 super(pI);
229 }
230
231 @Override
232 public boolean isMutable() {
233 return false;
234 }
235 }
236 }
237
238 /**
239 * Generated pattern matcher API of the queries.consecutiveReopensWithoutClose pattern,
240 * providing pattern-specific query methods.
241 *
242 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
243 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
244 *
245 * <p>Matches of the pattern will be represented as {@link Match}.
246 *
247 * <p>Original source:
248 * <code><pre>
249 * {@literal @}Constraint(key={i}, severity="error", message="error")
250 * pattern consecutiveReopensWithoutClose(i: Issue) {
251 * find checkAction(i, a1, Action::REOPENED);
252 * find checkAction(i, a2, Action::REOPENED);
253 * a1 != a2;
254 * neg find isClose(i, _);
255 * }
256 * </pre></code>
257 *
258 * @see Match
259 * @see ConsecutiveReopensWithoutClose
260 *
261 */
262 public static class Matcher extends BaseMatcher<ConsecutiveReopensWithoutClose.Match> {
263 /**
264 * Initializes the pattern matcher within an existing VIATRA Query engine.
265 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
266 *
267 * @param engine the existing VIATRA Query engine in which this matcher will be created.
268 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
269 *
270 */
271 public static ConsecutiveReopensWithoutClose.Matcher on(final ViatraQueryEngine engine) {
272 // check if matcher already exists
273 Matcher matcher = engine.getExistingMatcher(querySpecification());
274 if (matcher == null) {
275 matcher = (Matcher)engine.getMatcher(querySpecification());
276 }
277 return matcher;
278 }
279
280 /**
281 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
282 * @return an initialized matcher
283 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
284 *
285 */
286 public static ConsecutiveReopensWithoutClose.Matcher create() {
287 return new Matcher();
288 }
289
290 private static final int POSITION_I = 0;
291
292 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConsecutiveReopensWithoutClose.Matcher.class);
293
294 /**
295 * Initializes the pattern matcher within an existing VIATRA Query engine.
296 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
297 *
298 * @param engine the existing VIATRA Query engine in which this matcher will be created.
299 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
300 *
301 */
302 private Matcher() {
303 super(querySpecification());
304 }
305
306 /**
307 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
308 * @param pI the fixed value of pattern parameter i, or null if not bound.
309 * @return matches represented as a Match object.
310 *
311 */
312 public Collection<ConsecutiveReopensWithoutClose.Match> getAllMatches(final Issue pI) {
313 return rawStreamAllMatches(new Object[]{pI}).collect(Collectors.toSet());
314 }
315
316 /**
317 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
318 * </p>
319 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
320 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
321 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
322 * @param pI the fixed value of pattern parameter i, or null if not bound.
323 * @return a stream of matches represented as a Match object.
324 *
325 */
326 public Stream<ConsecutiveReopensWithoutClose.Match> streamAllMatches(final Issue pI) {
327 return rawStreamAllMatches(new Object[]{pI});
328 }
329
330 /**
331 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
332 * Neither determinism nor randomness of selection is guaranteed.
333 * @param pI the fixed value of pattern parameter i, or null if not bound.
334 * @return a match represented as a Match object, or null if no match is found.
335 *
336 */
337 public Optional<ConsecutiveReopensWithoutClose.Match> getOneArbitraryMatch(final Issue pI) {
338 return rawGetOneArbitraryMatch(new Object[]{pI});
339 }
340
341 /**
342 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
343 * under any possible substitution of the unspecified parameters (if any).
344 * @param pI the fixed value of pattern parameter i, or null if not bound.
345 * @return true if the input is a valid (partial) match of the pattern.
346 *
347 */
348 public boolean hasMatch(final Issue pI) {
349 return rawHasMatch(new Object[]{pI});
350 }
351
352 /**
353 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
354 * @param pI the fixed value of pattern parameter i, or null if not bound.
355 * @return the number of pattern matches found.
356 *
357 */
358 public int countMatches(final Issue pI) {
359 return rawCountMatches(new Object[]{pI});
360 }
361
362 /**
363 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
364 * Neither determinism nor randomness of selection is guaranteed.
365 * @param pI the fixed value of pattern parameter i, or null if not bound.
366 * @param processor the action that will process the selected match.
367 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
368 *
369 */
370 public boolean forOneArbitraryMatch(final Issue pI, final Consumer<? super ConsecutiveReopensWithoutClose.Match> processor) {
371 return rawForOneArbitraryMatch(new Object[]{pI}, processor);
372 }
373
374 /**
375 * Returns a new (partial) match.
376 * This can be used e.g. to call the matcher with a partial match.
377 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
378 * @param pI the fixed value of pattern parameter i, or null if not bound.
379 * @return the (partial) match object.
380 *
381 */
382 public ConsecutiveReopensWithoutClose.Match newMatch(final Issue pI) {
383 return ConsecutiveReopensWithoutClose.Match.newMatch(pI);
384 }
385
386 /**
387 * Retrieve the set of values that occur in matches for i.
388 * @return the Set of all values or empty set if there are no matches
389 *
390 */
391 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
392 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
393 }
394
395 /**
396 * Retrieve the set of values that occur in matches for i.
397 * @return the Set of all values or empty set if there are no matches
398 *
399 */
400 public Set<Issue> getAllValuesOfi() {
401 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
402 }
403
404 /**
405 * Retrieve the set of values that occur in matches for i.
406 * @return the Set of all values or empty set if there are no matches
407 *
408 */
409 public Stream<Issue> streamAllValuesOfi() {
410 return rawStreamAllValuesOfi(emptyArray());
411 }
412
413 @Override
414 protected ConsecutiveReopensWithoutClose.Match tupleToMatch(final Tuple t) {
415 try {
416 return ConsecutiveReopensWithoutClose.Match.newMatch((Issue) t.get(POSITION_I));
417 } catch(ClassCastException e) {
418 LOGGER.error("Element(s) in tuple not properly typed!",e);
419 return null;
420 }
421 }
422
423 @Override
424 protected ConsecutiveReopensWithoutClose.Match arrayToMatch(final Object[] match) {
425 try {
426 return ConsecutiveReopensWithoutClose.Match.newMatch((Issue) match[POSITION_I]);
427 } catch(ClassCastException e) {
428 LOGGER.error("Element(s) in array not properly typed!",e);
429 return null;
430 }
431 }
432
433 @Override
434 protected ConsecutiveReopensWithoutClose.Match arrayToMatchMutable(final Object[] match) {
435 try {
436 return ConsecutiveReopensWithoutClose.Match.newMutableMatch((Issue) match[POSITION_I]);
437 } catch(ClassCastException e) {
438 LOGGER.error("Element(s) in array not properly typed!",e);
439 return null;
440 }
441 }
442
443 /**
444 * @return the singleton instance of the query specification of this pattern
445 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
446 *
447 */
448 public static IQuerySpecification<ConsecutiveReopensWithoutClose.Matcher> querySpecification() {
449 return ConsecutiveReopensWithoutClose.instance();
450 }
451 }
452
453 private ConsecutiveReopensWithoutClose() {
454 super(GeneratedPQuery.INSTANCE);
455 }
456
457 /**
458 * @return the singleton instance of the query specification
459 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
460 *
461 */
462 public static ConsecutiveReopensWithoutClose instance() {
463 try{
464 return LazyHolder.INSTANCE;
465 } catch (ExceptionInInitializerError err) {
466 throw processInitializerError(err);
467 }
468 }
469
470 @Override
471 protected ConsecutiveReopensWithoutClose.Matcher instantiate(final ViatraQueryEngine engine) {
472 return ConsecutiveReopensWithoutClose.Matcher.on(engine);
473 }
474
475 @Override
476 public ConsecutiveReopensWithoutClose.Matcher instantiate() {
477 return ConsecutiveReopensWithoutClose.Matcher.create();
478 }
479
480 @Override
481 public ConsecutiveReopensWithoutClose.Match newEmptyMatch() {
482 return ConsecutiveReopensWithoutClose.Match.newEmptyMatch();
483 }
484
485 @Override
486 public ConsecutiveReopensWithoutClose.Match newMatch(final Object... parameters) {
487 return ConsecutiveReopensWithoutClose.Match.newMatch((github.Issue) parameters[0]);
488 }
489
490 /**
491 * Inner class allowing the singleton instance of {@link ConsecutiveReopensWithoutClose} to be created
492 * <b>not</b> at the class load time of the outer class,
493 * but rather at the first call to {@link ConsecutiveReopensWithoutClose#instance()}.
494 *
495 * <p> This workaround is required e.g. to support recursion.
496 *
497 */
498 private static class LazyHolder {
499 private static final ConsecutiveReopensWithoutClose INSTANCE = new ConsecutiveReopensWithoutClose();
500
501 /**
502 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
503 * This initialization order is required to support indirect recursion.
504 *
505 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
506 *
507 */
508 private static final Object STATIC_INITIALIZER = ensureInitialized();
509
510 public static Object ensureInitialized() {
511 INSTANCE.ensureInitializedInternal();
512 return null;
513 }
514 }
515
516 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
517 private static final ConsecutiveReopensWithoutClose.GeneratedPQuery INSTANCE = new GeneratedPQuery();
518
519 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
520
521 private final List<PParameter> parameters = Arrays.asList(parameter_i);
522
523 private GeneratedPQuery() {
524 super(PVisibility.PUBLIC);
525 }
526
527 @Override
528 public String getFullyQualifiedName() {
529 return "queries.consecutiveReopensWithoutClose";
530 }
531
532 @Override
533 public List<String> getParameterNames() {
534 return Arrays.asList("i");
535 }
536
537 @Override
538 public List<PParameter> getParameters() {
539 return parameters;
540 }
541
542 @Override
543 public Set<PBody> doGetContainedBodies() {
544 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
545 Set<PBody> bodies = new LinkedHashSet<>();
546 {
547 PBody body = new PBody(this);
548 PVariable var_i = body.getOrCreateVariableByName("i");
549 PVariable var_a1 = body.getOrCreateVariableByName("a1");
550 PVariable var_a2 = body.getOrCreateVariableByName("a2");
551 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
552 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
553 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
554 new ExportedParameter(body, var_i, parameter_i)
555 ));
556 // find checkAction(i, a1, Action::REOPENED)
557 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
558 new ConstantValue(body, var__virtual_0_, getEnumLiteral("sure.ghtorrent.github", "Action", "REOPENED").getInstance());
559 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_a1, var__virtual_0_), CheckAction.instance().getInternalQueryRepresentation());
560 // find checkAction(i, a2, Action::REOPENED)
561 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
562 new ConstantValue(body, var__virtual_1_, getEnumLiteral("sure.ghtorrent.github", "Action", "REOPENED").getInstance());
563 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_a2, var__virtual_1_), CheckAction.instance().getInternalQueryRepresentation());
564 // a1 != a2
565 new Inequality(body, var_a1, var_a2);
566 // neg find isClose(i, _)
567 new NegativePatternCall(body, Tuples.flatTupleOf(var_i, var___0_), IsClose.instance().getInternalQueryRepresentation());
568 bodies.add(body);
569 }
570 {
571 PAnnotation annotation = new PAnnotation("Constraint");
572 annotation.addAttribute("key", Arrays.asList(new Object[] {
573 new ParameterReference("i")
574 }));
575 annotation.addAttribute("severity", "error");
576 annotation.addAttribute("message", "error");
577 addAnnotation(annotation);
578 }
579 return bodies;
580 }
581 }
582}
diff --git a/Domains/github-graph/src-gen/queries/ConsecutiveSubWithoutUnSub.java b/Domains/github-graph/src-gen/queries/ConsecutiveSubWithoutUnSub.java
new file mode 100644
index 00000000..a3820a80
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/ConsecutiveSubWithoutUnSub.java
@@ -0,0 +1,738 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import github.User;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45import queries.CheckUserAction;
46import queries.IsUnSubscribe;
47
48/**
49 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
50 *
51 * <p>Original source:
52 * <code><pre>
53 * {@literal @}Constraint(key={i, u}, severity="error", message="error")
54 * pattern consecutiveSubWithoutUnSub(i: Issue, u: User) {
55 * find checkUserAction(i, u, a1, Action::SUBSCRIBED);
56 * find checkUserAction(i, u, a2, Action::SUBSCRIBED);
57 * a1 != a2;
58 * neg find isUnSubscribe(i, u, _);
59 * }
60 * </pre></code>
61 *
62 * @see Matcher
63 * @see Match
64 *
65 */
66@SuppressWarnings("all")
67public final class ConsecutiveSubWithoutUnSub extends BaseGeneratedEMFQuerySpecification<ConsecutiveSubWithoutUnSub.Matcher> {
68 /**
69 * Pattern-specific match representation of the queries.consecutiveSubWithoutUnSub pattern,
70 * to be used in conjunction with {@link Matcher}.
71 *
72 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
73 * Each instance is a (possibly partial) substitution of pattern parameters,
74 * usable to represent a match of the pattern in the result of a query,
75 * or to specify the bound (fixed) input parameters when issuing a query.
76 *
77 * @see Matcher
78 *
79 */
80 public static abstract class Match extends BasePatternMatch {
81 private Issue fI;
82
83 private User fU;
84
85 private static List<String> parameterNames = makeImmutableList("i", "u");
86
87 private Match(final Issue pI, final User pU) {
88 this.fI = pI;
89 this.fU = pU;
90 }
91
92 @Override
93 public Object get(final String parameterName) {
94 switch(parameterName) {
95 case "i": return this.fI;
96 case "u": return this.fU;
97 default: return null;
98 }
99 }
100
101 @Override
102 public Object get(final int index) {
103 switch(index) {
104 case 0: return this.fI;
105 case 1: return this.fU;
106 default: return null;
107 }
108 }
109
110 public Issue getI() {
111 return this.fI;
112 }
113
114 public User getU() {
115 return this.fU;
116 }
117
118 @Override
119 public boolean set(final String parameterName, final Object newValue) {
120 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
121 if ("i".equals(parameterName) ) {
122 this.fI = (Issue) newValue;
123 return true;
124 }
125 if ("u".equals(parameterName) ) {
126 this.fU = (User) newValue;
127 return true;
128 }
129 return false;
130 }
131
132 public void setI(final Issue pI) {
133 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
134 this.fI = pI;
135 }
136
137 public void setU(final User pU) {
138 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
139 this.fU = pU;
140 }
141
142 @Override
143 public String patternName() {
144 return "queries.consecutiveSubWithoutUnSub";
145 }
146
147 @Override
148 public List<String> parameterNames() {
149 return ConsecutiveSubWithoutUnSub.Match.parameterNames;
150 }
151
152 @Override
153 public Object[] toArray() {
154 return new Object[]{fI, fU};
155 }
156
157 @Override
158 public ConsecutiveSubWithoutUnSub.Match toImmutable() {
159 return isMutable() ? newMatch(fI, fU) : this;
160 }
161
162 @Override
163 public String prettyPrint() {
164 StringBuilder result = new StringBuilder();
165 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
166 result.append("\"u\"=" + prettyPrintValue(fU));
167 return result.toString();
168 }
169
170 @Override
171 public int hashCode() {
172 return Objects.hash(fI, fU);
173 }
174
175 @Override
176 public boolean equals(final Object obj) {
177 if (this == obj)
178 return true;
179 if (obj == null) {
180 return false;
181 }
182 if ((obj instanceof ConsecutiveSubWithoutUnSub.Match)) {
183 ConsecutiveSubWithoutUnSub.Match other = (ConsecutiveSubWithoutUnSub.Match) obj;
184 return Objects.equals(fI, other.fI) && Objects.equals(fU, other.fU);
185 } else {
186 // this should be infrequent
187 if (!(obj instanceof IPatternMatch)) {
188 return false;
189 }
190 IPatternMatch otherSig = (IPatternMatch) obj;
191 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
192 }
193 }
194
195 @Override
196 public ConsecutiveSubWithoutUnSub specification() {
197 return ConsecutiveSubWithoutUnSub.instance();
198 }
199
200 /**
201 * Returns an empty, mutable match.
202 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
203 *
204 * @return the empty match.
205 *
206 */
207 public static ConsecutiveSubWithoutUnSub.Match newEmptyMatch() {
208 return new Mutable(null, null);
209 }
210
211 /**
212 * Returns a mutable (partial) match.
213 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
214 *
215 * @param pI the fixed value of pattern parameter i, or null if not bound.
216 * @param pU the fixed value of pattern parameter u, or null if not bound.
217 * @return the new, mutable (partial) match object.
218 *
219 */
220 public static ConsecutiveSubWithoutUnSub.Match newMutableMatch(final Issue pI, final User pU) {
221 return new Mutable(pI, pU);
222 }
223
224 /**
225 * Returns a new (partial) match.
226 * This can be used e.g. to call the matcher with a partial match.
227 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
228 * @param pI the fixed value of pattern parameter i, or null if not bound.
229 * @param pU the fixed value of pattern parameter u, or null if not bound.
230 * @return the (partial) match object.
231 *
232 */
233 public static ConsecutiveSubWithoutUnSub.Match newMatch(final Issue pI, final User pU) {
234 return new Immutable(pI, pU);
235 }
236
237 private static final class Mutable extends ConsecutiveSubWithoutUnSub.Match {
238 Mutable(final Issue pI, final User pU) {
239 super(pI, pU);
240 }
241
242 @Override
243 public boolean isMutable() {
244 return true;
245 }
246 }
247
248 private static final class Immutable extends ConsecutiveSubWithoutUnSub.Match {
249 Immutable(final Issue pI, final User pU) {
250 super(pI, pU);
251 }
252
253 @Override
254 public boolean isMutable() {
255 return false;
256 }
257 }
258 }
259
260 /**
261 * Generated pattern matcher API of the queries.consecutiveSubWithoutUnSub pattern,
262 * providing pattern-specific query methods.
263 *
264 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
265 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
266 *
267 * <p>Matches of the pattern will be represented as {@link Match}.
268 *
269 * <p>Original source:
270 * <code><pre>
271 * {@literal @}Constraint(key={i, u}, severity="error", message="error")
272 * pattern consecutiveSubWithoutUnSub(i: Issue, u: User) {
273 * find checkUserAction(i, u, a1, Action::SUBSCRIBED);
274 * find checkUserAction(i, u, a2, Action::SUBSCRIBED);
275 * a1 != a2;
276 * neg find isUnSubscribe(i, u, _);
277 * }
278 * </pre></code>
279 *
280 * @see Match
281 * @see ConsecutiveSubWithoutUnSub
282 *
283 */
284 public static class Matcher extends BaseMatcher<ConsecutiveSubWithoutUnSub.Match> {
285 /**
286 * Initializes the pattern matcher within an existing VIATRA Query engine.
287 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
288 *
289 * @param engine the existing VIATRA Query engine in which this matcher will be created.
290 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
291 *
292 */
293 public static ConsecutiveSubWithoutUnSub.Matcher on(final ViatraQueryEngine engine) {
294 // check if matcher already exists
295 Matcher matcher = engine.getExistingMatcher(querySpecification());
296 if (matcher == null) {
297 matcher = (Matcher)engine.getMatcher(querySpecification());
298 }
299 return matcher;
300 }
301
302 /**
303 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
304 * @return an initialized matcher
305 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
306 *
307 */
308 public static ConsecutiveSubWithoutUnSub.Matcher create() {
309 return new Matcher();
310 }
311
312 private static final int POSITION_I = 0;
313
314 private static final int POSITION_U = 1;
315
316 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConsecutiveSubWithoutUnSub.Matcher.class);
317
318 /**
319 * Initializes the pattern matcher within an existing VIATRA Query engine.
320 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
321 *
322 * @param engine the existing VIATRA Query engine in which this matcher will be created.
323 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
324 *
325 */
326 private Matcher() {
327 super(querySpecification());
328 }
329
330 /**
331 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
332 * @param pI the fixed value of pattern parameter i, or null if not bound.
333 * @param pU the fixed value of pattern parameter u, or null if not bound.
334 * @return matches represented as a Match object.
335 *
336 */
337 public Collection<ConsecutiveSubWithoutUnSub.Match> getAllMatches(final Issue pI, final User pU) {
338 return rawStreamAllMatches(new Object[]{pI, pU}).collect(Collectors.toSet());
339 }
340
341 /**
342 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
343 * </p>
344 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
345 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
346 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
347 * @param pI the fixed value of pattern parameter i, or null if not bound.
348 * @param pU the fixed value of pattern parameter u, or null if not bound.
349 * @return a stream of matches represented as a Match object.
350 *
351 */
352 public Stream<ConsecutiveSubWithoutUnSub.Match> streamAllMatches(final Issue pI, final User pU) {
353 return rawStreamAllMatches(new Object[]{pI, pU});
354 }
355
356 /**
357 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
358 * Neither determinism nor randomness of selection is guaranteed.
359 * @param pI the fixed value of pattern parameter i, or null if not bound.
360 * @param pU the fixed value of pattern parameter u, or null if not bound.
361 * @return a match represented as a Match object, or null if no match is found.
362 *
363 */
364 public Optional<ConsecutiveSubWithoutUnSub.Match> getOneArbitraryMatch(final Issue pI, final User pU) {
365 return rawGetOneArbitraryMatch(new Object[]{pI, pU});
366 }
367
368 /**
369 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
370 * under any possible substitution of the unspecified parameters (if any).
371 * @param pI the fixed value of pattern parameter i, or null if not bound.
372 * @param pU the fixed value of pattern parameter u, or null if not bound.
373 * @return true if the input is a valid (partial) match of the pattern.
374 *
375 */
376 public boolean hasMatch(final Issue pI, final User pU) {
377 return rawHasMatch(new Object[]{pI, pU});
378 }
379
380 /**
381 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
382 * @param pI the fixed value of pattern parameter i, or null if not bound.
383 * @param pU the fixed value of pattern parameter u, or null if not bound.
384 * @return the number of pattern matches found.
385 *
386 */
387 public int countMatches(final Issue pI, final User pU) {
388 return rawCountMatches(new Object[]{pI, pU});
389 }
390
391 /**
392 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
393 * Neither determinism nor randomness of selection is guaranteed.
394 * @param pI the fixed value of pattern parameter i, or null if not bound.
395 * @param pU the fixed value of pattern parameter u, or null if not bound.
396 * @param processor the action that will process the selected match.
397 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
398 *
399 */
400 public boolean forOneArbitraryMatch(final Issue pI, final User pU, final Consumer<? super ConsecutiveSubWithoutUnSub.Match> processor) {
401 return rawForOneArbitraryMatch(new Object[]{pI, pU}, processor);
402 }
403
404 /**
405 * Returns a new (partial) match.
406 * This can be used e.g. to call the matcher with a partial match.
407 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
408 * @param pI the fixed value of pattern parameter i, or null if not bound.
409 * @param pU the fixed value of pattern parameter u, or null if not bound.
410 * @return the (partial) match object.
411 *
412 */
413 public ConsecutiveSubWithoutUnSub.Match newMatch(final Issue pI, final User pU) {
414 return ConsecutiveSubWithoutUnSub.Match.newMatch(pI, pU);
415 }
416
417 /**
418 * Retrieve the set of values that occur in matches for i.
419 * @return the Set of all values or empty set if there are no matches
420 *
421 */
422 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
423 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
424 }
425
426 /**
427 * Retrieve the set of values that occur in matches for i.
428 * @return the Set of all values or empty set if there are no matches
429 *
430 */
431 public Set<Issue> getAllValuesOfi() {
432 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
433 }
434
435 /**
436 * Retrieve the set of values that occur in matches for i.
437 * @return the Set of all values or empty set if there are no matches
438 *
439 */
440 public Stream<Issue> streamAllValuesOfi() {
441 return rawStreamAllValuesOfi(emptyArray());
442 }
443
444 /**
445 * Retrieve the set of values that occur in matches for i.
446 * </p>
447 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
448 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
449 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
450 *
451 * @return the Stream of all values or empty set if there are no matches
452 *
453 */
454 public Stream<Issue> streamAllValuesOfi(final ConsecutiveSubWithoutUnSub.Match partialMatch) {
455 return rawStreamAllValuesOfi(partialMatch.toArray());
456 }
457
458 /**
459 * Retrieve the set of values that occur in matches for i.
460 * </p>
461 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
462 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
463 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
464 *
465 * @return the Stream of all values or empty set if there are no matches
466 *
467 */
468 public Stream<Issue> streamAllValuesOfi(final User pU) {
469 return rawStreamAllValuesOfi(new Object[]{null, pU});
470 }
471
472 /**
473 * Retrieve the set of values that occur in matches for i.
474 * @return the Set of all values or empty set if there are no matches
475 *
476 */
477 public Set<Issue> getAllValuesOfi(final ConsecutiveSubWithoutUnSub.Match partialMatch) {
478 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
479 }
480
481 /**
482 * Retrieve the set of values that occur in matches for i.
483 * @return the Set of all values or empty set if there are no matches
484 *
485 */
486 public Set<Issue> getAllValuesOfi(final User pU) {
487 return rawStreamAllValuesOfi(new Object[]{null, pU}).collect(Collectors.toSet());
488 }
489
490 /**
491 * Retrieve the set of values that occur in matches for u.
492 * @return the Set of all values or empty set if there are no matches
493 *
494 */
495 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
496 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
497 }
498
499 /**
500 * Retrieve the set of values that occur in matches for u.
501 * @return the Set of all values or empty set if there are no matches
502 *
503 */
504 public Set<User> getAllValuesOfu() {
505 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
506 }
507
508 /**
509 * Retrieve the set of values that occur in matches for u.
510 * @return the Set of all values or empty set if there are no matches
511 *
512 */
513 public Stream<User> streamAllValuesOfu() {
514 return rawStreamAllValuesOfu(emptyArray());
515 }
516
517 /**
518 * Retrieve the set of values that occur in matches for u.
519 * </p>
520 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
521 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
522 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
523 *
524 * @return the Stream of all values or empty set if there are no matches
525 *
526 */
527 public Stream<User> streamAllValuesOfu(final ConsecutiveSubWithoutUnSub.Match partialMatch) {
528 return rawStreamAllValuesOfu(partialMatch.toArray());
529 }
530
531 /**
532 * Retrieve the set of values that occur in matches for u.
533 * </p>
534 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
535 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
536 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
537 *
538 * @return the Stream of all values or empty set if there are no matches
539 *
540 */
541 public Stream<User> streamAllValuesOfu(final Issue pI) {
542 return rawStreamAllValuesOfu(new Object[]{pI, null});
543 }
544
545 /**
546 * Retrieve the set of values that occur in matches for u.
547 * @return the Set of all values or empty set if there are no matches
548 *
549 */
550 public Set<User> getAllValuesOfu(final ConsecutiveSubWithoutUnSub.Match partialMatch) {
551 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
552 }
553
554 /**
555 * Retrieve the set of values that occur in matches for u.
556 * @return the Set of all values or empty set if there are no matches
557 *
558 */
559 public Set<User> getAllValuesOfu(final Issue pI) {
560 return rawStreamAllValuesOfu(new Object[]{pI, null}).collect(Collectors.toSet());
561 }
562
563 @Override
564 protected ConsecutiveSubWithoutUnSub.Match tupleToMatch(final Tuple t) {
565 try {
566 return ConsecutiveSubWithoutUnSub.Match.newMatch((Issue) t.get(POSITION_I), (User) t.get(POSITION_U));
567 } catch(ClassCastException e) {
568 LOGGER.error("Element(s) in tuple not properly typed!",e);
569 return null;
570 }
571 }
572
573 @Override
574 protected ConsecutiveSubWithoutUnSub.Match arrayToMatch(final Object[] match) {
575 try {
576 return ConsecutiveSubWithoutUnSub.Match.newMatch((Issue) match[POSITION_I], (User) match[POSITION_U]);
577 } catch(ClassCastException e) {
578 LOGGER.error("Element(s) in array not properly typed!",e);
579 return null;
580 }
581 }
582
583 @Override
584 protected ConsecutiveSubWithoutUnSub.Match arrayToMatchMutable(final Object[] match) {
585 try {
586 return ConsecutiveSubWithoutUnSub.Match.newMutableMatch((Issue) match[POSITION_I], (User) match[POSITION_U]);
587 } catch(ClassCastException e) {
588 LOGGER.error("Element(s) in array not properly typed!",e);
589 return null;
590 }
591 }
592
593 /**
594 * @return the singleton instance of the query specification of this pattern
595 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
596 *
597 */
598 public static IQuerySpecification<ConsecutiveSubWithoutUnSub.Matcher> querySpecification() {
599 return ConsecutiveSubWithoutUnSub.instance();
600 }
601 }
602
603 private ConsecutiveSubWithoutUnSub() {
604 super(GeneratedPQuery.INSTANCE);
605 }
606
607 /**
608 * @return the singleton instance of the query specification
609 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
610 *
611 */
612 public static ConsecutiveSubWithoutUnSub instance() {
613 try{
614 return LazyHolder.INSTANCE;
615 } catch (ExceptionInInitializerError err) {
616 throw processInitializerError(err);
617 }
618 }
619
620 @Override
621 protected ConsecutiveSubWithoutUnSub.Matcher instantiate(final ViatraQueryEngine engine) {
622 return ConsecutiveSubWithoutUnSub.Matcher.on(engine);
623 }
624
625 @Override
626 public ConsecutiveSubWithoutUnSub.Matcher instantiate() {
627 return ConsecutiveSubWithoutUnSub.Matcher.create();
628 }
629
630 @Override
631 public ConsecutiveSubWithoutUnSub.Match newEmptyMatch() {
632 return ConsecutiveSubWithoutUnSub.Match.newEmptyMatch();
633 }
634
635 @Override
636 public ConsecutiveSubWithoutUnSub.Match newMatch(final Object... parameters) {
637 return ConsecutiveSubWithoutUnSub.Match.newMatch((github.Issue) parameters[0], (github.User) parameters[1]);
638 }
639
640 /**
641 * Inner class allowing the singleton instance of {@link ConsecutiveSubWithoutUnSub} to be created
642 * <b>not</b> at the class load time of the outer class,
643 * but rather at the first call to {@link ConsecutiveSubWithoutUnSub#instance()}.
644 *
645 * <p> This workaround is required e.g. to support recursion.
646 *
647 */
648 private static class LazyHolder {
649 private static final ConsecutiveSubWithoutUnSub INSTANCE = new ConsecutiveSubWithoutUnSub();
650
651 /**
652 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
653 * This initialization order is required to support indirect recursion.
654 *
655 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
656 *
657 */
658 private static final Object STATIC_INITIALIZER = ensureInitialized();
659
660 public static Object ensureInitialized() {
661 INSTANCE.ensureInitializedInternal();
662 return null;
663 }
664 }
665
666 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
667 private static final ConsecutiveSubWithoutUnSub.GeneratedPQuery INSTANCE = new GeneratedPQuery();
668
669 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
670
671 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
672
673 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_u);
674
675 private GeneratedPQuery() {
676 super(PVisibility.PUBLIC);
677 }
678
679 @Override
680 public String getFullyQualifiedName() {
681 return "queries.consecutiveSubWithoutUnSub";
682 }
683
684 @Override
685 public List<String> getParameterNames() {
686 return Arrays.asList("i","u");
687 }
688
689 @Override
690 public List<PParameter> getParameters() {
691 return parameters;
692 }
693
694 @Override
695 public Set<PBody> doGetContainedBodies() {
696 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
697 Set<PBody> bodies = new LinkedHashSet<>();
698 {
699 PBody body = new PBody(this);
700 PVariable var_i = body.getOrCreateVariableByName("i");
701 PVariable var_u = body.getOrCreateVariableByName("u");
702 PVariable var_a1 = body.getOrCreateVariableByName("a1");
703 PVariable var_a2 = body.getOrCreateVariableByName("a2");
704 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
705 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
706 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
707 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
708 new ExportedParameter(body, var_i, parameter_i),
709 new ExportedParameter(body, var_u, parameter_u)
710 ));
711 // find checkUserAction(i, u, a1, Action::SUBSCRIBED)
712 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
713 new ConstantValue(body, var__virtual_0_, getEnumLiteral("sure.ghtorrent.github", "Action", "SUBSCRIBED").getInstance());
714 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_u, var_a1, var__virtual_0_), CheckUserAction.instance().getInternalQueryRepresentation());
715 // find checkUserAction(i, u, a2, Action::SUBSCRIBED)
716 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
717 new ConstantValue(body, var__virtual_1_, getEnumLiteral("sure.ghtorrent.github", "Action", "SUBSCRIBED").getInstance());
718 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_u, var_a2, var__virtual_1_), CheckUserAction.instance().getInternalQueryRepresentation());
719 // a1 != a2
720 new Inequality(body, var_a1, var_a2);
721 // neg find isUnSubscribe(i, u, _)
722 new NegativePatternCall(body, Tuples.flatTupleOf(var_i, var_u, var___0_), IsUnSubscribe.instance().getInternalQueryRepresentation());
723 bodies.add(body);
724 }
725 {
726 PAnnotation annotation = new PAnnotation("Constraint");
727 annotation.addAttribute("key", Arrays.asList(new Object[] {
728 new ParameterReference("i"),
729 new ParameterReference("u")
730 }));
731 annotation.addAttribute("severity", "error");
732 annotation.addAttribute("message", "error");
733 addAnnotation(annotation);
734 }
735 return bodies;
736 }
737 }
738}
diff --git a/Domains/github-graph/src-gen/queries/ConsecutiveUnSubWithoutSub.java b/Domains/github-graph/src-gen/queries/ConsecutiveUnSubWithoutSub.java
new file mode 100644
index 00000000..492e2c76
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/ConsecutiveUnSubWithoutSub.java
@@ -0,0 +1,738 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import github.User;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45import queries.CheckUserAction;
46import queries.IsSubscribe;
47
48/**
49 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
50 *
51 * <p>Original source:
52 * <code><pre>
53 * {@literal @}Constraint(key={i, u}, severity="error", message="error")
54 * pattern consecutiveUnSubWithoutSub(i: Issue, u: User) {
55 * find checkUserAction(i, u, a1, Action::UNSUBSCRIBED);
56 * find checkUserAction(i, u, a2, Action::UNSUBSCRIBED);
57 * a1 != a2;
58 * neg find isSubscribe(i, u, _);
59 * }
60 * </pre></code>
61 *
62 * @see Matcher
63 * @see Match
64 *
65 */
66@SuppressWarnings("all")
67public final class ConsecutiveUnSubWithoutSub extends BaseGeneratedEMFQuerySpecification<ConsecutiveUnSubWithoutSub.Matcher> {
68 /**
69 * Pattern-specific match representation of the queries.consecutiveUnSubWithoutSub pattern,
70 * to be used in conjunction with {@link Matcher}.
71 *
72 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
73 * Each instance is a (possibly partial) substitution of pattern parameters,
74 * usable to represent a match of the pattern in the result of a query,
75 * or to specify the bound (fixed) input parameters when issuing a query.
76 *
77 * @see Matcher
78 *
79 */
80 public static abstract class Match extends BasePatternMatch {
81 private Issue fI;
82
83 private User fU;
84
85 private static List<String> parameterNames = makeImmutableList("i", "u");
86
87 private Match(final Issue pI, final User pU) {
88 this.fI = pI;
89 this.fU = pU;
90 }
91
92 @Override
93 public Object get(final String parameterName) {
94 switch(parameterName) {
95 case "i": return this.fI;
96 case "u": return this.fU;
97 default: return null;
98 }
99 }
100
101 @Override
102 public Object get(final int index) {
103 switch(index) {
104 case 0: return this.fI;
105 case 1: return this.fU;
106 default: return null;
107 }
108 }
109
110 public Issue getI() {
111 return this.fI;
112 }
113
114 public User getU() {
115 return this.fU;
116 }
117
118 @Override
119 public boolean set(final String parameterName, final Object newValue) {
120 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
121 if ("i".equals(parameterName) ) {
122 this.fI = (Issue) newValue;
123 return true;
124 }
125 if ("u".equals(parameterName) ) {
126 this.fU = (User) newValue;
127 return true;
128 }
129 return false;
130 }
131
132 public void setI(final Issue pI) {
133 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
134 this.fI = pI;
135 }
136
137 public void setU(final User pU) {
138 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
139 this.fU = pU;
140 }
141
142 @Override
143 public String patternName() {
144 return "queries.consecutiveUnSubWithoutSub";
145 }
146
147 @Override
148 public List<String> parameterNames() {
149 return ConsecutiveUnSubWithoutSub.Match.parameterNames;
150 }
151
152 @Override
153 public Object[] toArray() {
154 return new Object[]{fI, fU};
155 }
156
157 @Override
158 public ConsecutiveUnSubWithoutSub.Match toImmutable() {
159 return isMutable() ? newMatch(fI, fU) : this;
160 }
161
162 @Override
163 public String prettyPrint() {
164 StringBuilder result = new StringBuilder();
165 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
166 result.append("\"u\"=" + prettyPrintValue(fU));
167 return result.toString();
168 }
169
170 @Override
171 public int hashCode() {
172 return Objects.hash(fI, fU);
173 }
174
175 @Override
176 public boolean equals(final Object obj) {
177 if (this == obj)
178 return true;
179 if (obj == null) {
180 return false;
181 }
182 if ((obj instanceof ConsecutiveUnSubWithoutSub.Match)) {
183 ConsecutiveUnSubWithoutSub.Match other = (ConsecutiveUnSubWithoutSub.Match) obj;
184 return Objects.equals(fI, other.fI) && Objects.equals(fU, other.fU);
185 } else {
186 // this should be infrequent
187 if (!(obj instanceof IPatternMatch)) {
188 return false;
189 }
190 IPatternMatch otherSig = (IPatternMatch) obj;
191 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
192 }
193 }
194
195 @Override
196 public ConsecutiveUnSubWithoutSub specification() {
197 return ConsecutiveUnSubWithoutSub.instance();
198 }
199
200 /**
201 * Returns an empty, mutable match.
202 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
203 *
204 * @return the empty match.
205 *
206 */
207 public static ConsecutiveUnSubWithoutSub.Match newEmptyMatch() {
208 return new Mutable(null, null);
209 }
210
211 /**
212 * Returns a mutable (partial) match.
213 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
214 *
215 * @param pI the fixed value of pattern parameter i, or null if not bound.
216 * @param pU the fixed value of pattern parameter u, or null if not bound.
217 * @return the new, mutable (partial) match object.
218 *
219 */
220 public static ConsecutiveUnSubWithoutSub.Match newMutableMatch(final Issue pI, final User pU) {
221 return new Mutable(pI, pU);
222 }
223
224 /**
225 * Returns a new (partial) match.
226 * This can be used e.g. to call the matcher with a partial match.
227 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
228 * @param pI the fixed value of pattern parameter i, or null if not bound.
229 * @param pU the fixed value of pattern parameter u, or null if not bound.
230 * @return the (partial) match object.
231 *
232 */
233 public static ConsecutiveUnSubWithoutSub.Match newMatch(final Issue pI, final User pU) {
234 return new Immutable(pI, pU);
235 }
236
237 private static final class Mutable extends ConsecutiveUnSubWithoutSub.Match {
238 Mutable(final Issue pI, final User pU) {
239 super(pI, pU);
240 }
241
242 @Override
243 public boolean isMutable() {
244 return true;
245 }
246 }
247
248 private static final class Immutable extends ConsecutiveUnSubWithoutSub.Match {
249 Immutable(final Issue pI, final User pU) {
250 super(pI, pU);
251 }
252
253 @Override
254 public boolean isMutable() {
255 return false;
256 }
257 }
258 }
259
260 /**
261 * Generated pattern matcher API of the queries.consecutiveUnSubWithoutSub pattern,
262 * providing pattern-specific query methods.
263 *
264 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
265 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
266 *
267 * <p>Matches of the pattern will be represented as {@link Match}.
268 *
269 * <p>Original source:
270 * <code><pre>
271 * {@literal @}Constraint(key={i, u}, severity="error", message="error")
272 * pattern consecutiveUnSubWithoutSub(i: Issue, u: User) {
273 * find checkUserAction(i, u, a1, Action::UNSUBSCRIBED);
274 * find checkUserAction(i, u, a2, Action::UNSUBSCRIBED);
275 * a1 != a2;
276 * neg find isSubscribe(i, u, _);
277 * }
278 * </pre></code>
279 *
280 * @see Match
281 * @see ConsecutiveUnSubWithoutSub
282 *
283 */
284 public static class Matcher extends BaseMatcher<ConsecutiveUnSubWithoutSub.Match> {
285 /**
286 * Initializes the pattern matcher within an existing VIATRA Query engine.
287 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
288 *
289 * @param engine the existing VIATRA Query engine in which this matcher will be created.
290 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
291 *
292 */
293 public static ConsecutiveUnSubWithoutSub.Matcher on(final ViatraQueryEngine engine) {
294 // check if matcher already exists
295 Matcher matcher = engine.getExistingMatcher(querySpecification());
296 if (matcher == null) {
297 matcher = (Matcher)engine.getMatcher(querySpecification());
298 }
299 return matcher;
300 }
301
302 /**
303 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
304 * @return an initialized matcher
305 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
306 *
307 */
308 public static ConsecutiveUnSubWithoutSub.Matcher create() {
309 return new Matcher();
310 }
311
312 private static final int POSITION_I = 0;
313
314 private static final int POSITION_U = 1;
315
316 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConsecutiveUnSubWithoutSub.Matcher.class);
317
318 /**
319 * Initializes the pattern matcher within an existing VIATRA Query engine.
320 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
321 *
322 * @param engine the existing VIATRA Query engine in which this matcher will be created.
323 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
324 *
325 */
326 private Matcher() {
327 super(querySpecification());
328 }
329
330 /**
331 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
332 * @param pI the fixed value of pattern parameter i, or null if not bound.
333 * @param pU the fixed value of pattern parameter u, or null if not bound.
334 * @return matches represented as a Match object.
335 *
336 */
337 public Collection<ConsecutiveUnSubWithoutSub.Match> getAllMatches(final Issue pI, final User pU) {
338 return rawStreamAllMatches(new Object[]{pI, pU}).collect(Collectors.toSet());
339 }
340
341 /**
342 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
343 * </p>
344 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
345 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
346 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
347 * @param pI the fixed value of pattern parameter i, or null if not bound.
348 * @param pU the fixed value of pattern parameter u, or null if not bound.
349 * @return a stream of matches represented as a Match object.
350 *
351 */
352 public Stream<ConsecutiveUnSubWithoutSub.Match> streamAllMatches(final Issue pI, final User pU) {
353 return rawStreamAllMatches(new Object[]{pI, pU});
354 }
355
356 /**
357 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
358 * Neither determinism nor randomness of selection is guaranteed.
359 * @param pI the fixed value of pattern parameter i, or null if not bound.
360 * @param pU the fixed value of pattern parameter u, or null if not bound.
361 * @return a match represented as a Match object, or null if no match is found.
362 *
363 */
364 public Optional<ConsecutiveUnSubWithoutSub.Match> getOneArbitraryMatch(final Issue pI, final User pU) {
365 return rawGetOneArbitraryMatch(new Object[]{pI, pU});
366 }
367
368 /**
369 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
370 * under any possible substitution of the unspecified parameters (if any).
371 * @param pI the fixed value of pattern parameter i, or null if not bound.
372 * @param pU the fixed value of pattern parameter u, or null if not bound.
373 * @return true if the input is a valid (partial) match of the pattern.
374 *
375 */
376 public boolean hasMatch(final Issue pI, final User pU) {
377 return rawHasMatch(new Object[]{pI, pU});
378 }
379
380 /**
381 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
382 * @param pI the fixed value of pattern parameter i, or null if not bound.
383 * @param pU the fixed value of pattern parameter u, or null if not bound.
384 * @return the number of pattern matches found.
385 *
386 */
387 public int countMatches(final Issue pI, final User pU) {
388 return rawCountMatches(new Object[]{pI, pU});
389 }
390
391 /**
392 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
393 * Neither determinism nor randomness of selection is guaranteed.
394 * @param pI the fixed value of pattern parameter i, or null if not bound.
395 * @param pU the fixed value of pattern parameter u, or null if not bound.
396 * @param processor the action that will process the selected match.
397 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
398 *
399 */
400 public boolean forOneArbitraryMatch(final Issue pI, final User pU, final Consumer<? super ConsecutiveUnSubWithoutSub.Match> processor) {
401 return rawForOneArbitraryMatch(new Object[]{pI, pU}, processor);
402 }
403
404 /**
405 * Returns a new (partial) match.
406 * This can be used e.g. to call the matcher with a partial match.
407 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
408 * @param pI the fixed value of pattern parameter i, or null if not bound.
409 * @param pU the fixed value of pattern parameter u, or null if not bound.
410 * @return the (partial) match object.
411 *
412 */
413 public ConsecutiveUnSubWithoutSub.Match newMatch(final Issue pI, final User pU) {
414 return ConsecutiveUnSubWithoutSub.Match.newMatch(pI, pU);
415 }
416
417 /**
418 * Retrieve the set of values that occur in matches for i.
419 * @return the Set of all values or empty set if there are no matches
420 *
421 */
422 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
423 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
424 }
425
426 /**
427 * Retrieve the set of values that occur in matches for i.
428 * @return the Set of all values or empty set if there are no matches
429 *
430 */
431 public Set<Issue> getAllValuesOfi() {
432 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
433 }
434
435 /**
436 * Retrieve the set of values that occur in matches for i.
437 * @return the Set of all values or empty set if there are no matches
438 *
439 */
440 public Stream<Issue> streamAllValuesOfi() {
441 return rawStreamAllValuesOfi(emptyArray());
442 }
443
444 /**
445 * Retrieve the set of values that occur in matches for i.
446 * </p>
447 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
448 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
449 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
450 *
451 * @return the Stream of all values or empty set if there are no matches
452 *
453 */
454 public Stream<Issue> streamAllValuesOfi(final ConsecutiveUnSubWithoutSub.Match partialMatch) {
455 return rawStreamAllValuesOfi(partialMatch.toArray());
456 }
457
458 /**
459 * Retrieve the set of values that occur in matches for i.
460 * </p>
461 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
462 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
463 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
464 *
465 * @return the Stream of all values or empty set if there are no matches
466 *
467 */
468 public Stream<Issue> streamAllValuesOfi(final User pU) {
469 return rawStreamAllValuesOfi(new Object[]{null, pU});
470 }
471
472 /**
473 * Retrieve the set of values that occur in matches for i.
474 * @return the Set of all values or empty set if there are no matches
475 *
476 */
477 public Set<Issue> getAllValuesOfi(final ConsecutiveUnSubWithoutSub.Match partialMatch) {
478 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
479 }
480
481 /**
482 * Retrieve the set of values that occur in matches for i.
483 * @return the Set of all values or empty set if there are no matches
484 *
485 */
486 public Set<Issue> getAllValuesOfi(final User pU) {
487 return rawStreamAllValuesOfi(new Object[]{null, pU}).collect(Collectors.toSet());
488 }
489
490 /**
491 * Retrieve the set of values that occur in matches for u.
492 * @return the Set of all values or empty set if there are no matches
493 *
494 */
495 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
496 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
497 }
498
499 /**
500 * Retrieve the set of values that occur in matches for u.
501 * @return the Set of all values or empty set if there are no matches
502 *
503 */
504 public Set<User> getAllValuesOfu() {
505 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
506 }
507
508 /**
509 * Retrieve the set of values that occur in matches for u.
510 * @return the Set of all values or empty set if there are no matches
511 *
512 */
513 public Stream<User> streamAllValuesOfu() {
514 return rawStreamAllValuesOfu(emptyArray());
515 }
516
517 /**
518 * Retrieve the set of values that occur in matches for u.
519 * </p>
520 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
521 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
522 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
523 *
524 * @return the Stream of all values or empty set if there are no matches
525 *
526 */
527 public Stream<User> streamAllValuesOfu(final ConsecutiveUnSubWithoutSub.Match partialMatch) {
528 return rawStreamAllValuesOfu(partialMatch.toArray());
529 }
530
531 /**
532 * Retrieve the set of values that occur in matches for u.
533 * </p>
534 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
535 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
536 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
537 *
538 * @return the Stream of all values or empty set if there are no matches
539 *
540 */
541 public Stream<User> streamAllValuesOfu(final Issue pI) {
542 return rawStreamAllValuesOfu(new Object[]{pI, null});
543 }
544
545 /**
546 * Retrieve the set of values that occur in matches for u.
547 * @return the Set of all values or empty set if there are no matches
548 *
549 */
550 public Set<User> getAllValuesOfu(final ConsecutiveUnSubWithoutSub.Match partialMatch) {
551 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
552 }
553
554 /**
555 * Retrieve the set of values that occur in matches for u.
556 * @return the Set of all values or empty set if there are no matches
557 *
558 */
559 public Set<User> getAllValuesOfu(final Issue pI) {
560 return rawStreamAllValuesOfu(new Object[]{pI, null}).collect(Collectors.toSet());
561 }
562
563 @Override
564 protected ConsecutiveUnSubWithoutSub.Match tupleToMatch(final Tuple t) {
565 try {
566 return ConsecutiveUnSubWithoutSub.Match.newMatch((Issue) t.get(POSITION_I), (User) t.get(POSITION_U));
567 } catch(ClassCastException e) {
568 LOGGER.error("Element(s) in tuple not properly typed!",e);
569 return null;
570 }
571 }
572
573 @Override
574 protected ConsecutiveUnSubWithoutSub.Match arrayToMatch(final Object[] match) {
575 try {
576 return ConsecutiveUnSubWithoutSub.Match.newMatch((Issue) match[POSITION_I], (User) match[POSITION_U]);
577 } catch(ClassCastException e) {
578 LOGGER.error("Element(s) in array not properly typed!",e);
579 return null;
580 }
581 }
582
583 @Override
584 protected ConsecutiveUnSubWithoutSub.Match arrayToMatchMutable(final Object[] match) {
585 try {
586 return ConsecutiveUnSubWithoutSub.Match.newMutableMatch((Issue) match[POSITION_I], (User) match[POSITION_U]);
587 } catch(ClassCastException e) {
588 LOGGER.error("Element(s) in array not properly typed!",e);
589 return null;
590 }
591 }
592
593 /**
594 * @return the singleton instance of the query specification of this pattern
595 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
596 *
597 */
598 public static IQuerySpecification<ConsecutiveUnSubWithoutSub.Matcher> querySpecification() {
599 return ConsecutiveUnSubWithoutSub.instance();
600 }
601 }
602
603 private ConsecutiveUnSubWithoutSub() {
604 super(GeneratedPQuery.INSTANCE);
605 }
606
607 /**
608 * @return the singleton instance of the query specification
609 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
610 *
611 */
612 public static ConsecutiveUnSubWithoutSub instance() {
613 try{
614 return LazyHolder.INSTANCE;
615 } catch (ExceptionInInitializerError err) {
616 throw processInitializerError(err);
617 }
618 }
619
620 @Override
621 protected ConsecutiveUnSubWithoutSub.Matcher instantiate(final ViatraQueryEngine engine) {
622 return ConsecutiveUnSubWithoutSub.Matcher.on(engine);
623 }
624
625 @Override
626 public ConsecutiveUnSubWithoutSub.Matcher instantiate() {
627 return ConsecutiveUnSubWithoutSub.Matcher.create();
628 }
629
630 @Override
631 public ConsecutiveUnSubWithoutSub.Match newEmptyMatch() {
632 return ConsecutiveUnSubWithoutSub.Match.newEmptyMatch();
633 }
634
635 @Override
636 public ConsecutiveUnSubWithoutSub.Match newMatch(final Object... parameters) {
637 return ConsecutiveUnSubWithoutSub.Match.newMatch((github.Issue) parameters[0], (github.User) parameters[1]);
638 }
639
640 /**
641 * Inner class allowing the singleton instance of {@link ConsecutiveUnSubWithoutSub} to be created
642 * <b>not</b> at the class load time of the outer class,
643 * but rather at the first call to {@link ConsecutiveUnSubWithoutSub#instance()}.
644 *
645 * <p> This workaround is required e.g. to support recursion.
646 *
647 */
648 private static class LazyHolder {
649 private static final ConsecutiveUnSubWithoutSub INSTANCE = new ConsecutiveUnSubWithoutSub();
650
651 /**
652 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
653 * This initialization order is required to support indirect recursion.
654 *
655 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
656 *
657 */
658 private static final Object STATIC_INITIALIZER = ensureInitialized();
659
660 public static Object ensureInitialized() {
661 INSTANCE.ensureInitializedInternal();
662 return null;
663 }
664 }
665
666 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
667 private static final ConsecutiveUnSubWithoutSub.GeneratedPQuery INSTANCE = new GeneratedPQuery();
668
669 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
670
671 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
672
673 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_u);
674
675 private GeneratedPQuery() {
676 super(PVisibility.PUBLIC);
677 }
678
679 @Override
680 public String getFullyQualifiedName() {
681 return "queries.consecutiveUnSubWithoutSub";
682 }
683
684 @Override
685 public List<String> getParameterNames() {
686 return Arrays.asList("i","u");
687 }
688
689 @Override
690 public List<PParameter> getParameters() {
691 return parameters;
692 }
693
694 @Override
695 public Set<PBody> doGetContainedBodies() {
696 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
697 Set<PBody> bodies = new LinkedHashSet<>();
698 {
699 PBody body = new PBody(this);
700 PVariable var_i = body.getOrCreateVariableByName("i");
701 PVariable var_u = body.getOrCreateVariableByName("u");
702 PVariable var_a1 = body.getOrCreateVariableByName("a1");
703 PVariable var_a2 = body.getOrCreateVariableByName("a2");
704 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
705 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
706 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
707 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
708 new ExportedParameter(body, var_i, parameter_i),
709 new ExportedParameter(body, var_u, parameter_u)
710 ));
711 // find checkUserAction(i, u, a1, Action::UNSUBSCRIBED)
712 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
713 new ConstantValue(body, var__virtual_0_, getEnumLiteral("sure.ghtorrent.github", "Action", "UNSUBSCRIBED").getInstance());
714 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_u, var_a1, var__virtual_0_), CheckUserAction.instance().getInternalQueryRepresentation());
715 // find checkUserAction(i, u, a2, Action::UNSUBSCRIBED)
716 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
717 new ConstantValue(body, var__virtual_1_, getEnumLiteral("sure.ghtorrent.github", "Action", "UNSUBSCRIBED").getInstance());
718 new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_u, var_a2, var__virtual_1_), CheckUserAction.instance().getInternalQueryRepresentation());
719 // a1 != a2
720 new Inequality(body, var_a1, var_a2);
721 // neg find isSubscribe(i, u, _)
722 new NegativePatternCall(body, Tuples.flatTupleOf(var_i, var_u, var___0_), IsSubscribe.instance().getInternalQueryRepresentation());
723 bodies.add(body);
724 }
725 {
726 PAnnotation annotation = new PAnnotation("Constraint");
727 annotation.addAttribute("key", Arrays.asList(new Object[] {
728 new ParameterReference("i"),
729 new ParameterReference("u")
730 }));
731 annotation.addAttribute("severity", "error");
732 annotation.addAttribute("message", "error");
733 addAnnotation(annotation);
734 }
735 return bodies;
736 }
737 }
738}
diff --git a/Domains/github-graph/src-gen/queries/EventUser.java b/Domains/github-graph/src-gen/queries/EventUser.java
new file mode 100644
index 00000000..6e075c24
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/EventUser.java
@@ -0,0 +1,705 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.IssueEvent;
7import github.User;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
40import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
41
42/**
43 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
44 *
45 * <p>Original source:
46 * <code><pre>
47 * pattern eventUser(e: IssueEvent, u:User){
48 * IssueEvent.user(e, u);
49 * }
50 * </pre></code>
51 *
52 * @see Matcher
53 * @see Match
54 *
55 */
56@SuppressWarnings("all")
57public final class EventUser extends BaseGeneratedEMFQuerySpecification<EventUser.Matcher> {
58 /**
59 * Pattern-specific match representation of the queries.eventUser pattern,
60 * to be used in conjunction with {@link Matcher}.
61 *
62 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
63 * Each instance is a (possibly partial) substitution of pattern parameters,
64 * usable to represent a match of the pattern in the result of a query,
65 * or to specify the bound (fixed) input parameters when issuing a query.
66 *
67 * @see Matcher
68 *
69 */
70 public static abstract class Match extends BasePatternMatch {
71 private IssueEvent fE;
72
73 private User fU;
74
75 private static List<String> parameterNames = makeImmutableList("e", "u");
76
77 private Match(final IssueEvent pE, final User pU) {
78 this.fE = pE;
79 this.fU = pU;
80 }
81
82 @Override
83 public Object get(final String parameterName) {
84 switch(parameterName) {
85 case "e": return this.fE;
86 case "u": return this.fU;
87 default: return null;
88 }
89 }
90
91 @Override
92 public Object get(final int index) {
93 switch(index) {
94 case 0: return this.fE;
95 case 1: return this.fU;
96 default: return null;
97 }
98 }
99
100 public IssueEvent getE() {
101 return this.fE;
102 }
103
104 public User getU() {
105 return this.fU;
106 }
107
108 @Override
109 public boolean set(final String parameterName, final Object newValue) {
110 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
111 if ("e".equals(parameterName) ) {
112 this.fE = (IssueEvent) newValue;
113 return true;
114 }
115 if ("u".equals(parameterName) ) {
116 this.fU = (User) newValue;
117 return true;
118 }
119 return false;
120 }
121
122 public void setE(final IssueEvent pE) {
123 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
124 this.fE = pE;
125 }
126
127 public void setU(final User pU) {
128 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
129 this.fU = pU;
130 }
131
132 @Override
133 public String patternName() {
134 return "queries.eventUser";
135 }
136
137 @Override
138 public List<String> parameterNames() {
139 return EventUser.Match.parameterNames;
140 }
141
142 @Override
143 public Object[] toArray() {
144 return new Object[]{fE, fU};
145 }
146
147 @Override
148 public EventUser.Match toImmutable() {
149 return isMutable() ? newMatch(fE, fU) : this;
150 }
151
152 @Override
153 public String prettyPrint() {
154 StringBuilder result = new StringBuilder();
155 result.append("\"e\"=" + prettyPrintValue(fE) + ", ");
156 result.append("\"u\"=" + prettyPrintValue(fU));
157 return result.toString();
158 }
159
160 @Override
161 public int hashCode() {
162 return Objects.hash(fE, fU);
163 }
164
165 @Override
166 public boolean equals(final Object obj) {
167 if (this == obj)
168 return true;
169 if (obj == null) {
170 return false;
171 }
172 if ((obj instanceof EventUser.Match)) {
173 EventUser.Match other = (EventUser.Match) obj;
174 return Objects.equals(fE, other.fE) && Objects.equals(fU, other.fU);
175 } else {
176 // this should be infrequent
177 if (!(obj instanceof IPatternMatch)) {
178 return false;
179 }
180 IPatternMatch otherSig = (IPatternMatch) obj;
181 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
182 }
183 }
184
185 @Override
186 public EventUser specification() {
187 return EventUser.instance();
188 }
189
190 /**
191 * Returns an empty, mutable match.
192 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
193 *
194 * @return the empty match.
195 *
196 */
197 public static EventUser.Match newEmptyMatch() {
198 return new Mutable(null, null);
199 }
200
201 /**
202 * Returns a mutable (partial) match.
203 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
204 *
205 * @param pE the fixed value of pattern parameter e, or null if not bound.
206 * @param pU the fixed value of pattern parameter u, or null if not bound.
207 * @return the new, mutable (partial) match object.
208 *
209 */
210 public static EventUser.Match newMutableMatch(final IssueEvent pE, final User pU) {
211 return new Mutable(pE, pU);
212 }
213
214 /**
215 * Returns a new (partial) match.
216 * This can be used e.g. to call the matcher with a partial match.
217 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
218 * @param pE the fixed value of pattern parameter e, or null if not bound.
219 * @param pU the fixed value of pattern parameter u, or null if not bound.
220 * @return the (partial) match object.
221 *
222 */
223 public static EventUser.Match newMatch(final IssueEvent pE, final User pU) {
224 return new Immutable(pE, pU);
225 }
226
227 private static final class Mutable extends EventUser.Match {
228 Mutable(final IssueEvent pE, final User pU) {
229 super(pE, pU);
230 }
231
232 @Override
233 public boolean isMutable() {
234 return true;
235 }
236 }
237
238 private static final class Immutable extends EventUser.Match {
239 Immutable(final IssueEvent pE, final User pU) {
240 super(pE, pU);
241 }
242
243 @Override
244 public boolean isMutable() {
245 return false;
246 }
247 }
248 }
249
250 /**
251 * Generated pattern matcher API of the queries.eventUser pattern,
252 * providing pattern-specific query methods.
253 *
254 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
255 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
256 *
257 * <p>Matches of the pattern will be represented as {@link Match}.
258 *
259 * <p>Original source:
260 * <code><pre>
261 * pattern eventUser(e: IssueEvent, u:User){
262 * IssueEvent.user(e, u);
263 * }
264 * </pre></code>
265 *
266 * @see Match
267 * @see EventUser
268 *
269 */
270 public static class Matcher extends BaseMatcher<EventUser.Match> {
271 /**
272 * Initializes the pattern matcher within an existing VIATRA Query engine.
273 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
274 *
275 * @param engine the existing VIATRA Query engine in which this matcher will be created.
276 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
277 *
278 */
279 public static EventUser.Matcher on(final ViatraQueryEngine engine) {
280 // check if matcher already exists
281 Matcher matcher = engine.getExistingMatcher(querySpecification());
282 if (matcher == null) {
283 matcher = (Matcher)engine.getMatcher(querySpecification());
284 }
285 return matcher;
286 }
287
288 /**
289 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
290 * @return an initialized matcher
291 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
292 *
293 */
294 public static EventUser.Matcher create() {
295 return new Matcher();
296 }
297
298 private static final int POSITION_E = 0;
299
300 private static final int POSITION_U = 1;
301
302 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EventUser.Matcher.class);
303
304 /**
305 * Initializes the pattern matcher within an existing VIATRA Query engine.
306 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
307 *
308 * @param engine the existing VIATRA Query engine in which this matcher will be created.
309 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
310 *
311 */
312 private Matcher() {
313 super(querySpecification());
314 }
315
316 /**
317 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
318 * @param pE the fixed value of pattern parameter e, or null if not bound.
319 * @param pU the fixed value of pattern parameter u, or null if not bound.
320 * @return matches represented as a Match object.
321 *
322 */
323 public Collection<EventUser.Match> getAllMatches(final IssueEvent pE, final User pU) {
324 return rawStreamAllMatches(new Object[]{pE, pU}).collect(Collectors.toSet());
325 }
326
327 /**
328 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
329 * </p>
330 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
331 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
332 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
333 * @param pE the fixed value of pattern parameter e, or null if not bound.
334 * @param pU the fixed value of pattern parameter u, or null if not bound.
335 * @return a stream of matches represented as a Match object.
336 *
337 */
338 public Stream<EventUser.Match> streamAllMatches(final IssueEvent pE, final User pU) {
339 return rawStreamAllMatches(new Object[]{pE, pU});
340 }
341
342 /**
343 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
344 * Neither determinism nor randomness of selection is guaranteed.
345 * @param pE the fixed value of pattern parameter e, or null if not bound.
346 * @param pU the fixed value of pattern parameter u, or null if not bound.
347 * @return a match represented as a Match object, or null if no match is found.
348 *
349 */
350 public Optional<EventUser.Match> getOneArbitraryMatch(final IssueEvent pE, final User pU) {
351 return rawGetOneArbitraryMatch(new Object[]{pE, pU});
352 }
353
354 /**
355 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
356 * under any possible substitution of the unspecified parameters (if any).
357 * @param pE the fixed value of pattern parameter e, or null if not bound.
358 * @param pU the fixed value of pattern parameter u, or null if not bound.
359 * @return true if the input is a valid (partial) match of the pattern.
360 *
361 */
362 public boolean hasMatch(final IssueEvent pE, final User pU) {
363 return rawHasMatch(new Object[]{pE, pU});
364 }
365
366 /**
367 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
368 * @param pE the fixed value of pattern parameter e, or null if not bound.
369 * @param pU the fixed value of pattern parameter u, or null if not bound.
370 * @return the number of pattern matches found.
371 *
372 */
373 public int countMatches(final IssueEvent pE, final User pU) {
374 return rawCountMatches(new Object[]{pE, pU});
375 }
376
377 /**
378 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
379 * Neither determinism nor randomness of selection is guaranteed.
380 * @param pE the fixed value of pattern parameter e, or null if not bound.
381 * @param pU the fixed value of pattern parameter u, or null if not bound.
382 * @param processor the action that will process the selected match.
383 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
384 *
385 */
386 public boolean forOneArbitraryMatch(final IssueEvent pE, final User pU, final Consumer<? super EventUser.Match> processor) {
387 return rawForOneArbitraryMatch(new Object[]{pE, pU}, processor);
388 }
389
390 /**
391 * Returns a new (partial) match.
392 * This can be used e.g. to call the matcher with a partial match.
393 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
394 * @param pE the fixed value of pattern parameter e, or null if not bound.
395 * @param pU the fixed value of pattern parameter u, or null if not bound.
396 * @return the (partial) match object.
397 *
398 */
399 public EventUser.Match newMatch(final IssueEvent pE, final User pU) {
400 return EventUser.Match.newMatch(pE, pU);
401 }
402
403 /**
404 * Retrieve the set of values that occur in matches for e.
405 * @return the Set of all values or empty set if there are no matches
406 *
407 */
408 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
409 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
410 }
411
412 /**
413 * Retrieve the set of values that occur in matches for e.
414 * @return the Set of all values or empty set if there are no matches
415 *
416 */
417 public Set<IssueEvent> getAllValuesOfe() {
418 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
419 }
420
421 /**
422 * Retrieve the set of values that occur in matches for e.
423 * @return the Set of all values or empty set if there are no matches
424 *
425 */
426 public Stream<IssueEvent> streamAllValuesOfe() {
427 return rawStreamAllValuesOfe(emptyArray());
428 }
429
430 /**
431 * Retrieve the set of values that occur in matches for e.
432 * </p>
433 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
434 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
435 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
436 *
437 * @return the Stream of all values or empty set if there are no matches
438 *
439 */
440 public Stream<IssueEvent> streamAllValuesOfe(final EventUser.Match partialMatch) {
441 return rawStreamAllValuesOfe(partialMatch.toArray());
442 }
443
444 /**
445 * Retrieve the set of values that occur in matches for e.
446 * </p>
447 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
448 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
449 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
450 *
451 * @return the Stream of all values or empty set if there are no matches
452 *
453 */
454 public Stream<IssueEvent> streamAllValuesOfe(final User pU) {
455 return rawStreamAllValuesOfe(new Object[]{null, pU});
456 }
457
458 /**
459 * Retrieve the set of values that occur in matches for e.
460 * @return the Set of all values or empty set if there are no matches
461 *
462 */
463 public Set<IssueEvent> getAllValuesOfe(final EventUser.Match partialMatch) {
464 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
465 }
466
467 /**
468 * Retrieve the set of values that occur in matches for e.
469 * @return the Set of all values or empty set if there are no matches
470 *
471 */
472 public Set<IssueEvent> getAllValuesOfe(final User pU) {
473 return rawStreamAllValuesOfe(new Object[]{null, pU}).collect(Collectors.toSet());
474 }
475
476 /**
477 * Retrieve the set of values that occur in matches for u.
478 * @return the Set of all values or empty set if there are no matches
479 *
480 */
481 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
482 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
483 }
484
485 /**
486 * Retrieve the set of values that occur in matches for u.
487 * @return the Set of all values or empty set if there are no matches
488 *
489 */
490 public Set<User> getAllValuesOfu() {
491 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
492 }
493
494 /**
495 * Retrieve the set of values that occur in matches for u.
496 * @return the Set of all values or empty set if there are no matches
497 *
498 */
499 public Stream<User> streamAllValuesOfu() {
500 return rawStreamAllValuesOfu(emptyArray());
501 }
502
503 /**
504 * Retrieve the set of values that occur in matches for u.
505 * </p>
506 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
507 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
508 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
509 *
510 * @return the Stream of all values or empty set if there are no matches
511 *
512 */
513 public Stream<User> streamAllValuesOfu(final EventUser.Match partialMatch) {
514 return rawStreamAllValuesOfu(partialMatch.toArray());
515 }
516
517 /**
518 * Retrieve the set of values that occur in matches for u.
519 * </p>
520 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
521 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
522 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
523 *
524 * @return the Stream of all values or empty set if there are no matches
525 *
526 */
527 public Stream<User> streamAllValuesOfu(final IssueEvent pE) {
528 return rawStreamAllValuesOfu(new Object[]{pE, null});
529 }
530
531 /**
532 * Retrieve the set of values that occur in matches for u.
533 * @return the Set of all values or empty set if there are no matches
534 *
535 */
536 public Set<User> getAllValuesOfu(final EventUser.Match partialMatch) {
537 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
538 }
539
540 /**
541 * Retrieve the set of values that occur in matches for u.
542 * @return the Set of all values or empty set if there are no matches
543 *
544 */
545 public Set<User> getAllValuesOfu(final IssueEvent pE) {
546 return rawStreamAllValuesOfu(new Object[]{pE, null}).collect(Collectors.toSet());
547 }
548
549 @Override
550 protected EventUser.Match tupleToMatch(final Tuple t) {
551 try {
552 return EventUser.Match.newMatch((IssueEvent) t.get(POSITION_E), (User) t.get(POSITION_U));
553 } catch(ClassCastException e) {
554 LOGGER.error("Element(s) in tuple not properly typed!",e);
555 return null;
556 }
557 }
558
559 @Override
560 protected EventUser.Match arrayToMatch(final Object[] match) {
561 try {
562 return EventUser.Match.newMatch((IssueEvent) match[POSITION_E], (User) match[POSITION_U]);
563 } catch(ClassCastException e) {
564 LOGGER.error("Element(s) in array not properly typed!",e);
565 return null;
566 }
567 }
568
569 @Override
570 protected EventUser.Match arrayToMatchMutable(final Object[] match) {
571 try {
572 return EventUser.Match.newMutableMatch((IssueEvent) match[POSITION_E], (User) match[POSITION_U]);
573 } catch(ClassCastException e) {
574 LOGGER.error("Element(s) in array not properly typed!",e);
575 return null;
576 }
577 }
578
579 /**
580 * @return the singleton instance of the query specification of this pattern
581 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
582 *
583 */
584 public static IQuerySpecification<EventUser.Matcher> querySpecification() {
585 return EventUser.instance();
586 }
587 }
588
589 private EventUser() {
590 super(GeneratedPQuery.INSTANCE);
591 }
592
593 /**
594 * @return the singleton instance of the query specification
595 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
596 *
597 */
598 public static EventUser instance() {
599 try{
600 return LazyHolder.INSTANCE;
601 } catch (ExceptionInInitializerError err) {
602 throw processInitializerError(err);
603 }
604 }
605
606 @Override
607 protected EventUser.Matcher instantiate(final ViatraQueryEngine engine) {
608 return EventUser.Matcher.on(engine);
609 }
610
611 @Override
612 public EventUser.Matcher instantiate() {
613 return EventUser.Matcher.create();
614 }
615
616 @Override
617 public EventUser.Match newEmptyMatch() {
618 return EventUser.Match.newEmptyMatch();
619 }
620
621 @Override
622 public EventUser.Match newMatch(final Object... parameters) {
623 return EventUser.Match.newMatch((github.IssueEvent) parameters[0], (github.User) parameters[1]);
624 }
625
626 /**
627 * Inner class allowing the singleton instance of {@link EventUser} to be created
628 * <b>not</b> at the class load time of the outer class,
629 * but rather at the first call to {@link EventUser#instance()}.
630 *
631 * <p> This workaround is required e.g. to support recursion.
632 *
633 */
634 private static class LazyHolder {
635 private static final EventUser INSTANCE = new EventUser();
636
637 /**
638 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
639 * This initialization order is required to support indirect recursion.
640 *
641 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
642 *
643 */
644 private static final Object STATIC_INITIALIZER = ensureInitialized();
645
646 public static Object ensureInitialized() {
647 INSTANCE.ensureInitializedInternal();
648 return null;
649 }
650 }
651
652 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
653 private static final EventUser.GeneratedPQuery INSTANCE = new GeneratedPQuery();
654
655 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
656
657 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
658
659 private final List<PParameter> parameters = Arrays.asList(parameter_e, parameter_u);
660
661 private GeneratedPQuery() {
662 super(PVisibility.PUBLIC);
663 }
664
665 @Override
666 public String getFullyQualifiedName() {
667 return "queries.eventUser";
668 }
669
670 @Override
671 public List<String> getParameterNames() {
672 return Arrays.asList("e","u");
673 }
674
675 @Override
676 public List<PParameter> getParameters() {
677 return parameters;
678 }
679
680 @Override
681 public Set<PBody> doGetContainedBodies() {
682 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
683 Set<PBody> bodies = new LinkedHashSet<>();
684 {
685 PBody body = new PBody(this);
686 PVariable var_e = body.getOrCreateVariableByName("e");
687 PVariable var_u = body.getOrCreateVariableByName("u");
688 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
689 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
690 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
691 new ExportedParameter(body, var_e, parameter_e),
692 new ExportedParameter(body, var_u, parameter_u)
693 ));
694 // IssueEvent.user(e, u)
695 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
696 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
697 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "user")));
698 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
699 new Equality(body, var__virtual_0_, var_u);
700 bodies.add(body);
701 }
702 return bodies;
703 }
704 }
705}
diff --git a/Domains/github-graph/src-gen/queries/IsClose.java b/Domains/github-graph/src-gen/queries/IsClose.java
new file mode 100644
index 00000000..15732fc5
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/IsClose.java
@@ -0,0 +1,723 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import github.IssueEvent;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.emf.ecore.EDataType;
21import org.eclipse.viatra.query.runtime.api.IPatternMatch;
22import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
26import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
27import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
28import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
29import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
30import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
31import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
43import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
44
45/**
46 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
47 *
48 * <p>Original source:
49 * <code><pre>
50 * pattern isClose(i: Issue, e: IssueEvent) {
51 * Issue.issueevent(i, e);
52 * IssueEvent.action(e, a);
53 * a == Action::CLOSED;
54 * }
55 * </pre></code>
56 *
57 * @see Matcher
58 * @see Match
59 *
60 */
61@SuppressWarnings("all")
62public final class IsClose extends BaseGeneratedEMFQuerySpecification<IsClose.Matcher> {
63 /**
64 * Pattern-specific match representation of the queries.isClose pattern,
65 * to be used in conjunction with {@link Matcher}.
66 *
67 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
68 * Each instance is a (possibly partial) substitution of pattern parameters,
69 * usable to represent a match of the pattern in the result of a query,
70 * or to specify the bound (fixed) input parameters when issuing a query.
71 *
72 * @see Matcher
73 *
74 */
75 public static abstract class Match extends BasePatternMatch {
76 private Issue fI;
77
78 private IssueEvent fE;
79
80 private static List<String> parameterNames = makeImmutableList("i", "e");
81
82 private Match(final Issue pI, final IssueEvent pE) {
83 this.fI = pI;
84 this.fE = pE;
85 }
86
87 @Override
88 public Object get(final String parameterName) {
89 switch(parameterName) {
90 case "i": return this.fI;
91 case "e": return this.fE;
92 default: return null;
93 }
94 }
95
96 @Override
97 public Object get(final int index) {
98 switch(index) {
99 case 0: return this.fI;
100 case 1: return this.fE;
101 default: return null;
102 }
103 }
104
105 public Issue getI() {
106 return this.fI;
107 }
108
109 public IssueEvent getE() {
110 return this.fE;
111 }
112
113 @Override
114 public boolean set(final String parameterName, final Object newValue) {
115 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
116 if ("i".equals(parameterName) ) {
117 this.fI = (Issue) newValue;
118 return true;
119 }
120 if ("e".equals(parameterName) ) {
121 this.fE = (IssueEvent) newValue;
122 return true;
123 }
124 return false;
125 }
126
127 public void setI(final Issue pI) {
128 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
129 this.fI = pI;
130 }
131
132 public void setE(final IssueEvent pE) {
133 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
134 this.fE = pE;
135 }
136
137 @Override
138 public String patternName() {
139 return "queries.isClose";
140 }
141
142 @Override
143 public List<String> parameterNames() {
144 return IsClose.Match.parameterNames;
145 }
146
147 @Override
148 public Object[] toArray() {
149 return new Object[]{fI, fE};
150 }
151
152 @Override
153 public IsClose.Match toImmutable() {
154 return isMutable() ? newMatch(fI, fE) : this;
155 }
156
157 @Override
158 public String prettyPrint() {
159 StringBuilder result = new StringBuilder();
160 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
161 result.append("\"e\"=" + prettyPrintValue(fE));
162 return result.toString();
163 }
164
165 @Override
166 public int hashCode() {
167 return Objects.hash(fI, fE);
168 }
169
170 @Override
171 public boolean equals(final Object obj) {
172 if (this == obj)
173 return true;
174 if (obj == null) {
175 return false;
176 }
177 if ((obj instanceof IsClose.Match)) {
178 IsClose.Match other = (IsClose.Match) obj;
179 return Objects.equals(fI, other.fI) && Objects.equals(fE, other.fE);
180 } else {
181 // this should be infrequent
182 if (!(obj instanceof IPatternMatch)) {
183 return false;
184 }
185 IPatternMatch otherSig = (IPatternMatch) obj;
186 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
187 }
188 }
189
190 @Override
191 public IsClose specification() {
192 return IsClose.instance();
193 }
194
195 /**
196 * Returns an empty, mutable match.
197 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
198 *
199 * @return the empty match.
200 *
201 */
202 public static IsClose.Match newEmptyMatch() {
203 return new Mutable(null, null);
204 }
205
206 /**
207 * Returns a mutable (partial) match.
208 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
209 *
210 * @param pI the fixed value of pattern parameter i, or null if not bound.
211 * @param pE the fixed value of pattern parameter e, or null if not bound.
212 * @return the new, mutable (partial) match object.
213 *
214 */
215 public static IsClose.Match newMutableMatch(final Issue pI, final IssueEvent pE) {
216 return new Mutable(pI, pE);
217 }
218
219 /**
220 * Returns a new (partial) match.
221 * This can be used e.g. to call the matcher with a partial match.
222 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
223 * @param pI the fixed value of pattern parameter i, or null if not bound.
224 * @param pE the fixed value of pattern parameter e, or null if not bound.
225 * @return the (partial) match object.
226 *
227 */
228 public static IsClose.Match newMatch(final Issue pI, final IssueEvent pE) {
229 return new Immutable(pI, pE);
230 }
231
232 private static final class Mutable extends IsClose.Match {
233 Mutable(final Issue pI, final IssueEvent pE) {
234 super(pI, pE);
235 }
236
237 @Override
238 public boolean isMutable() {
239 return true;
240 }
241 }
242
243 private static final class Immutable extends IsClose.Match {
244 Immutable(final Issue pI, final IssueEvent pE) {
245 super(pI, pE);
246 }
247
248 @Override
249 public boolean isMutable() {
250 return false;
251 }
252 }
253 }
254
255 /**
256 * Generated pattern matcher API of the queries.isClose pattern,
257 * providing pattern-specific query methods.
258 *
259 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
260 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
261 *
262 * <p>Matches of the pattern will be represented as {@link Match}.
263 *
264 * <p>Original source:
265 * <code><pre>
266 * pattern isClose(i: Issue, e: IssueEvent) {
267 * Issue.issueevent(i, e);
268 * IssueEvent.action(e, a);
269 * a == Action::CLOSED;
270 * }
271 * </pre></code>
272 *
273 * @see Match
274 * @see IsClose
275 *
276 */
277 public static class Matcher extends BaseMatcher<IsClose.Match> {
278 /**
279 * Initializes the pattern matcher within an existing VIATRA Query engine.
280 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
281 *
282 * @param engine the existing VIATRA Query engine in which this matcher will be created.
283 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
284 *
285 */
286 public static IsClose.Matcher on(final ViatraQueryEngine engine) {
287 // check if matcher already exists
288 Matcher matcher = engine.getExistingMatcher(querySpecification());
289 if (matcher == null) {
290 matcher = (Matcher)engine.getMatcher(querySpecification());
291 }
292 return matcher;
293 }
294
295 /**
296 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
297 * @return an initialized matcher
298 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
299 *
300 */
301 public static IsClose.Matcher create() {
302 return new Matcher();
303 }
304
305 private static final int POSITION_I = 0;
306
307 private static final int POSITION_E = 1;
308
309 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IsClose.Matcher.class);
310
311 /**
312 * Initializes the pattern matcher within an existing VIATRA Query engine.
313 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
314 *
315 * @param engine the existing VIATRA Query engine in which this matcher will be created.
316 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
317 *
318 */
319 private Matcher() {
320 super(querySpecification());
321 }
322
323 /**
324 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
325 * @param pI the fixed value of pattern parameter i, or null if not bound.
326 * @param pE the fixed value of pattern parameter e, or null if not bound.
327 * @return matches represented as a Match object.
328 *
329 */
330 public Collection<IsClose.Match> getAllMatches(final Issue pI, final IssueEvent pE) {
331 return rawStreamAllMatches(new Object[]{pI, pE}).collect(Collectors.toSet());
332 }
333
334 /**
335 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
336 * </p>
337 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
338 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
339 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
340 * @param pI the fixed value of pattern parameter i, or null if not bound.
341 * @param pE the fixed value of pattern parameter e, or null if not bound.
342 * @return a stream of matches represented as a Match object.
343 *
344 */
345 public Stream<IsClose.Match> streamAllMatches(final Issue pI, final IssueEvent pE) {
346 return rawStreamAllMatches(new Object[]{pI, pE});
347 }
348
349 /**
350 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
351 * Neither determinism nor randomness of selection is guaranteed.
352 * @param pI the fixed value of pattern parameter i, or null if not bound.
353 * @param pE the fixed value of pattern parameter e, or null if not bound.
354 * @return a match represented as a Match object, or null if no match is found.
355 *
356 */
357 public Optional<IsClose.Match> getOneArbitraryMatch(final Issue pI, final IssueEvent pE) {
358 return rawGetOneArbitraryMatch(new Object[]{pI, pE});
359 }
360
361 /**
362 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
363 * under any possible substitution of the unspecified parameters (if any).
364 * @param pI the fixed value of pattern parameter i, or null if not bound.
365 * @param pE the fixed value of pattern parameter e, or null if not bound.
366 * @return true if the input is a valid (partial) match of the pattern.
367 *
368 */
369 public boolean hasMatch(final Issue pI, final IssueEvent pE) {
370 return rawHasMatch(new Object[]{pI, pE});
371 }
372
373 /**
374 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
375 * @param pI the fixed value of pattern parameter i, or null if not bound.
376 * @param pE the fixed value of pattern parameter e, or null if not bound.
377 * @return the number of pattern matches found.
378 *
379 */
380 public int countMatches(final Issue pI, final IssueEvent pE) {
381 return rawCountMatches(new Object[]{pI, pE});
382 }
383
384 /**
385 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
386 * Neither determinism nor randomness of selection is guaranteed.
387 * @param pI the fixed value of pattern parameter i, or null if not bound.
388 * @param pE the fixed value of pattern parameter e, or null if not bound.
389 * @param processor the action that will process the selected match.
390 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
391 *
392 */
393 public boolean forOneArbitraryMatch(final Issue pI, final IssueEvent pE, final Consumer<? super IsClose.Match> processor) {
394 return rawForOneArbitraryMatch(new Object[]{pI, pE}, processor);
395 }
396
397 /**
398 * Returns a new (partial) match.
399 * This can be used e.g. to call the matcher with a partial match.
400 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
401 * @param pI the fixed value of pattern parameter i, or null if not bound.
402 * @param pE the fixed value of pattern parameter e, or null if not bound.
403 * @return the (partial) match object.
404 *
405 */
406 public IsClose.Match newMatch(final Issue pI, final IssueEvent pE) {
407 return IsClose.Match.newMatch(pI, pE);
408 }
409
410 /**
411 * Retrieve the set of values that occur in matches for i.
412 * @return the Set of all values or empty set if there are no matches
413 *
414 */
415 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
416 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
417 }
418
419 /**
420 * Retrieve the set of values that occur in matches for i.
421 * @return the Set of all values or empty set if there are no matches
422 *
423 */
424 public Set<Issue> getAllValuesOfi() {
425 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
426 }
427
428 /**
429 * Retrieve the set of values that occur in matches for i.
430 * @return the Set of all values or empty set if there are no matches
431 *
432 */
433 public Stream<Issue> streamAllValuesOfi() {
434 return rawStreamAllValuesOfi(emptyArray());
435 }
436
437 /**
438 * Retrieve the set of values that occur in matches for i.
439 * </p>
440 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
441 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
442 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
443 *
444 * @return the Stream of all values or empty set if there are no matches
445 *
446 */
447 public Stream<Issue> streamAllValuesOfi(final IsClose.Match partialMatch) {
448 return rawStreamAllValuesOfi(partialMatch.toArray());
449 }
450
451 /**
452 * Retrieve the set of values that occur in matches for i.
453 * </p>
454 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
455 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
456 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
457 *
458 * @return the Stream of all values or empty set if there are no matches
459 *
460 */
461 public Stream<Issue> streamAllValuesOfi(final IssueEvent pE) {
462 return rawStreamAllValuesOfi(new Object[]{null, pE});
463 }
464
465 /**
466 * Retrieve the set of values that occur in matches for i.
467 * @return the Set of all values or empty set if there are no matches
468 *
469 */
470 public Set<Issue> getAllValuesOfi(final IsClose.Match partialMatch) {
471 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
472 }
473
474 /**
475 * Retrieve the set of values that occur in matches for i.
476 * @return the Set of all values or empty set if there are no matches
477 *
478 */
479 public Set<Issue> getAllValuesOfi(final IssueEvent pE) {
480 return rawStreamAllValuesOfi(new Object[]{null, pE}).collect(Collectors.toSet());
481 }
482
483 /**
484 * Retrieve the set of values that occur in matches for e.
485 * @return the Set of all values or empty set if there are no matches
486 *
487 */
488 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
489 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
490 }
491
492 /**
493 * Retrieve the set of values that occur in matches for e.
494 * @return the Set of all values or empty set if there are no matches
495 *
496 */
497 public Set<IssueEvent> getAllValuesOfe() {
498 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
499 }
500
501 /**
502 * Retrieve the set of values that occur in matches for e.
503 * @return the Set of all values or empty set if there are no matches
504 *
505 */
506 public Stream<IssueEvent> streamAllValuesOfe() {
507 return rawStreamAllValuesOfe(emptyArray());
508 }
509
510 /**
511 * Retrieve the set of values that occur in matches for e.
512 * </p>
513 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
514 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
515 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
516 *
517 * @return the Stream of all values or empty set if there are no matches
518 *
519 */
520 public Stream<IssueEvent> streamAllValuesOfe(final IsClose.Match partialMatch) {
521 return rawStreamAllValuesOfe(partialMatch.toArray());
522 }
523
524 /**
525 * Retrieve the set of values that occur in matches for e.
526 * </p>
527 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
528 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
529 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
530 *
531 * @return the Stream of all values or empty set if there are no matches
532 *
533 */
534 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI) {
535 return rawStreamAllValuesOfe(new Object[]{pI, null});
536 }
537
538 /**
539 * Retrieve the set of values that occur in matches for e.
540 * @return the Set of all values or empty set if there are no matches
541 *
542 */
543 public Set<IssueEvent> getAllValuesOfe(final IsClose.Match partialMatch) {
544 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
545 }
546
547 /**
548 * Retrieve the set of values that occur in matches for e.
549 * @return the Set of all values or empty set if there are no matches
550 *
551 */
552 public Set<IssueEvent> getAllValuesOfe(final Issue pI) {
553 return rawStreamAllValuesOfe(new Object[]{pI, null}).collect(Collectors.toSet());
554 }
555
556 @Override
557 protected IsClose.Match tupleToMatch(final Tuple t) {
558 try {
559 return IsClose.Match.newMatch((Issue) t.get(POSITION_I), (IssueEvent) t.get(POSITION_E));
560 } catch(ClassCastException e) {
561 LOGGER.error("Element(s) in tuple not properly typed!",e);
562 return null;
563 }
564 }
565
566 @Override
567 protected IsClose.Match arrayToMatch(final Object[] match) {
568 try {
569 return IsClose.Match.newMatch((Issue) match[POSITION_I], (IssueEvent) match[POSITION_E]);
570 } catch(ClassCastException e) {
571 LOGGER.error("Element(s) in array not properly typed!",e);
572 return null;
573 }
574 }
575
576 @Override
577 protected IsClose.Match arrayToMatchMutable(final Object[] match) {
578 try {
579 return IsClose.Match.newMutableMatch((Issue) match[POSITION_I], (IssueEvent) match[POSITION_E]);
580 } catch(ClassCastException e) {
581 LOGGER.error("Element(s) in array not properly typed!",e);
582 return null;
583 }
584 }
585
586 /**
587 * @return the singleton instance of the query specification of this pattern
588 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
589 *
590 */
591 public static IQuerySpecification<IsClose.Matcher> querySpecification() {
592 return IsClose.instance();
593 }
594 }
595
596 private IsClose() {
597 super(GeneratedPQuery.INSTANCE);
598 }
599
600 /**
601 * @return the singleton instance of the query specification
602 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
603 *
604 */
605 public static IsClose instance() {
606 try{
607 return LazyHolder.INSTANCE;
608 } catch (ExceptionInInitializerError err) {
609 throw processInitializerError(err);
610 }
611 }
612
613 @Override
614 protected IsClose.Matcher instantiate(final ViatraQueryEngine engine) {
615 return IsClose.Matcher.on(engine);
616 }
617
618 @Override
619 public IsClose.Matcher instantiate() {
620 return IsClose.Matcher.create();
621 }
622
623 @Override
624 public IsClose.Match newEmptyMatch() {
625 return IsClose.Match.newEmptyMatch();
626 }
627
628 @Override
629 public IsClose.Match newMatch(final Object... parameters) {
630 return IsClose.Match.newMatch((github.Issue) parameters[0], (github.IssueEvent) parameters[1]);
631 }
632
633 /**
634 * Inner class allowing the singleton instance of {@link IsClose} to be created
635 * <b>not</b> at the class load time of the outer class,
636 * but rather at the first call to {@link IsClose#instance()}.
637 *
638 * <p> This workaround is required e.g. to support recursion.
639 *
640 */
641 private static class LazyHolder {
642 private static final IsClose INSTANCE = new IsClose();
643
644 /**
645 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
646 * This initialization order is required to support indirect recursion.
647 *
648 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
649 *
650 */
651 private static final Object STATIC_INITIALIZER = ensureInitialized();
652
653 public static Object ensureInitialized() {
654 INSTANCE.ensureInitializedInternal();
655 return null;
656 }
657 }
658
659 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
660 private static final IsClose.GeneratedPQuery INSTANCE = new GeneratedPQuery();
661
662 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
663
664 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
665
666 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_e);
667
668 private GeneratedPQuery() {
669 super(PVisibility.PUBLIC);
670 }
671
672 @Override
673 public String getFullyQualifiedName() {
674 return "queries.isClose";
675 }
676
677 @Override
678 public List<String> getParameterNames() {
679 return Arrays.asList("i","e");
680 }
681
682 @Override
683 public List<PParameter> getParameters() {
684 return parameters;
685 }
686
687 @Override
688 public Set<PBody> doGetContainedBodies() {
689 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
690 Set<PBody> bodies = new LinkedHashSet<>();
691 {
692 PBody body = new PBody(this);
693 PVariable var_i = body.getOrCreateVariableByName("i");
694 PVariable var_e = body.getOrCreateVariableByName("e");
695 PVariable var_a = body.getOrCreateVariableByName("a");
696 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
697 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
698 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
699 new ExportedParameter(body, var_i, parameter_i),
700 new ExportedParameter(body, var_e, parameter_e)
701 ));
702 // Issue.issueevent(i, e)
703 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
704 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
705 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
706 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
707 new Equality(body, var__virtual_0_, var_e);
708 // IssueEvent.action(e, a)
709 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
710 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
711 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
712 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
713 new Equality(body, var__virtual_1_, var_a);
714 // a == Action::CLOSED
715 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
716 new ConstantValue(body, var__virtual_2_, getEnumLiteral("sure.ghtorrent.github", "Action", "CLOSED").getInstance());
717 new Equality(body, var_a, var__virtual_2_);
718 bodies.add(body);
719 }
720 return bodies;
721 }
722 }
723}
diff --git a/Domains/github-graph/src-gen/queries/IsReopen.java b/Domains/github-graph/src-gen/queries/IsReopen.java
new file mode 100644
index 00000000..32ae02c5
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/IsReopen.java
@@ -0,0 +1,723 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import github.IssueEvent;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.emf.ecore.EDataType;
21import org.eclipse.viatra.query.runtime.api.IPatternMatch;
22import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
26import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
27import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
28import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
29import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
30import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
31import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
43import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
44
45/**
46 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
47 *
48 * <p>Original source:
49 * <code><pre>
50 * pattern isReopen(i: Issue, e: IssueEvent) {
51 * Issue.issueevent(i, e);
52 * IssueEvent.action(e, a);
53 * a == Action::REOPENED;
54 * }
55 * </pre></code>
56 *
57 * @see Matcher
58 * @see Match
59 *
60 */
61@SuppressWarnings("all")
62public final class IsReopen extends BaseGeneratedEMFQuerySpecification<IsReopen.Matcher> {
63 /**
64 * Pattern-specific match representation of the queries.isReopen pattern,
65 * to be used in conjunction with {@link Matcher}.
66 *
67 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
68 * Each instance is a (possibly partial) substitution of pattern parameters,
69 * usable to represent a match of the pattern in the result of a query,
70 * or to specify the bound (fixed) input parameters when issuing a query.
71 *
72 * @see Matcher
73 *
74 */
75 public static abstract class Match extends BasePatternMatch {
76 private Issue fI;
77
78 private IssueEvent fE;
79
80 private static List<String> parameterNames = makeImmutableList("i", "e");
81
82 private Match(final Issue pI, final IssueEvent pE) {
83 this.fI = pI;
84 this.fE = pE;
85 }
86
87 @Override
88 public Object get(final String parameterName) {
89 switch(parameterName) {
90 case "i": return this.fI;
91 case "e": return this.fE;
92 default: return null;
93 }
94 }
95
96 @Override
97 public Object get(final int index) {
98 switch(index) {
99 case 0: return this.fI;
100 case 1: return this.fE;
101 default: return null;
102 }
103 }
104
105 public Issue getI() {
106 return this.fI;
107 }
108
109 public IssueEvent getE() {
110 return this.fE;
111 }
112
113 @Override
114 public boolean set(final String parameterName, final Object newValue) {
115 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
116 if ("i".equals(parameterName) ) {
117 this.fI = (Issue) newValue;
118 return true;
119 }
120 if ("e".equals(parameterName) ) {
121 this.fE = (IssueEvent) newValue;
122 return true;
123 }
124 return false;
125 }
126
127 public void setI(final Issue pI) {
128 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
129 this.fI = pI;
130 }
131
132 public void setE(final IssueEvent pE) {
133 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
134 this.fE = pE;
135 }
136
137 @Override
138 public String patternName() {
139 return "queries.isReopen";
140 }
141
142 @Override
143 public List<String> parameterNames() {
144 return IsReopen.Match.parameterNames;
145 }
146
147 @Override
148 public Object[] toArray() {
149 return new Object[]{fI, fE};
150 }
151
152 @Override
153 public IsReopen.Match toImmutable() {
154 return isMutable() ? newMatch(fI, fE) : this;
155 }
156
157 @Override
158 public String prettyPrint() {
159 StringBuilder result = new StringBuilder();
160 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
161 result.append("\"e\"=" + prettyPrintValue(fE));
162 return result.toString();
163 }
164
165 @Override
166 public int hashCode() {
167 return Objects.hash(fI, fE);
168 }
169
170 @Override
171 public boolean equals(final Object obj) {
172 if (this == obj)
173 return true;
174 if (obj == null) {
175 return false;
176 }
177 if ((obj instanceof IsReopen.Match)) {
178 IsReopen.Match other = (IsReopen.Match) obj;
179 return Objects.equals(fI, other.fI) && Objects.equals(fE, other.fE);
180 } else {
181 // this should be infrequent
182 if (!(obj instanceof IPatternMatch)) {
183 return false;
184 }
185 IPatternMatch otherSig = (IPatternMatch) obj;
186 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
187 }
188 }
189
190 @Override
191 public IsReopen specification() {
192 return IsReopen.instance();
193 }
194
195 /**
196 * Returns an empty, mutable match.
197 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
198 *
199 * @return the empty match.
200 *
201 */
202 public static IsReopen.Match newEmptyMatch() {
203 return new Mutable(null, null);
204 }
205
206 /**
207 * Returns a mutable (partial) match.
208 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
209 *
210 * @param pI the fixed value of pattern parameter i, or null if not bound.
211 * @param pE the fixed value of pattern parameter e, or null if not bound.
212 * @return the new, mutable (partial) match object.
213 *
214 */
215 public static IsReopen.Match newMutableMatch(final Issue pI, final IssueEvent pE) {
216 return new Mutable(pI, pE);
217 }
218
219 /**
220 * Returns a new (partial) match.
221 * This can be used e.g. to call the matcher with a partial match.
222 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
223 * @param pI the fixed value of pattern parameter i, or null if not bound.
224 * @param pE the fixed value of pattern parameter e, or null if not bound.
225 * @return the (partial) match object.
226 *
227 */
228 public static IsReopen.Match newMatch(final Issue pI, final IssueEvent pE) {
229 return new Immutable(pI, pE);
230 }
231
232 private static final class Mutable extends IsReopen.Match {
233 Mutable(final Issue pI, final IssueEvent pE) {
234 super(pI, pE);
235 }
236
237 @Override
238 public boolean isMutable() {
239 return true;
240 }
241 }
242
243 private static final class Immutable extends IsReopen.Match {
244 Immutable(final Issue pI, final IssueEvent pE) {
245 super(pI, pE);
246 }
247
248 @Override
249 public boolean isMutable() {
250 return false;
251 }
252 }
253 }
254
255 /**
256 * Generated pattern matcher API of the queries.isReopen pattern,
257 * providing pattern-specific query methods.
258 *
259 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
260 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
261 *
262 * <p>Matches of the pattern will be represented as {@link Match}.
263 *
264 * <p>Original source:
265 * <code><pre>
266 * pattern isReopen(i: Issue, e: IssueEvent) {
267 * Issue.issueevent(i, e);
268 * IssueEvent.action(e, a);
269 * a == Action::REOPENED;
270 * }
271 * </pre></code>
272 *
273 * @see Match
274 * @see IsReopen
275 *
276 */
277 public static class Matcher extends BaseMatcher<IsReopen.Match> {
278 /**
279 * Initializes the pattern matcher within an existing VIATRA Query engine.
280 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
281 *
282 * @param engine the existing VIATRA Query engine in which this matcher will be created.
283 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
284 *
285 */
286 public static IsReopen.Matcher on(final ViatraQueryEngine engine) {
287 // check if matcher already exists
288 Matcher matcher = engine.getExistingMatcher(querySpecification());
289 if (matcher == null) {
290 matcher = (Matcher)engine.getMatcher(querySpecification());
291 }
292 return matcher;
293 }
294
295 /**
296 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
297 * @return an initialized matcher
298 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
299 *
300 */
301 public static IsReopen.Matcher create() {
302 return new Matcher();
303 }
304
305 private static final int POSITION_I = 0;
306
307 private static final int POSITION_E = 1;
308
309 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IsReopen.Matcher.class);
310
311 /**
312 * Initializes the pattern matcher within an existing VIATRA Query engine.
313 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
314 *
315 * @param engine the existing VIATRA Query engine in which this matcher will be created.
316 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
317 *
318 */
319 private Matcher() {
320 super(querySpecification());
321 }
322
323 /**
324 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
325 * @param pI the fixed value of pattern parameter i, or null if not bound.
326 * @param pE the fixed value of pattern parameter e, or null if not bound.
327 * @return matches represented as a Match object.
328 *
329 */
330 public Collection<IsReopen.Match> getAllMatches(final Issue pI, final IssueEvent pE) {
331 return rawStreamAllMatches(new Object[]{pI, pE}).collect(Collectors.toSet());
332 }
333
334 /**
335 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
336 * </p>
337 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
338 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
339 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
340 * @param pI the fixed value of pattern parameter i, or null if not bound.
341 * @param pE the fixed value of pattern parameter e, or null if not bound.
342 * @return a stream of matches represented as a Match object.
343 *
344 */
345 public Stream<IsReopen.Match> streamAllMatches(final Issue pI, final IssueEvent pE) {
346 return rawStreamAllMatches(new Object[]{pI, pE});
347 }
348
349 /**
350 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
351 * Neither determinism nor randomness of selection is guaranteed.
352 * @param pI the fixed value of pattern parameter i, or null if not bound.
353 * @param pE the fixed value of pattern parameter e, or null if not bound.
354 * @return a match represented as a Match object, or null if no match is found.
355 *
356 */
357 public Optional<IsReopen.Match> getOneArbitraryMatch(final Issue pI, final IssueEvent pE) {
358 return rawGetOneArbitraryMatch(new Object[]{pI, pE});
359 }
360
361 /**
362 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
363 * under any possible substitution of the unspecified parameters (if any).
364 * @param pI the fixed value of pattern parameter i, or null if not bound.
365 * @param pE the fixed value of pattern parameter e, or null if not bound.
366 * @return true if the input is a valid (partial) match of the pattern.
367 *
368 */
369 public boolean hasMatch(final Issue pI, final IssueEvent pE) {
370 return rawHasMatch(new Object[]{pI, pE});
371 }
372
373 /**
374 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
375 * @param pI the fixed value of pattern parameter i, or null if not bound.
376 * @param pE the fixed value of pattern parameter e, or null if not bound.
377 * @return the number of pattern matches found.
378 *
379 */
380 public int countMatches(final Issue pI, final IssueEvent pE) {
381 return rawCountMatches(new Object[]{pI, pE});
382 }
383
384 /**
385 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
386 * Neither determinism nor randomness of selection is guaranteed.
387 * @param pI the fixed value of pattern parameter i, or null if not bound.
388 * @param pE the fixed value of pattern parameter e, or null if not bound.
389 * @param processor the action that will process the selected match.
390 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
391 *
392 */
393 public boolean forOneArbitraryMatch(final Issue pI, final IssueEvent pE, final Consumer<? super IsReopen.Match> processor) {
394 return rawForOneArbitraryMatch(new Object[]{pI, pE}, processor);
395 }
396
397 /**
398 * Returns a new (partial) match.
399 * This can be used e.g. to call the matcher with a partial match.
400 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
401 * @param pI the fixed value of pattern parameter i, or null if not bound.
402 * @param pE the fixed value of pattern parameter e, or null if not bound.
403 * @return the (partial) match object.
404 *
405 */
406 public IsReopen.Match newMatch(final Issue pI, final IssueEvent pE) {
407 return IsReopen.Match.newMatch(pI, pE);
408 }
409
410 /**
411 * Retrieve the set of values that occur in matches for i.
412 * @return the Set of all values or empty set if there are no matches
413 *
414 */
415 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
416 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
417 }
418
419 /**
420 * Retrieve the set of values that occur in matches for i.
421 * @return the Set of all values or empty set if there are no matches
422 *
423 */
424 public Set<Issue> getAllValuesOfi() {
425 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
426 }
427
428 /**
429 * Retrieve the set of values that occur in matches for i.
430 * @return the Set of all values or empty set if there are no matches
431 *
432 */
433 public Stream<Issue> streamAllValuesOfi() {
434 return rawStreamAllValuesOfi(emptyArray());
435 }
436
437 /**
438 * Retrieve the set of values that occur in matches for i.
439 * </p>
440 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
441 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
442 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
443 *
444 * @return the Stream of all values or empty set if there are no matches
445 *
446 */
447 public Stream<Issue> streamAllValuesOfi(final IsReopen.Match partialMatch) {
448 return rawStreamAllValuesOfi(partialMatch.toArray());
449 }
450
451 /**
452 * Retrieve the set of values that occur in matches for i.
453 * </p>
454 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
455 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
456 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
457 *
458 * @return the Stream of all values or empty set if there are no matches
459 *
460 */
461 public Stream<Issue> streamAllValuesOfi(final IssueEvent pE) {
462 return rawStreamAllValuesOfi(new Object[]{null, pE});
463 }
464
465 /**
466 * Retrieve the set of values that occur in matches for i.
467 * @return the Set of all values or empty set if there are no matches
468 *
469 */
470 public Set<Issue> getAllValuesOfi(final IsReopen.Match partialMatch) {
471 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
472 }
473
474 /**
475 * Retrieve the set of values that occur in matches for i.
476 * @return the Set of all values or empty set if there are no matches
477 *
478 */
479 public Set<Issue> getAllValuesOfi(final IssueEvent pE) {
480 return rawStreamAllValuesOfi(new Object[]{null, pE}).collect(Collectors.toSet());
481 }
482
483 /**
484 * Retrieve the set of values that occur in matches for e.
485 * @return the Set of all values or empty set if there are no matches
486 *
487 */
488 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
489 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
490 }
491
492 /**
493 * Retrieve the set of values that occur in matches for e.
494 * @return the Set of all values or empty set if there are no matches
495 *
496 */
497 public Set<IssueEvent> getAllValuesOfe() {
498 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
499 }
500
501 /**
502 * Retrieve the set of values that occur in matches for e.
503 * @return the Set of all values or empty set if there are no matches
504 *
505 */
506 public Stream<IssueEvent> streamAllValuesOfe() {
507 return rawStreamAllValuesOfe(emptyArray());
508 }
509
510 /**
511 * Retrieve the set of values that occur in matches for e.
512 * </p>
513 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
514 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
515 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
516 *
517 * @return the Stream of all values or empty set if there are no matches
518 *
519 */
520 public Stream<IssueEvent> streamAllValuesOfe(final IsReopen.Match partialMatch) {
521 return rawStreamAllValuesOfe(partialMatch.toArray());
522 }
523
524 /**
525 * Retrieve the set of values that occur in matches for e.
526 * </p>
527 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
528 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
529 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
530 *
531 * @return the Stream of all values or empty set if there are no matches
532 *
533 */
534 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI) {
535 return rawStreamAllValuesOfe(new Object[]{pI, null});
536 }
537
538 /**
539 * Retrieve the set of values that occur in matches for e.
540 * @return the Set of all values or empty set if there are no matches
541 *
542 */
543 public Set<IssueEvent> getAllValuesOfe(final IsReopen.Match partialMatch) {
544 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
545 }
546
547 /**
548 * Retrieve the set of values that occur in matches for e.
549 * @return the Set of all values or empty set if there are no matches
550 *
551 */
552 public Set<IssueEvent> getAllValuesOfe(final Issue pI) {
553 return rawStreamAllValuesOfe(new Object[]{pI, null}).collect(Collectors.toSet());
554 }
555
556 @Override
557 protected IsReopen.Match tupleToMatch(final Tuple t) {
558 try {
559 return IsReopen.Match.newMatch((Issue) t.get(POSITION_I), (IssueEvent) t.get(POSITION_E));
560 } catch(ClassCastException e) {
561 LOGGER.error("Element(s) in tuple not properly typed!",e);
562 return null;
563 }
564 }
565
566 @Override
567 protected IsReopen.Match arrayToMatch(final Object[] match) {
568 try {
569 return IsReopen.Match.newMatch((Issue) match[POSITION_I], (IssueEvent) match[POSITION_E]);
570 } catch(ClassCastException e) {
571 LOGGER.error("Element(s) in array not properly typed!",e);
572 return null;
573 }
574 }
575
576 @Override
577 protected IsReopen.Match arrayToMatchMutable(final Object[] match) {
578 try {
579 return IsReopen.Match.newMutableMatch((Issue) match[POSITION_I], (IssueEvent) match[POSITION_E]);
580 } catch(ClassCastException e) {
581 LOGGER.error("Element(s) in array not properly typed!",e);
582 return null;
583 }
584 }
585
586 /**
587 * @return the singleton instance of the query specification of this pattern
588 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
589 *
590 */
591 public static IQuerySpecification<IsReopen.Matcher> querySpecification() {
592 return IsReopen.instance();
593 }
594 }
595
596 private IsReopen() {
597 super(GeneratedPQuery.INSTANCE);
598 }
599
600 /**
601 * @return the singleton instance of the query specification
602 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
603 *
604 */
605 public static IsReopen instance() {
606 try{
607 return LazyHolder.INSTANCE;
608 } catch (ExceptionInInitializerError err) {
609 throw processInitializerError(err);
610 }
611 }
612
613 @Override
614 protected IsReopen.Matcher instantiate(final ViatraQueryEngine engine) {
615 return IsReopen.Matcher.on(engine);
616 }
617
618 @Override
619 public IsReopen.Matcher instantiate() {
620 return IsReopen.Matcher.create();
621 }
622
623 @Override
624 public IsReopen.Match newEmptyMatch() {
625 return IsReopen.Match.newEmptyMatch();
626 }
627
628 @Override
629 public IsReopen.Match newMatch(final Object... parameters) {
630 return IsReopen.Match.newMatch((github.Issue) parameters[0], (github.IssueEvent) parameters[1]);
631 }
632
633 /**
634 * Inner class allowing the singleton instance of {@link IsReopen} to be created
635 * <b>not</b> at the class load time of the outer class,
636 * but rather at the first call to {@link IsReopen#instance()}.
637 *
638 * <p> This workaround is required e.g. to support recursion.
639 *
640 */
641 private static class LazyHolder {
642 private static final IsReopen INSTANCE = new IsReopen();
643
644 /**
645 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
646 * This initialization order is required to support indirect recursion.
647 *
648 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
649 *
650 */
651 private static final Object STATIC_INITIALIZER = ensureInitialized();
652
653 public static Object ensureInitialized() {
654 INSTANCE.ensureInitializedInternal();
655 return null;
656 }
657 }
658
659 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
660 private static final IsReopen.GeneratedPQuery INSTANCE = new GeneratedPQuery();
661
662 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
663
664 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
665
666 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_e);
667
668 private GeneratedPQuery() {
669 super(PVisibility.PUBLIC);
670 }
671
672 @Override
673 public String getFullyQualifiedName() {
674 return "queries.isReopen";
675 }
676
677 @Override
678 public List<String> getParameterNames() {
679 return Arrays.asList("i","e");
680 }
681
682 @Override
683 public List<PParameter> getParameters() {
684 return parameters;
685 }
686
687 @Override
688 public Set<PBody> doGetContainedBodies() {
689 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
690 Set<PBody> bodies = new LinkedHashSet<>();
691 {
692 PBody body = new PBody(this);
693 PVariable var_i = body.getOrCreateVariableByName("i");
694 PVariable var_e = body.getOrCreateVariableByName("e");
695 PVariable var_a = body.getOrCreateVariableByName("a");
696 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
697 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
698 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
699 new ExportedParameter(body, var_i, parameter_i),
700 new ExportedParameter(body, var_e, parameter_e)
701 ));
702 // Issue.issueevent(i, e)
703 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
704 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
705 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
706 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
707 new Equality(body, var__virtual_0_, var_e);
708 // IssueEvent.action(e, a)
709 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
710 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
711 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
712 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
713 new Equality(body, var__virtual_1_, var_a);
714 // a == Action::REOPENED
715 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
716 new ConstantValue(body, var__virtual_2_, getEnumLiteral("sure.ghtorrent.github", "Action", "REOPENED").getInstance());
717 new Equality(body, var_a, var__virtual_2_);
718 bodies.add(body);
719 }
720 return bodies;
721 }
722 }
723}
diff --git a/Domains/github-graph/src-gen/queries/IsSubscribe.java b/Domains/github-graph/src-gen/queries/IsSubscribe.java
new file mode 100644
index 00000000..6ef51558
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/IsSubscribe.java
@@ -0,0 +1,840 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import github.IssueEvent;
8import github.User;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.emf.ecore.EClass;
21import org.eclipse.emf.ecore.EDataType;
22import org.eclipse.viatra.query.runtime.api.IPatternMatch;
23import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
26import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
27import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
28import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
29import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
30import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
31import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
32import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45
46/**
47 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
48 *
49 * <p>Original source:
50 * <code><pre>
51 * pattern isSubscribe(i: Issue, u: User, e: IssueEvent) {
52 * Issue.issueevent(i, e);
53 * IssueEvent.user(e, u);
54 * IssueEvent.action(e, a);
55 * a == Action::SUBSCRIBED;
56 * }
57 * </pre></code>
58 *
59 * @see Matcher
60 * @see Match
61 *
62 */
63@SuppressWarnings("all")
64public final class IsSubscribe extends BaseGeneratedEMFQuerySpecification<IsSubscribe.Matcher> {
65 /**
66 * Pattern-specific match representation of the queries.isSubscribe pattern,
67 * to be used in conjunction with {@link Matcher}.
68 *
69 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
70 * Each instance is a (possibly partial) substitution of pattern parameters,
71 * usable to represent a match of the pattern in the result of a query,
72 * or to specify the bound (fixed) input parameters when issuing a query.
73 *
74 * @see Matcher
75 *
76 */
77 public static abstract class Match extends BasePatternMatch {
78 private Issue fI;
79
80 private User fU;
81
82 private IssueEvent fE;
83
84 private static List<String> parameterNames = makeImmutableList("i", "u", "e");
85
86 private Match(final Issue pI, final User pU, final IssueEvent pE) {
87 this.fI = pI;
88 this.fU = pU;
89 this.fE = pE;
90 }
91
92 @Override
93 public Object get(final String parameterName) {
94 switch(parameterName) {
95 case "i": return this.fI;
96 case "u": return this.fU;
97 case "e": return this.fE;
98 default: return null;
99 }
100 }
101
102 @Override
103 public Object get(final int index) {
104 switch(index) {
105 case 0: return this.fI;
106 case 1: return this.fU;
107 case 2: return this.fE;
108 default: return null;
109 }
110 }
111
112 public Issue getI() {
113 return this.fI;
114 }
115
116 public User getU() {
117 return this.fU;
118 }
119
120 public IssueEvent getE() {
121 return this.fE;
122 }
123
124 @Override
125 public boolean set(final String parameterName, final Object newValue) {
126 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
127 if ("i".equals(parameterName) ) {
128 this.fI = (Issue) newValue;
129 return true;
130 }
131 if ("u".equals(parameterName) ) {
132 this.fU = (User) newValue;
133 return true;
134 }
135 if ("e".equals(parameterName) ) {
136 this.fE = (IssueEvent) newValue;
137 return true;
138 }
139 return false;
140 }
141
142 public void setI(final Issue pI) {
143 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
144 this.fI = pI;
145 }
146
147 public void setU(final User pU) {
148 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
149 this.fU = pU;
150 }
151
152 public void setE(final IssueEvent pE) {
153 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
154 this.fE = pE;
155 }
156
157 @Override
158 public String patternName() {
159 return "queries.isSubscribe";
160 }
161
162 @Override
163 public List<String> parameterNames() {
164 return IsSubscribe.Match.parameterNames;
165 }
166
167 @Override
168 public Object[] toArray() {
169 return new Object[]{fI, fU, fE};
170 }
171
172 @Override
173 public IsSubscribe.Match toImmutable() {
174 return isMutable() ? newMatch(fI, fU, fE) : this;
175 }
176
177 @Override
178 public String prettyPrint() {
179 StringBuilder result = new StringBuilder();
180 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
181 result.append("\"u\"=" + prettyPrintValue(fU) + ", ");
182 result.append("\"e\"=" + prettyPrintValue(fE));
183 return result.toString();
184 }
185
186 @Override
187 public int hashCode() {
188 return Objects.hash(fI, fU, fE);
189 }
190
191 @Override
192 public boolean equals(final Object obj) {
193 if (this == obj)
194 return true;
195 if (obj == null) {
196 return false;
197 }
198 if ((obj instanceof IsSubscribe.Match)) {
199 IsSubscribe.Match other = (IsSubscribe.Match) obj;
200 return Objects.equals(fI, other.fI) && Objects.equals(fU, other.fU) && Objects.equals(fE, other.fE);
201 } else {
202 // this should be infrequent
203 if (!(obj instanceof IPatternMatch)) {
204 return false;
205 }
206 IPatternMatch otherSig = (IPatternMatch) obj;
207 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
208 }
209 }
210
211 @Override
212 public IsSubscribe specification() {
213 return IsSubscribe.instance();
214 }
215
216 /**
217 * Returns an empty, mutable match.
218 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
219 *
220 * @return the empty match.
221 *
222 */
223 public static IsSubscribe.Match newEmptyMatch() {
224 return new Mutable(null, null, null);
225 }
226
227 /**
228 * Returns a mutable (partial) match.
229 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
230 *
231 * @param pI the fixed value of pattern parameter i, or null if not bound.
232 * @param pU the fixed value of pattern parameter u, or null if not bound.
233 * @param pE the fixed value of pattern parameter e, or null if not bound.
234 * @return the new, mutable (partial) match object.
235 *
236 */
237 public static IsSubscribe.Match newMutableMatch(final Issue pI, final User pU, final IssueEvent pE) {
238 return new Mutable(pI, pU, pE);
239 }
240
241 /**
242 * Returns a new (partial) match.
243 * This can be used e.g. to call the matcher with a partial match.
244 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
245 * @param pI the fixed value of pattern parameter i, or null if not bound.
246 * @param pU the fixed value of pattern parameter u, or null if not bound.
247 * @param pE the fixed value of pattern parameter e, or null if not bound.
248 * @return the (partial) match object.
249 *
250 */
251 public static IsSubscribe.Match newMatch(final Issue pI, final User pU, final IssueEvent pE) {
252 return new Immutable(pI, pU, pE);
253 }
254
255 private static final class Mutable extends IsSubscribe.Match {
256 Mutable(final Issue pI, final User pU, final IssueEvent pE) {
257 super(pI, pU, pE);
258 }
259
260 @Override
261 public boolean isMutable() {
262 return true;
263 }
264 }
265
266 private static final class Immutable extends IsSubscribe.Match {
267 Immutable(final Issue pI, final User pU, final IssueEvent pE) {
268 super(pI, pU, pE);
269 }
270
271 @Override
272 public boolean isMutable() {
273 return false;
274 }
275 }
276 }
277
278 /**
279 * Generated pattern matcher API of the queries.isSubscribe pattern,
280 * providing pattern-specific query methods.
281 *
282 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
283 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
284 *
285 * <p>Matches of the pattern will be represented as {@link Match}.
286 *
287 * <p>Original source:
288 * <code><pre>
289 * pattern isSubscribe(i: Issue, u: User, e: IssueEvent) {
290 * Issue.issueevent(i, e);
291 * IssueEvent.user(e, u);
292 * IssueEvent.action(e, a);
293 * a == Action::SUBSCRIBED;
294 * }
295 * </pre></code>
296 *
297 * @see Match
298 * @see IsSubscribe
299 *
300 */
301 public static class Matcher extends BaseMatcher<IsSubscribe.Match> {
302 /**
303 * Initializes the pattern matcher within an existing VIATRA Query engine.
304 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
305 *
306 * @param engine the existing VIATRA Query engine in which this matcher will be created.
307 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
308 *
309 */
310 public static IsSubscribe.Matcher on(final ViatraQueryEngine engine) {
311 // check if matcher already exists
312 Matcher matcher = engine.getExistingMatcher(querySpecification());
313 if (matcher == null) {
314 matcher = (Matcher)engine.getMatcher(querySpecification());
315 }
316 return matcher;
317 }
318
319 /**
320 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
321 * @return an initialized matcher
322 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
323 *
324 */
325 public static IsSubscribe.Matcher create() {
326 return new Matcher();
327 }
328
329 private static final int POSITION_I = 0;
330
331 private static final int POSITION_U = 1;
332
333 private static final int POSITION_E = 2;
334
335 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IsSubscribe.Matcher.class);
336
337 /**
338 * Initializes the pattern matcher within an existing VIATRA Query engine.
339 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
340 *
341 * @param engine the existing VIATRA Query engine in which this matcher will be created.
342 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
343 *
344 */
345 private Matcher() {
346 super(querySpecification());
347 }
348
349 /**
350 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
351 * @param pI the fixed value of pattern parameter i, or null if not bound.
352 * @param pU the fixed value of pattern parameter u, or null if not bound.
353 * @param pE the fixed value of pattern parameter e, or null if not bound.
354 * @return matches represented as a Match object.
355 *
356 */
357 public Collection<IsSubscribe.Match> getAllMatches(final Issue pI, final User pU, final IssueEvent pE) {
358 return rawStreamAllMatches(new Object[]{pI, pU, pE}).collect(Collectors.toSet());
359 }
360
361 /**
362 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
363 * </p>
364 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
365 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
366 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
367 * @param pI the fixed value of pattern parameter i, or null if not bound.
368 * @param pU the fixed value of pattern parameter u, or null if not bound.
369 * @param pE the fixed value of pattern parameter e, or null if not bound.
370 * @return a stream of matches represented as a Match object.
371 *
372 */
373 public Stream<IsSubscribe.Match> streamAllMatches(final Issue pI, final User pU, final IssueEvent pE) {
374 return rawStreamAllMatches(new Object[]{pI, pU, pE});
375 }
376
377 /**
378 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
379 * Neither determinism nor randomness of selection is guaranteed.
380 * @param pI the fixed value of pattern parameter i, or null if not bound.
381 * @param pU the fixed value of pattern parameter u, or null if not bound.
382 * @param pE the fixed value of pattern parameter e, or null if not bound.
383 * @return a match represented as a Match object, or null if no match is found.
384 *
385 */
386 public Optional<IsSubscribe.Match> getOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE) {
387 return rawGetOneArbitraryMatch(new Object[]{pI, pU, pE});
388 }
389
390 /**
391 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
392 * under any possible substitution of the unspecified parameters (if any).
393 * @param pI the fixed value of pattern parameter i, or null if not bound.
394 * @param pU the fixed value of pattern parameter u, or null if not bound.
395 * @param pE the fixed value of pattern parameter e, or null if not bound.
396 * @return true if the input is a valid (partial) match of the pattern.
397 *
398 */
399 public boolean hasMatch(final Issue pI, final User pU, final IssueEvent pE) {
400 return rawHasMatch(new Object[]{pI, pU, pE});
401 }
402
403 /**
404 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
405 * @param pI the fixed value of pattern parameter i, or null if not bound.
406 * @param pU the fixed value of pattern parameter u, or null if not bound.
407 * @param pE the fixed value of pattern parameter e, or null if not bound.
408 * @return the number of pattern matches found.
409 *
410 */
411 public int countMatches(final Issue pI, final User pU, final IssueEvent pE) {
412 return rawCountMatches(new Object[]{pI, pU, pE});
413 }
414
415 /**
416 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
417 * Neither determinism nor randomness of selection is guaranteed.
418 * @param pI the fixed value of pattern parameter i, or null if not bound.
419 * @param pU the fixed value of pattern parameter u, or null if not bound.
420 * @param pE the fixed value of pattern parameter e, or null if not bound.
421 * @param processor the action that will process the selected match.
422 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
423 *
424 */
425 public boolean forOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE, final Consumer<? super IsSubscribe.Match> processor) {
426 return rawForOneArbitraryMatch(new Object[]{pI, pU, pE}, processor);
427 }
428
429 /**
430 * Returns a new (partial) match.
431 * This can be used e.g. to call the matcher with a partial match.
432 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
433 * @param pI the fixed value of pattern parameter i, or null if not bound.
434 * @param pU the fixed value of pattern parameter u, or null if not bound.
435 * @param pE the fixed value of pattern parameter e, or null if not bound.
436 * @return the (partial) match object.
437 *
438 */
439 public IsSubscribe.Match newMatch(final Issue pI, final User pU, final IssueEvent pE) {
440 return IsSubscribe.Match.newMatch(pI, pU, pE);
441 }
442
443 /**
444 * Retrieve the set of values that occur in matches for i.
445 * @return the Set of all values or empty set if there are no matches
446 *
447 */
448 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
449 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
450 }
451
452 /**
453 * Retrieve the set of values that occur in matches for i.
454 * @return the Set of all values or empty set if there are no matches
455 *
456 */
457 public Set<Issue> getAllValuesOfi() {
458 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
459 }
460
461 /**
462 * Retrieve the set of values that occur in matches for i.
463 * @return the Set of all values or empty set if there are no matches
464 *
465 */
466 public Stream<Issue> streamAllValuesOfi() {
467 return rawStreamAllValuesOfi(emptyArray());
468 }
469
470 /**
471 * Retrieve the set of values that occur in matches for i.
472 * </p>
473 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
474 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
475 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
476 *
477 * @return the Stream of all values or empty set if there are no matches
478 *
479 */
480 public Stream<Issue> streamAllValuesOfi(final IsSubscribe.Match partialMatch) {
481 return rawStreamAllValuesOfi(partialMatch.toArray());
482 }
483
484 /**
485 * Retrieve the set of values that occur in matches for i.
486 * </p>
487 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
488 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
489 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
490 *
491 * @return the Stream of all values or empty set if there are no matches
492 *
493 */
494 public Stream<Issue> streamAllValuesOfi(final User pU, final IssueEvent pE) {
495 return rawStreamAllValuesOfi(new Object[]{null, pU, pE});
496 }
497
498 /**
499 * Retrieve the set of values that occur in matches for i.
500 * @return the Set of all values or empty set if there are no matches
501 *
502 */
503 public Set<Issue> getAllValuesOfi(final IsSubscribe.Match partialMatch) {
504 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
505 }
506
507 /**
508 * Retrieve the set of values that occur in matches for i.
509 * @return the Set of all values or empty set if there are no matches
510 *
511 */
512 public Set<Issue> getAllValuesOfi(final User pU, final IssueEvent pE) {
513 return rawStreamAllValuesOfi(new Object[]{null, pU, pE}).collect(Collectors.toSet());
514 }
515
516 /**
517 * Retrieve the set of values that occur in matches for u.
518 * @return the Set of all values or empty set if there are no matches
519 *
520 */
521 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
522 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
523 }
524
525 /**
526 * Retrieve the set of values that occur in matches for u.
527 * @return the Set of all values or empty set if there are no matches
528 *
529 */
530 public Set<User> getAllValuesOfu() {
531 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
532 }
533
534 /**
535 * Retrieve the set of values that occur in matches for u.
536 * @return the Set of all values or empty set if there are no matches
537 *
538 */
539 public Stream<User> streamAllValuesOfu() {
540 return rawStreamAllValuesOfu(emptyArray());
541 }
542
543 /**
544 * Retrieve the set of values that occur in matches for u.
545 * </p>
546 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
547 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
548 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
549 *
550 * @return the Stream of all values or empty set if there are no matches
551 *
552 */
553 public Stream<User> streamAllValuesOfu(final IsSubscribe.Match partialMatch) {
554 return rawStreamAllValuesOfu(partialMatch.toArray());
555 }
556
557 /**
558 * Retrieve the set of values that occur in matches for u.
559 * </p>
560 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
561 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
562 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
563 *
564 * @return the Stream of all values or empty set if there are no matches
565 *
566 */
567 public Stream<User> streamAllValuesOfu(final Issue pI, final IssueEvent pE) {
568 return rawStreamAllValuesOfu(new Object[]{pI, null, pE});
569 }
570
571 /**
572 * Retrieve the set of values that occur in matches for u.
573 * @return the Set of all values or empty set if there are no matches
574 *
575 */
576 public Set<User> getAllValuesOfu(final IsSubscribe.Match partialMatch) {
577 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
578 }
579
580 /**
581 * Retrieve the set of values that occur in matches for u.
582 * @return the Set of all values or empty set if there are no matches
583 *
584 */
585 public Set<User> getAllValuesOfu(final Issue pI, final IssueEvent pE) {
586 return rawStreamAllValuesOfu(new Object[]{pI, null, pE}).collect(Collectors.toSet());
587 }
588
589 /**
590 * Retrieve the set of values that occur in matches for e.
591 * @return the Set of all values or empty set if there are no matches
592 *
593 */
594 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
595 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
596 }
597
598 /**
599 * Retrieve the set of values that occur in matches for e.
600 * @return the Set of all values or empty set if there are no matches
601 *
602 */
603 public Set<IssueEvent> getAllValuesOfe() {
604 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
605 }
606
607 /**
608 * Retrieve the set of values that occur in matches for e.
609 * @return the Set of all values or empty set if there are no matches
610 *
611 */
612 public Stream<IssueEvent> streamAllValuesOfe() {
613 return rawStreamAllValuesOfe(emptyArray());
614 }
615
616 /**
617 * Retrieve the set of values that occur in matches for e.
618 * </p>
619 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
620 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
621 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
622 *
623 * @return the Stream of all values or empty set if there are no matches
624 *
625 */
626 public Stream<IssueEvent> streamAllValuesOfe(final IsSubscribe.Match partialMatch) {
627 return rawStreamAllValuesOfe(partialMatch.toArray());
628 }
629
630 /**
631 * Retrieve the set of values that occur in matches for e.
632 * </p>
633 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
634 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
635 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
636 *
637 * @return the Stream of all values or empty set if there are no matches
638 *
639 */
640 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI, final User pU) {
641 return rawStreamAllValuesOfe(new Object[]{pI, pU, null});
642 }
643
644 /**
645 * Retrieve the set of values that occur in matches for e.
646 * @return the Set of all values or empty set if there are no matches
647 *
648 */
649 public Set<IssueEvent> getAllValuesOfe(final IsSubscribe.Match partialMatch) {
650 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
651 }
652
653 /**
654 * Retrieve the set of values that occur in matches for e.
655 * @return the Set of all values or empty set if there are no matches
656 *
657 */
658 public Set<IssueEvent> getAllValuesOfe(final Issue pI, final User pU) {
659 return rawStreamAllValuesOfe(new Object[]{pI, pU, null}).collect(Collectors.toSet());
660 }
661
662 @Override
663 protected IsSubscribe.Match tupleToMatch(final Tuple t) {
664 try {
665 return IsSubscribe.Match.newMatch((Issue) t.get(POSITION_I), (User) t.get(POSITION_U), (IssueEvent) t.get(POSITION_E));
666 } catch(ClassCastException e) {
667 LOGGER.error("Element(s) in tuple not properly typed!",e);
668 return null;
669 }
670 }
671
672 @Override
673 protected IsSubscribe.Match arrayToMatch(final Object[] match) {
674 try {
675 return IsSubscribe.Match.newMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E]);
676 } catch(ClassCastException e) {
677 LOGGER.error("Element(s) in array not properly typed!",e);
678 return null;
679 }
680 }
681
682 @Override
683 protected IsSubscribe.Match arrayToMatchMutable(final Object[] match) {
684 try {
685 return IsSubscribe.Match.newMutableMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E]);
686 } catch(ClassCastException e) {
687 LOGGER.error("Element(s) in array not properly typed!",e);
688 return null;
689 }
690 }
691
692 /**
693 * @return the singleton instance of the query specification of this pattern
694 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
695 *
696 */
697 public static IQuerySpecification<IsSubscribe.Matcher> querySpecification() {
698 return IsSubscribe.instance();
699 }
700 }
701
702 private IsSubscribe() {
703 super(GeneratedPQuery.INSTANCE);
704 }
705
706 /**
707 * @return the singleton instance of the query specification
708 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
709 *
710 */
711 public static IsSubscribe instance() {
712 try{
713 return LazyHolder.INSTANCE;
714 } catch (ExceptionInInitializerError err) {
715 throw processInitializerError(err);
716 }
717 }
718
719 @Override
720 protected IsSubscribe.Matcher instantiate(final ViatraQueryEngine engine) {
721 return IsSubscribe.Matcher.on(engine);
722 }
723
724 @Override
725 public IsSubscribe.Matcher instantiate() {
726 return IsSubscribe.Matcher.create();
727 }
728
729 @Override
730 public IsSubscribe.Match newEmptyMatch() {
731 return IsSubscribe.Match.newEmptyMatch();
732 }
733
734 @Override
735 public IsSubscribe.Match newMatch(final Object... parameters) {
736 return IsSubscribe.Match.newMatch((github.Issue) parameters[0], (github.User) parameters[1], (github.IssueEvent) parameters[2]);
737 }
738
739 /**
740 * Inner class allowing the singleton instance of {@link IsSubscribe} to be created
741 * <b>not</b> at the class load time of the outer class,
742 * but rather at the first call to {@link IsSubscribe#instance()}.
743 *
744 * <p> This workaround is required e.g. to support recursion.
745 *
746 */
747 private static class LazyHolder {
748 private static final IsSubscribe INSTANCE = new IsSubscribe();
749
750 /**
751 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
752 * This initialization order is required to support indirect recursion.
753 *
754 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
755 *
756 */
757 private static final Object STATIC_INITIALIZER = ensureInitialized();
758
759 public static Object ensureInitialized() {
760 INSTANCE.ensureInitializedInternal();
761 return null;
762 }
763 }
764
765 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
766 private static final IsSubscribe.GeneratedPQuery INSTANCE = new GeneratedPQuery();
767
768 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
769
770 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
771
772 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
773
774 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_u, parameter_e);
775
776 private GeneratedPQuery() {
777 super(PVisibility.PUBLIC);
778 }
779
780 @Override
781 public String getFullyQualifiedName() {
782 return "queries.isSubscribe";
783 }
784
785 @Override
786 public List<String> getParameterNames() {
787 return Arrays.asList("i","u","e");
788 }
789
790 @Override
791 public List<PParameter> getParameters() {
792 return parameters;
793 }
794
795 @Override
796 public Set<PBody> doGetContainedBodies() {
797 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
798 Set<PBody> bodies = new LinkedHashSet<>();
799 {
800 PBody body = new PBody(this);
801 PVariable var_i = body.getOrCreateVariableByName("i");
802 PVariable var_u = body.getOrCreateVariableByName("u");
803 PVariable var_e = body.getOrCreateVariableByName("e");
804 PVariable var_a = body.getOrCreateVariableByName("a");
805 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
806 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
807 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
808 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
809 new ExportedParameter(body, var_i, parameter_i),
810 new ExportedParameter(body, var_u, parameter_u),
811 new ExportedParameter(body, var_e, parameter_e)
812 ));
813 // Issue.issueevent(i, e)
814 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
815 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
816 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
817 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
818 new Equality(body, var__virtual_0_, var_e);
819 // IssueEvent.user(e, u)
820 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
821 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
822 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "user")));
823 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
824 new Equality(body, var__virtual_1_, var_u);
825 // IssueEvent.action(e, a)
826 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
827 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
828 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
829 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
830 new Equality(body, var__virtual_2_, var_a);
831 // a == Action::SUBSCRIBED
832 PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
833 new ConstantValue(body, var__virtual_3_, getEnumLiteral("sure.ghtorrent.github", "Action", "SUBSCRIBED").getInstance());
834 new Equality(body, var_a, var__virtual_3_);
835 bodies.add(body);
836 }
837 return bodies;
838 }
839 }
840}
diff --git a/Domains/github-graph/src-gen/queries/IsUnSubscribe.java b/Domains/github-graph/src-gen/queries/IsUnSubscribe.java
new file mode 100644
index 00000000..0e4e0a30
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/IsUnSubscribe.java
@@ -0,0 +1,840 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Issue;
7import github.IssueEvent;
8import github.User;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.emf.ecore.EClass;
21import org.eclipse.emf.ecore.EDataType;
22import org.eclipse.viatra.query.runtime.api.IPatternMatch;
23import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
26import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
27import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
28import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
29import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
30import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
31import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
32import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45
46/**
47 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
48 *
49 * <p>Original source:
50 * <code><pre>
51 * pattern isUnSubscribe(i: Issue, u: User, e: IssueEvent) {
52 * Issue.issueevent(i, e);
53 * IssueEvent.user(e, u);
54 * IssueEvent.action(e, a);
55 * a == Action::UNSUBSCRIBED;
56 * }
57 * </pre></code>
58 *
59 * @see Matcher
60 * @see Match
61 *
62 */
63@SuppressWarnings("all")
64public final class IsUnSubscribe extends BaseGeneratedEMFQuerySpecification<IsUnSubscribe.Matcher> {
65 /**
66 * Pattern-specific match representation of the queries.isUnSubscribe pattern,
67 * to be used in conjunction with {@link Matcher}.
68 *
69 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
70 * Each instance is a (possibly partial) substitution of pattern parameters,
71 * usable to represent a match of the pattern in the result of a query,
72 * or to specify the bound (fixed) input parameters when issuing a query.
73 *
74 * @see Matcher
75 *
76 */
77 public static abstract class Match extends BasePatternMatch {
78 private Issue fI;
79
80 private User fU;
81
82 private IssueEvent fE;
83
84 private static List<String> parameterNames = makeImmutableList("i", "u", "e");
85
86 private Match(final Issue pI, final User pU, final IssueEvent pE) {
87 this.fI = pI;
88 this.fU = pU;
89 this.fE = pE;
90 }
91
92 @Override
93 public Object get(final String parameterName) {
94 switch(parameterName) {
95 case "i": return this.fI;
96 case "u": return this.fU;
97 case "e": return this.fE;
98 default: return null;
99 }
100 }
101
102 @Override
103 public Object get(final int index) {
104 switch(index) {
105 case 0: return this.fI;
106 case 1: return this.fU;
107 case 2: return this.fE;
108 default: return null;
109 }
110 }
111
112 public Issue getI() {
113 return this.fI;
114 }
115
116 public User getU() {
117 return this.fU;
118 }
119
120 public IssueEvent getE() {
121 return this.fE;
122 }
123
124 @Override
125 public boolean set(final String parameterName, final Object newValue) {
126 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
127 if ("i".equals(parameterName) ) {
128 this.fI = (Issue) newValue;
129 return true;
130 }
131 if ("u".equals(parameterName) ) {
132 this.fU = (User) newValue;
133 return true;
134 }
135 if ("e".equals(parameterName) ) {
136 this.fE = (IssueEvent) newValue;
137 return true;
138 }
139 return false;
140 }
141
142 public void setI(final Issue pI) {
143 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
144 this.fI = pI;
145 }
146
147 public void setU(final User pU) {
148 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
149 this.fU = pU;
150 }
151
152 public void setE(final IssueEvent pE) {
153 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
154 this.fE = pE;
155 }
156
157 @Override
158 public String patternName() {
159 return "queries.isUnSubscribe";
160 }
161
162 @Override
163 public List<String> parameterNames() {
164 return IsUnSubscribe.Match.parameterNames;
165 }
166
167 @Override
168 public Object[] toArray() {
169 return new Object[]{fI, fU, fE};
170 }
171
172 @Override
173 public IsUnSubscribe.Match toImmutable() {
174 return isMutable() ? newMatch(fI, fU, fE) : this;
175 }
176
177 @Override
178 public String prettyPrint() {
179 StringBuilder result = new StringBuilder();
180 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
181 result.append("\"u\"=" + prettyPrintValue(fU) + ", ");
182 result.append("\"e\"=" + prettyPrintValue(fE));
183 return result.toString();
184 }
185
186 @Override
187 public int hashCode() {
188 return Objects.hash(fI, fU, fE);
189 }
190
191 @Override
192 public boolean equals(final Object obj) {
193 if (this == obj)
194 return true;
195 if (obj == null) {
196 return false;
197 }
198 if ((obj instanceof IsUnSubscribe.Match)) {
199 IsUnSubscribe.Match other = (IsUnSubscribe.Match) obj;
200 return Objects.equals(fI, other.fI) && Objects.equals(fU, other.fU) && Objects.equals(fE, other.fE);
201 } else {
202 // this should be infrequent
203 if (!(obj instanceof IPatternMatch)) {
204 return false;
205 }
206 IPatternMatch otherSig = (IPatternMatch) obj;
207 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
208 }
209 }
210
211 @Override
212 public IsUnSubscribe specification() {
213 return IsUnSubscribe.instance();
214 }
215
216 /**
217 * Returns an empty, mutable match.
218 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
219 *
220 * @return the empty match.
221 *
222 */
223 public static IsUnSubscribe.Match newEmptyMatch() {
224 return new Mutable(null, null, null);
225 }
226
227 /**
228 * Returns a mutable (partial) match.
229 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
230 *
231 * @param pI the fixed value of pattern parameter i, or null if not bound.
232 * @param pU the fixed value of pattern parameter u, or null if not bound.
233 * @param pE the fixed value of pattern parameter e, or null if not bound.
234 * @return the new, mutable (partial) match object.
235 *
236 */
237 public static IsUnSubscribe.Match newMutableMatch(final Issue pI, final User pU, final IssueEvent pE) {
238 return new Mutable(pI, pU, pE);
239 }
240
241 /**
242 * Returns a new (partial) match.
243 * This can be used e.g. to call the matcher with a partial match.
244 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
245 * @param pI the fixed value of pattern parameter i, or null if not bound.
246 * @param pU the fixed value of pattern parameter u, or null if not bound.
247 * @param pE the fixed value of pattern parameter e, or null if not bound.
248 * @return the (partial) match object.
249 *
250 */
251 public static IsUnSubscribe.Match newMatch(final Issue pI, final User pU, final IssueEvent pE) {
252 return new Immutable(pI, pU, pE);
253 }
254
255 private static final class Mutable extends IsUnSubscribe.Match {
256 Mutable(final Issue pI, final User pU, final IssueEvent pE) {
257 super(pI, pU, pE);
258 }
259
260 @Override
261 public boolean isMutable() {
262 return true;
263 }
264 }
265
266 private static final class Immutable extends IsUnSubscribe.Match {
267 Immutable(final Issue pI, final User pU, final IssueEvent pE) {
268 super(pI, pU, pE);
269 }
270
271 @Override
272 public boolean isMutable() {
273 return false;
274 }
275 }
276 }
277
278 /**
279 * Generated pattern matcher API of the queries.isUnSubscribe pattern,
280 * providing pattern-specific query methods.
281 *
282 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
283 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
284 *
285 * <p>Matches of the pattern will be represented as {@link Match}.
286 *
287 * <p>Original source:
288 * <code><pre>
289 * pattern isUnSubscribe(i: Issue, u: User, e: IssueEvent) {
290 * Issue.issueevent(i, e);
291 * IssueEvent.user(e, u);
292 * IssueEvent.action(e, a);
293 * a == Action::UNSUBSCRIBED;
294 * }
295 * </pre></code>
296 *
297 * @see Match
298 * @see IsUnSubscribe
299 *
300 */
301 public static class Matcher extends BaseMatcher<IsUnSubscribe.Match> {
302 /**
303 * Initializes the pattern matcher within an existing VIATRA Query engine.
304 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
305 *
306 * @param engine the existing VIATRA Query engine in which this matcher will be created.
307 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
308 *
309 */
310 public static IsUnSubscribe.Matcher on(final ViatraQueryEngine engine) {
311 // check if matcher already exists
312 Matcher matcher = engine.getExistingMatcher(querySpecification());
313 if (matcher == null) {
314 matcher = (Matcher)engine.getMatcher(querySpecification());
315 }
316 return matcher;
317 }
318
319 /**
320 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
321 * @return an initialized matcher
322 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
323 *
324 */
325 public static IsUnSubscribe.Matcher create() {
326 return new Matcher();
327 }
328
329 private static final int POSITION_I = 0;
330
331 private static final int POSITION_U = 1;
332
333 private static final int POSITION_E = 2;
334
335 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IsUnSubscribe.Matcher.class);
336
337 /**
338 * Initializes the pattern matcher within an existing VIATRA Query engine.
339 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
340 *
341 * @param engine the existing VIATRA Query engine in which this matcher will be created.
342 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
343 *
344 */
345 private Matcher() {
346 super(querySpecification());
347 }
348
349 /**
350 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
351 * @param pI the fixed value of pattern parameter i, or null if not bound.
352 * @param pU the fixed value of pattern parameter u, or null if not bound.
353 * @param pE the fixed value of pattern parameter e, or null if not bound.
354 * @return matches represented as a Match object.
355 *
356 */
357 public Collection<IsUnSubscribe.Match> getAllMatches(final Issue pI, final User pU, final IssueEvent pE) {
358 return rawStreamAllMatches(new Object[]{pI, pU, pE}).collect(Collectors.toSet());
359 }
360
361 /**
362 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
363 * </p>
364 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
365 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
366 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
367 * @param pI the fixed value of pattern parameter i, or null if not bound.
368 * @param pU the fixed value of pattern parameter u, or null if not bound.
369 * @param pE the fixed value of pattern parameter e, or null if not bound.
370 * @return a stream of matches represented as a Match object.
371 *
372 */
373 public Stream<IsUnSubscribe.Match> streamAllMatches(final Issue pI, final User pU, final IssueEvent pE) {
374 return rawStreamAllMatches(new Object[]{pI, pU, pE});
375 }
376
377 /**
378 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
379 * Neither determinism nor randomness of selection is guaranteed.
380 * @param pI the fixed value of pattern parameter i, or null if not bound.
381 * @param pU the fixed value of pattern parameter u, or null if not bound.
382 * @param pE the fixed value of pattern parameter e, or null if not bound.
383 * @return a match represented as a Match object, or null if no match is found.
384 *
385 */
386 public Optional<IsUnSubscribe.Match> getOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE) {
387 return rawGetOneArbitraryMatch(new Object[]{pI, pU, pE});
388 }
389
390 /**
391 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
392 * under any possible substitution of the unspecified parameters (if any).
393 * @param pI the fixed value of pattern parameter i, or null if not bound.
394 * @param pU the fixed value of pattern parameter u, or null if not bound.
395 * @param pE the fixed value of pattern parameter e, or null if not bound.
396 * @return true if the input is a valid (partial) match of the pattern.
397 *
398 */
399 public boolean hasMatch(final Issue pI, final User pU, final IssueEvent pE) {
400 return rawHasMatch(new Object[]{pI, pU, pE});
401 }
402
403 /**
404 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
405 * @param pI the fixed value of pattern parameter i, or null if not bound.
406 * @param pU the fixed value of pattern parameter u, or null if not bound.
407 * @param pE the fixed value of pattern parameter e, or null if not bound.
408 * @return the number of pattern matches found.
409 *
410 */
411 public int countMatches(final Issue pI, final User pU, final IssueEvent pE) {
412 return rawCountMatches(new Object[]{pI, pU, pE});
413 }
414
415 /**
416 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
417 * Neither determinism nor randomness of selection is guaranteed.
418 * @param pI the fixed value of pattern parameter i, or null if not bound.
419 * @param pU the fixed value of pattern parameter u, or null if not bound.
420 * @param pE the fixed value of pattern parameter e, or null if not bound.
421 * @param processor the action that will process the selected match.
422 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
423 *
424 */
425 public boolean forOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE, final Consumer<? super IsUnSubscribe.Match> processor) {
426 return rawForOneArbitraryMatch(new Object[]{pI, pU, pE}, processor);
427 }
428
429 /**
430 * Returns a new (partial) match.
431 * This can be used e.g. to call the matcher with a partial match.
432 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
433 * @param pI the fixed value of pattern parameter i, or null if not bound.
434 * @param pU the fixed value of pattern parameter u, or null if not bound.
435 * @param pE the fixed value of pattern parameter e, or null if not bound.
436 * @return the (partial) match object.
437 *
438 */
439 public IsUnSubscribe.Match newMatch(final Issue pI, final User pU, final IssueEvent pE) {
440 return IsUnSubscribe.Match.newMatch(pI, pU, pE);
441 }
442
443 /**
444 * Retrieve the set of values that occur in matches for i.
445 * @return the Set of all values or empty set if there are no matches
446 *
447 */
448 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
449 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
450 }
451
452 /**
453 * Retrieve the set of values that occur in matches for i.
454 * @return the Set of all values or empty set if there are no matches
455 *
456 */
457 public Set<Issue> getAllValuesOfi() {
458 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
459 }
460
461 /**
462 * Retrieve the set of values that occur in matches for i.
463 * @return the Set of all values or empty set if there are no matches
464 *
465 */
466 public Stream<Issue> streamAllValuesOfi() {
467 return rawStreamAllValuesOfi(emptyArray());
468 }
469
470 /**
471 * Retrieve the set of values that occur in matches for i.
472 * </p>
473 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
474 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
475 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
476 *
477 * @return the Stream of all values or empty set if there are no matches
478 *
479 */
480 public Stream<Issue> streamAllValuesOfi(final IsUnSubscribe.Match partialMatch) {
481 return rawStreamAllValuesOfi(partialMatch.toArray());
482 }
483
484 /**
485 * Retrieve the set of values that occur in matches for i.
486 * </p>
487 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
488 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
489 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
490 *
491 * @return the Stream of all values or empty set if there are no matches
492 *
493 */
494 public Stream<Issue> streamAllValuesOfi(final User pU, final IssueEvent pE) {
495 return rawStreamAllValuesOfi(new Object[]{null, pU, pE});
496 }
497
498 /**
499 * Retrieve the set of values that occur in matches for i.
500 * @return the Set of all values or empty set if there are no matches
501 *
502 */
503 public Set<Issue> getAllValuesOfi(final IsUnSubscribe.Match partialMatch) {
504 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
505 }
506
507 /**
508 * Retrieve the set of values that occur in matches for i.
509 * @return the Set of all values or empty set if there are no matches
510 *
511 */
512 public Set<Issue> getAllValuesOfi(final User pU, final IssueEvent pE) {
513 return rawStreamAllValuesOfi(new Object[]{null, pU, pE}).collect(Collectors.toSet());
514 }
515
516 /**
517 * Retrieve the set of values that occur in matches for u.
518 * @return the Set of all values or empty set if there are no matches
519 *
520 */
521 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
522 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
523 }
524
525 /**
526 * Retrieve the set of values that occur in matches for u.
527 * @return the Set of all values or empty set if there are no matches
528 *
529 */
530 public Set<User> getAllValuesOfu() {
531 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
532 }
533
534 /**
535 * Retrieve the set of values that occur in matches for u.
536 * @return the Set of all values or empty set if there are no matches
537 *
538 */
539 public Stream<User> streamAllValuesOfu() {
540 return rawStreamAllValuesOfu(emptyArray());
541 }
542
543 /**
544 * Retrieve the set of values that occur in matches for u.
545 * </p>
546 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
547 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
548 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
549 *
550 * @return the Stream of all values or empty set if there are no matches
551 *
552 */
553 public Stream<User> streamAllValuesOfu(final IsUnSubscribe.Match partialMatch) {
554 return rawStreamAllValuesOfu(partialMatch.toArray());
555 }
556
557 /**
558 * Retrieve the set of values that occur in matches for u.
559 * </p>
560 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
561 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
562 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
563 *
564 * @return the Stream of all values or empty set if there are no matches
565 *
566 */
567 public Stream<User> streamAllValuesOfu(final Issue pI, final IssueEvent pE) {
568 return rawStreamAllValuesOfu(new Object[]{pI, null, pE});
569 }
570
571 /**
572 * Retrieve the set of values that occur in matches for u.
573 * @return the Set of all values or empty set if there are no matches
574 *
575 */
576 public Set<User> getAllValuesOfu(final IsUnSubscribe.Match partialMatch) {
577 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
578 }
579
580 /**
581 * Retrieve the set of values that occur in matches for u.
582 * @return the Set of all values or empty set if there are no matches
583 *
584 */
585 public Set<User> getAllValuesOfu(final Issue pI, final IssueEvent pE) {
586 return rawStreamAllValuesOfu(new Object[]{pI, null, pE}).collect(Collectors.toSet());
587 }
588
589 /**
590 * Retrieve the set of values that occur in matches for e.
591 * @return the Set of all values or empty set if there are no matches
592 *
593 */
594 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
595 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
596 }
597
598 /**
599 * Retrieve the set of values that occur in matches for e.
600 * @return the Set of all values or empty set if there are no matches
601 *
602 */
603 public Set<IssueEvent> getAllValuesOfe() {
604 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
605 }
606
607 /**
608 * Retrieve the set of values that occur in matches for e.
609 * @return the Set of all values or empty set if there are no matches
610 *
611 */
612 public Stream<IssueEvent> streamAllValuesOfe() {
613 return rawStreamAllValuesOfe(emptyArray());
614 }
615
616 /**
617 * Retrieve the set of values that occur in matches for e.
618 * </p>
619 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
620 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
621 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
622 *
623 * @return the Stream of all values or empty set if there are no matches
624 *
625 */
626 public Stream<IssueEvent> streamAllValuesOfe(final IsUnSubscribe.Match partialMatch) {
627 return rawStreamAllValuesOfe(partialMatch.toArray());
628 }
629
630 /**
631 * Retrieve the set of values that occur in matches for e.
632 * </p>
633 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
634 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
635 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
636 *
637 * @return the Stream of all values or empty set if there are no matches
638 *
639 */
640 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI, final User pU) {
641 return rawStreamAllValuesOfe(new Object[]{pI, pU, null});
642 }
643
644 /**
645 * Retrieve the set of values that occur in matches for e.
646 * @return the Set of all values or empty set if there are no matches
647 *
648 */
649 public Set<IssueEvent> getAllValuesOfe(final IsUnSubscribe.Match partialMatch) {
650 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
651 }
652
653 /**
654 * Retrieve the set of values that occur in matches for e.
655 * @return the Set of all values or empty set if there are no matches
656 *
657 */
658 public Set<IssueEvent> getAllValuesOfe(final Issue pI, final User pU) {
659 return rawStreamAllValuesOfe(new Object[]{pI, pU, null}).collect(Collectors.toSet());
660 }
661
662 @Override
663 protected IsUnSubscribe.Match tupleToMatch(final Tuple t) {
664 try {
665 return IsUnSubscribe.Match.newMatch((Issue) t.get(POSITION_I), (User) t.get(POSITION_U), (IssueEvent) t.get(POSITION_E));
666 } catch(ClassCastException e) {
667 LOGGER.error("Element(s) in tuple not properly typed!",e);
668 return null;
669 }
670 }
671
672 @Override
673 protected IsUnSubscribe.Match arrayToMatch(final Object[] match) {
674 try {
675 return IsUnSubscribe.Match.newMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E]);
676 } catch(ClassCastException e) {
677 LOGGER.error("Element(s) in array not properly typed!",e);
678 return null;
679 }
680 }
681
682 @Override
683 protected IsUnSubscribe.Match arrayToMatchMutable(final Object[] match) {
684 try {
685 return IsUnSubscribe.Match.newMutableMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E]);
686 } catch(ClassCastException e) {
687 LOGGER.error("Element(s) in array not properly typed!",e);
688 return null;
689 }
690 }
691
692 /**
693 * @return the singleton instance of the query specification of this pattern
694 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
695 *
696 */
697 public static IQuerySpecification<IsUnSubscribe.Matcher> querySpecification() {
698 return IsUnSubscribe.instance();
699 }
700 }
701
702 private IsUnSubscribe() {
703 super(GeneratedPQuery.INSTANCE);
704 }
705
706 /**
707 * @return the singleton instance of the query specification
708 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
709 *
710 */
711 public static IsUnSubscribe instance() {
712 try{
713 return LazyHolder.INSTANCE;
714 } catch (ExceptionInInitializerError err) {
715 throw processInitializerError(err);
716 }
717 }
718
719 @Override
720 protected IsUnSubscribe.Matcher instantiate(final ViatraQueryEngine engine) {
721 return IsUnSubscribe.Matcher.on(engine);
722 }
723
724 @Override
725 public IsUnSubscribe.Matcher instantiate() {
726 return IsUnSubscribe.Matcher.create();
727 }
728
729 @Override
730 public IsUnSubscribe.Match newEmptyMatch() {
731 return IsUnSubscribe.Match.newEmptyMatch();
732 }
733
734 @Override
735 public IsUnSubscribe.Match newMatch(final Object... parameters) {
736 return IsUnSubscribe.Match.newMatch((github.Issue) parameters[0], (github.User) parameters[1], (github.IssueEvent) parameters[2]);
737 }
738
739 /**
740 * Inner class allowing the singleton instance of {@link IsUnSubscribe} to be created
741 * <b>not</b> at the class load time of the outer class,
742 * but rather at the first call to {@link IsUnSubscribe#instance()}.
743 *
744 * <p> This workaround is required e.g. to support recursion.
745 *
746 */
747 private static class LazyHolder {
748 private static final IsUnSubscribe INSTANCE = new IsUnSubscribe();
749
750 /**
751 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
752 * This initialization order is required to support indirect recursion.
753 *
754 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
755 *
756 */
757 private static final Object STATIC_INITIALIZER = ensureInitialized();
758
759 public static Object ensureInitialized() {
760 INSTANCE.ensureInitializedInternal();
761 return null;
762 }
763 }
764
765 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
766 private static final IsUnSubscribe.GeneratedPQuery INSTANCE = new GeneratedPQuery();
767
768 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
769
770 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
771
772 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
773
774 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_u, parameter_e);
775
776 private GeneratedPQuery() {
777 super(PVisibility.PUBLIC);
778 }
779
780 @Override
781 public String getFullyQualifiedName() {
782 return "queries.isUnSubscribe";
783 }
784
785 @Override
786 public List<String> getParameterNames() {
787 return Arrays.asList("i","u","e");
788 }
789
790 @Override
791 public List<PParameter> getParameters() {
792 return parameters;
793 }
794
795 @Override
796 public Set<PBody> doGetContainedBodies() {
797 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
798 Set<PBody> bodies = new LinkedHashSet<>();
799 {
800 PBody body = new PBody(this);
801 PVariable var_i = body.getOrCreateVariableByName("i");
802 PVariable var_u = body.getOrCreateVariableByName("u");
803 PVariable var_e = body.getOrCreateVariableByName("e");
804 PVariable var_a = body.getOrCreateVariableByName("a");
805 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
806 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
807 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
808 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
809 new ExportedParameter(body, var_i, parameter_i),
810 new ExportedParameter(body, var_u, parameter_u),
811 new ExportedParameter(body, var_e, parameter_e)
812 ));
813 // Issue.issueevent(i, e)
814 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
815 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
816 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
817 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
818 new Equality(body, var__virtual_0_, var_e);
819 // IssueEvent.user(e, u)
820 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
821 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
822 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "user")));
823 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
824 new Equality(body, var__virtual_1_, var_u);
825 // IssueEvent.action(e, a)
826 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
827 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
828 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
829 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
830 new Equality(body, var__virtual_2_, var_a);
831 // a == Action::UNSUBSCRIBED
832 PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
833 new ConstantValue(body, var__virtual_3_, getEnumLiteral("sure.ghtorrent.github", "Action", "UNSUBSCRIBED").getInstance());
834 new Equality(body, var_a, var__virtual_3_);
835 bodies.add(body);
836 }
837 return bodies;
838 }
839 }
840}
diff --git a/Domains/github-graph/src-gen/queries/NoCommitter.java b/Domains/github-graph/src-gen/queries/NoCommitter.java
new file mode 100644
index 00000000..4a34d2cb
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/NoCommitter.java
@@ -0,0 +1,560 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Commit;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
40import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
41import queries.Committer;
42
43/**
44 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
45 *
46 * <p>Original source:
47 * <code><pre>
48 * {@literal @}Constraint(key={c}, severity="error", message="error")
49 * pattern noCommitter(c: Commit) {
50 * neg find committer(c, _);
51 * }
52 * </pre></code>
53 *
54 * @see Matcher
55 * @see Match
56 *
57 */
58@SuppressWarnings("all")
59public final class NoCommitter extends BaseGeneratedEMFQuerySpecification<NoCommitter.Matcher> {
60 /**
61 * Pattern-specific match representation of the queries.noCommitter pattern,
62 * to be used in conjunction with {@link Matcher}.
63 *
64 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
65 * Each instance is a (possibly partial) substitution of pattern parameters,
66 * usable to represent a match of the pattern in the result of a query,
67 * or to specify the bound (fixed) input parameters when issuing a query.
68 *
69 * @see Matcher
70 *
71 */
72 public static abstract class Match extends BasePatternMatch {
73 private Commit fC;
74
75 private static List<String> parameterNames = makeImmutableList("c");
76
77 private Match(final Commit pC) {
78 this.fC = pC;
79 }
80
81 @Override
82 public Object get(final String parameterName) {
83 switch(parameterName) {
84 case "c": return this.fC;
85 default: return null;
86 }
87 }
88
89 @Override
90 public Object get(final int index) {
91 switch(index) {
92 case 0: return this.fC;
93 default: return null;
94 }
95 }
96
97 public Commit getC() {
98 return this.fC;
99 }
100
101 @Override
102 public boolean set(final String parameterName, final Object newValue) {
103 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
104 if ("c".equals(parameterName) ) {
105 this.fC = (Commit) newValue;
106 return true;
107 }
108 return false;
109 }
110
111 public void setC(final Commit pC) {
112 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
113 this.fC = pC;
114 }
115
116 @Override
117 public String patternName() {
118 return "queries.noCommitter";
119 }
120
121 @Override
122 public List<String> parameterNames() {
123 return NoCommitter.Match.parameterNames;
124 }
125
126 @Override
127 public Object[] toArray() {
128 return new Object[]{fC};
129 }
130
131 @Override
132 public NoCommitter.Match toImmutable() {
133 return isMutable() ? newMatch(fC) : this;
134 }
135
136 @Override
137 public String prettyPrint() {
138 StringBuilder result = new StringBuilder();
139 result.append("\"c\"=" + prettyPrintValue(fC));
140 return result.toString();
141 }
142
143 @Override
144 public int hashCode() {
145 return Objects.hash(fC);
146 }
147
148 @Override
149 public boolean equals(final Object obj) {
150 if (this == obj)
151 return true;
152 if (obj == null) {
153 return false;
154 }
155 if ((obj instanceof NoCommitter.Match)) {
156 NoCommitter.Match other = (NoCommitter.Match) obj;
157 return Objects.equals(fC, other.fC);
158 } else {
159 // this should be infrequent
160 if (!(obj instanceof IPatternMatch)) {
161 return false;
162 }
163 IPatternMatch otherSig = (IPatternMatch) obj;
164 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
165 }
166 }
167
168 @Override
169 public NoCommitter specification() {
170 return NoCommitter.instance();
171 }
172
173 /**
174 * Returns an empty, mutable match.
175 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
176 *
177 * @return the empty match.
178 *
179 */
180 public static NoCommitter.Match newEmptyMatch() {
181 return new Mutable(null);
182 }
183
184 /**
185 * Returns a mutable (partial) match.
186 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
187 *
188 * @param pC the fixed value of pattern parameter c, or null if not bound.
189 * @return the new, mutable (partial) match object.
190 *
191 */
192 public static NoCommitter.Match newMutableMatch(final Commit pC) {
193 return new Mutable(pC);
194 }
195
196 /**
197 * Returns a new (partial) match.
198 * This can be used e.g. to call the matcher with a partial match.
199 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
200 * @param pC the fixed value of pattern parameter c, or null if not bound.
201 * @return the (partial) match object.
202 *
203 */
204 public static NoCommitter.Match newMatch(final Commit pC) {
205 return new Immutable(pC);
206 }
207
208 private static final class Mutable extends NoCommitter.Match {
209 Mutable(final Commit pC) {
210 super(pC);
211 }
212
213 @Override
214 public boolean isMutable() {
215 return true;
216 }
217 }
218
219 private static final class Immutable extends NoCommitter.Match {
220 Immutable(final Commit pC) {
221 super(pC);
222 }
223
224 @Override
225 public boolean isMutable() {
226 return false;
227 }
228 }
229 }
230
231 /**
232 * Generated pattern matcher API of the queries.noCommitter pattern,
233 * providing pattern-specific query methods.
234 *
235 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
236 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
237 *
238 * <p>Matches of the pattern will be represented as {@link Match}.
239 *
240 * <p>Original source:
241 * <code><pre>
242 * {@literal @}Constraint(key={c}, severity="error", message="error")
243 * pattern noCommitter(c: Commit) {
244 * neg find committer(c, _);
245 * }
246 * </pre></code>
247 *
248 * @see Match
249 * @see NoCommitter
250 *
251 */
252 public static class Matcher extends BaseMatcher<NoCommitter.Match> {
253 /**
254 * Initializes the pattern matcher within an existing VIATRA Query engine.
255 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
256 *
257 * @param engine the existing VIATRA Query engine in which this matcher will be created.
258 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
259 *
260 */
261 public static NoCommitter.Matcher on(final ViatraQueryEngine engine) {
262 // check if matcher already exists
263 Matcher matcher = engine.getExistingMatcher(querySpecification());
264 if (matcher == null) {
265 matcher = (Matcher)engine.getMatcher(querySpecification());
266 }
267 return matcher;
268 }
269
270 /**
271 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
272 * @return an initialized matcher
273 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
274 *
275 */
276 public static NoCommitter.Matcher create() {
277 return new Matcher();
278 }
279
280 private static final int POSITION_C = 0;
281
282 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NoCommitter.Matcher.class);
283
284 /**
285 * Initializes the pattern matcher within an existing VIATRA Query engine.
286 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
287 *
288 * @param engine the existing VIATRA Query engine in which this matcher will be created.
289 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
290 *
291 */
292 private Matcher() {
293 super(querySpecification());
294 }
295
296 /**
297 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
298 * @param pC the fixed value of pattern parameter c, or null if not bound.
299 * @return matches represented as a Match object.
300 *
301 */
302 public Collection<NoCommitter.Match> getAllMatches(final Commit pC) {
303 return rawStreamAllMatches(new Object[]{pC}).collect(Collectors.toSet());
304 }
305
306 /**
307 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
308 * </p>
309 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
310 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
311 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
312 * @param pC the fixed value of pattern parameter c, or null if not bound.
313 * @return a stream of matches represented as a Match object.
314 *
315 */
316 public Stream<NoCommitter.Match> streamAllMatches(final Commit pC) {
317 return rawStreamAllMatches(new Object[]{pC});
318 }
319
320 /**
321 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
322 * Neither determinism nor randomness of selection is guaranteed.
323 * @param pC the fixed value of pattern parameter c, or null if not bound.
324 * @return a match represented as a Match object, or null if no match is found.
325 *
326 */
327 public Optional<NoCommitter.Match> getOneArbitraryMatch(final Commit pC) {
328 return rawGetOneArbitraryMatch(new Object[]{pC});
329 }
330
331 /**
332 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
333 * under any possible substitution of the unspecified parameters (if any).
334 * @param pC the fixed value of pattern parameter c, or null if not bound.
335 * @return true if the input is a valid (partial) match of the pattern.
336 *
337 */
338 public boolean hasMatch(final Commit pC) {
339 return rawHasMatch(new Object[]{pC});
340 }
341
342 /**
343 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
344 * @param pC the fixed value of pattern parameter c, or null if not bound.
345 * @return the number of pattern matches found.
346 *
347 */
348 public int countMatches(final Commit pC) {
349 return rawCountMatches(new Object[]{pC});
350 }
351
352 /**
353 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
354 * Neither determinism nor randomness of selection is guaranteed.
355 * @param pC the fixed value of pattern parameter c, or null if not bound.
356 * @param processor the action that will process the selected match.
357 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
358 *
359 */
360 public boolean forOneArbitraryMatch(final Commit pC, final Consumer<? super NoCommitter.Match> processor) {
361 return rawForOneArbitraryMatch(new Object[]{pC}, processor);
362 }
363
364 /**
365 * Returns a new (partial) match.
366 * This can be used e.g. to call the matcher with a partial match.
367 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
368 * @param pC the fixed value of pattern parameter c, or null if not bound.
369 * @return the (partial) match object.
370 *
371 */
372 public NoCommitter.Match newMatch(final Commit pC) {
373 return NoCommitter.Match.newMatch(pC);
374 }
375
376 /**
377 * Retrieve the set of values that occur in matches for c.
378 * @return the Set of all values or empty set if there are no matches
379 *
380 */
381 protected Stream<Commit> rawStreamAllValuesOfc(final Object[] parameters) {
382 return rawStreamAllValues(POSITION_C, parameters).map(Commit.class::cast);
383 }
384
385 /**
386 * Retrieve the set of values that occur in matches for c.
387 * @return the Set of all values or empty set if there are no matches
388 *
389 */
390 public Set<Commit> getAllValuesOfc() {
391 return rawStreamAllValuesOfc(emptyArray()).collect(Collectors.toSet());
392 }
393
394 /**
395 * Retrieve the set of values that occur in matches for c.
396 * @return the Set of all values or empty set if there are no matches
397 *
398 */
399 public Stream<Commit> streamAllValuesOfc() {
400 return rawStreamAllValuesOfc(emptyArray());
401 }
402
403 @Override
404 protected NoCommitter.Match tupleToMatch(final Tuple t) {
405 try {
406 return NoCommitter.Match.newMatch((Commit) t.get(POSITION_C));
407 } catch(ClassCastException e) {
408 LOGGER.error("Element(s) in tuple not properly typed!",e);
409 return null;
410 }
411 }
412
413 @Override
414 protected NoCommitter.Match arrayToMatch(final Object[] match) {
415 try {
416 return NoCommitter.Match.newMatch((Commit) match[POSITION_C]);
417 } catch(ClassCastException e) {
418 LOGGER.error("Element(s) in array not properly typed!",e);
419 return null;
420 }
421 }
422
423 @Override
424 protected NoCommitter.Match arrayToMatchMutable(final Object[] match) {
425 try {
426 return NoCommitter.Match.newMutableMatch((Commit) match[POSITION_C]);
427 } catch(ClassCastException e) {
428 LOGGER.error("Element(s) in array not properly typed!",e);
429 return null;
430 }
431 }
432
433 /**
434 * @return the singleton instance of the query specification of this pattern
435 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
436 *
437 */
438 public static IQuerySpecification<NoCommitter.Matcher> querySpecification() {
439 return NoCommitter.instance();
440 }
441 }
442
443 private NoCommitter() {
444 super(GeneratedPQuery.INSTANCE);
445 }
446
447 /**
448 * @return the singleton instance of the query specification
449 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
450 *
451 */
452 public static NoCommitter instance() {
453 try{
454 return LazyHolder.INSTANCE;
455 } catch (ExceptionInInitializerError err) {
456 throw processInitializerError(err);
457 }
458 }
459
460 @Override
461 protected NoCommitter.Matcher instantiate(final ViatraQueryEngine engine) {
462 return NoCommitter.Matcher.on(engine);
463 }
464
465 @Override
466 public NoCommitter.Matcher instantiate() {
467 return NoCommitter.Matcher.create();
468 }
469
470 @Override
471 public NoCommitter.Match newEmptyMatch() {
472 return NoCommitter.Match.newEmptyMatch();
473 }
474
475 @Override
476 public NoCommitter.Match newMatch(final Object... parameters) {
477 return NoCommitter.Match.newMatch((github.Commit) parameters[0]);
478 }
479
480 /**
481 * Inner class allowing the singleton instance of {@link NoCommitter} to be created
482 * <b>not</b> at the class load time of the outer class,
483 * but rather at the first call to {@link NoCommitter#instance()}.
484 *
485 * <p> This workaround is required e.g. to support recursion.
486 *
487 */
488 private static class LazyHolder {
489 private static final NoCommitter INSTANCE = new NoCommitter();
490
491 /**
492 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
493 * This initialization order is required to support indirect recursion.
494 *
495 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
496 *
497 */
498 private static final Object STATIC_INITIALIZER = ensureInitialized();
499
500 public static Object ensureInitialized() {
501 INSTANCE.ensureInitializedInternal();
502 return null;
503 }
504 }
505
506 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
507 private static final NoCommitter.GeneratedPQuery INSTANCE = new GeneratedPQuery();
508
509 private final PParameter parameter_c = new PParameter("c", "github.Commit", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Commit")), PParameterDirection.INOUT);
510
511 private final List<PParameter> parameters = Arrays.asList(parameter_c);
512
513 private GeneratedPQuery() {
514 super(PVisibility.PUBLIC);
515 }
516
517 @Override
518 public String getFullyQualifiedName() {
519 return "queries.noCommitter";
520 }
521
522 @Override
523 public List<String> getParameterNames() {
524 return Arrays.asList("c");
525 }
526
527 @Override
528 public List<PParameter> getParameters() {
529 return parameters;
530 }
531
532 @Override
533 public Set<PBody> doGetContainedBodies() {
534 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
535 Set<PBody> bodies = new LinkedHashSet<>();
536 {
537 PBody body = new PBody(this);
538 PVariable var_c = body.getOrCreateVariableByName("c");
539 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
540 new TypeConstraint(body, Tuples.flatTupleOf(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Commit")));
541 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
542 new ExportedParameter(body, var_c, parameter_c)
543 ));
544 // neg find committer(c, _)
545 new NegativePatternCall(body, Tuples.flatTupleOf(var_c, var___0_), Committer.instance().getInternalQueryRepresentation());
546 bodies.add(body);
547 }
548 {
549 PAnnotation annotation = new PAnnotation("Constraint");
550 annotation.addAttribute("key", Arrays.asList(new Object[] {
551 new ParameterReference("c")
552 }));
553 annotation.addAttribute("severity", "error");
554 annotation.addAttribute("message", "error");
555 addAnnotation(annotation);
556 }
557 return bodies;
558 }
559 }
560}
diff --git a/Domains/github-graph/src-gen/queries/NoUser.java b/Domains/github-graph/src-gen/queries/NoUser.java
new file mode 100644
index 00000000..293b5d56
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/NoUser.java
@@ -0,0 +1,560 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.IssueEvent;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
40import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
41import queries.EventUser;
42
43/**
44 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
45 *
46 * <p>Original source:
47 * <code><pre>
48 * {@literal @}Constraint(key={e}, severity="error", message="error")
49 * pattern noUser(e: IssueEvent) {
50 * neg find eventUser(e, _);
51 * }
52 * </pre></code>
53 *
54 * @see Matcher
55 * @see Match
56 *
57 */
58@SuppressWarnings("all")
59public final class NoUser extends BaseGeneratedEMFQuerySpecification<NoUser.Matcher> {
60 /**
61 * Pattern-specific match representation of the queries.noUser pattern,
62 * to be used in conjunction with {@link Matcher}.
63 *
64 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
65 * Each instance is a (possibly partial) substitution of pattern parameters,
66 * usable to represent a match of the pattern in the result of a query,
67 * or to specify the bound (fixed) input parameters when issuing a query.
68 *
69 * @see Matcher
70 *
71 */
72 public static abstract class Match extends BasePatternMatch {
73 private IssueEvent fE;
74
75 private static List<String> parameterNames = makeImmutableList("e");
76
77 private Match(final IssueEvent pE) {
78 this.fE = pE;
79 }
80
81 @Override
82 public Object get(final String parameterName) {
83 switch(parameterName) {
84 case "e": return this.fE;
85 default: return null;
86 }
87 }
88
89 @Override
90 public Object get(final int index) {
91 switch(index) {
92 case 0: return this.fE;
93 default: return null;
94 }
95 }
96
97 public IssueEvent getE() {
98 return this.fE;
99 }
100
101 @Override
102 public boolean set(final String parameterName, final Object newValue) {
103 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
104 if ("e".equals(parameterName) ) {
105 this.fE = (IssueEvent) newValue;
106 return true;
107 }
108 return false;
109 }
110
111 public void setE(final IssueEvent pE) {
112 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
113 this.fE = pE;
114 }
115
116 @Override
117 public String patternName() {
118 return "queries.noUser";
119 }
120
121 @Override
122 public List<String> parameterNames() {
123 return NoUser.Match.parameterNames;
124 }
125
126 @Override
127 public Object[] toArray() {
128 return new Object[]{fE};
129 }
130
131 @Override
132 public NoUser.Match toImmutable() {
133 return isMutable() ? newMatch(fE) : this;
134 }
135
136 @Override
137 public String prettyPrint() {
138 StringBuilder result = new StringBuilder();
139 result.append("\"e\"=" + prettyPrintValue(fE));
140 return result.toString();
141 }
142
143 @Override
144 public int hashCode() {
145 return Objects.hash(fE);
146 }
147
148 @Override
149 public boolean equals(final Object obj) {
150 if (this == obj)
151 return true;
152 if (obj == null) {
153 return false;
154 }
155 if ((obj instanceof NoUser.Match)) {
156 NoUser.Match other = (NoUser.Match) obj;
157 return Objects.equals(fE, other.fE);
158 } else {
159 // this should be infrequent
160 if (!(obj instanceof IPatternMatch)) {
161 return false;
162 }
163 IPatternMatch otherSig = (IPatternMatch) obj;
164 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
165 }
166 }
167
168 @Override
169 public NoUser specification() {
170 return NoUser.instance();
171 }
172
173 /**
174 * Returns an empty, mutable match.
175 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
176 *
177 * @return the empty match.
178 *
179 */
180 public static NoUser.Match newEmptyMatch() {
181 return new Mutable(null);
182 }
183
184 /**
185 * Returns a mutable (partial) match.
186 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
187 *
188 * @param pE the fixed value of pattern parameter e, or null if not bound.
189 * @return the new, mutable (partial) match object.
190 *
191 */
192 public static NoUser.Match newMutableMatch(final IssueEvent pE) {
193 return new Mutable(pE);
194 }
195
196 /**
197 * Returns a new (partial) match.
198 * This can be used e.g. to call the matcher with a partial match.
199 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
200 * @param pE the fixed value of pattern parameter e, or null if not bound.
201 * @return the (partial) match object.
202 *
203 */
204 public static NoUser.Match newMatch(final IssueEvent pE) {
205 return new Immutable(pE);
206 }
207
208 private static final class Mutable extends NoUser.Match {
209 Mutable(final IssueEvent pE) {
210 super(pE);
211 }
212
213 @Override
214 public boolean isMutable() {
215 return true;
216 }
217 }
218
219 private static final class Immutable extends NoUser.Match {
220 Immutable(final IssueEvent pE) {
221 super(pE);
222 }
223
224 @Override
225 public boolean isMutable() {
226 return false;
227 }
228 }
229 }
230
231 /**
232 * Generated pattern matcher API of the queries.noUser pattern,
233 * providing pattern-specific query methods.
234 *
235 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
236 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
237 *
238 * <p>Matches of the pattern will be represented as {@link Match}.
239 *
240 * <p>Original source:
241 * <code><pre>
242 * {@literal @}Constraint(key={e}, severity="error", message="error")
243 * pattern noUser(e: IssueEvent) {
244 * neg find eventUser(e, _);
245 * }
246 * </pre></code>
247 *
248 * @see Match
249 * @see NoUser
250 *
251 */
252 public static class Matcher extends BaseMatcher<NoUser.Match> {
253 /**
254 * Initializes the pattern matcher within an existing VIATRA Query engine.
255 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
256 *
257 * @param engine the existing VIATRA Query engine in which this matcher will be created.
258 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
259 *
260 */
261 public static NoUser.Matcher on(final ViatraQueryEngine engine) {
262 // check if matcher already exists
263 Matcher matcher = engine.getExistingMatcher(querySpecification());
264 if (matcher == null) {
265 matcher = (Matcher)engine.getMatcher(querySpecification());
266 }
267 return matcher;
268 }
269
270 /**
271 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
272 * @return an initialized matcher
273 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
274 *
275 */
276 public static NoUser.Matcher create() {
277 return new Matcher();
278 }
279
280 private static final int POSITION_E = 0;
281
282 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NoUser.Matcher.class);
283
284 /**
285 * Initializes the pattern matcher within an existing VIATRA Query engine.
286 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
287 *
288 * @param engine the existing VIATRA Query engine in which this matcher will be created.
289 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
290 *
291 */
292 private Matcher() {
293 super(querySpecification());
294 }
295
296 /**
297 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
298 * @param pE the fixed value of pattern parameter e, or null if not bound.
299 * @return matches represented as a Match object.
300 *
301 */
302 public Collection<NoUser.Match> getAllMatches(final IssueEvent pE) {
303 return rawStreamAllMatches(new Object[]{pE}).collect(Collectors.toSet());
304 }
305
306 /**
307 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
308 * </p>
309 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
310 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
311 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
312 * @param pE the fixed value of pattern parameter e, or null if not bound.
313 * @return a stream of matches represented as a Match object.
314 *
315 */
316 public Stream<NoUser.Match> streamAllMatches(final IssueEvent pE) {
317 return rawStreamAllMatches(new Object[]{pE});
318 }
319
320 /**
321 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
322 * Neither determinism nor randomness of selection is guaranteed.
323 * @param pE the fixed value of pattern parameter e, or null if not bound.
324 * @return a match represented as a Match object, or null if no match is found.
325 *
326 */
327 public Optional<NoUser.Match> getOneArbitraryMatch(final IssueEvent pE) {
328 return rawGetOneArbitraryMatch(new Object[]{pE});
329 }
330
331 /**
332 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
333 * under any possible substitution of the unspecified parameters (if any).
334 * @param pE the fixed value of pattern parameter e, or null if not bound.
335 * @return true if the input is a valid (partial) match of the pattern.
336 *
337 */
338 public boolean hasMatch(final IssueEvent pE) {
339 return rawHasMatch(new Object[]{pE});
340 }
341
342 /**
343 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
344 * @param pE the fixed value of pattern parameter e, or null if not bound.
345 * @return the number of pattern matches found.
346 *
347 */
348 public int countMatches(final IssueEvent pE) {
349 return rawCountMatches(new Object[]{pE});
350 }
351
352 /**
353 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
354 * Neither determinism nor randomness of selection is guaranteed.
355 * @param pE the fixed value of pattern parameter e, or null if not bound.
356 * @param processor the action that will process the selected match.
357 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
358 *
359 */
360 public boolean forOneArbitraryMatch(final IssueEvent pE, final Consumer<? super NoUser.Match> processor) {
361 return rawForOneArbitraryMatch(new Object[]{pE}, processor);
362 }
363
364 /**
365 * Returns a new (partial) match.
366 * This can be used e.g. to call the matcher with a partial match.
367 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
368 * @param pE the fixed value of pattern parameter e, or null if not bound.
369 * @return the (partial) match object.
370 *
371 */
372 public NoUser.Match newMatch(final IssueEvent pE) {
373 return NoUser.Match.newMatch(pE);
374 }
375
376 /**
377 * Retrieve the set of values that occur in matches for e.
378 * @return the Set of all values or empty set if there are no matches
379 *
380 */
381 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
382 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
383 }
384
385 /**
386 * Retrieve the set of values that occur in matches for e.
387 * @return the Set of all values or empty set if there are no matches
388 *
389 */
390 public Set<IssueEvent> getAllValuesOfe() {
391 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
392 }
393
394 /**
395 * Retrieve the set of values that occur in matches for e.
396 * @return the Set of all values or empty set if there are no matches
397 *
398 */
399 public Stream<IssueEvent> streamAllValuesOfe() {
400 return rawStreamAllValuesOfe(emptyArray());
401 }
402
403 @Override
404 protected NoUser.Match tupleToMatch(final Tuple t) {
405 try {
406 return NoUser.Match.newMatch((IssueEvent) t.get(POSITION_E));
407 } catch(ClassCastException e) {
408 LOGGER.error("Element(s) in tuple not properly typed!",e);
409 return null;
410 }
411 }
412
413 @Override
414 protected NoUser.Match arrayToMatch(final Object[] match) {
415 try {
416 return NoUser.Match.newMatch((IssueEvent) match[POSITION_E]);
417 } catch(ClassCastException e) {
418 LOGGER.error("Element(s) in array not properly typed!",e);
419 return null;
420 }
421 }
422
423 @Override
424 protected NoUser.Match arrayToMatchMutable(final Object[] match) {
425 try {
426 return NoUser.Match.newMutableMatch((IssueEvent) match[POSITION_E]);
427 } catch(ClassCastException e) {
428 LOGGER.error("Element(s) in array not properly typed!",e);
429 return null;
430 }
431 }
432
433 /**
434 * @return the singleton instance of the query specification of this pattern
435 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
436 *
437 */
438 public static IQuerySpecification<NoUser.Matcher> querySpecification() {
439 return NoUser.instance();
440 }
441 }
442
443 private NoUser() {
444 super(GeneratedPQuery.INSTANCE);
445 }
446
447 /**
448 * @return the singleton instance of the query specification
449 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
450 *
451 */
452 public static NoUser instance() {
453 try{
454 return LazyHolder.INSTANCE;
455 } catch (ExceptionInInitializerError err) {
456 throw processInitializerError(err);
457 }
458 }
459
460 @Override
461 protected NoUser.Matcher instantiate(final ViatraQueryEngine engine) {
462 return NoUser.Matcher.on(engine);
463 }
464
465 @Override
466 public NoUser.Matcher instantiate() {
467 return NoUser.Matcher.create();
468 }
469
470 @Override
471 public NoUser.Match newEmptyMatch() {
472 return NoUser.Match.newEmptyMatch();
473 }
474
475 @Override
476 public NoUser.Match newMatch(final Object... parameters) {
477 return NoUser.Match.newMatch((github.IssueEvent) parameters[0]);
478 }
479
480 /**
481 * Inner class allowing the singleton instance of {@link NoUser} to be created
482 * <b>not</b> at the class load time of the outer class,
483 * but rather at the first call to {@link NoUser#instance()}.
484 *
485 * <p> This workaround is required e.g. to support recursion.
486 *
487 */
488 private static class LazyHolder {
489 private static final NoUser INSTANCE = new NoUser();
490
491 /**
492 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
493 * This initialization order is required to support indirect recursion.
494 *
495 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
496 *
497 */
498 private static final Object STATIC_INITIALIZER = ensureInitialized();
499
500 public static Object ensureInitialized() {
501 INSTANCE.ensureInitializedInternal();
502 return null;
503 }
504 }
505
506 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
507 private static final NoUser.GeneratedPQuery INSTANCE = new GeneratedPQuery();
508
509 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
510
511 private final List<PParameter> parameters = Arrays.asList(parameter_e);
512
513 private GeneratedPQuery() {
514 super(PVisibility.PUBLIC);
515 }
516
517 @Override
518 public String getFullyQualifiedName() {
519 return "queries.noUser";
520 }
521
522 @Override
523 public List<String> getParameterNames() {
524 return Arrays.asList("e");
525 }
526
527 @Override
528 public List<PParameter> getParameters() {
529 return parameters;
530 }
531
532 @Override
533 public Set<PBody> doGetContainedBodies() {
534 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
535 Set<PBody> bodies = new LinkedHashSet<>();
536 {
537 PBody body = new PBody(this);
538 PVariable var_e = body.getOrCreateVariableByName("e");
539 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
540 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
541 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
542 new ExportedParameter(body, var_e, parameter_e)
543 ));
544 // neg find eventUser(e, _)
545 new NegativePatternCall(body, Tuples.flatTupleOf(var_e, var___0_), EventUser.instance().getInternalQueryRepresentation());
546 bodies.add(body);
547 }
548 {
549 PAnnotation annotation = new PAnnotation("Constraint");
550 annotation.addAttribute("key", Arrays.asList(new Object[] {
551 new ParameterReference("e")
552 }));
553 annotation.addAttribute("severity", "error");
554 annotation.addAttribute("message", "error");
555 addAnnotation(annotation);
556 }
557 return bodies;
558 }
559 }
560}