aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/VariableDirection.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/literal/VariableDirection.java')
-rw-r--r--subprojects/store-query/src/main/java/tools/refinery/store/query/literal/VariableDirection.java82
1 files changed, 0 insertions, 82 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/VariableDirection.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/VariableDirection.java
deleted file mode 100644
index 0b7a2960..00000000
--- a/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/VariableDirection.java
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
3 *
4 * SPDX-License-Identifier: EPL-2.0
5 */
6package tools.refinery.store.query.literal;
7
8import tools.refinery.store.query.term.ParameterDirection;
9
10/**
11 * Directions of the flow of a variable to ro from a clause.
12 * <p>
13 * During the evaluation of a clause
14 * <ol>
15 * <li>reads already bound {@code IN} variables,</li>
16 * <li>enumerates over all possible bindings of {@code CLOSURE} variables, and</li>
17 * <li>
18 * produces bindings for
19 * <ul>
20 * <li>{@code IN_OUT} variables that may already be bound in clause (if they already have a binding,
21 * the existing values are compared to the new binding by {@link Object#equals(Object)}), and</li>
22 * <li>{@code OUT} variables that must not be already bound in the clause (because comparison by
23 * equality wouldn't produce an appropriate join).</li>
24 * </ul>
25 * </li>
26 * </ol>
27 * Variables marked as {@code NEUTRAL} may act as {@code IN} or {@code CLOSURE} depending on whether they have an
28 * existing binding that can be read.
29 */
30public enum VariableDirection {
31 /**
32 * Binds a node variable or check equality with a node variable.
33 * <p>
34 * This is the usual direction for positive constraints on nodes. A data variable may have multiple {@code IN_OUT}
35 * bindings, even on the same parameter list.
36 * <p>
37 * Cannot be used for data variables.
38 */
39 IN_OUT,
40
41 /**
42 * Binds a data variable.
43 * <p>
44 * A single variable must have at most one {@code OUT} binding. A variable with a {@code OUT} binding cannot
45 * appear in any other place in a parameter list.
46 * <p>
47 * Cannot be used for node variables.
48 */
49 OUT,
50
51 /**
52 * Takes an already bound variable.
53 * <p>
54 * May be used with node or data variables. An {@code IN_OUT} or {@code OUT} binding on the same parameter list
55 * cannot satisfy the {@code IN} binding, because it might introduce a (non-monotonic) circular dependency.
56 */
57 IN,
58
59 /**
60 * Either takes a bound data variable or enumerates all possible data variable bindings.
61 * <p>
62 * Cannot be used for data variables.
63 */
64 NEUTRAL,
65
66 /**
67 * Enumerates over all possible data variable bindings.
68 * <p>
69 * May be used with node or data variables. The variable may not appear in any other parameter list. A data
70 * variable may only appear once in the parameter list, but node variables can appear multiple times to form
71 * diagonal constraints.
72 */
73 CLOSURE;
74
75 public static VariableDirection from(boolean positive, ParameterDirection parameterDirection) {
76 return switch (parameterDirection) {
77 case IN_OUT -> positive ? IN_OUT : NEUTRAL;
78 case OUT -> positive ? OUT : CLOSURE;
79 case IN -> IN;
80 };
81 }
82}