77import java .util .List ;
88import java .util .Map ;
99
10- import static graphql .Assert .assertTrue ;
11-
1210@ Internal
1311public class SchemaParentRestrictions {
1412 public static boolean isApplicableChildVertex (Vertex vertex ) {
@@ -24,6 +22,21 @@ public static boolean isApplicableParentVertex(Vertex vertex) {
2422 || vertex .isOfType (SchemaGraph .ENUM );
2523 }
2624
25+ /**
26+ * This computes the initial set of parent restrictions based on the fixed portion of the mapping.
27+ * <p>
28+ * See {@link Mapping} for definition of fixed vs non-fixed.
29+ * <p>
30+ * If a {@link Vertex} is present in the output {@link Map} then the value is the parent the
31+ * vertex MUST map to.
32+ * <p>
33+ * e.g. for an output {collar -> Dog} then the collar vertex must be a child of Dog in the mapping.
34+ *
35+ * @param sourceGraph source graph
36+ * @param sourceToTargetMapping the fixed mappings
37+ * @param needsFixing the non fixed mappings that need restrictions
38+ * @return Map where key is any vertex, and the value is the parent that vertex must map to
39+ */
2740 public static Map <Vertex , Vertex > getFixedRestrictions (SchemaGraph sourceGraph ,
2841 BiMap <Vertex , Vertex > sourceToTargetMapping ,
2942 List <Vertex > needsFixing ) {
@@ -49,12 +62,28 @@ public static Map<Vertex, Vertex> getFixedRestrictions(SchemaGraph sourceGraph,
4962 return restrictions ;
5063 }
5164
52- public static Map <Vertex , Vertex > getNonFixedRestrictions (Mapping parentMapping ,
65+
66+ /**
67+ * This computes the initial set of parent restrictions based on the given non-fixed mapping.
68+ * <p>
69+ * See {@link Mapping} for definition of fixed vs non-fixed.
70+ * <p>
71+ * If a {@link Vertex} is present in the output {@link Map} then the value is the parent the
72+ * vertex MUST map to.
73+ * <p>
74+ * e.g. for an output {collar -> Dog} then the collar vertex must be a child of Dog in the mapping.
75+ *
76+ * @param mapping the mapping to get non-fixed parent restrictions for
77+ * @param completeSourceGraph source graph
78+ * @param completeTargetGraph target graph
79+ * @return Map where key is any vertex, and the value is the parent that vertex must map to
80+ */
81+ public static Map <Vertex , Vertex > getNonFixedRestrictions (Mapping mapping ,
5382 SchemaGraph completeSourceGraph ,
5483 SchemaGraph completeTargetGraph ) {
5584 Map <Vertex , Vertex > restrictions = new LinkedHashMap <>();
5685
57- parentMapping .forEachNonFixedSourceAndTarget ((source , target ) -> {
86+ mapping .forEachNonFixedSourceAndTarget ((source , target ) -> {
5887 if (isApplicableParentVertex (source ) && isApplicableParentVertex (target )) {
5988 for (Edge edge : completeSourceGraph .getAdjacentEdgesNonCopy (source )) {
6089 Vertex child = edge .getTo ();
0 commit comments