Skip to content

Commit c4cfe05

Browse files
committed
Rename method to be more generic
1 parent 3ed0ff2 commit c4cfe05

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/main/java/graphql/schema/diffing/DiffImpl.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,13 @@ private void addChildToQueue(int fixedEditorialCost,
204204
double[][] costMatrix = new double[costMatrixSize][costMatrixSize];
205205

206206
Map<Vertex, Double> isolatedVerticesCache = new LinkedHashMap<>();
207-
208-
Map<Vertex, Vertex> parentRestrictions = getNonFixedRestrictions(parentPartialMapping, completeSourceGraph, completeTargetGraph);
207+
Map<Vertex, Vertex> nonFixedParentRestrictions = getNonFixedRestrictions(parentPartialMapping, completeSourceGraph, completeTargetGraph);
209208

210209
for (int i = parentLevel; i < allSources.size(); i++) {
211210
Vertex v = allSources.get(i);
212211
int j = 0;
213212
for (Vertex u : availableTargetVertices) {
214-
double cost = calcLowerBoundMappingCost(v, u, parentPartialMapping, isolatedVerticesCache, parentRestrictions);
213+
double cost = calcLowerBoundMappingCost(v, u, parentPartialMapping, isolatedVerticesCache, nonFixedParentRestrictions);
215214
costMatrixForHungarianAlgo[i - parentLevel][j] = cost;
216215
costMatrix[i - parentLevel][j] = cost;
217216
j++;
@@ -399,9 +398,9 @@ private double calcLowerBoundMappingCost(Vertex v,
399398
Vertex u,
400399
Mapping partialMapping,
401400
Map<Vertex, Double> isolatedVerticesCache,
402-
Map<Vertex, Vertex> parentRestrictions) {
403-
if (parentRestrictions.containsKey(v) || partialMapping.hasParentRestriction(v)) {
404-
Vertex uParentRestriction = parentRestrictions.get(v);
401+
Map<Vertex, Vertex> nonFixedParentRestrictions) {
402+
if (nonFixedParentRestrictions.containsKey(v) || partialMapping.hasParentRestriction(v)) {
403+
Vertex uParentRestriction = nonFixedParentRestrictions.get(v);
405404
if (uParentRestriction == null) {
406405
uParentRestriction = partialMapping.getParentRestriction(v);
407406
}

src/main/java/graphql/schema/diffing/SchemaGraph.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ public Vertex getAppliedDirectiveContainerForAppliedDirective(Vertex appliedDire
259259
}
260260

261261
/**
262-
* Assuming the child has one parent, this gets it.
262+
* Gets the one inverse adjacent edge to the input and gets the other vertex.
263263
*/
264-
public Vertex getSingleParent(Vertex child) {
265-
Collection<Edge> adjacentVertices = this.getAdjacentEdgesInverseNonCopy(child);
266-
assertTrue(adjacentVertices.size() == 1, () -> format("No parent found for %s", child));
264+
public Vertex getSingleAdjacentInverseVertex(Vertex input) {
265+
Collection<Edge> adjacentVertices = this.getAdjacentEdgesInverseNonCopy(input);
266+
assertTrue(adjacentVertices.size() == 1, () -> format("No parent found for %s", input));
267267
return adjacentVertices.iterator().next().getFrom();
268268
}
269269

src/main/java/graphql/schema/diffing/SchemaParentRestrictions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static Map<Vertex, Vertex> getFixedRestrictions(SchemaGraph sourceGraph,
3131

3232
for (Vertex vertex : needsFixing) {
3333
if (isApplicableChildVertex(vertex)) {
34-
Vertex sourceParent = sourceGraph.getSingleParent(vertex);
34+
Vertex sourceParent = sourceGraph.getSingleAdjacentInverseVertex(vertex);
3535
Vertex fixedTargetParent = sourceToTargetMapping.get(sourceParent);
3636

3737
if (fixedTargetParent != null) {
@@ -64,8 +64,8 @@ public static Map<Vertex, Vertex> getNonFixedRestrictions(Mapping parentMapping,
6464
}
6565
}
6666
} else if (isApplicableChildVertex(source) && isApplicableChildVertex(target)) {
67-
Vertex sourceParent = completeSourceGraph.getSingleParent(source);
68-
Vertex targetParent = completeTargetGraph.getSingleParent(target);
67+
Vertex sourceParent = completeSourceGraph.getSingleAdjacentInverseVertex(source);
68+
Vertex targetParent = completeTargetGraph.getSingleAdjacentInverseVertex(target);
6969

7070
for (Edge edge : completeSourceGraph.getAdjacentEdgesNonCopy(sourceParent)) {
7171
Vertex sibling = edge.getTo();

0 commit comments

Comments
 (0)